diff --git a/.github/workflows/test-playwright-full.yml b/.github/workflows/test-playwright-full.yml index a0a1a3ce38..5b6554cb5d 100644 --- a/.github/workflows/test-playwright-full.yml +++ b/.github/workflows/test-playwright-full.yml @@ -167,9 +167,12 @@ jobs: - name: Merge into HTML Report run: npx playwright merge-reports --reporter html ./all-blob-reports + - name: Rename report directory + run: mv playwright-report playwright-report-full + - name: Upload HTML report uses: actions/upload-artifact@v4 with: - name: html-report--attempt-${{ github.run_attempt }} + name: playwright-report-full-attempt-${{ github.run_attempt }} path: playwright-report-full retention-days: 7 diff --git a/.github/workflows/test-playwright.yml b/.github/workflows/test-playwright.yml index b4adb58ecf..5f08ad7b95 100644 --- a/.github/workflows/test-playwright.yml +++ b/.github/workflows/test-playwright.yml @@ -117,6 +117,6 @@ jobs: - name: Upload HTML report uses: actions/upload-artifact@v4 with: - name: html-report--attempt-${{ github.run_attempt }} + name: playwright-report-attempt-${{ github.run_attempt }} path: playwright-report retention-days: 7 diff --git a/site/gatsby-site/cypress/e2e/unit/discover/routing.cy.js b/site/gatsby-site/cypress/e2e/unit/discover/routing.cy.js deleted file mode 100644 index aa41c27837..0000000000 --- a/site/gatsby-site/cypress/e2e/unit/discover/routing.cy.js +++ /dev/null @@ -1,48 +0,0 @@ -import parseURL from '../../../../../gatsby-site/src/components/discover/parseURL'; -import createURL from '../../../../../gatsby-site/src/components/discover/createURL'; -import { queryConfig } from '../../../../../gatsby-site/src/components/discover/queryParams'; - -chai.config.truncateThreshold = 0; - -describe('Discover routing', () => { - it('Should parse back and forth a discover URL', () => { - const indexName = 'instant_search-en'; - - const location = { - search: - '?authors=Christopher%20Knaus%7C%7CSam%20Levin&classifications=CSETv0%3AIntent%3AAccident&epoch_date_published_max=1670371200&is_incident_report=true&page=1&s=tesla&sortBy=published-date-asc&source_domain=theguardian.com', - }; - - const result = parseURL({ location, indexName, queryConfig }); - - const state = result[indexName]; - - expect(state.query).to.eq('tesla'); - expect(state.page).to.eq(1); - expect(state.sortBy).to.eq('published-date-asc'); - expect(state.refinementList).to.deep.eq({ - source_domain: ['theguardian.com'], - authors: ['Christopher Knaus', 'Sam Levin'], - 'CSETv0.Intent': ['Accident'], - is_incident_report: ['true'], - }); - expect(state.range).to.deep.eq({ - epoch_date_published: `:1670371200`, - }); - - expect(state.configure).to.deep.eq({ - distinct: false, - hitsPerPage: 28, - }); - - const resultURL = createURL({ - routeState: { [indexName]: state }, - indexName, - locale: 'en', - queryConfig, - taxa: ['CSETv0', 'CSETv1'], - }); - - expect('?' + resultURL).to.eq(location.search); - }); -}); diff --git a/site/gatsby-site/migrations/2024.09.17T16.03.27.fix-incidents-invalid-values.js b/site/gatsby-site/migrations/2024.09.17T16.03.27.fix-incidents-invalid-values.js new file mode 100644 index 0000000000..51a58d4b28 --- /dev/null +++ b/site/gatsby-site/migrations/2024.09.17T16.03.27.fix-incidents-invalid-values.js @@ -0,0 +1,26 @@ +const config = require('../config'); + +/** @type {import('umzug').MigrationFn} */ +exports.up = async ({ context: { client } }) => { + const db = client.db(config.realm.production_db.db_name).collection('incidents'); + + // If the incident has "editor_notes" field and it is null, set it to empty string + const editor_notes_results = await db.updateMany( + { editor_notes: null }, + { $set: { editor_notes: '' } } + ); + + console.log( + `Updated ${editor_notes_results.modifiedCount} incidents with null editor_notes field` + ); + + // If the incident has the "flagged_dissimilar_incidents" field and it is null, set it to empty array + const flagged_dissimilar_incidents_results = await db.updateMany( + { flagged_dissimilar_incidents: null }, + { $set: { flagged_dissimilar_incidents: [] } } + ); + + console.log( + `Updated ${flagged_dissimilar_incidents_results.modifiedCount} incidents with null flagged_dissimilar_incidents field` + ); +}; diff --git a/site/gatsby-site/migrations/2024.09.19T18.12.21.mark-pending-notifications-as-processed.js b/site/gatsby-site/migrations/2024.09.19T18.12.21.mark-pending-notifications-as-processed.js new file mode 100644 index 0000000000..59a6e9b0b9 --- /dev/null +++ b/site/gatsby-site/migrations/2024.09.19T18.12.21.mark-pending-notifications-as-processed.js @@ -0,0 +1,16 @@ +const config = require('../config'); + +/** @type {import('umzug').MigrationFn} */ +exports.up = async ({ context: { client } }) => { + const db = client.db(config.realm.production_db.db_custom_data); + + const notifications = db.collection('notifications'); + + // Mark all pending notifications as processed + const result = await notifications.updateMany( + { processed: false }, + { $set: { processed: true } } + ); + + console.log(`All pending notifications marked as processed. Total: ${result.modifiedCount}`); +}; diff --git a/site/gatsby-site/playwright/e2e-full/cite.spec.ts b/site/gatsby-site/playwright/e2e-full/cite.spec.ts index 96d0b4fe6a..45e1eaf1fe 100644 --- a/site/gatsby-site/playwright/e2e-full/cite.spec.ts +++ b/site/gatsby-site/playwright/e2e-full/cite.spec.ts @@ -640,6 +640,8 @@ test.describe('Cite pages', () => { "Alleged harmed or nearly harmed parties": ["entity3"], editors: ["user1"], reports: [1], + editor_notes: "", + flagged_dissimilar_incidents: [] } await init({ aiidprod: { incidents: [incident] } }); diff --git a/site/gatsby-site/playwright/e2e-full/incidents/new.spec.ts b/site/gatsby-site/playwright/e2e-full/incidents/new.spec.ts index 5a35852e30..737b03135b 100644 --- a/site/gatsby-site/playwright/e2e-full/incidents/new.spec.ts +++ b/site/gatsby-site/playwright/e2e-full/incidents/new.spec.ts @@ -42,8 +42,6 @@ test.describe('New Incident page', () => { 'logIncidentHistory' ); - await page.context().grantPermissions(['clipboard-read', 'clipboard-write']); - await page.getByText('Save').click(); await waitForRequest('logIncidentHistory'); diff --git a/site/gatsby-site/playwright/e2e/unit/discover/routing.spec.ts b/site/gatsby-site/playwright/e2e/unit/discover/routing.spec.ts new file mode 100644 index 0000000000..e61777ab5b --- /dev/null +++ b/site/gatsby-site/playwright/e2e/unit/discover/routing.spec.ts @@ -0,0 +1,47 @@ + +import parseURL from '../../../../../gatsby-site/src/components/discover/parseURL'; +import createURL from '../../../../../gatsby-site/src/components/discover/createURL'; +import { queryConfig } from '../../../../../gatsby-site/src/components/discover/queryParams'; +import { test } from '../../../utils'; +import { expect } from '@playwright/test'; + +test('Should parse back and forth a discover URL', async () => { + const indexName = 'instant_search-en'; + + const location = { + search: + '?authors=Christopher%20Knaus%7C%7CSam%20Levin&classifications=CSETv0%3AIntent%3AAccident&epoch_date_published_max=1670371200&is_incident_report=true&page=1&s=tesla&sortBy=published-date-asc&source_domain=theguardian.com', + }; + + const result = parseURL({ location, indexName, queryConfig }); + + const state = result[indexName]; + + expect(state.query).toBe('tesla'); + expect(state.page).toBe(1); + expect(state.sortBy).toBe('published-date-asc'); + expect(state.refinementList).toEqual({ + source_domain: ['theguardian.com'], + authors: ['Christopher Knaus', 'Sam Levin'], + 'CSETv0.Intent': ['Accident'], + is_incident_report: ['true'], + }); + expect(state.range).toEqual({ + epoch_date_published: `:1670371200`, + }); + + expect(state.configure).toEqual({ + distinct: false, + hitsPerPage: 28, + }); + + const resultURL = createURL({ + routeState: { [indexName]: state }, + indexName, + locale: 'en', + queryConfig, + taxa: ['CSETv0', 'CSETv1'], + }); + + expect('?' + resultURL).toBe(location.search); +}); diff --git a/site/gatsby-site/playwright/seeds/aiidprod/incidents.ts b/site/gatsby-site/playwright/seeds/aiidprod/incidents.ts index a7cc804355..24b10058f2 100644 --- a/site/gatsby-site/playwright/seeds/aiidprod/incidents.ts +++ b/site/gatsby-site/playwright/seeds/aiidprod/incidents.ts @@ -18,10 +18,11 @@ const incidents: DBIncident[] = [ reports: [1], // TODO: this aren't required but break the build if missing + editor_notes: "", nlp_similar_incidents: [], editor_similar_incidents: [], editor_dissimilar_incidents: [], - + flagged_dissimilar_incidents: [], }, { incident_id: 2, @@ -34,9 +35,11 @@ const incidents: DBIncident[] = [ reports: [2], // TODO: this aren't required but break the build if missing + editor_notes: "", nlp_similar_incidents: [], editor_similar_incidents: [], editor_dissimilar_incidents: [], + flagged_dissimilar_incidents: [], }, { incident_id: 3, @@ -48,6 +51,7 @@ const incidents: DBIncident[] = [ 7, 8, ], + editor_notes: "", "Alleged deployer of AI system": [ "starbucks" ], diff --git a/site/gatsby-site/server/fields/submissions.ts b/site/gatsby-site/server/fields/submissions.ts index 7fdf9f107e..daf0bd5259 100644 --- a/site/gatsby-site/server/fields/submissions.ts +++ b/site/gatsby-site/server/fields/submissions.ts @@ -104,6 +104,8 @@ export const mutationFields: GraphQLFieldConfigMap = { nlp_similar_incidents: submission.nlp_similar_incidents || [], editor_similar_incidents: submission.editor_similar_incidents || [], editor_dissimilar_incidents: submission.editor_dissimilar_incidents || [], + editor_notes: "", + flagged_dissimilar_incidents: [], } if (submission.embedding) { newIncident.embedding = { diff --git a/site/gatsby-site/server/tests/fixtures/incidents.ts b/site/gatsby-site/server/tests/fixtures/incidents.ts index 8e153e6d9b..a338a00103 100644 --- a/site/gatsby-site/server/tests/fixtures/incidents.ts +++ b/site/gatsby-site/server/tests/fixtures/incidents.ts @@ -191,6 +191,7 @@ const incident1: DBIncident = { y: -0.2 }, reports: [1, 2], + editor_notes: "Sample editor notes", }; const incident2: DBIncident = { @@ -238,6 +239,7 @@ const incident2: DBIncident = { y: -0.4 }, reports: [3], + editor_notes: "", }; const incident3: DBIncident = { @@ -285,6 +287,7 @@ const incident3: DBIncident = { y: -0.6 }, reports: [2, 3], + editor_notes: "", }; const fixture: Fixture = { @@ -423,6 +426,8 @@ const fixture: Fixture = { reports: { link: [1, 2] }, incident_id: 5, editors: { link: [editor1.userId] }, + editor_notes: "", + flagged_dissimilar_incidents: [], }, result: { _id: expect.any(String), diff --git a/site/gatsby-site/server/tests/utils.spec.ts b/site/gatsby-site/server/tests/utils.spec.ts index b448563d83..83c3c884b1 100644 --- a/site/gatsby-site/server/tests/utils.spec.ts +++ b/site/gatsby-site/server/tests/utils.spec.ts @@ -41,7 +41,9 @@ describe(`Utils`, () => { ] }, "date": "2029-01-01", - "title": "Test" + "title": "Test", + "editor_notes": "", + "flagged_dissimilar_incidents": [] } } diff --git a/site/gatsby-site/server/types/incidents.ts b/site/gatsby-site/server/types/incidents.ts index 774917d9db..d6d8320d35 100644 --- a/site/gatsby-site/server/types/incidents.ts +++ b/site/gatsby-site/server/types/incidents.ts @@ -28,7 +28,7 @@ export const IncidentType = new GraphQLObjectType({ _id: { type: ObjectIdScalar }, date: { type: new GraphQLNonNull(GraphQLString) }, description: { type: GraphQLString }, - editor_notes: { type: GraphQLString }, + editor_notes: { type: new GraphQLNonNull(GraphQLString) }, epoch_date_modified: { type: GraphQLInt }, incident_id: { type: new GraphQLNonNull(GraphQLInt) }, title: { type: new GraphQLNonNull(GraphQLString) }, @@ -57,7 +57,7 @@ export const IncidentType = new GraphQLObjectType({ editor_similar_incidents: { type: new GraphQLList(GraphQLInt) }, editors: getListRelationshipConfig(UserType, GraphQLString, 'editors', 'userId', 'users', 'customData'), embedding: { type: EmbeddingType }, - flagged_dissimilar_incidents: { type: new GraphQLList(GraphQLInt) }, + flagged_dissimilar_incidents: { type: new GraphQLNonNull(new GraphQLList(GraphQLInt)) }, nlp_similar_incidents: { type: new GraphQLList(NlpSimilarIncidentType) }, reports: getListRelationshipConfig(ReportType, GraphQLInt, 'reports', 'report_number', 'reports', 'aiidprod'), tsne: { type: TsneType } diff --git a/site/gatsby-site/src/pages/incidents/new.js b/site/gatsby-site/src/pages/incidents/new.js index 4fde937b36..5eb444c308 100644 --- a/site/gatsby-site/src/pages/incidents/new.js +++ b/site/gatsby-site/src/pages/incidents/new.js @@ -103,6 +103,7 @@ function NewIncidentPage() { newIncident.editor_similar_incidents = []; newIncident.editor_dissimilar_incidents = []; + newIncident.flagged_dissimilar_incidents = []; await insertIncident({ variables: { data: newIncident } }); @@ -148,11 +149,11 @@ function NewIncidentPage() { AllegedHarmedOrNearlyHarmedParties: AllegedHarmedOrNearlyHarmedParties.map( (entity) => entity.entity_id ), - editor_notes, + editor_notes: editor_notes ?? '', editors: editors.map((editor) => editor.userId), }); } else { - setInitialValues({ editors: [] }); + setInitialValues({ editors: [], editor_notes: '' }); } } }, [incidentToCloneData]);