Skip to content

Commit

Permalink
fix: workspace cypress tests
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Trovic <luka@nextcloud.com>
  • Loading branch information
luka-nextcloud committed Oct 13, 2023
1 parent 6ee5636 commit 46c65aa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 26 deletions.
26 changes: 13 additions & 13 deletions cypress/e2e/workspace.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import { randUser } from '../utils/index.js'
const user = randUser()

describe.skip('Workspace', function() {
describe('Workspace', function() {
let currentFolder

before(function() {
Expand All @@ -49,7 +49,6 @@ describe.skip('Workspace', function() {
.should('contain', 'Hello world')
cy.openFolder('subdirectory')
cy.get('#rich-workspace')
.get('.ProseMirror')
.should('not.exist')
})

Expand All @@ -66,29 +65,30 @@ describe.skip('Workspace', function() {
})

it('adds a Readme.md', function() {
cy.createDescription()
cy.createDescription(currentFolder)
openSidebar('Readme.md')
cy.get('#rich-workspace .text-editor .text-editor__wrapper')
.should('be.visible')
})

it('formats text', function() {
cy.visit(`apps/files?dir=/${encodeURIComponent(currentFolder)}`)
cy.openWorkspace()
cy.openWorkspace(currentFolder)
const buttons = [
['bold', 'strong'],
['italic', 'em'],
['underline', 'u'],
['strikethrough', 's'],
]
cy.getContent().click()
buttons.forEach(([button, tag]) => testButtonUnselected(button, tag))
cy.getContent().type('Format me{selectall}')
buttons.forEach(([button, tag]) => testButton(button, tag, 'Format me'))
})

it('creates headings via submenu', function() {
cy.visit(`apps/files?dir=/${encodeURIComponent(currentFolder)}`)
cy.openWorkspace().type('Heading')
cy.openWorkspace(currentFolder).type('Heading')
cy.getContent().type('{selectall}')
;['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].forEach((heading) => {
const actionName = `headings-${heading}`
Expand All @@ -109,7 +109,7 @@ describe.skip('Workspace', function() {

it('creates lists', function() {
cy.visit(`apps/files?dir=/${encodeURIComponent(currentFolder)}`)
cy.openWorkspace().type('List me')
cy.openWorkspace(currentFolder).type('List me')
cy.getContent().type('{selectall}')
;[
['unordered-list', 'ul'],
Expand All @@ -128,7 +128,7 @@ describe.skip('Workspace', function() {

it('emoji picker', () => {
cy.visit(`apps/files?dir=/${encodeURIComponent(currentFolder)}`)
cy.openWorkspace()
cy.openWorkspace(currentFolder)
.type('# Let\'s smile together{enter}## ')

cy.getMenuEntry('emoji-picker')
Expand All @@ -150,7 +150,7 @@ describe.skip('Workspace', function() {
cy.uploadFile('test.md', 'text/markdown', `${currentFolder}/sub-folder/alpha/test.md`)
cy.visit(`apps/files?dir=/${encodeURIComponent(currentFolder)}`)

cy.openWorkspace()
cy.openWorkspace(currentFolder)
.type('link me')
cy.getContent()
.type('{selectall}')
Expand All @@ -160,7 +160,7 @@ describe.skip('Workspace', function() {

cy.get('.file-picker__main .file-picker__file-name[title="sub-folder"]').click()
cy.get('.file-picker__main .file-picker__file-name[title="alpha"]').click()
cy.get('.file-picker__main .file-picker__file-name[title="test.md"]').click()
cy.get('.file-picker__main .file-picker__file-name[title="test"]').click()
cy.get('.dialog__actions button.button-vue--vue-primary').click()

cy.getEditor()
Expand Down Expand Up @@ -188,7 +188,7 @@ describe.skip('Workspace', function() {

beforeEach(function() {
cy.visit(`apps/files?dir=/${encodeURIComponent(currentFolder)}`)
cy.openWorkspace().type('Callout')
cy.openWorkspace(currentFolder).type('Callout')
})
// eslint-disable-next-line cypress/no-async-tests
it('create callout', () => {
Expand Down Expand Up @@ -266,17 +266,17 @@ describe.skip('Workspace', function() {
})

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

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

it('spacebar', () => {
cy.openWorkspace()
cy.openWorkspace(currentFolder)
.trigger('keyup', {
keyCode: 32,
which: 32,
Expand Down
18 changes: 5 additions & 13 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ Cypress.Commands.add('clearContent', () => {
cy.getContent()
})

Cypress.Commands.add('openWorkspace', () => {
cy.createDescription()
Cypress.Commands.add('openWorkspace', (folder) => {
cy.createDescription(folder)
cy.get('#rich-workspace .editor__content').click({ force: true })
cy.getEditor().find('[data-text-el="editor-content-wrapper"]').click({ force: true })

Expand All @@ -415,17 +415,9 @@ Cypress.Commands.add('showHiddenFiles', () => {
cy.get('.modal-container__close').click()
})

Cypress.Commands.add('createDescription', () => {
const url = '**/remote.php/dav/files/**'
cy.intercept({ method: 'PUT', url })
.as('addDescription')

cy.get('[data-cy-files-list] tr[data-cy-files-list-row-name="Readme.md"]').should('not.exist')
cy.get('.files-controls').first().within(() => {
cy.get('.button.new').click()
cy.get('.newFileMenu a.menuitem[data-action="rich-workspace-init"]').click()
})
cy.wait('@addDescription')
Cypress.Commands.add('createDescription', (folder) => {
cy.uploadFile('empty.md', 'text/markdown', `${folder}/Readme.md`)
cy.visit(`apps/files?dir=/${encodeURIComponent(folder)}`)
})

Cypress.on(
Expand Down

0 comments on commit 46c65aa

Please sign in to comment.