Skip to content

Commit

Permalink
add end2end test for column type number stars
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 c3316d3 commit 6e666b2
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
46 changes: 46 additions & 0 deletions cypress/e2e/column-number-stars.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
let localUser
const columnTitle = 'stars'
const tableTitle = 'Test number stars'

describe('Test column stars', () => {

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 values', () => {
cy.loadTable(tableTitle)
cy.createNumberStarsColumn(columnTitle, 2, true)

// insert default value row
cy.get('button').contains('Create row').click()
cy.get('.modal__content').contains('β˜…β˜…β˜†β˜†β˜†').should('be.visible')
cy.get('button').contains('Save').click()
cy.get('.custom-table table tr td div').contains('β˜…β˜…β˜†β˜†β˜†').should('be.visible')

// insert row
cy.get('button').contains('Create row').click()
cy.get('.slot button').last().click().click()
cy.get('button').contains('Save').click()
cy.get('.custom-table table tr td div').contains('β˜…β˜…β˜…β˜…β˜†').should('be.visible')

// insert row
cy.get('button').contains('Create row').click()
cy.get('.slot button').first().click().click()
cy.get('button').contains('Save').click()
cy.get('.custom-table table tr td div').contains('β˜†β˜†β˜†β˜†β˜†').should('be.visible')
})

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

Cypress.Commands.add('createNumberStarsColumn', (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('Stars rating').click({ force: true })

if (defaultValue) {
for (let n = 0; n < defaultValue; n++) {
cy.get('[data-cy="NumberStarsForm"] button').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 6e666b2

Please sign in to comment.