Skip to content

Commit

Permalink
[92] indicate whether each source is a government (#135)
Browse files Browse the repository at this point in the history
* Update Government source indication

* Update tests

* Update BulkCaseForm.spec.ts
  • Loading branch information
stanislaw-zakrzewski committed Jun 4, 2024
1 parent d6660a7 commit e549f18
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('Bulk upload form', function () {

// Case data
cy.contains('www.bulksource.com');
cy.contains('NO');
cy.get('Government Source').should('not.exist');
cy.contains('Data upload IDs')
.parent()
.parent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ describe('Curator', function () {
cy.get('div[data-testid="caseReference"]').type('www.example.com');
cy.contains('www.example.com').click();
cy.get('input[name="caseReference.isGovernmentSource"]').click()
cy.get('button[data-testid="add-additional-source"]').click();
cy.get('div[data-testid="additional-source-0"]').type('www.example2.com');
cy.get('button[data-testid="add-additional-source"]').click();
cy.get('div[data-testid="additional-source-1"]').type('www.example3.com');
cy.get('span[data-testid="government-source-1"]').click();

// LOCATION
cy.get('div[data-testid="location.geocodeLocation"]').type('France', { delay: 0});
Expand Down Expand Up @@ -223,6 +228,18 @@ describe('Curator', function () {
'www.example.com',
);
});
cy.get('div[data-testid="additional-source-0"]').within(() => {
cy.get('input[type="text"]').should(
'have.value',
'www.example2.com',
);
});
cy.get('div[data-testid="additional-source-1"]').within(() => {
cy.get('input[type="text"]').should(
'have.value',
'www.example3.com',
);
});

// Demographics.
cy.get('input[name="demographics.gender"]').should(
Expand Down Expand Up @@ -430,7 +447,9 @@ describe('Curator', function () {
// Curator's comment.
cy.contains('This case should be consulted with Supervisor.');
// Case data.
cy.contains('www.example.com');
cy.contains('www.example.com (Government Source)');
cy.contains('www.example2.com');
cy.contains('www.example3.com (Government Source)');
// Demographics.
// TODO UI for demographics.age needs redesigning
cy.contains('male');
Expand Down
36 changes: 22 additions & 14 deletions verification/curator-service/ui/src/components/ViewCase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -433,17 +433,14 @@ function CaseDetails(props: CaseDetailsProps): JSX.Element {
<RowHeader title="Case status" />
<RowContent content={props.c.caseStatus} />

<RowHeader title="Data source URL" />
<RowHeader title="Data source" />
<RowContent
content={props.c.caseReference?.sourceUrl || ''}
isLink
/>
<RowHeader title="Government Source" />
<RowContent
content={
linkComment={
props.c.caseReference?.isGovernmentSource
? 'YES'
: 'NO'
? 'Government Source'
: undefined
}
/>
{props.c.caseReference.additionalSources &&
Expand All @@ -453,11 +450,16 @@ function CaseDetails(props: CaseDetailsProps): JSX.Element {
(source, idx) => (
<>
<RowHeader
title={`Source ${idx + 2}`}
title={`Additional source ${idx + 2}`}
/>
<RowContent
content={source.sourceUrl || ''}
isLink
linkComment={
source.isGovernmentSource
? 'Government Source'
: undefined
}
/>
</>
),
Expand Down Expand Up @@ -536,15 +538,19 @@ function CaseDetails(props: CaseDetailsProps): JSX.Element {

<RowHeader title="Latitude" />
<RowContent
content={`${props.c.location.geometry?.latitude?.toFixed(
4,
) || ''}`}
content={`${
props.c.location.geometry?.latitude?.toFixed(
4,
) || ''
}`}
/>
<RowHeader title="Longitude" />
<RowContent
content={`${props.c.location.geometry?.longitude?.toFixed(
4,
) || ''}`}
content={`${
props.c.location.geometry?.longitude?.toFixed(
4,
) || ''
}`}
/>

<RowHeader title="Comment" />
Expand Down Expand Up @@ -957,6 +963,7 @@ function RowContent(props: {
content?: string;
isLink?: boolean;
isMultiline?: boolean;
linkComment?: string;
}): JSX.Element {
const searchQuery = useSelector(selectSearchQuery);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -987,6 +994,7 @@ function RowContent(props: {
autoEscape={true}
textToHighlight={props.content ?? ''}
/>
{props.linkComment && ` (${props.linkComment})`}
</a>
) : (
<Highlighter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export default function Source(props: SourceProps) {
label="Additional source"
name={`caseReference.additionalSources.${index}.sourceUrl`}
type="text"
data-testid={`additional-source-${index}`}
component={TextField}
sx={{ minWidth: '13rem' }}
/>
Expand Down Expand Up @@ -158,7 +159,7 @@ export default function Source(props: SourceProps) {
type="checkbox"
// helperText="Whether cases from this source can appear in the line list"
required
data-testid="governmentSource"
data-testid={`government-source-${index}`}
Label={{
label: 'Government Source',
}}
Expand All @@ -173,6 +174,7 @@ export default function Source(props: SourceProps) {
type="button"
variant="outlined"
id="add-additional-source"
data-testid="add-additional-source"
startIcon={<AddIcon />}
onClick={() =>
arrayHelpers.push({
Expand Down

0 comments on commit e549f18

Please sign in to comment.