-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AE-2317: Add e2e test to test effects of destroying expired todistukset
- Loading branch information
1 parent
efcbdea
commit 371dae7
Showing
2 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
e2e-tests/cypress/cypress/e2e/vanhentuneiden-tuhoaminen/laatija.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { FIXTURES } from '../../fixtures/laatija'; | ||
|
||
const baseUrl = Cypress.config('baseUrl'); | ||
|
||
context('Laatija', () => { | ||
beforeEach(() => { | ||
cy.intercept(/\/api\/private/, req => { | ||
req.headers = { ...req.headers, ...FIXTURES.headers }; | ||
}); | ||
cy.resetDb(); | ||
}); | ||
|
||
describe('energiatodistukset', () => { | ||
it('should see energiatodistus before it is expired', async () => { | ||
cy.visit('/#/energiatodistus/all'); | ||
|
||
cy.get('[data-cy="energiatodistus-id"]').contains('1').should('exist'); | ||
cy.get('[data-cy="energiatodistus-id"]') | ||
.contains('1') | ||
.siblings('[data-cy="energiatodistus-tila"]') | ||
.should('have.text', 'Voimassa'); | ||
|
||
const query = | ||
"update etp.energiatodistus set voimassaolo_paattymisaika = now() - interval '2 days' where id = 1;"; | ||
// This does not matter but it needs to be parseable by our database audit system. | ||
const applicationName = '-6@cypress'; | ||
|
||
// Call the Cypress task to execute the query | ||
cy.task('executeQuery', { query, applicationName }); | ||
cy.request( | ||
'POST', | ||
'http://localhost:3444/api/internal/energiatodistukset/anonymize-and-delete-expired' | ||
).then(response => { | ||
expect(response.status).to.eq(200); | ||
}); | ||
|
||
//cy.get('[data-cy="energiatodistus-id"]').contains('1').should('exist'); | ||
|
||
// This is kind of flaky as there is no way to know when the expiration is finished... | ||
|
||
cy.wait(3000); | ||
|
||
cy.reload(); | ||
|
||
cy.get('[data-cy="energiatodistus-id"]').contains('1').should('exist'); | ||
cy.get('[data-cy="energiatodistus-id"]') | ||
.contains('1') | ||
.siblings('[data-cy="energiatodistus-tila"]') | ||
.should('have.text', 'energiatodistus.tila.undefined'); | ||
//TODO: | ||
//cy.get('[data-cy="energiatodistus-id"]').contains('1').siblings('[data-cy="energiatodistus-tila"]').should('not.exist'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters