mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 09:45:37 -04:00
Add cypress id attribute only in test mode (#1566)
* Add function for test attribute Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Adjust components Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Fix naming of attribute Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Rename method Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Rename method, interface, attribute and use interface Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Lint and format fix Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
2abe40ef1d
commit
a398660c18
48 changed files with 229 additions and 167 deletions
|
@ -29,63 +29,63 @@ describe('Motd', () => {
|
|||
it('shows the correct alert Motd text', () => {
|
||||
mockExistingMotd()
|
||||
cy.visit('/')
|
||||
cy.get('[data-cy="motd"]').contains(motdMockContent)
|
||||
cy.get('[data-cypress-id="motd"]').contains(motdMockContent)
|
||||
})
|
||||
|
||||
it('can be dismissed', () => {
|
||||
mockExistingMotd()
|
||||
cy.visit('/')
|
||||
cy.get('[data-cy="motd"]').contains(motdMockContent)
|
||||
cy.get('button[data-cy="motd-dismiss"]')
|
||||
cy.get('[data-cypress-id="motd"]').contains(motdMockContent)
|
||||
cy.get('button[data-cypress-id="motd-dismiss"]')
|
||||
.click()
|
||||
.then(() => {
|
||||
expect(localStorage.getItem(MOTD_LOCAL_STORAGE_KEY)).to.equal(MOCK_LAST_MODIFIED)
|
||||
})
|
||||
cy.get('[data-cy="motd"]').should('not.exist')
|
||||
cy.get('[data-cypress-id="motd"]').should('not.exist')
|
||||
})
|
||||
|
||||
it("won't show again after dismiss and reload", () => {
|
||||
mockExistingMotd()
|
||||
cy.visit('/')
|
||||
cy.get('[data-cy="motd"]').contains(motdMockContent)
|
||||
cy.get('button[data-cy="motd-dismiss"]')
|
||||
cy.get('[data-cypress-id="motd"]').contains(motdMockContent)
|
||||
cy.get('button[data-cypress-id="motd-dismiss"]')
|
||||
.click()
|
||||
.then(() => {
|
||||
expect(localStorage.getItem(MOTD_LOCAL_STORAGE_KEY)).to.equal(MOCK_LAST_MODIFIED)
|
||||
})
|
||||
cy.get('[data-cy="motd"]').should('not.exist')
|
||||
cy.get('[data-cypress-id="motd"]').should('not.exist')
|
||||
cy.reload()
|
||||
cy.get('main').should('exist')
|
||||
cy.get('[data-cy="motd"]').should('not.exist')
|
||||
cy.get('[data-cypress-id="motd"]').should('not.exist')
|
||||
})
|
||||
|
||||
it("will show again after reload without dismiss", () => {
|
||||
mockExistingMotd()
|
||||
cy.visit('/')
|
||||
cy.get('[data-cy="motd"]').contains(motdMockContent)
|
||||
cy.get('[data-cypress-id="motd"]').contains(motdMockContent)
|
||||
cy.reload()
|
||||
cy.get('main').should('exist')
|
||||
cy.get('[data-cy="motd"]').contains(motdMockContent)
|
||||
cy.get('[data-cypress-id="motd"]').contains(motdMockContent)
|
||||
})
|
||||
|
||||
it("won't show again after dismiss and page navigation", () => {
|
||||
mockExistingMotd()
|
||||
cy.visit('/')
|
||||
cy.get('[data-cy="motd"]').contains(motdMockContent)
|
||||
cy.get('button[data-cy="motd-dismiss"]')
|
||||
cy.get('[data-cypress-id="motd"]').contains(motdMockContent)
|
||||
cy.get('button[data-cypress-id="motd-dismiss"]')
|
||||
.click()
|
||||
.then(() => {
|
||||
expect(localStorage.getItem(MOTD_LOCAL_STORAGE_KEY)).to.equal(MOCK_LAST_MODIFIED)
|
||||
})
|
||||
cy.get('[data-cy="motd"]').should('not.exist')
|
||||
cy.get('[data-cypress-id="motd"]').should('not.exist')
|
||||
cy.get('#navLinkHistory').click()
|
||||
cy.get('main').should('exist')
|
||||
cy.get('[data-cy="motd"]').should('not.exist')
|
||||
cy.get('[data-cypress-id="motd"]').should('not.exist')
|
||||
})
|
||||
|
||||
it("won't show if no file exists", () => {
|
||||
cy.visit('/')
|
||||
cy.get('main').should('exist')
|
||||
cy.get('[data-cy="motd"]').should('not.exist')
|
||||
cy.get('[data-cypress-id="motd"]').should('not.exist')
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue