Merge pull request #292 from nowcommunity/add-tests-for-time-bound

Add tests for time bound
This commit is contained in:
Eero Antikainen
2024-09-27 15:31:59 +03:00
committed by GitHub
3 changed files with 58 additions and 26 deletions
+27
View File
@@ -0,0 +1,27 @@
describe("Locality min and max age checks work", () => {
beforeEach('Login as admin', () => {
cy.login('testSu')
})
it("Editing a locality with contradictory min and max ages does not work", () => {
cy.on("uncaught:exception", (error) => {
// this is here to ignore the error that happens when you put contradictory data to backend
// might ignore errors that should not be ignored too!
console.log(error)
return false
})
cy.visit(`/locality/20920?tab=0`)
cy.contains('Dating method')
cy.get('[id=edit-button]').click()
// the id's for these next two might change which breaks the test, don't know why
cy.get("[id=\\:r1\\:]").first().type("{backspace}{backspace}{backspace}10") // min age input field
cy.get("[id=\\:r5\\:]").type("{backspace}{backspace}{backspace}{backspace}{backspace}9") // max age input field
cy.contains("Min value cannot be higher than max")
cy.get('[id=write-button]').click()
cy.get('[id=write-button]').click()
// make sure the values didn't change
cy.contains("7.2")
cy.contains("11.63")
})
})
-26
View File
@@ -85,31 +85,5 @@ describe('Test individual features across the app', () => {
doesNotHaveStagingMode('person/AD')
})
})
describe("Min and max age checks work", () => {
beforeEach('Login as admin', () => {
cy.login('testSu')
})
it("Editing a locality with contradictory min and max ages does not work", () => {
cy.on("uncaught:exception", (error) => {
// this is here to ignore the error that happens when you put contradictory data to backend
// might ignore errors that should not be ignored too!
console.log(error)
return false
})
cy.visit(`/locality/20920?tab=0`)
cy.get('[id=edit-button]').click()
// the id's for these next two might change which breaks the test, don't know why
cy.get("[id=\\:r1\\:]").first().type("{backspace}{backspace}{backspace}10") // min age input field
cy.get("[id=\\:r5\\:]").type("{backspace}{backspace}{backspace}{backspace}{backspace}9") // max age input field
cy.contains("Min value cannot be higher than max")
cy.get('[id=write-button]').click()
cy.get('[id=write-button]').click()
// make sure the values didn't change
cy.contains("7.2")
cy.contains("11.63")
})
})
})
+31
View File
@@ -0,0 +1,31 @@
describe("Editing time bound", () => {
beforeEach('Login as admin', () => {
cy.login('testSu')
})
beforeEach('Reset database', () => {
cy.request(Cypress.env("databaseResetUrl"));
});
it("User editing time bound with correct values succeeds", () => {
cy.visit(`/time-bound/11?tab=0`)
cy.contains('C2N-y')
cy.get('[id=edit-button]').click()
// this id might change which breaks the test, don't know why
cy.get("[id=\\:r1\\:]").first().type("{backspace}{backspace}{backspace}{backspace}{backspace}2.5")
cy.contains("This field is required").should('not.exist')
cy.get('[id=write-button]').click()
cy.get('[id=write-button]').click()
cy.contains("2.5")
})
it("User editing time bound with incorrect values is notified about it", () => {
cy.visit(`/time-bound/11?tab=0`)
cy.contains('C2N-y')
cy.get('[id=edit-button]').click()
// this id might change which breaks the test, don't know why
cy.get("[id=\\:r1\\:]").first().type("{backspace}{backspace}{backspace}{backspace}{backspace}")
cy.contains("This field is required")
cy.get('[id=write-button]').click()
cy.get('[id=write-button]').click()
// make sure the age value didn't change
cy.contains("1.778")
})
})