Skip to content

Commit

Permalink
AE-2317: Add e2e test to test effects of destroying expired todistukset
Browse files Browse the repository at this point in the history
  • Loading branch information
solita-juhohaa committed Oct 25, 2024
1 parent efcbdea commit 371dae7
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
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');
});
});
});
6 changes: 4 additions & 2 deletions etp-front/src/pages/energiatodistus/energiatodistukset.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,15 @@
data-cy="energiatodistus-row"
class="etp-table--tr etp-table--tr__link"
on:click={ETViews.toETView(energiatodistus)}>
<td class="etp-table--td">
<td data-cy="energiatodistus-tila" class="etp-table--td">
{i18n(
'energiatodistus.tila.' +
et.tilaKey(energiatodistus['tila-id'])
)}
</td>
<td class="etp-table--td">{energiatodistus.id}</td>
<td data-cy="energiatodistus-id" class="etp-table--td">
{energiatodistus.id}
</td>
<td class="etp-table--td">
{orEmpty(energiatodistus.tulokset['e-luokka'])}
</td>
Expand Down

0 comments on commit 371dae7

Please sign in to comment.