Skip to content

Commit

Permalink
test(cypress): Add tests to move/copy page in/between collectives
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Oct 25, 2023
1 parent ac490a1 commit c855703
Showing 1 changed file with 113 additions and 15 deletions.
128 changes: 113 additions & 15 deletions cypress/e2e/page-list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,22 @@ describe('Page list', function() {
before(function() {
cy.login('bob', { route: '/apps/collectives' })
cy.deleteAndSeedCollective('Our Garden')
cy.seedPage('Day 1', '', 'Readme.md')
cy.seedPage('Target', '', 'Readme.md')
cy.seedPage('Target Subpage', '', 'Target.md')
// Wait 1 second to make sure that page order by time is right
cy.wait(1000) // eslint-disable-line cypress/no-unnecessary-waiting
cy.seedPage('Day 1', '', 'Readme.md')
cy.seedPage('Subpage Title', '', 'Day 1.md')
cy.seedPage('Day 2', '', 'Readme.md')
cy.seedPage('Page Title', '', 'Readme.md')
cy.seedPage('Subpage Title', '', 'Day 1.md')
cy.seedPage('Move me internal', '', 'Readme.md')
cy.seedPage('Copy me internal', '', 'Readme.md')
cy.seedPage('Move me external', '', 'Readme.md')
cy.seedPage('Copy me external', '', 'Readme.md')
cy.seedPage('#% special chars', '', 'Readme.md')
cy.deleteAndSeedCollective('MoveCopyTargetCollective')
cy.seedPage('Target external', '', 'Readme.md')
cy.seedPage('Target Subpage external', '', 'Target external.md')
})

beforeEach(function() {
Expand All @@ -48,27 +57,27 @@ describe('Page list', function() {
cy.get('.app-content-list-item').eq(1)
.should('contain', '#% special chars')
cy.get('.app-content-list-item').last()
.should('contain', 'Day 1')
.should('contain', 'Target')
})
it('can sort pages by title/timestamp and sort order is persistent', function() {
// Select sorting by title
cy.get('span.sort-ascending-icon').click()
cy.get('.sort-alphabetical-ascending-icon').click()
cy.get('.app-content-list-item').last()
.should('contain', 'Page Title')
.should('contain', 'Target')

// Reload to test persistance of sort order
cy.intercept('GET', '**/_api/*/_pages').as('getPages')
cy.reload()
cy.wait('@getPages')
cy.get('.app-content-list-item').last()
.should('contain', 'Page Title')
.should('contain', 'Target')

// Select sorting by timestamp
cy.get('span.sort-alphabetical-ascending-icon').click()
cy.get('button.action-button > span.sort-clock-ascending-outline-icon').click()
cy.get('.app-content-list-item').last()
.should('contain', 'Day 1')
.should('contain', 'Target')

// Remove alternative sort order
cy.get('span.sort-order-chip > button').click()
Expand All @@ -77,19 +86,16 @@ describe('Page list', function() {
cy.get('.app-content-list-item').eq(1)
.should('contain', '#% special chars')
cy.get('.app-content-list-item').last()
.should('contain', 'Day 1')
.should('contain', 'Target')
})
})

describe('Move a page using the modal', function() {
describe('Move and copy a page using the modal', function() {
it('Moves page to a subpage', function() {
cy.seedPage('Move me', '', 'Readme.md')
cy.seedPage('Target', '', 'Readme.md')
cy.seedPage('Target Subpage', '', 'Target.md')
cy.visit('/apps/collectives/Our%20Garden')
cy.openPageMenu('Move me')
cy.clickMenuButton('Move page')
cy.get('.picker-page-list li')
cy.openPageMenu('Move me internal')
cy.clickMenuButton('Move or copy')
cy.get('.picker-list li')
.contains('Target')
.click()
cy.get('.picker-move-buttons button .arrow-down-icon')
Expand All @@ -106,7 +112,99 @@ describe('Page list', function() {
cy.contains('.page-list-drag-item', 'Target')
.get('.page-list-indent .app-content-list-item')
.last()
.contains('Move me')
.contains('Move me internal')
})

it('Copies page to a subpage', function() {
cy.visit('/apps/collectives/Our%20Garden')
cy.openPageMenu('Copy me internal')
cy.clickMenuButton('Move or copy')
cy.get('.picker-list li')
.contains('Target')
.click()
cy.get('.picker-move-buttons button .arrow-down-icon')
.click()
cy.get('.picker-buttons button')
.contains('Copy page here')
.click()

cy.openPage('Target')
cy.contains('.page-list-drag-item', 'Target')
.get('.page-list-indent .app-content-list-item')
.first()
.contains('Target Subpage')
cy.contains('.page-list-drag-item', 'Target')
.get('.page-list-indent .app-content-list-item')
.eq(1)
.contains('Copy me internal')
cy.contains('.page-list-drag-item', 'Target')
.get('.page-list-indent .app-content-list-item')
.last()
.contains('Move me internal')
})

it('Moves page to a subpage in another collective', function() {
cy.visit('/apps/collectives/Our%20Garden')
cy.openPageMenu('Move me external')
cy.clickMenuButton('Move or copy')
cy.get('.crumbs-home')
.click()
cy.get('.picker-list li')
.contains('MoveCopyTargetCollective')
.click()
cy.get('.picker-list li')
.contains('Target external')
.click()
cy.get('.picker-move-buttons button .arrow-down-icon')
.click()
cy.get('.picker-buttons button')
.contains('Move page to MoveCopyTargetCollective')
.click()

cy.visit('/apps/collectives/MoveCopyTargetCollective')
cy.openPage('Target external')
cy.contains('.page-list-drag-item', 'Target external')
.get('.page-list-indent .app-content-list-item')
.first()
.contains('Target Subpage external')
cy.contains('.page-list-drag-item', 'Target external')
.get('.page-list-indent .app-content-list-item')
.last()
.contains('Move me external')
})

it('Copies page to a subpage in another collective', function() {
cy.visit('/apps/collectives/Our%20Garden')
cy.openPageMenu('Copy me external')
cy.clickMenuButton('Move or copy')
cy.get('.crumbs-home')
.click()
cy.get('.picker-list li')
.contains('MoveCopyTargetCollective')
.click()
cy.get('.picker-list li')
.contains('Target external')
.click()
cy.get('.picker-move-buttons button .arrow-down-icon')
.click()
cy.get('.picker-buttons button')
.contains('Copy page to MoveCopyTargetCollective')
.click()

cy.visit('/apps/collectives/MoveCopyTargetCollective')
cy.openPage('Target external')
cy.contains('.page-list-drag-item', 'Target external')
.get('.page-list-indent .app-content-list-item')
.first()
.contains('Target Subpage external')
cy.contains('.page-list-drag-item', 'Target external')
.get('.page-list-indent .app-content-list-item')
.eq(1)
.contains('Copy me external')
cy.contains('.page-list-drag-item', 'Target external')
.get('.page-list-indent .app-content-list-item')
.last()
.contains('Move me external')
})
})

Expand Down

0 comments on commit c855703

Please sign in to comment.