Skip to content

Commit

Permalink
add end2end test for column type selection check
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
  • Loading branch information
Florian Steffens committed Nov 13, 2023
1 parent b75d163 commit 6b58f3c
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
59 changes: 59 additions & 0 deletions cypress/e2e/column-selection-check.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
let localUser
const columnTitle = 'check'
const tableTitle = 'Test selection check'

describe('Test column ' + columnTitle, () => {

before(function() {
cy.createRandomUser().then(user => {
localUser = user
cy.login(localUser)
})
})

beforeEach(function() {
cy.login(localUser)
cy.visit('apps/tables')
})

it('Table and column setup', () => {
cy.createTable(tableTitle)
})

it('Insert and test rows - default value unchecked', () => {
cy.loadTable(tableTitle)
cy.createSelectionCheckColumn(columnTitle, null, true)

// insert row
cy.get('button').contains('Create row').click()
cy.get('button').contains('Save').click()
cy.get('.custom-table table tr td div .material-design-icon.radiobox-blank-icon').should('be.visible')

// insert row
cy.get('button').contains('Create row').click()
cy.get('.modal__content .checkbox-radio-switch__label').first().click()
cy.get('button').contains('Save').click()
cy.get('.custom-table table tr td div .material-design-icon.check-circle-outline-icon').should('be.visible')

cy.removeColumn(columnTitle)
})

it('Insert and test rows - default value checked', () => {
cy.loadTable(tableTitle)
cy.createSelectionCheckColumn(columnTitle, true, true)

// insert row
cy.get('button').contains('Create row').click()
cy.get('button').contains('Save').click()
cy.get('.custom-table table tr td div .material-design-icon.check-circle-outline-icon').should('be.visible')

// insert row
cy.get('button').contains('Create row').click()
cy.get('.modal__content .checkbox-radio-switch__label').first().click()
cy.get('button').contains('Save').click()
cy.get('.custom-table table tr td div .material-design-icon.radiobox-blank-icon').should('be.visible')

cy.removeColumn(columnTitle)
})

})
20 changes: 20 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,26 @@ Cypress.Commands.add('createNumberStarsColumn', (title, defaultValue, firstColum
cy.get('.custom-table table tr th .cell').contains(title).should('exist')
})

Cypress.Commands.add('createSelectionCheckColumn', (title, defaultValue, firstColumn) => {
if (firstColumn) {
cy.get('.button-vue__text').contains('Create column').click({ force: true })
} else {
cy.get('[data-cy="customTableAction"] button').click()
cy.get('.v-popper__popper li button span').contains('Create column').click({ force: true })
}
cy.get('.modal-container').get('input[placeholder*="Enter a column title"]').clear().type(title)
cy.get('.columnTypeSelection .vs__open-indicator').click({ force: true })
cy.get('.multiSelectOptionLabel').contains('Selection').click({ force: true })
cy.get('.modal-container label').contains('Yes/No').click()

if (defaultValue) {
cy.get('[data-cy="SelectionCheckForm"] label').last().click()
}
cy.get('.modal-container button').contains('Save').click()
cy.wait(10).get('.toastify.toast-success').should('be.visible')
cy.get('.custom-table table tr th .cell').contains(title).should('exist')
})

Cypress.Commands.add('uploadFile', (fileName, mimeType, target) => {
return cy.fixture(fileName, 'binary')
.then(Cypress.Blob.binaryStringToBlob)
Expand Down

0 comments on commit 6b58f3c

Please sign in to comment.