-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add cypress test for scheme export import
Signed-off-by: grnd-alt <[email protected]>
- Loading branch information
Showing
4 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ SPDX-PackageSupplier = "Nextcloud <[email protected]>" | |
SPDX-PackageDownloadLocation = "https://github.com/nextcloud/tables" | ||
|
||
[[annotations]] | ||
path = [".tx/config", "l10n/**.js", "l10n/**.json", "composer.json", "composer.lock", "package.json", "package-lock.json"] | ||
path = [".tx/config", "l10n/**.js", "l10n/**.json", "composer.json", "composer.lock", cypress/e2e/ToDo list.json", "package.json", "package-lock.json"] | ||
precedence = "aggregate" | ||
SPDX-FileCopyrightText = "2021 Nextcloud GmbH and Nextcloud contributors" | ||
SPDX-License-Identifier = "AGPL-3.0-or-later" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"title":"ToDo list","emoji":"\u2705","columns":[{"id":491,"tableId":132,"title":"Task","createdBy":"admin","createdByDisplayName":"admin","createdAt":"2024-08-26 12:58:43","lastEditBy":"admin","lastEditByDisplayName":"admin","lastEditAt":"2024-08-26 12:58:43","type":"text","subtype":"line","mandatory":true,"description":"","numberDefault":null,"numberMin":null,"numberMax":null,"numberDecimals":0,"numberPrefix":"","numberSuffix":"","textDefault":"","textAllowedPattern":"","textMaxLength":-1,"selectionOptions":[],"selectionDefault":"","datetimeDefault":"","usergroupDefault":[],"usergroupMultipleItems":false,"usergroupSelectUsers":false,"usergroupSelectGroups":false,"showUserStatus":false},{"id":492,"tableId":132,"title":"Description","createdBy":"admin","createdByDisplayName":"admin","createdAt":"2024-08-26 12:58:43","lastEditBy":"admin","lastEditByDisplayName":"admin","lastEditAt":"2024-08-26 12:58:43","type":"text","subtype":"rich","mandatory":false,"description":"Title or short description","numberDefault":null,"numberMin":null,"numberMax":null,"numberDecimals":0,"numberPrefix":"","numberSuffix":"","textDefault":"","textAllowedPattern":"","textMaxLength":-1,"selectionOptions":[],"selectionDefault":"","datetimeDefault":"","usergroupDefault":[],"usergroupMultipleItems":false,"usergroupSelectUsers":false,"usergroupSelectGroups":false,"showUserStatus":false},{"id":493,"tableId":132,"title":"Target","createdBy":"admin","createdByDisplayName":"admin","createdAt":"2024-08-26 12:58:43","lastEditBy":"admin","lastEditByDisplayName":"admin","lastEditAt":"2024-08-26 12:58:43","type":"text","subtype":"rich","mandatory":false,"description":"Date, time or whatever","numberDefault":null,"numberMin":null,"numberMax":null,"numberDecimals":0,"numberPrefix":"","numberSuffix":"","textDefault":"","textAllowedPattern":"","textMaxLength":-1,"selectionOptions":[],"selectionDefault":"","datetimeDefault":"","usergroupDefault":[],"usergroupMultipleItems":false,"usergroupSelectUsers":false,"usergroupSelectGroups":false,"showUserStatus":false},{"id":494,"tableId":132,"title":"Progress","createdBy":"admin","createdByDisplayName":"admin","createdAt":"2024-08-26 12:58:43","lastEditBy":"admin","lastEditByDisplayName":"admin","lastEditAt":"2024-08-26 12:58:43","type":"number","subtype":"progress","mandatory":false,"description":"","numberDefault":0,"numberMin":null,"numberMax":null,"numberDecimals":0,"numberPrefix":"","numberSuffix":"","textDefault":"","textAllowedPattern":"","textMaxLength":-1,"selectionOptions":[],"selectionDefault":"","datetimeDefault":"","usergroupDefault":[],"usergroupMultipleItems":false,"usergroupSelectUsers":false,"usergroupSelectGroups":false,"showUserStatus":false},{"id":495,"tableId":132,"title":"Comments","createdBy":"admin","createdByDisplayName":"admin","createdAt":"2024-08-26 12:58:43","lastEditBy":"admin","lastEditByDisplayName":"admin","lastEditAt":"2024-08-26 12:58:43","type":"text","subtype":"rich","mandatory":false,"description":"","numberDefault":null,"numberMin":null,"numberMax":null,"numberDecimals":0,"numberPrefix":"","numberSuffix":"","textDefault":"","textAllowedPattern":"","textMaxLength":-1,"selectionOptions":[],"selectionDefault":"","datetimeDefault":"","usergroupDefault":[],"usergroupMultipleItems":false,"usergroupSelectUsers":false,"usergroupSelectGroups":false,"showUserStatus":false},{"id":496,"tableId":132,"title":"Proofed","createdBy":"admin","createdByDisplayName":"admin","createdAt":"2024-08-26 12:58:43","lastEditBy":"admin","lastEditByDisplayName":"admin","lastEditAt":"2024-08-26 12:58:43","type":"selection","subtype":"check","mandatory":false,"description":"","numberDefault":null,"numberMin":null,"numberMax":null,"numberDecimals":0,"numberPrefix":"","numberSuffix":"","textDefault":"","textAllowedPattern":"","textMaxLength":-1,"selectionOptions":[],"selectionDefault":"","datetimeDefault":"","usergroupDefault":[],"usergroupMultipleItems":false,"usergroupSelectUsers":false,"usergroupSelectGroups":false,"showUserStatus":false}],"views":[],"description":"","tablesVersion":"0.8.0-beta.2"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
let localUser | ||
|
||
const omitSubFields = (array, fields) => { | ||
return array.map( | ||
(item) => Object.keys(item).filter( | ||
filterKey => !fields.includes(filterKey)).reduce( | ||
(obj, key) => { | ||
obj[key] = item[key] | ||
return obj | ||
}, {}), | ||
) | ||
} | ||
|
||
describe('Import Export Scheme', () => { | ||
|
||
before(function() { | ||
cy.createRandomUser().then(user => { | ||
localUser = user | ||
}) | ||
}) | ||
|
||
beforeEach(function() { | ||
cy.login(localUser) | ||
cy.visit('apps/tables') | ||
}) | ||
|
||
it('Import table from scheme', () => { | ||
cy.get('.icon-loading').should('not.exist') | ||
cy.get('[data-cy="navigationCreateTableIcon"]').click({ force: true }) | ||
cy.get('p').contains('Import Scheme').click({ force: true }) | ||
cy.contains('button', 'Create table').scrollIntoView().click() | ||
cy.get('input[type=file].hidden-visually').selectFile('./cypress/e2e/ToDo list.json', { force: true }) | ||
cy.get('button').contains('Import').click() | ||
cy.get('.app-navigation-toggle-wrapper').should('be.visible').click() | ||
cy.get('.app-navigation__list').contains('ToDo list').should('exist') | ||
}) | ||
|
||
it('Export scheme to json', () => { | ||
const columnFieldsToIgnore = ['id', 'tableId', 'createdAt', 'lastEditAt', 'createdBy', 'createdByDisplayName', 'lastEditBy', 'lastEditByDisplayName'] | ||
cy.get('.app-navigation-toggle-wrapper').should('be.visible').click() | ||
cy.get('.app-navigation__list').contains('ToDo list').click() | ||
cy.get('.row.first-row').should('be.visible') | ||
cy.get('.app-navigation__list').contains('ToDo list').trigger('mouseover') | ||
cy.get('.app-navigation-entry__actions').last('').click() | ||
cy.get('.action-button__text').contains('Export').click() | ||
const downloadsFolder = Cypress.config('downloadsFolder') | ||
cy.readFile('./cypress/e2e/ToDo list.json').then(content => { | ||
cy.readFile(`${downloadsFolder}/ToDo list.json`).then(expectedContent => { | ||
expectedContent.columns = omitSubFields(expectedContent.columns, columnFieldsToIgnore) | ||
content.columns = omitSubFields(content.columns, columnFieldsToIgnore) | ||
expect(JSON.stringify(expectedContent)).to.eq(JSON.stringify(content)) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters