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 d497557
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 85 deletions.
168 changes: 84 additions & 84 deletions cypress/e2e/trendingTopics/trendingTopics.cy.ts
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
describe('test trending topics', () => {
it('Checking it trending topics exist', () => {
cy.intercept({
method: 'GET',
url: 'http://localhost:8444/api/prediction/graph/search/latest*',
}).as('loadLatest')

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*',
}).as('search')

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

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

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

// wait for boltwall queue to send tweets to jarvis
cy.wait(70000)

cy.get('[data-testid="explore-graph-btn"]').click()

cy.wait('@getTrends').then((interception) => {
const responseBody = interception.response.body

cy.get('.list').should('exist')

for (let i = 0; i < responseBody.length; i++) {
cy.contains('.list', `${responseBody[i].name}`).should('exist')
}

cy.contains(`${responseBody[0].name}`).eq(0).click()

// wait for search result
cy.wait('@search', { timeout: 90000 }).then((interception) => {
cy.log('Search request intercepted')
expect(interception.response.statusCode).to.eq(402)
})

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

cy.wait('@search2')

// Check if the search result list has more than one child
// cy.get('.episode-wrapper')
// .should('exist') // Ensure they exist
// .should('have.length.greaterThan', 1) // Check that there are more than one
// .first() // Select the first element
// .click()

// cy.get('[data-testid="sidebar-sub-view"]').should('have.css', 'position', 'relative')

// cancel search
cy.get('[data-testid="search_action_icon"]').click()

cy.get('.list').should('exist')
})
})
})
describe('test trending topics', () => {
it('Checking it trending topics exist', () => {
cy.intercept({
method: 'GET',
url: 'http://localhost:8444/api/prediction/graph/search/latest*',
}).as('loadLatest')

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*',
}).as('search')

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

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

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

// wait for boltwall queue to send tweets to jarvis
cy.wait(70000)

// cy.get('[data-testid="explore-graph-btn"]').click()

cy.wait('@getTrends').then((interception) => {
const responseBody = interception.response.body

cy.get('.list').should('exist')

for (let i = 0; i < responseBody.length; i++) {
cy.contains('.list', `${responseBody[i].name}`).should('exist')
}

cy.contains(`${responseBody[0].name}`).eq(0).click()

// wait for search result
cy.wait('@search', { timeout: 90000 }).then((interception) => {
cy.log('Search request intercepted')
expect(interception.response.statusCode).to.eq(402)
})

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

cy.wait('@search2')

// Check if the search result list has more than one child
// cy.get('.episode-wrapper')
// .should('exist') // Ensure they exist
// .should('have.length.greaterThan', 1) // Check that there are more than one
// .first() // Select the first element
// .click()

// cy.get('[data-testid="sidebar-sub-view"]').should('have.css', 'position', 'relative')

// cancel search
cy.get('[data-testid="search_action_icon"]').click()

cy.get('.list').should('exist')
})
})
})
2 changes: 1 addition & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Cypress.Commands.add('initialSetup', (username, budget) => {

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

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

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

0 comments on commit d497557

Please sign in to comment.