2021-10-09 13:09:29 -04:00
|
|
|
/*
|
2022-06-08 07:19:51 -04:00
|
|
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
2021-10-09 13:09:29 -04:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
|
|
|
const MOTD_LOCAL_STORAGE_KEY = 'motd.lastModified'
|
|
|
|
const MOCK_LAST_MODIFIED = 'mockETag'
|
2022-02-10 03:27:09 -05:00
|
|
|
const motdMockContent = 'This is the **mock** Motd call'
|
|
|
|
const motdMockHtml = 'This is the <strong>mock</strong> Motd call'
|
2021-10-09 13:09:29 -04:00
|
|
|
|
|
|
|
describe('Motd', () => {
|
2022-10-01 12:06:31 -04:00
|
|
|
it("shows, dismisses and won't show again a motd modal", () => {
|
|
|
|
localStorage.removeItem(MOTD_LOCAL_STORAGE_KEY)
|
2023-08-12 14:07:38 -04:00
|
|
|
cy.intercept('GET', '/public/motd.md', {
|
2021-10-09 13:09:29 -04:00
|
|
|
statusCode: 200,
|
2022-10-01 12:06:31 -04:00
|
|
|
headers: { 'Last-Modified': MOCK_LAST_MODIFIED },
|
|
|
|
body: motdMockContent
|
2021-10-09 13:09:29 -04:00
|
|
|
})
|
|
|
|
|
2023-08-12 14:07:38 -04:00
|
|
|
cy.intercept('HEAD', '/public/motd.md', {
|
2021-10-09 13:09:29 -04:00
|
|
|
statusCode: 200,
|
2022-10-01 12:06:31 -04:00
|
|
|
headers: { 'Last-Modified': MOCK_LAST_MODIFIED }
|
2021-10-09 13:09:29 -04:00
|
|
|
})
|
2023-03-16 03:20:16 -04:00
|
|
|
cy.visitHistory()
|
|
|
|
cy.getSimpleRendererBody().should('contain.html', motdMockHtml)
|
2021-12-31 03:30:12 -05:00
|
|
|
cy.getByCypressId('motd-dismiss')
|
|
|
|
.click()
|
|
|
|
.then(() => {
|
|
|
|
expect(localStorage.getItem(MOTD_LOCAL_STORAGE_KEY)).to.equal(MOCK_LAST_MODIFIED)
|
|
|
|
})
|
2022-10-01 12:06:31 -04:00
|
|
|
cy.getByCypressId('motd-modal').should('not.exist')
|
2021-10-09 13:09:29 -04:00
|
|
|
cy.reload()
|
|
|
|
cy.get('main').should('exist')
|
2022-10-01 12:06:31 -04:00
|
|
|
cy.getByCypressId('motd-modal').should('not.exist')
|
2021-10-09 13:09:29 -04:00
|
|
|
})
|
|
|
|
})
|