2021-12-30 12:40:52 -05:00
|
|
|
/*
|
2022-06-08 07:19:51 -04:00
|
|
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
2021-12-30 12:40:52 -05:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
2022-04-15 17:03:15 -04:00
|
|
|
import { testNoteId } from '../support/visit-test-editor'
|
|
|
|
|
2021-12-30 12:40:52 -05:00
|
|
|
describe('Delete note', () => {
|
|
|
|
beforeEach(() => {
|
2022-01-30 15:46:43 -05:00
|
|
|
cy.visitTestNote()
|
2021-12-30 12:40:52 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('correctly deletes a note', () => {
|
2022-09-16 05:03:29 -04:00
|
|
|
cy.intercept('DELETE', `api/private/notes/${testNoteId}`, {
|
2022-04-15 17:03:15 -04:00
|
|
|
statusCode: 204
|
2021-12-30 12:40:52 -05:00
|
|
|
})
|
|
|
|
cy.getByCypressId('sidebar.deleteNote.button').click()
|
|
|
|
cy.getByCypressId('sidebar.deleteNote.modal').should('be.visible')
|
|
|
|
cy.getByCypressId('sidebar.deleteNote.modal.noteTitle').should('be.visible').text().should('eq', '')
|
|
|
|
cy.getByCypressId('deletionModal.confirmButton').should('be.visible').click()
|
|
|
|
cy.getByCypressId('sidebar.deleteNote.modal').should('not.be.exist')
|
|
|
|
cy.getByCypressId('notification-toast').should('not.exist')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('displays an error notification if something goes wrong', () => {
|
2023-01-14 16:35:37 -05:00
|
|
|
cy.intercept('DELETE', `api/private/notes/${testNoteId}`, {
|
|
|
|
statusCode: 400
|
|
|
|
})
|
2021-12-30 12:40:52 -05:00
|
|
|
cy.getByCypressId('sidebar.deleteNote.button').click()
|
|
|
|
cy.getByCypressId('sidebar.deleteNote.modal').should('be.visible')
|
|
|
|
cy.getByCypressId('sidebar.deleteNote.modal.noteTitle').should('be.visible').text().should('eq', '')
|
|
|
|
cy.getByCypressId('deletionModal.confirmButton').should('be.visible').click()
|
|
|
|
cy.getByCypressId('sidebar.deleteNote.modal').should('not.exist')
|
|
|
|
cy.getByCypressId('notification-toast').should('be.visible')
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('displays the note title coming from', () => {
|
|
|
|
const title = 'mock_title'
|
|
|
|
it('yaml metadata', () => {
|
|
|
|
cy.setCodemirrorContent(`---\ntitle: ${title}\n---`)
|
|
|
|
})
|
|
|
|
it('opengraph', () => {
|
|
|
|
cy.setCodemirrorContent(`---\nopengraph:\n title: ${title}\n---`)
|
|
|
|
})
|
|
|
|
it('just first heading', () => {
|
|
|
|
cy.setCodemirrorContent(`# ${title}`)
|
|
|
|
})
|
|
|
|
afterEach(() => {
|
|
|
|
cy.getByCypressId('sidebar.deleteNote.button').click()
|
|
|
|
cy.getByCypressId('sidebar.deleteNote.modal').should('be.visible')
|
|
|
|
cy.getByCypressId('sidebar.deleteNote.modal.noteTitle').should('be.visible').text().should('eq', title)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|