Skip to content

Commit

Permalink
Merge branch 'staging' into feature/edit-entity
Browse files Browse the repository at this point in the history
  • Loading branch information
pdcp1 committed Apr 1, 2024
2 parents e88be28 + 1e36315 commit 853d1c9
Show file tree
Hide file tree
Showing 39 changed files with 1,031 additions and 487 deletions.
121 changes: 121 additions & 0 deletions site/gatsby-site/cypress/e2e/integration/apps/checklistsIndex.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ describe('Checklists App Index', () => {

const newChecklistButtonQuery = '#new-checklist-button';

const testError = {
0: {
message: 'Test error',
locations: [{ line: 1, column: 1 }],
},
};

const usersQuery = {
query: gql`
{
Expand Down Expand Up @@ -91,4 +98,118 @@ describe('Checklists App Index', () => {
cy.get('[data-cy="checklist-card"]:last-child button').contains('Delete').should('not.exist');
});
});

it('Should show toast on error fetching checklists', () => {
cy.conditionalIntercept(
'**/graphql',
(req) => req.body.operationName == 'findChecklists',
'findChecklists',
{ errors: [testError] }
);

cy.visit(url);

cy.get('[data-cy="toast"]').contains('Could not fetch checklists').should('exist');
});

it('Should show toast on error fetching risks', () => {
cy.query(usersQuery).then(({ data: { users } }) => {
const user = users.find((user) => user.adminData.email == Cypress.env('e2eUsername'));

cy.conditionalIntercept(
'**/graphql',
(req) => req.body.operationName == 'findChecklists',
'findChecklists',
{
data: {
checklists: [
{
about: '',
id: 'fakeChecklist1',
name: 'My Checklist',
owner_id: user.userId,
risks: [],
tags_goals: ['GMF:Known AI Goal:Translation'],
tags_methods: [],
tags_other: [],
},
{
about: '',
id: 'fakeChecklist2',
name: "Somebody Else's Checklist",
owner_id: 'aFakeUserId',
risks: [],
tags_goals: [],
tags_methods: [],
tags_other: [],
},
],
},
}
);

cy.conditionalIntercept('**/graphql', (req) => req.body.query.includes('GMF'), 'risks', {
errors: [testError],
});

cy.login(Cypress.env('e2eUsername'), Cypress.env('e2ePassword'));

cy.visit(url);

cy.get('[data-cy="toast"]').contains('Failure searching for risks').should('exist');
});
});

maybeIt('Should show toast on error creating checklist', () => {
cy.query(usersQuery).then(({ data: { users } }) => {
const user = users.find((user) => user.adminData.email == Cypress.env('e2eUsername'));

cy.conditionalIntercept(
'**/graphql',
(req) => req.body.operationName == 'insertChecklist',
'insertChecklist',
{ errors: [testError] }
);

cy.conditionalIntercept(
'**/graphql',
(req) => req.body.operationName == 'findChecklists',
'findChecklists',
{
data: {
checklists: [
{
about: '',
id: 'fakeChecklist1',
name: 'My Checklist',
owner_id: user.userId,
risks: [],
tags_goals: [],
tags_methods: [],
tags_other: [],
},
{
about: '',
id: 'fakeChecklist2',
name: "Somebody Else's Checklist",
owner_id: 'aFakeUserId',
risks: [],
tags_goals: [],
tags_methods: [],
tags_other: [],
},
],
},
}
);

cy.login(Cypress.env('e2eUsername'), Cypress.env('e2ePassword'));

cy.visit(url);

cy.get(newChecklistButtonQuery).click();

cy.get('[data-cy="toast"]').contains('Could not create checklist.').should('exist');
});
});
});
21 changes: 8 additions & 13 deletions site/gatsby-site/cypress/e2e/integration/apps/reports.cy.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import reports from '../../../fixtures/reports/reports.json';

describe('Reports App', () => {
const url = '/apps/reports';
const url = '/apps/incidents';

it('Successfully loads', () => {
cy.visit(url);
it('Successfully loads reports', () => {
cy.visit(url + '?view=reports');
});

it('Filters a report by title ', () => {
cy.visit(url);
it('Successfully loads issue reports', () => {
cy.visit(url + '?view=issueReports');
});

cy.conditionalIntercept(
'**/graphql',
(req) => req.body.operationName == 'ReportsQuery',
'ReportsQuery',
reports
);
it('Filters a report by title ', () => {
cy.visit(url + '?view=reports');

cy.get('[data-cy="filter"]', { timeout: 15000 })
.eq(1)
Expand Down
4 changes: 2 additions & 2 deletions site/gatsby-site/cypress/e2e/integration/cite.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ describe('Cite pages', () => {
expect(variables.query.report_number).to.equal(23);
expect(variables.set).deep.eq({
flag: true,
date_modified: format(now, 'yyyy-MM-dd'),
date_modified: now.toISOString(),
epoch_date_modified: getUnixTime(now),
});
});
Expand All @@ -212,7 +212,7 @@ describe('Cite pages', () => {
);

expectedReport.modifiedBy = '';
expectedReport.date_modified = format(now, 'yyyy-MM-dd');
expectedReport.date_modified = now.toISOString();
expectedReport.epoch_date_modified = getUnixTime(now);

expect(input).to.deep.eq(expectedReport);
Expand Down
3 changes: 3 additions & 0 deletions site/gatsby-site/cypress/e2e/integration/citeEdit.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ describe('Edit report', () => {
cy.get(`[name=${key}]`).clear().type(updates[key]);
});

cy.get(`[name="quiet"]`).click();

cy.setEditorText(
'## This is text in English\n\nthat is longer that eighty characters, yes eighty characters!',
'[data-cy="text"] .CodeMirror'
Expand Down Expand Up @@ -215,6 +217,7 @@ describe('Edit report', () => {
source_domain: 'test.com',
editor_notes: 'Pro iustitia tantum',
language: 'en',
quiet: true,
};

cy.wait('@updateReport').then((xhr) => {
Expand Down
6 changes: 3 additions & 3 deletions site/gatsby-site/cypress/e2e/integration/discover.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import flaggedReport from '../../fixtures/reports/flagged.json';
import unflaggedReport from '../../fixtures/reports/unflagged.json';
import config from '../../../config';
import path from 'path';
import { format, getUnixTime } from 'date-fns';
import { getUnixTime } from 'date-fns';
import { deleteReportTypenames, transformReportData } from '../../../src/utils/reports';
import { conditionalIt } from '../../support/utils';

Expand Down Expand Up @@ -267,7 +267,7 @@ describe('The Discover app', () => {
expect(variables.query.report_number).to.equal(23);
expect(variables.set).deep.eq({
flag: true,
date_modified: format(now, 'yyyy-MM-dd'),
date_modified: now.toISOString(),
epoch_date_modified: getUnixTime(now),
});
});
Expand All @@ -280,7 +280,7 @@ describe('The Discover app', () => {
);

expectedReport.modifiedBy = '';
expectedReport.date_modified = format(now, 'yyyy-MM-dd');
expectedReport.date_modified = now.toISOString();
expectedReport.epoch_date_modified = getUnixTime(now);

expect(input).to.deep.eq(expectedReport);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const submission = {
editor_similar_incidents: [],
tags: [],
user: 'user1',
quiet: false,
};

const submission_with_embedding = {
Expand Down Expand Up @@ -68,6 +69,7 @@ const submission_with_embedding = {
editor_similar_incidents: [],
tags: [],
user: 'user1',
quiet: false,
embedding: {
vector: [1, 2, 3],
from_reports: [1],
Expand Down Expand Up @@ -244,6 +246,7 @@ describe('Functions', () => {
language: 'en',
tags: [],
user: 'user1',
quiet: false,
};

expect(reportsCollection.insertOne.firstCall.args[0]).to.deep.eq(expectedReport);
Expand Down Expand Up @@ -404,6 +407,7 @@ describe('Functions', () => {
language: 'en',
tags: [],
user: 'user1',
quiet: false,
embedding: {
vector: [1, 2, 3],
from_reports: [1],
Expand Down Expand Up @@ -561,6 +565,7 @@ describe('Functions', () => {
language: 'en',
tags: [],
user: 'user1',
quiet: false,
};

expect(reportsCollection.insertOne.firstCall.args[0]).to.deep.eq(expectedReport);
Expand Down Expand Up @@ -862,6 +867,7 @@ describe('Functions', () => {
source_domain: 'projects.tampabay.com',
language: 'en',
tags: [],
quiet: false,
};

expect(reportsCollection.insertOne.firstCall.args[0]).to.deep.eq(expectedReport);
Expand Down
3 changes: 2 additions & 1 deletion site/gatsby-site/cypress/fixtures/reports/flagged.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"epoch_date_downloaded": 1559347200,
"date_submitted": "2019-06-01",
"date_modified": "2019-06-02",
"language": "en"
"language": "en",
"quiet": false
}
}
}
3 changes: 2 additions & 1 deletion site/gatsby-site/cypress/fixtures/reports/unflagged.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"epoch_date_modified": 1559347200,
"epoch_date_downloaded": 1559347200,
"date_submitted": "2019-06-01",
"date_modified": "2019-06-02"
"date_modified": "2019-06-02",
"quiet": false
}
}
}
3 changes: 3 additions & 0 deletions site/gatsby-site/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const createCitationPages = require('./page-creators/createCitationPages');

const createWordCountsPages = require('./page-creators/createWordCountsPage');

const createLandingPage = require('./page-creators/createLandingPage');

const createBackupsPage = require('./page-creators/createBackupsPage');

const createTaxonomyPages = require('./page-creators/createTaxonomyPages');
Expand Down Expand Up @@ -76,6 +78,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
createBlogPages,
createCitationPages,
createWordCountsPages,
createLandingPage,
createBackupsPage,
createTaxonomyPages,
createDownloadIndexPage,
Expand Down
4 changes: 4 additions & 0 deletions site/gatsby-site/i18n/locales/en/popovers.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,9 @@
"submittersLoggedIn": {
"title": "This is you!",
"text": "You are currently logged in so this submission will automatically be associated with your account. If you would like to remain anonymous, please open a private browsing window to submit."
},
"quiet": {
"title": "Quiet",
"text": "Quiet reports are those that will not be published in the 'Latest Reports' section of the homepage. Quiet reports are used for reports that are useful for internal data but do not need to be promoted. If you are unsure, leave this field blank."
}
}
4 changes: 4 additions & 0 deletions site/gatsby-site/i18n/locales/es/popovers.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,9 @@
"submittersLoggedIn": {
"title": "¡Este eres tú!",
"text": "Actualmente estás conectado, por lo que este reporte se asociará automáticamente con tu cuenta. Si deseas permanecer anónimo, por favor abre una ventana de navegación privada."
},
"quiet": {
"title": "¿Es un informe silencioso?",
"text": "Los informes silenciosos son aquellos que no se publicarán en la sección 'Últimos informes' de la página de inicio. Los informes silenciosos se utilizan para informes que son útiles para datos internos pero que no necesitan promocionarse. Si no está seguro, deje este campo en blanco."
}
}
2 changes: 2 additions & 0 deletions site/gatsby-site/i18n/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@
"Issue Reports": "Informes de Problemas",
"found": "encontrados",
"results found": "resultados encontrados",
"Displaying {{pageLength}} of {{allResultsCount}} reports": "Mostrando {{pageLength}} de {{allResultsCount}} informes",
"Displaying {{pageLength}} of {{allResultsCount}} incidents": "Mostrando {{pageLength}} de {{allResultsCount}} incidentes",
"Blog": "Blog",
"AI News Digest": "Resumen de noticias de IA",
"Remove Duplicate": "Eliminar Duplicado",
Expand Down
4 changes: 4 additions & 0 deletions site/gatsby-site/i18n/locales/fr/popovers.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,9 @@
"submittersLoggedIn": {
"title": "C'est vous !",
"text": "Vous êtes actuellement connecté, donc cette soumission sera automatiquement associée à votre compte. Si vous souhaitez rester anonyme, veuillez ouvrir une fenêtre de navigation privée pour soumettre."
},
"quiet": {
"title": "Est-ce un rapport silencieux ?",
"text": "Les rapports silencieux sont ceux qui ne seront pas publiés dans la section « Derniers rapports » de la page d'accueil. Les rapports silencieux sont utilisés pour les rapports utiles pour les données internes mais qui n'ont pas besoin d'être promus. Si vous n'êtes pas sûr, laissez ce champ vide."
}
}
2 changes: 2 additions & 0 deletions site/gatsby-site/i18n/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@
"Issue Reports": "Rapports de problèmes",
"found": "trouvés",
"results found": "résultats trouvés",
"Displaying {{pageLength}} of {{allResultsCount}} reports": "Affichage de {{pageLength}} sur {{allResultsCount}} rapports",
"Displaying {{pageLength}} of {{allResultsCount}} incidents": "Affichage de {{pageLength}} sur {{allResultsCount}} incidents",
"Blog": "Blog",
"AI News Digest": "Résumé de l’Actualité sur l’IA",
"Remove Duplicate": "Supprimer le doublon",
Expand Down
Loading

0 comments on commit 853d1c9

Please sign in to comment.