From bc757a36711c72164818ce782a44f8dbbbcbe765 Mon Sep 17 00:00:00 2001 From: Elizabeth Danzberger Date: Wed, 6 Mar 2024 12:56:57 -0500 Subject: [PATCH] test: refactored tests and cypress github workflow to skip file action import test for v26-27 Signed-off-by: Elizabeth Danzberger --- .github/workflows/cypress.yml | 1 + cypress/e2e/tables-import.cy.js | 86 +++++++++++++++++---------------- 2 files changed, 46 insertions(+), 41 deletions(-) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 47f025720..fbaf2c159 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -139,6 +139,7 @@ jobs: COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }} CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} + CYPRESS_ncVersion: ${{ matrix.server-versions }} npm_package_name: ${{ env.APP_NAME }} - name: Print logs diff --git a/cypress/e2e/tables-import.cy.js b/cypress/e2e/tables-import.cy.js index 320e13f13..692b0cf4e 100644 --- a/cypress/e2e/tables-import.cy.js +++ b/cypress/e2e/tables-import.cy.js @@ -49,55 +49,59 @@ describe('Import csv', () => { }) -describe('Import csv from Files file action', () => { +// only run the following tests if not testing on v26 or v27 +// the files api in use is only supported on v28+ +if (!['stable26', 'stable27'].includes(Cypress.env('ncVersion'))) { + describe('Import csv from Files file action', () => { + + before(function() { + cy.createRandomUser().then(user => { + localUser = user + cy.login(localUser) + cy.uploadFile('test-import.csv', 'text/csv') + }) + }) - before(function() { - cy.createRandomUser().then(user => { - localUser = user + beforeEach(function() { cy.login(localUser) - cy.uploadFile('test-import.csv', 'text/csv') + cy.visit('apps/files/files') }) - }) - beforeEach(function() { - cy.login(localUser) - cy.visit('apps/files/files') - }) - - it('Import to new table', () => { - cy.get('[data-cy-files-list-row-name="test-import.csv"] [data-cy-files-list-row-actions] .action-item button').click() - cy.get('[data-cy-files-list-row-action="import-to-tables"]').click() + it('Import to new table', () => { + cy.get('[data-cy-files-list-row-name="test-import.csv"] [data-cy-files-list-row-actions] .action-item button').click() + cy.get('[data-cy-files-list-row-action="import-to-tables"]').click() - cy.intercept({ method: 'POST', url: '**/apps/tables/import/table/*'}).as('importNewTableReq') - cy.get('[data-cy="fileActionImportButton"]').click() - cy.wait('@importNewTableReq').its('response.statusCode').should('equal', 200) + cy.intercept({ method: 'POST', url: '**/apps/tables/import/table/*'}).as('importNewTableReq') + cy.get('[data-cy="fileActionImportButton"]').click() + cy.wait('@importNewTableReq').its('response.statusCode').should('equal', 200) - cy.get('[data-cy="importResultColumnsFound"]').should('contain.text', '4') - cy.get('[data-cy="importResultColumnsMatch"]').should('contain.text', '0') - cy.get('[data-cy="importResultColumnsCreated"]').should('contain.text', '4') - cy.get('[data-cy="importResultRowsInserted"]').should('contain.text', '3') - cy.get('[data-cy="importResultParsingErrors"]').should('contain.text', '0') - cy.get('[data-cy="importResultRowErrors"]').should('contain.text', '0') - }) + cy.get('[data-cy="importResultColumnsFound"]').should('contain.text', '4') + cy.get('[data-cy="importResultColumnsMatch"]').should('contain.text', '0') + cy.get('[data-cy="importResultColumnsCreated"]').should('contain.text', '4') + cy.get('[data-cy="importResultRowsInserted"]').should('contain.text', '3') + cy.get('[data-cy="importResultParsingErrors"]').should('contain.text', '0') + cy.get('[data-cy="importResultRowErrors"]').should('contain.text', '0') + }) - it('Import to existing table', () => { - cy.get('[data-cy-files-list-row-name="test-import.csv"] [data-cy-files-list-row-actions] .action-item button').click() - cy.get('[data-cy-files-list-row-action="import-to-tables"]').click() + it('Import to existing table', () => { + cy.get('[data-cy-files-list-row-name="test-import.csv"] [data-cy-files-list-row-actions] .action-item button').click() + cy.get('[data-cy-files-list-row-action="import-to-tables"]').click() - cy.get('[data-cy="importAsNewTableSwitch"]').click() - cy.get('[data-cy="selectExistingTableDropdown"]').type('tutorial') - cy.get('.name-parts').click() + cy.get('[data-cy="importAsNewTableSwitch"]').click() + cy.get('[data-cy="selectExistingTableDropdown"]').type('tutorial') + cy.get('.name-parts').click() - cy.intercept({ method: 'POST', url: '**/apps/tables/import/table/*'}).as('importExistingTableReq') - cy.get('[data-cy="fileActionImportButton"]').click() - cy.wait('@importExistingTableReq').its('response.statusCode').should('equal', 200) + cy.intercept({ method: 'POST', url: '**/apps/tables/import/table/*'}).as('importExistingTableReq') + cy.get('[data-cy="fileActionImportButton"]').click() + cy.wait('@importExistingTableReq').its('response.statusCode').should('equal', 200) - cy.get('[data-cy="importResultColumnsFound"]').should('contain.text', '4') - cy.get('[data-cy="importResultColumnsMatch"]').should('contain.text', '4') - cy.get('[data-cy="importResultColumnsCreated"]').should('contain.text', '0') - cy.get('[data-cy="importResultRowsInserted"]').should('contain.text', '3') - cy.get('[data-cy="importResultParsingErrors"]').should('contain.text', '0') - cy.get('[data-cy="importResultRowErrors"]').should('contain.text', '0') - }) + cy.get('[data-cy="importResultColumnsFound"]').should('contain.text', '4') + cy.get('[data-cy="importResultColumnsMatch"]').should('contain.text', '4') + cy.get('[data-cy="importResultColumnsCreated"]').should('contain.text', '0') + cy.get('[data-cy="importResultRowsInserted"]').should('contain.text', '3') + cy.get('[data-cy="importResultParsingErrors"]').should('contain.text', '0') + cy.get('[data-cy="importResultRowErrors"]').should('contain.text', '0') + }) -}) + }) +}