mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 14:44:43 -04:00
Add new visit functions in e2e tests
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
566b3009b6
commit
ca5dae3f82
34 changed files with 88 additions and 56 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
describe('Autocompletion works for', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
cy.get('.CodeMirror').click().get('textarea').as('codeinput')
|
||||
})
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
describe('Delete note', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
it('correctly deletes a note', () => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
describe('Diagram codeblock ', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
/*
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { PAGE_MODE } from '../support/visit'
|
||||
|
||||
describe('Document read only page', () => {
|
||||
it('renders the document mode', () => {
|
||||
cy.visit('/s/test')
|
||||
cy.visitTestNote(PAGE_MODE.DOCUMENT_READ_ONLY)
|
||||
cy.getMarkdownBody().should('exist')
|
||||
})
|
||||
})
|
||||
|
|
|
@ -9,7 +9,7 @@ import { branding } from '../support/config'
|
|||
const title = 'This is a test title'
|
||||
describe('Document Title', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
cy.getByCypressId('view-mode-both').should('exist')
|
||||
})
|
||||
|
||||
|
|
|
@ -4,20 +4,22 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { PAGE_MODE } from '../support/visit'
|
||||
|
||||
describe('Editor mode from URL parameter is used', () => {
|
||||
it('mode view', () => {
|
||||
cy.visitTestEditor('view')
|
||||
cy.visitTestNote(PAGE_MODE.EDITOR, 'view')
|
||||
cy.getByCypressId('splitter-left').should('not.be.visible')
|
||||
cy.getByCypressId('splitter-right').should('be.visible')
|
||||
})
|
||||
it('mode both', () => {
|
||||
cy.visitTestEditor('both')
|
||||
cy.visitTestNote(PAGE_MODE.EDITOR, 'both')
|
||||
cy.getByCypressId('splitter-left').should('be.visible')
|
||||
cy.getByCypressId('splitter-separator').should('exist')
|
||||
cy.getByCypressId('splitter-right').should('be.visible')
|
||||
})
|
||||
it('mode edit', () => {
|
||||
cy.visitTestEditor('edit')
|
||||
cy.visitTestNote(PAGE_MODE.EDITOR, 'edit')
|
||||
cy.getByCypressId('splitter-left').should('be.visible')
|
||||
cy.getByCypressId('splitter-right').should('not.be.visible')
|
||||
})
|
||||
|
|
|
@ -8,7 +8,7 @@ describe('emojis', () => {
|
|||
const HEDGEHOG_UNICODE_CHARACTER = '\n🦔\n'
|
||||
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
it('renders an emoji shortcode', () => {
|
||||
|
|
|
@ -9,7 +9,7 @@ describe('Export', () => {
|
|||
const testContent = `---\ntitle: ${testTitle}\n---\nThis is some test content`
|
||||
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
cy.setCodemirrorContent(testContent)
|
||||
})
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ const imageUrl = 'http://example.com/non-existing.png'
|
|||
|
||||
describe('File upload', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
it("doesn't prevent drag'n'drop of plain text", () => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
describe('Help Dialog', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
it('ToDo-List', () => {
|
||||
|
|
|
@ -10,7 +10,7 @@ const findHljsCodeBlock = () => {
|
|||
|
||||
describe('Code', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
describe('with just the language', () => {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
describe('History', () => {
|
||||
describe('History Mode', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/history')
|
||||
cy.visitHistory()
|
||||
})
|
||||
|
||||
it('Cards', () => {
|
||||
|
@ -35,7 +35,7 @@ describe('History', () => {
|
|||
}
|
||||
]
|
||||
})
|
||||
cy.visit('/history')
|
||||
cy.visitHistory()
|
||||
})
|
||||
|
||||
it('in table view', () => {
|
||||
|
@ -62,7 +62,7 @@ describe('History', () => {
|
|||
}
|
||||
]
|
||||
})
|
||||
cy.visit('/history')
|
||||
cy.visitHistory()
|
||||
})
|
||||
|
||||
it('in table view', () => {
|
||||
|
@ -79,7 +79,7 @@ describe('History', () => {
|
|||
|
||||
describe('Pinning', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/history')
|
||||
cy.visitHistory()
|
||||
})
|
||||
|
||||
describe('working', () => {
|
||||
|
@ -131,7 +131,7 @@ describe('History', () => {
|
|||
cy.intercept('GET', '/mock-backend/api/private/me/history', {
|
||||
body: []
|
||||
})
|
||||
cy.visit('/history')
|
||||
cy.visitHistory()
|
||||
cy.logout()
|
||||
})
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
describe('Iframe capsule', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
it('shows a clickable click shield instead of the iframe', () => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
describe('Import markdown file', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
it('import on blank note', () => {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
describe('Intro page', () => {
|
||||
beforeEach(() => {
|
||||
cy.intercept('/mock-backend/public/intro.md', 'test content')
|
||||
cy.visit('/')
|
||||
cy.visitHome()
|
||||
})
|
||||
|
||||
describe('customizable content', () => {
|
||||
|
@ -20,7 +20,7 @@ describe('Intro page', () => {
|
|||
cy.intercept('/mock-backend/public/intro.md', {
|
||||
statusCode: 404
|
||||
})
|
||||
cy.visit('/')
|
||||
cy.visitHome()
|
||||
|
||||
cy.getByCypressId('documentIframe').should('not.exist')
|
||||
})
|
||||
|
|
|
@ -8,7 +8,7 @@ import { languages } from '../fixtures/languages'
|
|||
|
||||
describe('Languages', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/')
|
||||
cy.visitHome()
|
||||
})
|
||||
|
||||
it('all languages are available', () => {
|
||||
|
|
|
@ -8,7 +8,7 @@ import '../support/index'
|
|||
|
||||
describe('Links Intro', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/')
|
||||
cy.visitHome()
|
||||
})
|
||||
|
||||
it('History', () => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
describe('Link gets replaced with embedding: ', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
// TODO Add general testing of one-click-embedding component. The tests below just test a specific use of the component.
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
describe('markdown formatted links to', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
it('external domains render as external link', () => {
|
||||
|
@ -41,7 +41,7 @@ describe('markdown formatted links to', () => {
|
|||
|
||||
describe('HTML anchor element links to', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
it('external domains render as external link', () => {
|
||||
|
|
|
@ -10,7 +10,7 @@ describe('The status bar text length info', () => {
|
|||
const tooMuchTestContent = `${dangerTestContent}a`
|
||||
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
it('shows the maximal length of the document as number of available characters in the tooltip', () => {
|
||||
|
|
|
@ -28,13 +28,13 @@ describe('Motd', () => {
|
|||
|
||||
it('shows the correct alert Motd text', () => {
|
||||
mockExistingMotd()
|
||||
cy.visit('/')
|
||||
cy.visitHome()
|
||||
cy.getByCypressId('motd').contains(motdMockContent)
|
||||
})
|
||||
|
||||
it('can be dismissed using etag', () => {
|
||||
mockExistingMotd(true)
|
||||
cy.visit('/')
|
||||
cy.visitHome()
|
||||
cy.getByCypressId('motd').contains(motdMockContent)
|
||||
cy.getByCypressId('motd-dismiss')
|
||||
.click()
|
||||
|
@ -46,7 +46,7 @@ describe('Motd', () => {
|
|||
|
||||
it('can be dismissed', () => {
|
||||
mockExistingMotd()
|
||||
cy.visit('/')
|
||||
cy.visitHome()
|
||||
cy.getByCypressId('motd').contains(motdMockContent)
|
||||
cy.getByCypressId('motd-dismiss')
|
||||
.click()
|
||||
|
@ -58,7 +58,7 @@ describe('Motd', () => {
|
|||
|
||||
it("won't show again after dismiss and reload", () => {
|
||||
mockExistingMotd()
|
||||
cy.visit('/')
|
||||
cy.visitHome()
|
||||
cy.getByCypressId('motd').contains(motdMockContent)
|
||||
cy.getByCypressId('motd-dismiss')
|
||||
.click()
|
||||
|
@ -73,7 +73,7 @@ describe('Motd', () => {
|
|||
|
||||
it('will show again after reload without dismiss', () => {
|
||||
mockExistingMotd()
|
||||
cy.visit('/')
|
||||
cy.visitHome()
|
||||
cy.getByCypressId('motd').contains(motdMockContent)
|
||||
cy.reload()
|
||||
cy.get('main').should('exist')
|
||||
|
@ -82,7 +82,7 @@ describe('Motd', () => {
|
|||
|
||||
it("won't show again after dismiss and page navigation", () => {
|
||||
mockExistingMotd()
|
||||
cy.visit('/')
|
||||
cy.visitHome()
|
||||
cy.getByCypressId('motd').contains(motdMockContent)
|
||||
cy.getByCypressId('motd-dismiss')
|
||||
.click()
|
||||
|
@ -96,7 +96,7 @@ describe('Motd', () => {
|
|||
})
|
||||
|
||||
it("won't show if no file exists", () => {
|
||||
cy.visit('/')
|
||||
cy.visitHome()
|
||||
cy.get('main').should('exist')
|
||||
cy.getByCypressId('motd').should('not.exist')
|
||||
})
|
||||
|
|
|
@ -48,7 +48,7 @@ describe('profile page', () => {
|
|||
body: []
|
||||
}
|
||||
)
|
||||
cy.visit('/profile')
|
||||
cy.visit('/profile', { retryOnNetworkFailure: true })
|
||||
})
|
||||
|
||||
describe('access tokens', () => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
describe('Quote extra tags', function () {
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
describe('Name quote tag', () => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
describe('Renderer mode', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
it("should be 'document' without type specified", () => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
describe('Short code gets replaced or rendered: ', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
describe('pdf', () => {
|
||||
|
|
|
@ -27,13 +27,13 @@ const initLoggedOutTestWithCustomAuthProviders = (
|
|||
...enabledProviders
|
||||
}
|
||||
})
|
||||
cy.visit('/')
|
||||
cy.visitHome()
|
||||
cy.logout()
|
||||
}
|
||||
|
||||
describe('When logged-in, ', () => {
|
||||
it('sign-in button is hidden', () => {
|
||||
cy.visit('/')
|
||||
cy.visitHome()
|
||||
cy.getByCypressId('sign-in-button').should('not.exist')
|
||||
})
|
||||
})
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { PAGE_MODE } from '../support/visit'
|
||||
|
||||
describe('Slideshow only page', () => {
|
||||
it('renders slide show mode', () => {
|
||||
cy.visit('/p/test')
|
||||
cy.visitTestNote(PAGE_MODE.PRESENTATION)
|
||||
cy.getReveal().should('exist')
|
||||
})
|
||||
})
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
describe('Split view', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
it('can show both panes', () => {
|
||||
|
|
|
@ -11,7 +11,7 @@ const TEST_STRING_INVALID = '- [Y] abc\n\n* [ ] abc\n\n+ [-] abc\n\n1. [.] abc\
|
|||
|
||||
describe('Task lists ', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
describe('render with checkboxes ', () => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
describe('Test word count with', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
it('empty note', () => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
describe('YAML Array for deprecated syntax of document tags in frontmatter', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestEditor()
|
||||
cy.visitTestNote()
|
||||
})
|
||||
|
||||
it('is shown when using old syntax', () => {
|
||||
|
|
|
@ -28,3 +28,4 @@ import './get-by-id'
|
|||
import './get-iframe-content'
|
||||
import './login'
|
||||
import './visit-test-editor'
|
||||
import './visit'
|
||||
|
|
|
@ -4,18 +4,8 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
declare namespace Cypress {
|
||||
interface Chainable {
|
||||
visitTestEditor(query?: string): Chainable<Cypress.AUTWindow>
|
||||
}
|
||||
}
|
||||
|
||||
export const testNoteId = 'test'
|
||||
|
||||
Cypress.Commands.add('visitTestEditor', (query?: string) => {
|
||||
return cy.visit(`/n/${testNoteId}${query ? `?${query}` : ''}`)
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
cy.intercept(`/mock-backend/api/private/notes/${testNoteId}-get`, {
|
||||
content: '',
|
||||
|
|
35
cypress/support/visit.ts
Normal file
35
cypress/support/visit.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { testNoteId } from './visit-test-editor'
|
||||
|
||||
declare namespace Cypress {
|
||||
interface Chainable {
|
||||
visitTestNote(pageMode?: PAGE_MODE, query?: string): Chainable<Cypress.AUTWindow>
|
||||
|
||||
visitHome(): Chainable<Cypress.AUTWindow>
|
||||
|
||||
visitHistory(): Chainable<Cypress.AUTWindow>
|
||||
}
|
||||
}
|
||||
|
||||
Cypress.Commands.add('visitHome', () => {
|
||||
return cy.visit('/', { retryOnNetworkFailure: true })
|
||||
})
|
||||
|
||||
Cypress.Commands.add('visitHistory', () => {
|
||||
return cy.visit(`/history`, { retryOnNetworkFailure: true })
|
||||
})
|
||||
|
||||
export enum PAGE_MODE {
|
||||
EDITOR = 'n',
|
||||
PRESENTATION = 'p',
|
||||
DOCUMENT_READ_ONLY = 's'
|
||||
}
|
||||
|
||||
Cypress.Commands.add('visitTestNote', (pageMode: PAGE_MODE = PAGE_MODE.EDITOR, query?: string) => {
|
||||
return cy.visit(`/${pageMode}/${testNoteId}${query ? `?${query}` : ''}`, { retryOnNetworkFailure: true })
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue