Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: File action to import from Files to Tables #890

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: refactored tests and cypress github workflow to skip file actio…
…n import test for v26-27

Signed-off-by: Elizabeth Danzberger <[email protected]>
elzody authored and juliusknorr committed Mar 8, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit d4e99e89ff9de9597c6a455f7a189852b4f493b7
1 change: 1 addition & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -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
86 changes: 45 additions & 41 deletions cypress/e2e/tables-import.cy.js
Original file line number Diff line number Diff line change
@@ -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')
})

})
})
}