Skip to content

Commit

Permalink
Use testids for speaker tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gmcauliffe committed Dec 20, 2024
1 parent 55d4496 commit 9d25dc6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
43 changes: 23 additions & 20 deletions cypress/e2e/dashboard/speaker.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,45 +30,48 @@ describe(
})
cy.contains('Explore Languages').click()
})

const testSpeakerName = Date.now().toString()
it('Create Speaker', () => {
cy.visit(`${Cypress.env('baseUrl')}${Cypress.env('DIALECT')}`)
cy.contains(`${Cypress.env('CYPRESS_FV_INITIALS')}`).click()
cy.contains('Dashboard').click()
cy.contains('Create').click()
cy.contains('Add a speaker').click()
cy.get('[data-testid="user-menu-btn"]').click()
cy.get('[data-testid="user-dashboard-link"]').click()
cy.get('[data-testid="dashboard-create-link"]').click()
cy.get('[data-testid="create-speaker-link"]').click()

cy.contains('Add Speaker').click()
cy.get('[data-testid="form-submit"]').click()
cy.contains('name must be at least 1 characters').should('be.visible')
cy.contains('A bio is required').should('be.visible')

cy.get('#name').type('qatestspeaker')
cy.get('#name').type(testSpeakerName)
cy.get('#bio').type('qabio test - new speaker')
cy.contains('Add Speaker').click()
cy.contains('Dismiss').should('be.visible')
cy.get('[data-testid="form-submit"]').click()
cy.get('[data-testid="success-close-btn"]').should('exist')
})

it('Edit Speaker', () => {
cy.visit(`${Cypress.env('baseUrl')}${Cypress.env('DIALECT')}`)
cy.contains(`${Cypress.env('CYPRESS_FV_INITIALS')}`).click()
cy.contains('Dashboard').click()
cy.contains('Edit').click()
cy.contains('Edit speakers').click()
cy.get('[data-testid="edit-speaker-qatestspeaker"]').click()
cy.get('[data-testid="user-menu-btn"]').click()
cy.get('[data-testid="user-dashboard-link"]').click()
cy.get('[data-testid="dashboard-edit-link"]').click()
cy.get('[data-testid="edit-speakers-link"]').click()
cy.get(`[data-testid="edit-speaker-${testSpeakerName}"]`).click()
cy.get('#bio').type('this is the new value')
cy.contains('Save Changes').click()
cy.get('[data-testid="form-submit"]').click()
cy.get('[data-testid="success-close-btn"]').should('exist')
})

it('Delete Speaker', () => {
cy.visit(`${Cypress.env('baseUrl')}${Cypress.env('DIALECT')}`)
cy.contains(`${Cypress.env('CYPRESS_FV_INITIALS')}`).click()
cy.contains('Dashboard').click()
cy.contains('Edit').click()
cy.contains('Edit speakers').click()
cy.get('[data-testid="edit-speaker-qatestspeaker"]').click()
cy.get('[data-testid="user-menu-btn"]').click()
cy.get('[data-testid="user-dashboard-link"]').click()
cy.get('[data-testid="dashboard-edit-link"]').click()
cy.get('[data-testid="edit-speakers-link"]').click()
cy.get(`[data-testid="edit-speaker-${testSpeakerName}"]`).click()
cy.get('#bio')
.invoke('val')
.then((sometext) => sometext === 'this is the new value')
cy.contains('Delete Speaker').click()
cy.get('[data-testid="delete-btn"]').click()
cy.get('[data-testid="DeleteModal"]').contains('Delete').click()
})
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/DeleteButton/DeleteButtonPresentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function DeleteButtonPresentation({
atLeastEditor && (
<>
<button
data-testid="DeleteButton"
data-testid="delete-btn"
type="button"
onClick={() => setDeleteModalOpen(true)}
className={styling}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function DeleteButtonMediaPresentation({ docType, usage, deleteHandler }) {
<>
<button
type="button"
data-testid="DeleteButton"
data-testid="delete-btn"
onClick={() => setDeleteModalOpen(true)}
className="btn-outlined"
>
Expand Down

0 comments on commit 9d25dc6

Please sign in to comment.