Skip to content

Commit

Permalink
fix(cypress): test
Browse files Browse the repository at this point in the history
  • Loading branch information
aliraza556 committed Oct 26, 2024
1 parent d0105fd commit 1709b3c
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 70 deletions.
2 changes: 2 additions & 0 deletions cypress/e2e/admin/signin.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ describe('Admin Login', () => {

cy.wait(1000)

cy.get('div[data-testid="modal-overlay"]').should('not.exist')

cy.get('.title').should('have.text', title)
})
})
140 changes: 70 additions & 70 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
import '@testing-library/cypress/add-commands'

/// <reference types="cypress" />

// @ts-check
/// <reference path="../global.d.ts" />

// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

Cypress.Commands.add('initialSetup', (username, budget) => {
cy.intercept({
method: 'GET',
url: 'http://localhost:8444/api/about*',
}).as('loadAbout')

cy.intercept({
method: 'GET',
url: 'http://localhost:8444/api/stats*',
}).as('loadStats')

cy.intercept({
method: 'GET',
url: 'http://localhost:8444/api/get_trends*',
}).as('getTrends')

cy.intercept({
method: 'GET',
url: 'http://localhost:8444/api/prediction/graph/search/latest*',
}).as('loadLatest')

cy.visit('/', {
onBeforeLoad(win) {
// @ts-ignore
win.CYPRESS_USER = username || '' // eslint-disable-line no-param-reassign

// @ts-ignore
win.CYPRESS_USER_BUDGET = budget || 0 // eslint-disable-line no-param-reassign
},
})

cy.wait(['@loadAbout', '@loadLatest', '@loadStats'])

cy.get('[data-testid="explore-graph-btn"]', { timeout: 90000 }).should('be.visible').click()

cy.wait(['@getTrends'])
})
import '@testing-library/cypress/add-commands'

/// <reference types="cypress" />

// @ts-check
/// <reference path="../global.d.ts" />

// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

Cypress.Commands.add('initialSetup', (username, budget) => {
cy.intercept({
method: 'GET',
url: 'http://localhost:8444/api/about*',
}).as('loadAbout')

cy.intercept({
method: 'GET',
url: 'http://localhost:8444/api/stats*',
}).as('loadStats')

cy.intercept({
method: 'GET',
url: 'http://localhost:8444/api/get_trends*',
}).as('getTrends')

cy.intercept({
method: 'GET',
url: 'http://localhost:8444/api/prediction/graph/search/latest*',
}).as('loadLatest')

cy.visit('/', {
onBeforeLoad(win) {
// @ts-ignore
win.CYPRESS_USER = username || '' // eslint-disable-line no-param-reassign

// @ts-ignore
win.CYPRESS_USER_BUDGET = budget || 0 // eslint-disable-line no-param-reassign
},
})

cy.wait(['@loadAbout', '@loadLatest', '@loadStats'])

// cy.get('[data-testid="explore-graph-btn"]', { timeout: 90000 }).should('be.visible').click()

cy.wait(['@getTrends'])
})

0 comments on commit 1709b3c

Please sign in to comment.