Cypress-IDs and prettier for tests (#1634)

* Add cy.getById method and run prettier

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
Erik Michelson 2021-11-19 18:04:04 +01:00 committed by GitHub
parent 8a8bacc0aa
commit d725b65140
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 758 additions and 1203 deletions

View file

@ -29,63 +29,63 @@ describe('Motd', () => {
it('shows the correct alert Motd text', () => {
mockExistingMotd()
cy.visit('/')
cy.get('[data-cypress-id="motd"]').contains(motdMockContent)
cy.getById('motd').contains(motdMockContent)
})
it('can be dismissed', () => {
mockExistingMotd()
cy.visit('/')
cy.get('[data-cypress-id="motd"]').contains(motdMockContent)
cy.get('button[data-cypress-id="motd-dismiss"]')
cy.getById('motd').contains(motdMockContent)
cy.getById('motd-dismiss')
.click()
.then(() => {
expect(localStorage.getItem(MOTD_LOCAL_STORAGE_KEY)).to.equal(MOCK_LAST_MODIFIED)
})
cy.get('[data-cypress-id="motd"]').should('not.exist')
cy.getById('motd').should('not.exist')
})
it("won't show again after dismiss and reload", () => {
mockExistingMotd()
cy.visit('/')
cy.get('[data-cypress-id="motd"]').contains(motdMockContent)
cy.get('button[data-cypress-id="motd-dismiss"]')
cy.getById('motd').contains(motdMockContent)
cy.getById('motd-dismiss')
.click()
.then(() => {
expect(localStorage.getItem(MOTD_LOCAL_STORAGE_KEY)).to.equal(MOCK_LAST_MODIFIED)
})
cy.get('[data-cypress-id="motd"]').should('not.exist')
cy.getById('motd').should('not.exist')
cy.reload()
cy.get('main').should('exist')
cy.get('[data-cypress-id="motd"]').should('not.exist')
cy.getById('motd').should('not.exist')
})
it("will show again after reload without dismiss", () => {
it('will show again after reload without dismiss', () => {
mockExistingMotd()
cy.visit('/')
cy.get('[data-cypress-id="motd"]').contains(motdMockContent)
cy.getById('motd').contains(motdMockContent)
cy.reload()
cy.get('main').should('exist')
cy.get('[data-cypress-id="motd"]').contains(motdMockContent)
cy.getById('motd').contains(motdMockContent)
})
it("won't show again after dismiss and page navigation", () => {
mockExistingMotd()
cy.visit('/')
cy.get('[data-cypress-id="motd"]').contains(motdMockContent)
cy.get('button[data-cypress-id="motd-dismiss"]')
cy.getById('motd').contains(motdMockContent)
cy.getById('motd-dismiss')
.click()
.then(() => {
expect(localStorage.getItem(MOTD_LOCAL_STORAGE_KEY)).to.equal(MOCK_LAST_MODIFIED)
})
cy.get('[data-cypress-id="motd"]').should('not.exist')
cy.get('#navLinkHistory').click()
cy.getById('motd').should('not.exist')
cy.getById('navLinkHistory').click()
cy.get('main').should('exist')
cy.get('[data-cypress-id="motd"]').should('not.exist')
cy.getById('motd').should('not.exist')
})
it("won't show if no file exists", () => {
cy.visit('/')
cy.get('main').should('exist')
cy.get('[data-cypress-id="motd"]').should('not.exist')
cy.getById('motd').should('not.exist')
})
})