Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress tweaks #947

Merged
merged 5 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cypress/e2e/apps.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ describe('The apps', function() {
})

it('Renders the default files list', function() {
const fileListSelector = '.files-fileList a, [data-cy-files-list-row] a'
cy.login('jane', { route: 'apps/files' })
cy.get(fileListSelector).should('contain', 'welcome')
cy.fileList().should('contain', 'welcome')
})

})
Expand Down
10 changes: 2 additions & 8 deletions cypress/e2e/collective-members.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,8 @@ describe('Collective members', function() {

beforeEach(function() {
cy.login('bob')

cy.get('.collectives_list_item')
.contains('li', 'Members Collective')
.find('.action-item__menutoggle')
.click({ force: true })
cy.get('button.action-button')
.contains('Manage members')
.click()
cy.openCollectiveMenu('Members Collective')
cy.clickMenuButton('Manage members')
})

describe('Manage members', function() {
Expand Down
65 changes: 15 additions & 50 deletions cypress/e2e/collective-settings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,8 @@ describe('Collective settings', function() {

describe('set emoji', function() {
it('Allows setting an emoji', function() {
cy.visit('/apps/collectives')
cy.get('.collectives_list_item')
.contains('li', 'Change me')
.find('.action-item__menutoggle')
.click({ force: true })
cy.get('button.action-button')
.contains('Settings')
.click()
cy.openCollectiveMenu('Change me')
cy.clickMenuButton('Settings')
cy.get('button.button-emoji')
.click()
cy.contains('.emoji-mart-scroll .emoji-mart-emoji', '🥰').click()
Expand All @@ -55,13 +49,8 @@ describe('Collective settings', function() {
.find('.app-navigation-entry-icon').should('contain', '🥰')

// Unset emoji
cy.get('.collectives_list_item')
.contains('li', 'Change me')
.find('.action-item__menutoggle')
.click({ force: true })
cy.get('button.action-button')
.contains('Settings')
.click()
cy.openCollectiveMenu('Change me')
cy.clickMenuButton('Settings')
cy.get('button.button-emoji')
.click()
cy.contains('.emoji-mart-emoji.emoji-selected', '🥰').click()
Expand All @@ -75,13 +64,8 @@ describe('Collective settings', function() {

describe('rename collective', function() {
it('Allows to rename the collective', function() {
cy.get('.collectives_list_item')
.contains('li', 'Change me')
.find('.action-item__menutoggle')
.click({ force: true })
cy.get('button.action-button')
.contains('Settings')
.click()
cy.openCollectiveMenu('Change me')
cy.clickMenuButton('Settings')
cy.get('div.collective-name input[type="text"]').type(' now{enter}')
cy.reload()
cy.get('.collectives_list_item')
Expand All @@ -91,13 +75,8 @@ describe('Collective settings', function() {

describe('change edit permissions', function() {
it('Allows to change editing permissions', function() {
cy.get('.collectives_list_item')
.contains('li', 'Change me now')
.find('.action-item__menutoggle')
.click({ force: true })
cy.get('button.action-button')
.contains('Settings')
.click()
cy.openCollectiveMenu('Change me now')
cy.clickMenuButton('Settings')
cy.get('div.permissions-input-edit > :first-child > .checkbox-radio-switch__label')
.click()
cy.get('div.toast-success').should('contain', 'Editing permissions updated')
Expand All @@ -106,13 +85,8 @@ describe('Collective settings', function() {

describe('change share permissions', function() {
it('Allows to change sharing permissions', function() {
cy.get('.collectives_list_item')
.contains('li', 'Change me now')
.find('.action-item__menutoggle')
.click({ force: true })
cy.get('button.action-button')
.contains('Settings')
.click()
cy.openCollectiveMenu('Change me now')
cy.clickMenuButton('Settings')
cy.get('div.permissions-input-share > :first-child > .checkbox-radio-switch__label')
.click()
cy.get('div.toast-success').should('contain', 'Sharing permissions updated')
Expand All @@ -121,13 +95,8 @@ describe('Collective settings', function() {

describe('change page mode', function() {
it('Allows to change page mode', function() {
cy.get('.collectives_list_item')
.contains('li', 'Change me now')
.find('.action-item__menutoggle')
.click({ force: true })
cy.get('button.action-button')
.contains('Settings')
.click()
cy.openCollectiveMenu('Change me now')
cy.clickMenuButton('Settings')
cy.get('a.navigation-list__link')
.contains('Page settings')
.click()
Expand All @@ -139,13 +108,9 @@ describe('Collective settings', function() {

describe('open settings from landing page actions', function() {
it('Allows to open settings from landing page actions', function() {
cy.visit('/apps/collectives/Change%20me%20now')
cy.contains('.app-content-list-item', 'Change me now')
.find('.action-item__menutoggle')
.click({ force: true })
cy.get('button.action-button')
.contains('Settings')
.click()
cy.openCollective('Change me now')
cy.openPageMenu('Change me now')
cy.clickMenuButton('Settings')
cy.get('div.permissions-input-edit')
})
})
Expand Down
23 changes: 5 additions & 18 deletions cypress/e2e/collective-share.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,9 @@ describe('Collective Share', function() {
.as('clipBoardWriteText')
},
})
cy.get('.collectives_list_item')
.contains('li', 'Share me')
.find('.action-item__menutoggle')
.click({ force: true })
cy.openCollectiveMenu('Share me')
cy.intercept('POST', '**/_api/*/share').as('createShare')
cy.get('button')
.contains('Share link')
.click()
cy.clickMenuButton('Share link')
cy.wait('@createShare')
cy.get('div.open ul')
.contains('Share link').should('not.be.visible')
Expand All @@ -86,10 +81,7 @@ describe('Collective Share', function() {
})
it('Allows toggling the editable flag for a collective share', function() {
cy.login('bob')
cy.get('.collectives_list_item')
.contains('li', 'Share me')
.find('.action-item__menutoggle')
.click({ force: true })
cy.openCollectiveMenu('Share me')
cy.intercept('PUT', '**/_api/*/share/*').as('updateShare')
cy.get('input#shareEditable')
.check({ force: true })
Expand Down Expand Up @@ -122,14 +114,9 @@ describe('Collective Share', function() {
})
it('Allows unsharing a collective', function() {
cy.login('bob')
cy.get('.collectives_list_item')
.contains('li', 'Share me')
.find('.action-item__menutoggle')
.click({ force: true })
cy.openCollectiveMenu('Share me')
cy.intercept('DELETE', '**/_api/*/share/*').as('deleteShare')
cy.get('button')
.contains('Unshare')
.click()
cy.clickMenuButton('Unshare')
cy.wait('@deleteShare')
cy.get('div.open ul')
.contains('Share link').should('be.visible')
Expand Down
29 changes: 8 additions & 21 deletions cypress/e2e/collective.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,13 @@ describe('Collective', function() {
cy.login('bob', { route: '/apps/files' })
})
it('has a matching folder', function() {
const fileListSelector = '.files-fileList a, [data-cy-files-list-row] a'
const breadcrumbsSelector = '.files-controls .breadcrumb, [data-cy-files-content-breadcrumbs] a'
cy.get(fileListSelector).should('contain', 'Collectives')
cy.get(fileListSelector).contains('Collectives').click()
cy.openFile('Collectives')
cy.get(breadcrumbsSelector).should('contain', 'Collectives')
cy.get(fileListSelector).should('contain', 'Preexisting Collective')
cy.get(fileListSelector).contains('Preexisting Collective').click()
cy.openFile('Preexisting Collective')
cy.get(breadcrumbsSelector).should('contain', 'Preexisting Collective')
cy.get(fileListSelector).should('contain', 'Readme')
cy.get(fileListSelector).should('contain', '.md')
cy.fileList().should('contain', 'Readme')
cy.fileList().should('contain', '.md')
cy.get('.filelist-collectives-wrapper')
.should('contain', 'The content of this folder is best viewed in the Collectives app.')
})
Expand Down Expand Up @@ -153,13 +150,8 @@ describe('Collective', function() {
cy.visit('/apps/collectives')

// Leave collective
cy.get('.collectives_list_item')
.contains('li', 'Preexisting Collective')
.find('.action-item__menutoggle')
.click({ force: true })
cy.get('button.action-button')
.contains('Leave collective')
.click()
cy.openCollectiveMenu('Preexisting Collective')
cy.clickMenuButton('Leave collective')
cy.get('.app-navigation-entry')
.contains('Preexisting Collective')
.should('not.be.visible')
Expand All @@ -176,14 +168,9 @@ describe('Collective', function() {
.should('be.visible')

// Leave collective and wait for 10 seconds
cy.get('.collectives_list_item')
.contains('li', 'Preexisting Collective')
.find('.action-item__menutoggle')
.click({ force: true })
cy.openCollectiveMenu('Preexisting Collective')
cy.intercept('PUT', '**/apps/circles/circles/**/leave').as('leaveCircle')
cy.get('button.action-button')
.contains('Leave collective')
.click()
cy.clickMenuButton('Leave collective')
cy.get('.app-navigation-entry')
.contains('Preexisting Collective')
.should('not.be.visible')
Expand Down
36 changes: 8 additions & 28 deletions cypress/e2e/collectives-trash.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,8 @@ describe('Collective', function() {
})
it('Allows moving the collective to trash', function() {
cy.visit('/apps/collectives')
cy.get('.collectives_list_item')
.contains('li', 'Delete me')
.find('.action-item__menutoggle')
.click({ force: true })
cy.get('button.action-button')
.contains('Settings')
.click()
cy.openCollectiveMenu('Delete me')
cy.clickMenuButton('Settings')
cy.get('button')
.contains('Delete collective')
.click()
Expand All @@ -51,13 +46,8 @@ describe('Collective', function() {
cy.login('bob')
cy.get('#collectives-trash')
.click()
cy.get('.collectives_trash_list_item')
.contains('li', 'Delete me')
.find('.action-item__menutoggle')
.click({ force: true })
cy.get('button')
.contains('Restore')
.click()
cy.openTrashedCollectiveMenu('Delete me')
cy.clickMenuButton('Restore')
cy.get('.collectives_list_item')
.should('contain', 'Delete me')
})
Expand All @@ -66,13 +56,8 @@ describe('Collective', function() {
describe('move collective to trash and delete permanently', function() {
it('Allows moving the collective to trash', function() {
cy.login('bob')
cy.get('.collectives_list_item')
.contains('li', 'Delete me')
.find('.action-item__menutoggle')
.click({ force: true })
cy.get('button.action-button')
.contains('Settings')
.click()
cy.openCollectiveMenu('Delete me')
cy.clickMenuButton('Settings')
cy.get('button')
.contains('Delete collective')
.click()
Expand All @@ -85,13 +70,8 @@ describe('Collective', function() {
cy.login('bob')
cy.get('#collectives-trash')
.click()
cy.get('.collectives_trash_list_item')
.contains('li', 'Delete me')
.find('.action-item__menutoggle')
.click({ force: true })
cy.get('button')
.contains('Delete permanently')
.click()
cy.openTrashedCollectiveMenu('Delete me')
cy.clickMenuButton('Delete permanently')
cy.get('button')
.contains('Collective and circle')
.click()
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/page-details.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('Page details', function() {

describe('Display table of contents', function() {
it('Allows to display/close TOC and switch page modes in between', function() {
cy.visit('/apps/collectives/Our%20Garden/TableOfContents')
cy.openPage('TableOfContents')
cy.get('#titleform .action-item__menutoggle')
.click()

Expand Down Expand Up @@ -73,7 +73,7 @@ describe('Page details', function() {
describe('Displaying backlinks', function() {
it('Lists backlinks for a page', function() {
cy.intercept('PUT', '**/apps/text/session/create').as('textCreateSession')
cy.visit('/apps/collectives/Our%20Garden/Day%201')
cy.openPage('Day 1')
cy.wait('@textCreateSession')
cy.get('button.action-item .icon-menu-sidebar').click()
cy.get('a#backlinks').click()
Expand Down
23 changes: 8 additions & 15 deletions cypress/e2e/page-list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,8 @@ describe('Page list', function() {
cy.seedPage('Target', '', 'Readme.md')
cy.seedPage('Target Subpage', '', 'Target.md')
cy.visit('/apps/collectives/Our%20Garden')
cy.contains('.app-content-list-item', 'Move me')
.find('.action-item__menutoggle')
.click({ force: true })
cy.get('button.action-button')
.contains('Move page')
.click()
cy.openPageMenu('Move me')
cy.clickMenuButton('Move page')
cy.get('.picker-page-list li')
.contains('Target')
.click()
Expand All @@ -102,7 +98,7 @@ describe('Page list', function() {
.contains('Move page here')
.click()

cy.visit('/apps/collectives/Our%20Garden/Target')
cy.openPage('Target')
cy.contains('.page-list-drag-item', 'Target')
.get('.page-list-indent .app-content-list-item')
.first()
Expand Down Expand Up @@ -149,7 +145,7 @@ describe('Page list', function() {

describe('Page trash', function() {
it('allows to trash and restore page with subpage and attachment', function() {
cy.visit('/apps/collectives/Our%20Garden/Day%201')
cy.openPage('Day 1')

// Insert attachment
cy.intercept({ method: 'POST', url: '**/text/attachment/upload*' }).as('attachmentUpload')
Expand All @@ -159,12 +155,8 @@ describe('Page list', function() {
cy.switchPageMode(0)

// Trash page
cy.contains('.page-list .app-content-list-item', 'Day 1')
.find('.action-item__menutoggle')
.click({ force: true })
cy.get('button.action-button')
.contains('Delete page and subpages')
.click()
cy.openPageMenu('Day 1')
cy.clickMenuButton('Delete page and subpages')
cy.get('.page-list .app-content-list-item')
.should('not.contain', 'Day 1')

Expand All @@ -177,8 +169,9 @@ describe('Page list', function() {
.click()
cy.get('table tr')
.should('not.exist')
cy.get('button.modal-container__close').click()

cy.visit('/apps/collectives/Our%20Garden/Day%201')
cy.openPage('Day 1')
if (Cypress.env('ncVersion') === 'stable25') {
cy.getEditor()
.find('img.image__main')
Expand Down
Loading