Skip to content

Commit

Permalink
fix cypress checks for different time formats
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Steffens <[email protected]>
  • Loading branch information
Florian Steffens committed Nov 14, 2023
1 parent 107d946 commit 75d2cfa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
14 changes: 9 additions & 5 deletions cypress/e2e/column-datetime.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ describe('Test column ' + columnTitle, () => {
cy.get('.modal__content input').first().clear().type('2023-12-24 05:15')
cy.get('.modal-container .checkbox-radio-switch label').click().click()
cy.get('button').contains('Save').click()
cy.get('.custom-table table tr td div').contains('24 Dec 2023 05:15').should('be.visible')
cy.get('.custom-table table tr td div').contains('24').should('be.visible')
cy.get('.custom-table table tr td div').contains('Dec').should('be.visible')
cy.get('.custom-table table tr td div').contains('2023').should('be.visible')
cy.get('.custom-table table tr td div').contains('5:15').should('be.visible')

// delete row
cy.get('.NcTable tr td button').first().click()
Expand All @@ -49,14 +52,15 @@ describe('Test column ' + columnTitle, () => {
const minutes = new Date().getMinutes().toString().length < 2 ? '0' + new Date().getMinutes() : new Date().getMinutes().toString()
const date = new Date().toISOString().slice(2, 10)
const datetime = date + ' ' + hour + ':' + minutes
cy.get('.modal__content input').first().should('contain.value', datetime)
cy.get('.modal__content input').first().should('contain.value', '20' + datetime)
cy.get('.modal-container .checkbox-radio-switch label').click().click()
cy.get('button').contains('Save').click()
const monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'June',
'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec']
const datetime2 = new Date().getDate() + ' ' + monthNames[new Date().getMonth()] + ' ' + new Date().getFullYear() + ' ' + hour + ':' + minutes
cy.log(datetime2)
cy.get('.custom-table table tr td div').contains(datetime2).should('be.visible')
cy.get('.custom-table table tr td div').contains(new Date().getDate()).should('be.visible')
cy.get('.custom-table table tr td div').contains(monthNames[new Date().getMonth()]).should('be.visible')
cy.get('.custom-table table tr td div').contains(new Date().getFullYear()).should('be.visible')
cy.get('.custom-table table tr td div').contains(':' + minutes).should('be.visible')
})

})
8 changes: 6 additions & 2 deletions cypress/e2e/column-datetimeDate.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ describe('Test column ' + columnTitle, () => {
cy.get('.modal__content input').first().clear().type('2023-12-24')
cy.get('.modal-container .checkbox-radio-switch label').click().click()
cy.get('button').contains('Save').click()
cy.get('.custom-table table tr td div').contains('24 Dec 2023').should('be.visible')
cy.get('.custom-table table tr td div').contains('24').should('be.visible')
cy.get('.custom-table table tr td div').contains('Dec').should('be.visible')
cy.get('.custom-table table tr td div').contains('2023').should('be.visible')

// delete row
cy.get('.NcTable tr td button').first().click()
Expand All @@ -53,7 +55,9 @@ describe('Test column ' + columnTitle, () => {
'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec']
const datetime2 = new Date().getDate() + ' ' + monthNames[new Date().getMonth()] + ' ' + new Date().getFullYear()
cy.log(datetime2)
cy.get('.custom-table table tr td div').contains(datetime2).should('be.visible')
cy.get('.custom-table table tr td div').contains(new Date().getDate()).should('be.visible')
cy.get('.custom-table table tr td div').contains(monthNames[new Date().getMonth()]).should('be.visible')
cy.get('.custom-table table tr td div').contains(new Date().getFullYear()).should('be.visible')
})

})
10 changes: 4 additions & 6 deletions cypress/e2e/column-datetimeTime.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('Test column ' + columnTitle, () => {
cy.get('.modal__content input').first().clear().type('05:15')
cy.get('.modal-container .checkbox-radio-switch label').click().click()
cy.get('button').contains('Save').click()
cy.get('.custom-table table tr td div').contains('05:15').should('be.visible')
cy.get('.custom-table table tr td div').contains('5:15').should('be.visible')

// delete row
cy.get('.NcTable tr td button').first().click()
Expand All @@ -45,13 +45,11 @@ describe('Test column ' + columnTitle, () => {

// insert row with int value
cy.get('button').contains('Create row').click()
const hour = new Date().getHours().toString().length < 2 ? '0' + new Date().getHours() : new Date().getHours().toString()
const minutes = new Date().getMinutes().toString().length < 2 ? '0' + new Date().getMinutes() : new Date().getMinutes().toString()
const datetime = hour + ':' + minutes
cy.get('.modal__content input').first().should('contain.value', datetime)
const minutes = ':' + new Date().getMinutes().toString().length < 2 ? '0' + new Date().getMinutes() : new Date().getMinutes().toString()
cy.get('.modal__content input').first().should('contain.value', minutes)
cy.get('.modal-container .checkbox-radio-switch label').click().click()
cy.get('button').contains('Save').click()
cy.get('.custom-table table tr td div').contains(datetime).should('be.visible')
cy.get('.custom-table table tr td div').contains(minutes).should('be.visible')
})

})

0 comments on commit 75d2cfa

Please sign in to comment.