From 55e4ff01f1cbd1f432a8148d0c24587c90afd1f3 Mon Sep 17 00:00:00 2001 From: Jonas Date: Tue, 24 Oct 2023 14:14:58 +0200 Subject: [PATCH] test(cypress): Add tests to move/copy page in/between collectives Signed-off-by: Jonas --- cypress/e2e/page-list.spec.js | 128 ++++++++++++++++++++++++++++++---- 1 file changed, 113 insertions(+), 15 deletions(-) diff --git a/cypress/e2e/page-list.spec.js b/cypress/e2e/page-list.spec.js index 929345a7fe..ca87ba1d3e 100644 --- a/cypress/e2e/page-list.spec.js +++ b/cypress/e2e/page-list.spec.js @@ -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() { @@ -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() @@ -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') @@ -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') }) })