diff --git a/cypress/e2e/boardFeatures.js b/cypress/e2e/boardFeatures.js index acf37ac34..ab47289c5 100644 --- a/cypress/e2e/boardFeatures.js +++ b/cypress/e2e/boardFeatures.js @@ -1,10 +1,12 @@ import { randUser } from '../utils/index.js' const user = randUser() +const recipient = randUser() describe('Board', function() { before(function() { cy.createUser(user) + cy.createUser(recipient) }) beforeEach(function() { @@ -21,7 +23,6 @@ describe('Board', function() { }).as('createBoardRequest') // Click "Add board" - cy.openLeftSidebar() cy.get('#app-navigation-vue .app-navigation__list .app-navigation-entry') .eq(3).find('a').first().click({ force: true }) @@ -38,4 +39,18 @@ describe('Board', function() { cy.get('.app-navigation__list .app-navigation-entry__children .app-navigation-entry') .contains(board).should('be.visible') }) + + it('Shows and hides the navigation', () => { + cy.get('#app-navigation-vue .app-navigation__list .app-navigation-entry') + .contains('Upcoming cards') + .should('be.visible') + cy.openLeftSidebar() + cy.get('#app-navigation-vue .app-navigation__list .app-navigation-entry') + .contains('Upcoming cards') + .should('not.be.visible') + cy.openLeftSidebar() + cy.get('#app-navigation-vue .app-navigation__list .app-navigation-entry') + .contains('Upcoming cards') + .should('be.visible') + }) }) diff --git a/cypress/e2e/cardFeatures.js b/cypress/e2e/cardFeatures.js index fbc994978..7cc1aae4a 100644 --- a/cypress/e2e/cardFeatures.js +++ b/cypress/e2e/cardFeatures.js @@ -1,40 +1,29 @@ import { randUser } from '../utils/index.js' -const user = randUser() +import { sampleBoard } from '../utils/sampleBoard' -const testBoardData = { - title: 'MyBoardTest', - color: '00ff00', - stacks: [ - { - title: 'TestList', - cards: [ - { - title: 'Hello world', - }, - ], - }, - ], -} +const user = randUser() +const boardData = sampleBoard() describe('Card', function() { + let boardId before(function() { cy.createUser(user) cy.login(user) cy.createExampleBoard({ - user: user.userId, - password: user.password, - board: testBoardData, + user, + board: boardData, + }).then((board) => { + boardId = board.id }) }) beforeEach(function() { cy.login(user) - cy.visit('/apps/deck') + cy.visit(`/apps/deck/#/board/${boardId}`) }) it('Can show card details modal', function() { - cy.openLeftSidebar() - cy.getNavigationEntry(testBoardData.title) + cy.getNavigationEntry(boardData.title) .first().click({ force: true }) cy.get('.board .stack').eq(0).within(() => { @@ -48,8 +37,7 @@ describe('Card', function() { it('Can add a card', function() { const newCardTitle = 'Write some cypress tests' - cy.openLeftSidebar() - cy.getNavigationEntry(testBoardData.title) + cy.getNavigationEntry(boardData.title) .first().click({ force: true }) cy.get('.board .stack').eq(0).within(() => { diff --git a/cypress/e2e/deckDashboard.js b/cypress/e2e/deckDashboard.js index 6cd65b6c4..f48f289da 100644 --- a/cypress/e2e/deckDashboard.js +++ b/cypress/e2e/deckDashboard.js @@ -20,7 +20,6 @@ describe('Deck dashboard', function() { it('Can see the default "Personal Board" created for user by default', function() { const defaultBoard = 'Personal' - cy.openLeftSidebar() cy.get('.app-navigation-entry-wrapper[icon=icon-deck]') .find('ul.app-navigation-entry__children .app-navigation-entry:contains(' + defaultBoard + ')') .first() diff --git a/cypress/e2e/sharingFeatures.js b/cypress/e2e/sharingFeatures.js new file mode 100644 index 000000000..634af242b --- /dev/null +++ b/cypress/e2e/sharingFeatures.js @@ -0,0 +1,50 @@ +import { randUser } from '../utils/index.js' +import { sampleBoard } from '../utils/sampleBoard' +const user = randUser() +const recipient = randUser() + +describe('Board', function() { + before(function() { + cy.createUser(user) + cy.createUser(recipient) + }) + + beforeEach(function() { + cy.login(user) + }) + + it('Share a board to a user', function() { + const board = sampleBoard('Read only board') + cy.createExampleBoard({ user, board }).then((board) => { + const boardId = board.id + cy.visit(`/apps/deck/#/board/${boardId}`) + cy.get('.board-title').contains(board.title) + + cy.shareBoardWithUi(recipient.userId) + + cy.login(recipient) + cy.visit(`/apps/deck/#/board/${boardId}`) + cy.get('.board-title').contains(board.title) + cy.get('.button-vue[aria-label*="Add card"]') + .should('not.exist') + }) + }) + + it('Share a board to a user as writable', function() { + const board = sampleBoard('Editable board') + cy.createExampleBoard({ user, board }).then((board) => { + const boardId = board.id + cy.visit(`/apps/deck/#/board/${boardId}`) + cy.get('.board-title').contains(board.title) + + cy.shareBoardWithUi(recipient.userId) + cy.get(`[data-cy="acl-participant:${recipient.userId}"]`).find('[data-cy="action:permission-edit"]').click() + + cy.login(recipient) + cy.visit(`/apps/deck/#/board/${boardId}`) + cy.get('.board-title').contains(board.title) + cy.get('.button-vue[aria-label*="Add card"]') + .first().click() + }) + }) +}) diff --git a/cypress/e2e/stackFeatures.js b/cypress/e2e/stackFeatures.js index 81f5dc721..7eb514f1f 100644 --- a/cypress/e2e/stackFeatures.js +++ b/cypress/e2e/stackFeatures.js @@ -16,8 +16,7 @@ describe('Stack', function() { cy.createUser(user) cy.login(user) cy.createExampleBoard({ - user: user.userId, - password: user.password, + user, board: testBoardData, }) }) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index f81ad73d4..070cbc7c2 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -63,14 +63,15 @@ Cypress.Commands.add('deckCreateList', ({ user, password }, title) => { cy.get('#stack-add form input[type=submit]').first().click() }) -Cypress.Commands.add('createExampleBoard', ({ user, password, board }) => { +Cypress.Commands.add('createExampleBoard', ({ user, board }) => { + const auth = { + user: user.userId, + password: user.password, + } cy.request({ method: 'POST', url: `${Cypress.env('baseUrl')}/index.php/apps/deck/api/v1.0/boards`, - auth: { - user, - password, - }, + auth, body: { title: board.title, color: board.color ?? 'ff0000' }, }).then((boardResponse) => { expect(boardResponse.status).to.eq(200) @@ -80,10 +81,7 @@ Cypress.Commands.add('createExampleBoard', ({ user, password, board }) => { cy.request({ method: 'POST', url: `${Cypress.env('baseUrl')}/index.php/apps/deck/api/v1.0/boards/${boardData.id}/stacks`, - auth: { - user, - password, - }, + auth, body: { title: stack.title, order: 0 }, }).then((stackResponse) => { const stackData = stackResponse.body @@ -92,15 +90,13 @@ Cypress.Commands.add('createExampleBoard', ({ user, password, board }) => { cy.request({ method: 'POST', url: `${Cypress.env('baseUrl')}/index.php/apps/deck/api/v1.0/boards/${boardData.id}/stacks/${stackData.id}/cards`, - auth: { - user, - password, - }, + auth, body: { title: card.title }, }) } }) } + cy.wrap(boardData) }) }) @@ -109,3 +105,13 @@ Cypress.Commands.add('getNavigationEntry', (boardTitle) => { .find('ul.app-navigation-entry__children .app-navigation-entry:contains(' + boardTitle + ')') .find('a.app-navigation-entry-link') }) + +Cypress.Commands.add('shareBoardWithUi', (userId) => { + cy.get('[aria-label="Open details"]').click() + cy.get('.app-sidebar').should('be.visible') + cy.get('.multiselect__input').type(`${userId}`) + cy.get('.multiselect__content .multiselect__element').first().contains(userId) + cy.get('.multiselect__input').type('{enter}') + + cy.get('.shareWithList').contains(userId) +}) diff --git a/cypress/support/component-index.html b/cypress/support/component-index.html new file mode 100644 index 000000000..ac6e79fd8 --- /dev/null +++ b/cypress/support/component-index.html @@ -0,0 +1,12 @@ + + +
+ + + +