Skip to content

Commit

Permalink
test(cy): use function() instead of arrow shorthand
Browse files Browse the repository at this point in the history
Otherwise `this.testFolder` is not available
as `this` cannot be reassigned with arrow functions.

Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud committed Dec 18, 2023
1 parent b63c004 commit 7842447
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions cypress/e2e/workspace.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const user = randUser()
describe('Workspace', function() {

before(function() {
cy.createUser(user, 'password')
cy.createUser(user)
})

beforeEach(function() {
Expand Down Expand Up @@ -125,7 +125,7 @@ describe('Workspace', function() {
.should('contain', 'Hello world')
})

it('emoji picker', () => {
it('emoji picker', function() {
cy.visitTestFolder()
cy.openWorkspace()
.type('# Let\'s smile together{enter}## ')
Expand All @@ -142,7 +142,7 @@ describe('Workspace', function() {
.contains('😀')
})

it('relative folder links', () => {
it('relative folder links', function() {
cy.createFolder(`${this.testFolder}/sub-folder`)
cy.createFolder(`${this.testFolder}/sub-folder/alpha`)

Expand Down Expand Up @@ -182,15 +182,15 @@ describe('Workspace', function() {
cy.getModal().find('button.header-close').click()
})

describe('callouts', () => {
describe('callouts', function() {
const types = ['info', 'warn', 'error', 'success']

beforeEach(function() {
cy.visitTestFolder()
cy.openWorkspace().type('Callout')
})
// eslint-disable-next-line cypress/no-async-tests
it('create callout', () => {
it('create callout', function() {
cy.wrap(types).each((type) => {
cy.log(`creating ${type} callout`)

Expand All @@ -211,7 +211,7 @@ describe('Workspace', function() {
})
})

it('toggle callouts', () => {
it('toggle callouts', function() {
const [first, ...rest] = types

// enable callout
Expand All @@ -232,7 +232,7 @@ describe('Workspace', function() {
})
})

describe('localize', () => {
describe('localize', function() {
it('takes localized file name into account', function() {
cy.modifyUser(user, 'language', 'de_DE')
cy.uploadFile('test.md', 'text/markdown', `${this.testFolder}/Anleitung.md`)
Expand All @@ -247,11 +247,13 @@ describe('Workspace', function() {
cy.uploadFile('test.md', 'text/markdown', `${this.testFolder}/Anleitung.md`)
cy.visitTestFolder()
cy.getFile('Anleitung.md')
cy.get('#rich-workspace .ProseMirror')
.should('not.exist')
})
})

describe('create Readme.md', () => {
const checkContent = () => {
describe('create Readme.md', function() {
const checkContent = function() {
const txt = Cypress.currentTest.title

cy.getEditor().find('[data-text-el="editor-content-wrapper"]').click()
Expand All @@ -260,21 +262,21 @@ describe('Workspace', function() {
cy.getContent().should('contain', txt)
}

beforeEach(() => {
beforeEach(function() {
cy.visitTestFolder()
})

it('click', () => {
it('click', function() {
cy.openWorkspace().click()
checkContent()
})

it('enter', () => {
it('enter', function() {
cy.openWorkspace().type('{enter}')
checkContent()
})

it('spacebar', () => {
it('spacebar', function() {
cy.openWorkspace()
.trigger('keyup', {
keyCode: 32,
Expand Down

0 comments on commit 7842447

Please sign in to comment.