Skip to content

Commit

Permalink
Merge pull request #3029 from aiidtest/fix-dynamic-cite
Browse files Browse the repository at this point in the history
Fix cite page not loading recently promoted incidents
  • Loading branch information
pdcp1 committed Aug 16, 2024
2 parents 58c20a2 + 2891edf commit af28cc8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
26 changes: 25 additions & 1 deletion site/gatsby-site/playwright/e2e-full/cite.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import incident50 from '../fixtures/incidents/fullIncident50.json';
import { gql } from '@apollo/client';
import { expect } from '@playwright/test';
import config from '../config';
import { init, seedCollection, seedFixture } from '../memory-mongo';
import { init } from '../memory-mongo';
import { DBIncident } from '../seeds/aiidprod/incidents';

test.describe('Cite pages', () => {
const discoverUrl = '/apps/discover';
Expand Down Expand Up @@ -640,4 +641,27 @@ test.describe('Cite pages', () => {
expect(data.incident_2).toMatchObject({ editor_dissimilar_incidents: [3], editor_similar_incidents: [] });
expect(data.incident_3).toMatchObject({ editor_dissimilar_incidents: [2], editor_similar_incidents: [1] });
});

test('Should load incident data not yet in build', async ({ page }) => {

const incident: DBIncident = {
incident_id: 4,
title: 'Test Title',
description: 'Incident 4 description',
date: "2020-01-01",
"Alleged deployer of AI system": ["entity1"],
"Alleged developer of AI system": ["entity2"],
"Alleged harmed or nearly harmed parties": ["entity3"],
editors: ["user1"],
reports: [1],
}

await init({ aiidprod: { incidents: [incident] } });

await page.goto('/cite/4');

await expect(page.getByText('Incident 4: Test Title')).toBeVisible();
await expect(page.getByText('Incident 4 description')).toBeVisible();
await expect(page.getByText('Alleged: Entity 2 developed an AI system deployed by Entity 1, which harmed Entity 3.')).toBeVisible()
});
});
2 changes: 1 addition & 1 deletion site/gatsby-site/playwright/seeds/aiidprod/incidents.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Incident } from '../../../server/generated/graphql'

type DBIncident = Omit<Incident, 'AllegedDeployerOfAISystem' | 'AllegedDeveloperOfAISystem' | 'AllegedHarmedOrNearlyHarmedParties' | 'reports' | 'editors'>
export type DBIncident = Omit<Incident, 'AllegedDeployerOfAISystem' | 'AllegedDeveloperOfAISystem' | 'AllegedHarmedOrNearlyHarmedParties' | 'reports' | 'editors'>
& { "Alleged deployer of AI system": string[], "Alleged developer of AI system": string[], "Alleged harmed or nearly harmed parties": string[] }
& { reports: number[] }
& { editors: string[] }
Expand Down
2 changes: 1 addition & 1 deletion site/gatsby-site/src/pages/cite/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function CiteDynamicPage(props) {
const [incident, setIncident] = useState(null);

const { data: incidentData, loading } = useQuery(FIND_FULL_INCIDENT, {
variables: { filter: { incident_id: { EQ: incident_id } } },
variables: { filter: { incident_id: { EQ: parseInt(incident_id) } } },
});

useEffect(() => {
Expand Down

0 comments on commit af28cc8

Please sign in to comment.