Skip to content

Commit

Permalink
Add tests for bundle verification
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislaw-zakrzewski committed Oct 16, 2024
1 parent 9af8949 commit 8be53f6
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 0 deletions.
4 changes: 4 additions & 0 deletions data-serving/data-service/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1040,12 +1040,16 @@ components:
description: name of a country
admin1:
type: string
nullable: true
admin2:
type: string
nullable: true
admin3:
type: string
nullable: true
location:
type: string
nullable: true
description: exact location
ageRange:
type: object
Expand Down
1 change: 1 addition & 0 deletions data-serving/data-service/src/controllers/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,7 @@ export class CasesController {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const upsertLambda = async (c: any) => {
delete c.caseCount;
c.bundleId = new mongoose.Types.ObjectId();
c = await caseFromDTO(c as CaseDTO);

if (
Expand Down
4 changes: 4 additions & 0 deletions verification/curator-service/api/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1861,12 +1861,16 @@ components:
description: name of a country
admin1:
type: string
nullable: true
admin2:
type: string
nullable: true
admin3:
type: string
nullable: true
location:
type: string
nullable: true
description: exact location
ageRange:
type: object
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { CaseStatus } from '../../support/commands';
import {Role} from "../../../src/api/models/User";

/* eslint-disable no-undef */
describe('Linelist table', function () {
beforeEach(() => {
cy.task('clearCasesDB', {});
cy.intercept('GET', '/auth/profile').as('getProfile');
cy.intercept('GET', '/api/cases*').as('getCases');
});

afterEach(() => {
cy.clearSeededLocations();
});

it('Displays and verifies bundled cases correctly', function () {
cy.login({roles: [ Role.JuniorCurator ]})
cy.addCase({
country: 'France',
countryISO3: 'FRA',
dateEntry: '2020-05-01',
dateReported: '2020-05-01',
sourceUrl: 'www.example.com',
caseStatus: CaseStatus.Confirmed,
});
cy.logout();
cy.login({roles: [ Role.Curator ]})

// Make sure that case is not verified
cy.visit('/');
cy.wait('@getProfile');
cy.wait('@getCases');
cy.get('[data-testid="CheckCircleOutlineIcon"]').should('not.exist');

// Verify case
cy.visit('/bulk-verification');

// We don't need additional library for just one test, we can format date manually
const today = new Date();
const year = today.getFullYear();
const month = today.getMonth() < 9 ? `0${today.getMonth() + 1}` : today.getMonth() + 1;
const day = today.getDate() < 10 ? `0${today.getDate()}` : today.getDate();
cy.contains(`${year}-${month}-${day}`)
cy.contains('superuser@test.com');
cy.contains('France');
cy.contains('www.example.com');
cy.contains('2020-05-01');
cy.contains('confirmed');
cy.get('tr').get('input[type="checkbox"]').check();
cy.get('[data-testid="verify-case-bundles-button"]').click();
cy.get('[data-testid="confirm-case-bundles-verification-button"]').click();

// Case bundle no longer shows in bulk verification list
cy.contains('No records to display').should('exist');

// Case from case bundle is now verified
cy.visit('/');
cy.wait('@getCases');
cy.get('[data-testid="CheckCircleOutlineIcon"]').should('exist');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const EnhancedTableToolbar = () => {
<Tooltip title="Verify selected rows">
<IconButton
sx={{ color: 'white' }}
data-testid="verify-case-bundles-button"
onClick={() =>
dispatch(setVerifyCasesDialogOpen(true))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const CaseVerifyDialog = ({
onClick={() =>
dispatch(verifyCaseBundle({ caseBundleIds, query }))
}
data-testid="confirm-case-bundles-verification-button"
color="primary"
>
{verificationLoading ? <CircularProgress size='1rem'/> : 'Yes'}
Expand Down

0 comments on commit 8be53f6

Please sign in to comment.