Skip to content

Commit

Permalink
fix(cyprss): test
Browse files Browse the repository at this point in the history
  • Loading branch information
aliraza556 committed Nov 2, 2024
1 parent 5e67eb0 commit bbda363
Showing 1 changed file with 29 additions and 36 deletions.
65 changes: 29 additions & 36 deletions cypress/e2e/addContent/addTweet.cy.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,29 @@
describe('Add Tweet Content', () => {
it('Carol adds tweet content to graph', () => {
cy.initialSetup('carol', 300)

cy.intercept({
method: 'POST',
url: 'http://localhost:8444/api/add_node*',
}).as('addTweet')

cy.get('[data-testid="add-content-modal"]').click()

cy.get('#addContent').should('exist')
cy.get('[id="cy-youtube-channel-id"]').type('https://twitter.com/ijbguy/status/1771096005162729663')
cy.get('[data-testid="add-content-btn"]').click()
cy.get('[data-testid="check-icon"]').click()

cy.wait('@addTweet').then((interception) => {
// check we get a 402 response code, when trying to add content for the first time
expect(interception.response.statusCode).to.eq(402)
})

cy.intercept({
method: 'POST',
url: 'http://localhost:8444/api/add_node*',
}).as('addTweet2')

cy.wait('@addTweet2').then((intersection) => {
console.log(intersection.response)
cy.log(JSON.stringify(intersection.response))
}) // This is because add source is currently skipped,

cy.get('.Toastify__toast-body').should('have.text', 'Content Added')

cy.get('#addContent').should('not.exist')
})
})
describe('Add Tweet Content', () => {
it('Carol adds tweet content to graph', () => {
cy.initialSetup('carol', 300)

cy.intercept({
method: 'POST',
url: 'http://localhost:8444/api/add_node*',
}).as('addTweet')

cy.get('[data-testid="add-content-modal"]').click()

cy.get('#addContent').should('exist')
cy.get('[id="cy-youtube-channel-id"]').type('https://twitter.com/ijbguy/status/1771096005162729663')
cy.get('[data-testid="add-content-btn"]').click()
cy.get('[data-testid="check-icon"]').click()

cy.wait('@addTweet').then((interception) => {
// check we get a 402 response code, when trying to add content for the first time
expect(interception.response.statusCode).to.eq(402)
})

// Wait for the UI to update and toast to appear
cy.wait(5000)
cy.get('.Toastify__toast-body', { timeout: 15000 }).should('have.text', 'Content Added')

// Verify the modal is closed
cy.get('#addContent').should('not.exist')
})
})

0 comments on commit bbda363

Please sign in to comment.