|
3 | 3 | * SPDX-License-Identifier: AGPL-3.0-or-later |
4 | 4 | */ |
5 | 5 | import { randUser } from '../utils/index.js' |
| 6 | +import { sampleBoard } from '../utils/sampleBoard.js' |
6 | 7 | const user = randUser() |
7 | 8 | const recipient = randUser() |
8 | 9 |
|
@@ -58,3 +59,81 @@ describe('Board', function() { |
58 | 59 | .should('be.visible') |
59 | 60 | }) |
60 | 61 | }) |
| 62 | + |
| 63 | +describe('Board export', function() { |
| 64 | + before(function() { |
| 65 | + cy.createUser(user) |
| 66 | + }) |
| 67 | + |
| 68 | + it('Exports a board as JSON', function() { |
| 69 | + const boardName = 'Export JSON board' |
| 70 | + const board = sampleBoard(boardName) |
| 71 | + cy.createExampleBoard({ user, board }).then((board) => { |
| 72 | + const boardId = board.id |
| 73 | + cy.visit(`/apps/deck/board/${boardId}`) |
| 74 | + cy.get('.app-navigation__list .app-navigation-entry:contains("' + boardName + '")') |
| 75 | + .parent() |
| 76 | + .find('button[aria-label="Actions"]') |
| 77 | + .click() |
| 78 | + cy.get('button:contains("Export board")') |
| 79 | + .click() |
| 80 | + cy.get('.modal-container .checkbox-radio-switch__text:contains("Export as JSON")') |
| 81 | + .click() |
| 82 | + cy.get('.modal-container button:contains("Export")') |
| 83 | + .click() |
| 84 | + |
| 85 | + const downloadsFolder = Cypress.config('downloadsFolder') |
| 86 | + cy.readFile(`${downloadsFolder}/${boardName}.json`) |
| 87 | + }) |
| 88 | + }) |
| 89 | + |
| 90 | + it('Exports a board as CSV', function() { |
| 91 | + const boardName = 'Export CSV board' |
| 92 | + const board = sampleBoard(boardName) |
| 93 | + cy.createExampleBoard({ user, board }).then((board) => { |
| 94 | + const boardId = board.id |
| 95 | + cy.visit(`/apps/deck/board/${boardId}`) |
| 96 | + cy.get('.app-navigation__list .app-navigation-entry:contains("' + boardName + '")') |
| 97 | + .parent() |
| 98 | + .find('button[aria-label="Actions"]') |
| 99 | + .click() |
| 100 | + cy.get('button:contains("Export board")') |
| 101 | + .click() |
| 102 | + cy.get('.modal-container .checkbox-radio-switch__text:contains("Export as CSV")') |
| 103 | + .click() |
| 104 | + cy.get('.modal-container button:contains("Export")') |
| 105 | + .click() |
| 106 | + |
| 107 | + const downloadsFolder = Cypress.config('downloadsFolder') |
| 108 | + cy.readFile(`${downloadsFolder}/${boardName}.csv`) |
| 109 | + }) |
| 110 | + }) |
| 111 | +}) |
| 112 | + |
| 113 | +describe('Board import', function() { |
| 114 | + before(function() { |
| 115 | + cy.createUser(user) |
| 116 | + }) |
| 117 | + beforeEach(function() { |
| 118 | + cy.login(user) |
| 119 | + cy.visit('/apps/deck') |
| 120 | + }) |
| 121 | + |
| 122 | + it('Imports a board from JSON', function() { |
| 123 | + cy.get('#app-navigation-vue .app-navigation__list .app-navigation-entry:contains("Import board")') |
| 124 | + .should('be.visible') |
| 125 | + .click() |
| 126 | + |
| 127 | + // Upload a JSON file |
| 128 | + cy.get('input[type="file"]') |
| 129 | + .selectFile([ |
| 130 | + { |
| 131 | + contents: 'cypress/fixtures/import-board.json', |
| 132 | + fileName: 'import-board.json', |
| 133 | + }, |
| 134 | + ], { force: true }) |
| 135 | + |
| 136 | + cy.get('.app-navigation__list .app-navigation-entry:contains("Imported board")') |
| 137 | + .should('be.visible') |
| 138 | + }) |
| 139 | +}) |
0 commit comments