Skip to content

Commit

Permalink
fix: improve Cypress selectors, wait for requests
Browse files Browse the repository at this point in the history
Signed-off-by: Cleopatra Enjeck M <[email protected]>
  • Loading branch information
enjeck committed Jul 16, 2024
1 parent b1f650a commit b1a209c
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 22 deletions.
7 changes: 3 additions & 4 deletions cypress/e2e/context.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('Manage a context', () => {
cy.login(nonLocalUser)
cy.visit('apps/tables')
cy.loadContext(contextTitle)
cy.contains('header .header-left .app-menu li.app-menu-entry__active', contextTitle).should('exist')
cy.contains('header .app-menu-entry', contextTitle).should('exist')
cy.contains('h1', contextTitle).should('exist')
cy.contains('h1', tableTitle).should('exist')

Expand All @@ -95,7 +95,7 @@ describe('Manage a context', () => {
cy.login(nonLocalUser)
cy.visit('apps/tables')
cy.loadContext(contextTitle)
cy.contains('header .header-left .app-menu li.app-menu-entry__active', contextTitle).should('exist')
cy.contains('header .app-menu-entry', contextTitle).should('exist')
cy.contains('h1', contextTitle).should('exist')
})

Expand Down Expand Up @@ -125,7 +125,6 @@ describe('Manage a context', () => {
it('Remove context resource', () => {
cy.createTable(tableTitle)
cy.loadContext(contextTitle)
cy.contains('header .header-left .app-menu li.app-menu-entry__active', contextTitle).should('exist')
cy.openContextEditModal(contextTitle)
cy.get('[data-cy="contextResourceForm"] input').clear().type(tableTitle)
cy.get('ul.vs__dropdown-menu li div').contains(tableTitle).click()
Expand Down Expand Up @@ -187,7 +186,7 @@ describe('Manage a context', () => {
cy.login(nonLocalUser)
cy.visit('apps/tables')
cy.loadContext(contextTitle)
cy.contains('header .header-left .app-menu li.app-menu-entry__active', contextTitle).should('exist')
cy.contains('header .app-menu-entry', contextTitle).should('exist')
cy.contains('h1', contextTitle).should('exist')
cy.contains('h1', tableTitle).should('exist')
cy.get('button').contains('Create row').click()
Expand Down
6 changes: 4 additions & 2 deletions cypress/e2e/tables-import.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ describe('Import csv', () => {
cy.get('.file-picker__files').contains('test-import').click()
cy.get('.file-picker button span').contains('Choose test-import.csv').click()
cy.get('.modal__content .import-filename', { timeout: 5000 }).should('be.visible')
cy.intercept({ method: 'POST', url: '**/apps/tables/import/table/*'}).as('importUploadReq')
cy.get('.modal__content button').contains('Import').click()

cy.wait('@importUploadReq')
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')
Expand All @@ -37,8 +38,9 @@ describe('Import csv', () => {
cy.clickOnTableThreeDotMenu('Import')
cy.get('.modal__content button').contains('Upload from device').click()
cy.get('input[type="file"]').selectFile('cypress/fixtures/test-import.csv', { force: true })
cy.intercept({ method: 'POST', url: '**/apps/tables/importupload/table/*'}).as('importUploadReq')
cy.get('.modal__content button').contains('Import').click()

cy.wait('@importUploadReq')
cy.get('[data-cy="importResultColumnsFound"]', { timeout: 20000 }).should('contain.text', '4')
cy.get('[data-cy="importResultColumnsMatch"]').should('contain.text', '4')
cy.get('[data-cy="importResultColumnsCreated"]').should('contain.text', '0')
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/tables-rows.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ describe('Rows for a table', () => {
})

it('Check mandatory fields error', () => {
cy.contains('.app-menu-entry--label', 'Tables').click()
cy.contains('button', 'Create new table').click()
cy.get('.icon-loading').should('not.exist')
cy.get('[data-cy="navigationCreateTableIcon"]').click({ force: true })
cy.get('.tile').contains('ToDo').click({ force: true })
cy.get('.modal__content').should('be.visible')
cy.get('.modal__content input[type="text"]').clear().type('to do list')
cy.get('[data-cy="createTableModal"]').should('be.visible')
cy.get('[data-cy="createTableModal"] input[type="text"]').clear().type('to do list')
cy.contains('button', 'Create table').click()

cy.get('.app-navigation-entry-link').contains('to do list').click({ force: true })
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/tables-share.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe('Manage a table', () => {
cy.visit('apps/tables')

// create table to share
cy.contains('.app-menu-entry--label', 'Tables').click()
cy.contains('button', 'Create new table').click()
cy.get('.icon-loading').should('not.exist')
cy.get('[data-cy="navigationCreateTableIcon"]').click({ force: true })
cy.get('.tile').contains('ToDo').click({ force: true })
cy.get('.modal__content input[type="text"]').clear().type('Shared todo')
cy.contains('button', 'Create table').click()
Expand Down
14 changes: 8 additions & 6 deletions cypress/e2e/tables-table.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ describe('Manage a table', () => {
})

it('Create', () => {
cy.contains('.app-menu-entry--label', 'Tables').click()
cy.contains('button', 'Create new table').click()
cy.get('.icon-loading').should('not.exist')
cy.get('[data-cy="navigationCreateTableIcon"]').click({ force: true })
cy.get('.tile').contains('ToDo').click({ force: true })
cy.get('.modal__content').should('be.visible')
cy.get('.modal__content input[type="text"]').clear().type('to do list')
Expand All @@ -34,8 +34,8 @@ describe('Manage a table', () => {

it('Create with import', () => {
cy.uploadFile('test-import.csv', 'text/csv')
cy.contains('.app-menu-entry--label', 'Tables').click()
cy.contains('button', 'Create new table').click()
cy.get('.icon-loading').should('not.exist')
cy.get('[data-cy="navigationCreateTableIcon"]').click({ force: true })
cy.get('.tile').contains('Import').click({ force: true })
cy.get('.modal__content').should('be.visible')
cy.get('.modal__content input[type="text"]').clear().type('import list')
Expand All @@ -45,7 +45,9 @@ describe('Manage a table', () => {
cy.get('.modal__content button').contains('Select from Files').click()
cy.get('.file-picker__files').contains('test-import').click()
cy.get('.file-picker button span').contains('Choose test-import.csv').click()
cy.intercept({ method: 'POST', url: '**/apps/tables/import/table/*'}).as('importUploadReq')
cy.get('.modal__content button').contains('Import').click()
cy.wait('@importUploadReq')
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')
Expand Down Expand Up @@ -83,8 +85,8 @@ describe('Manage a table', () => {
})

it('Transfer', () => {
cy.contains('.app-menu-entry--label', 'Tables').click()
cy.contains('button', 'Create new table').click()
cy.get('.icon-loading').should('not.exist')
cy.get('[data-cy="navigationCreateTableIcon"]').click({ force: true })
cy.get('.tile').contains('ToDo').click({ force: true })
cy.get('.modal__content').should('be.visible')
cy.get('.modal__content input[type="text"]').clear().type('test table')
Expand Down
6 changes: 3 additions & 3 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ Cypress.env('baseUrl', url)
addCommands()

Cypress.Commands.add('createTable', (title) => {
cy.get('.icon-loading').should('not.exist')
cy.get('[data-cy="navigationCreateTableIcon"]').click({ force: true })
cy.wait(1000)
cy.get('[data-cy="createTableModal"]').should('be.visible')
cy.get('.tile').contains('Custom table').click({ force: true })
cy.get('.modal__content input[type="text"]').clear().type(title)
cy.get('[data-cy="createTableModal"] input[type="text"]').clear().type(title)
cy.contains('button', 'Create table').click()

cy.contains('h1', title).should('be.visible')
})

Expand Down
2 changes: 1 addition & 1 deletion src/modules/modals/CreateTable.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<NcModal v-if="showModal" size="normal"
@close="actionCancel">
@close="actionCancel" data-cy="createTableModal">

Check warning on line 3 in src/modules/modals/CreateTable.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Attribute "data-cy" should go before "@close"
<div class="modal__content">
<div class="row">
<div class="col-4">
Expand Down

0 comments on commit b1a209c

Please sign in to comment.