Skip to content

Commit

Permalink
Merge pull request #3108 from responsible-ai-collaborative/staging
Browse files Browse the repository at this point in the history
Deploy to Production
  • Loading branch information
kepae authored Sep 24, 2024
2 parents 4bfa93d + f1d26cd commit 545d4e1
Show file tree
Hide file tree
Showing 14 changed files with 116 additions and 58 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/test-playwright-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/test-playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
48 changes: 0 additions & 48 deletions site/gatsby-site/cypress/e2e/unit/discover/routing.cy.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const config = require('../config');

/** @type {import('umzug').MigrationFn<any>} */
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`
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const config = require('../config');

/** @type {import('umzug').MigrationFn<any>} */
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}`);
};
2 changes: 2 additions & 0 deletions site/gatsby-site/playwright/e2e-full/cite.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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] } });
Expand Down
2 changes: 0 additions & 2 deletions site/gatsby-site/playwright/e2e-full/incidents/new.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
47 changes: 47 additions & 0 deletions site/gatsby-site/playwright/e2e/unit/discover/routing.spec.ts
Original file line number Diff line number Diff line change
@@ -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);
});
6 changes: 5 additions & 1 deletion site/gatsby-site/playwright/seeds/aiidprod/incidents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -48,6 +51,7 @@ const incidents: DBIncident[] = [
7,
8,
],
editor_notes: "",
"Alleged deployer of AI system": [
"starbucks"
],
Expand Down
2 changes: 2 additions & 0 deletions site/gatsby-site/server/fields/submissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ export const mutationFields: GraphQLFieldConfigMap<any, Context> = {
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 = {
Expand Down
5 changes: 5 additions & 0 deletions site/gatsby-site/server/tests/fixtures/incidents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ const incident1: DBIncident = {
y: -0.2
},
reports: [1, 2],
editor_notes: "Sample editor notes",
};

const incident2: DBIncident = {
Expand Down Expand Up @@ -238,6 +239,7 @@ const incident2: DBIncident = {
y: -0.4
},
reports: [3],
editor_notes: "",
};

const incident3: DBIncident = {
Expand Down Expand Up @@ -285,6 +287,7 @@ const incident3: DBIncident = {
y: -0.6
},
reports: [2, 3],
editor_notes: "",
};

const fixture: Fixture<Incident, IncidentUpdateType, IncidentInsertType> = {
Expand Down Expand Up @@ -423,6 +426,8 @@ const fixture: Fixture<Incident, IncidentUpdateType, IncidentInsertType> = {
reports: { link: [1, 2] },
incident_id: 5,
editors: { link: [editor1.userId] },
editor_notes: "",
flagged_dissimilar_incidents: [],
},
result: {
_id: expect.any(String),
Expand Down
4 changes: 3 additions & 1 deletion site/gatsby-site/server/tests/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ describe(`Utils`, () => {
]
},
"date": "2029-01-01",
"title": "Test"
"title": "Test",
"editor_notes": "",
"flagged_dissimilar_incidents": []
}
}

Expand Down
4 changes: 2 additions & 2 deletions site/gatsby-site/server/types/incidents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand Down Expand Up @@ -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 }
Expand Down
5 changes: 3 additions & 2 deletions site/gatsby-site/src/pages/incidents/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ function NewIncidentPage() {

newIncident.editor_similar_incidents = [];
newIncident.editor_dissimilar_incidents = [];
newIncident.flagged_dissimilar_incidents = [];

await insertIncident({ variables: { data: newIncident } });

Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit 545d4e1

Please sign in to comment.