Skip to content

Commit

Permalink
Merge pull request #2264 from responsible-ai-collaborative/staging
Browse files Browse the repository at this point in the history
Deploy to Production - 2023-09-07
  • Loading branch information
kepae authored Sep 7, 2023
2 parents 5a0e9d1 + cb19f27 commit 64a9def
Show file tree
Hide file tree
Showing 24 changed files with 1,057 additions and 120 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/mongodb-clone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ jobs:
- name: "Restore Staging database collection: translations"
run: mongorestore ${{ secrets.DB_STAGING_CONNECTION_STRING }}/translations ./dump/translations --drop --noOptionsRestore

- name: "Restore Staging database collection: history"
run: mongorestore ${{ secrets.DB_STAGING_CONNECTION_STRING }}/history ./dump/history --drop --noOptionsRestore

- name: Trigger Staging Netlify build
run: curl -X POST -d {} ${{ secrets.NETLIFY_BUILD_STAGING_URL }}
3 changes: 2 additions & 1 deletion site/gatsby-site/cypress/e2e/integration/admin.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const { gql } = require('@apollo/client');
describe('Admin', () => {
const baseUrl = '/admin';

it('Should show not enough permissions message', () => {
//TODO: (Issue #2272): Temporarily skip flaky test.
it.skip('Should show not enough permissions message', () => {
cy.visit(baseUrl);

cy.contains('Not enough permissions').should('be.visible');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ describe('CSET tool', () => {

expect(xhr.request.body.variables.data).to.deep.eq({
incidents: { link: [52] },
reports: [],
reports: { link: [] },
namespace: 'CSETv1',
notes:
'Annotator 1: \n\n This a note from the annotator 1\n\nAnnotator 2: \n\n This a note from the annotator 2',
Expand Down
140 changes: 140 additions & 0 deletions site/gatsby-site/cypress/e2e/integration/incidents/history.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { format, fromUnixTime, getUnixTime } from 'date-fns';
import incidentHistory from '../../../fixtures/history/incidentHistory.json';
import versionReports from '../../../fixtures/history/versionReports.json';
import { maybeIt } from '../../../support/utils';
const { gql } = require('@apollo/client');

Expand Down Expand Up @@ -359,4 +360,143 @@ describe('Incidents', () => {

cy.get('[data-cy="restoring-message"]').should('not.exist');
});

it('Should display the Version History details modal', () => {
cy.visit(url);

cy.conditionalIntercept(
'**/graphql',
(req) => req.body.operationName == 'FindIncidentHistory',
'FindIncidentHistory',
incidentHistory
);

cy.conditionalIntercept(
'**/graphql',
(req) => req.body.operationName == 'FindUsers',
'FindUsers',
{
data: {
users: [
{ userId: '1', first_name: 'Sean', last_name: 'McGregor', roles: [] },
{ userId: '2', first_name: 'Pablo', last_name: 'Costa', roles: [] },
],
},
}
);

cy.conditionalIntercept(
'**/graphql',
(req) => req.body.operationName == 'FindEntities',
'FindEntities',
{
data: {
entities: [
{ __typename: 'Entity', entity_id: 'youtube', name: 'Youtube' },
{ __typename: 'Entity', entity_id: 'google', name: 'Google' },
{ __typename: 'Entity', entity_id: 'tesla', name: 'Tesla' },
],
},
}
);

cy.conditionalIntercept(
'**/graphql',
(req) => req.body.operationName == 'FindReports',
'FindReports',
versionReports
);

cy.wait(['@FindIncidentHistory', '@FindEntities', '@FindUsers']);

cy.waitForStableDOM();

// Click the 2nd version
cy.get('[data-cy="history-row"]')
.eq(1)
.within(() => {
cy.get('[data-cy="view-full-version-button"]').click();
});

cy.wait('@FindReports').then((xhr) => {
expect(xhr.request.body.variables.query).to.deep.eq({
report_number_in: incidentHistory.data.history_incidents[1].reports,
});
});

cy.get('[data-cy="version-view-modal"]').as('modal').should('be.visible');

cy.get('[data-cy="version-view-modal"]').within(() => {
const version = incidentHistory.data.history_incidents[1];

cy.contains('View Version details').should('exist');
cy.contains(version.title).should('exist');
cy.contains('Modified by: Sean McGregor').should('exist');
cy.contains(
`Modified on: ${format(fromUnixTime(version.epoch_date_modified), 'yyyy-MM-dd hh:mm a')}`
).should('exist');
cy.contains(`Description: ${version.description}`).should('exist');
if (version.editor_notes) {
cy.contains(`Editor Notes: ${version.editor_notes}`).should('exist');
}
cy.get('[data-cy="alleged-entities"]').within(() => {
cy.contains(
'Alleged: developed an AI system deployed by Youtube, which harmed Google.'
).should('exist');
});
cy.get('[data-cy="citation"]').within(() => {
cy.contains(`${version.incident_id}`).should('exist');
cy.contains(`${version.reports.length}`).should('exist');
cy.contains(`${version.date}`).should('exist');
cy.contains('Sean McGregor, Pablo Costa').should('exist');
});
cy.get('[data-cy="classifications-editor"]').should('not.exist');
cy.get('button').contains('Close').click();
});
cy.get('[data-cy="version-view-modal"]').should('not.exist');

// Click the latest version
cy.get('[data-cy="history-row"]')
.eq(0)
.within(() => {
cy.get('[data-cy="view-full-version-button"]').click();
});

cy.wait('@FindReports').then((xhr) => {
expect(xhr.request.body.variables.query).to.deep.eq({
report_number_in: incidentHistory.data.history_incidents[0].reports,
});
});

cy.get('[data-cy="version-view-modal"]').as('modal').should('be.visible');

cy.get('[data-cy="version-view-modal"]').within(() => {
const version = incidentHistory.data.history_incidents[0];

cy.contains('View Version details').should('exist');
cy.contains(version.title).should('exist');
cy.contains('Modified by: Sean McGregor').should('exist');
cy.contains(
`Modified on: ${format(fromUnixTime(version.epoch_date_modified), 'yyyy-MM-dd hh:mm a')}`
).should('exist');
cy.contains(`Description: ${version.description}`).should('exist');
if (version.editor_notes) {
cy.contains(`Editor Notes: ${version.editor_notes}`).should('exist');
}
cy.get('[data-cy="alleged-entities"]').within(() => {
cy.contains(
'Alleged: developed an AI system deployed by Youtube, which harmed Google.'
).should('exist');
});
cy.get('[data-cy="citation"]').within(() => {
cy.contains(`${version.incident_id}`).should('exist');
cy.contains(`${version.reports.length}`).should('exist');
cy.contains(`${version.date}`).should('exist');
cy.contains('Sean McGregor, Pablo Costa').should('exist');
});
cy.get('[data-cy="classifications-editor"]').should('not.exist');
cy.get('button').contains('Close').click();
});
cy.get('[data-cy="version-view-modal"]').should('not.exist');
});
});
153 changes: 153 additions & 0 deletions site/gatsby-site/cypress/e2e/integration/reportHistory.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { format, fromUnixTime, getUnixTime } from 'date-fns';
import reportHistory from '../../fixtures/history/reportHistory.json';
import updateOneReport from '../../fixtures/reports/updateOneReport.json';
import { maybeIt } from '../../support/utils';
import supportedLanguages from '../../../src/components/i18n/languages.json';
const { gql } = require('@apollo/client');

describe('Report History', () => {
Expand Down Expand Up @@ -283,4 +284,156 @@ describe('Report History', () => {

cy.wait('@FindReportHistory');
});

it('Should display the Report Version History details modal', () => {
cy.visit(url);

cy.conditionalIntercept(
'**/graphql',
(req) => req.body.operationName == 'FindReport',
'FindReport',
{
data: {
report: reportHistory.data.history_reports[0],
},
}
);

cy.conditionalIntercept(
'**/graphql',
(req) => req.body.operationName == 'FindReportHistory',
'FindReportHistory',
reportHistory
);

cy.conditionalIntercept(
'**/graphql',
(req) => req.body.operationName == 'FindUsers',
'FindUsers',
{
data: {
users: [
{ userId: '1', first_name: 'Sean', last_name: 'McGregor', roles: [] },
{ userId: '2', first_name: 'Pablo', last_name: 'Costa', roles: [] },
],
},
}
);

cy.wait(['@FindReport', '@FindReportHistory', '@FindUsers']);

cy.waitForStableDOM();

// Click the 2nd version
cy.get('[data-cy="history-row"]')
.eq(1)
.within(() => {
cy.get('[data-cy="view-full-version-button"]').click();
});

cy.get('[data-cy="version-view-modal"]').as('modal').should('be.visible');

cy.get('[data-cy="version-view-modal"]').within(() => {
const version = reportHistory.data.history_reports[1];

cy.contains('Version details').should('exist');
cy.contains(
`Modified on: ${format(fromUnixTime(version.epoch_date_modified), 'yyyy-MM-dd hh:mm a')}`
).should('exist');
cy.contains('Modified by: Sean McGregor').should('exist');
let index = 0;

cy.get('.tw-row').eq(index).contains('Report Address:').should('exist');
cy.get('.tw-row').eq(index).contains(version.url).should('exist');
cy.get('.tw-row').eq(++index).contains('Title:').should('exist');
cy.get('.tw-row').eq(index).contains(version.title).should('exist');
cy.get('.tw-row').eq(++index).contains('Author CSV:').should('exist');
cy.get('.tw-row').eq(index).contains(version.authors.join(', ')).should('exist');
cy.get('.tw-row').eq(++index).contains('Submitter CSV:').should('exist');
cy.get('.tw-row').eq(index).contains(version.submitters.join(', ')).should('exist');
cy.get('.tw-row').eq(++index).contains('Date Published:').should('exist');
cy.get('.tw-row').eq(index).contains(version.date_published).should('exist');
cy.get('.tw-row').eq(++index).contains('Date Downloaded:').should('exist');
cy.get('.tw-row').eq(index).contains(version.date_downloaded).should('exist');
cy.get('.tw-row').eq(++index).contains('Image Address:').should('exist');
cy.get('.tw-row').eq(index).contains(version.image_url).should('exist');
cy.get('.tw-row')
.eq(++index)
.find('[data-cy="cloudinary-image"]')
.should('have.attr', 'src')
.and('include', version.cloudinary_id);
cy.get('.tw-row').eq(++index).contains('Text:').should('exist');
cy.get('.tw-row').eq(index).contains('By Aimee Picchi').should('exist');
cy.get('.tw-row').eq(++index).contains('Language:').should('exist');
cy.get('.tw-row')
.eq(index)
.contains(supportedLanguages.find((l) => l.code == version.language)?.name)
.should('exist');
cy.get('.tw-row').eq(++index).contains('Tags:').should('exist');
for (const tag of version.tags) {
cy.get('.tw-row').eq(index).contains(tag).should('exist');
}
cy.get('.tw-row').eq(++index).contains('Editor Notes:').should('exist');
cy.get('.tw-row').eq(index).contains(version.editor_notes).should('exist');

cy.get('button').contains('Close').click();
});
cy.get('[data-cy="version-view-modal"]').should('not.exist');

// Click the latest version
cy.get('[data-cy="history-row"]')
.eq(0)
.within(() => {
cy.get('[data-cy="view-full-version-button"]').click();
});

cy.get('[data-cy="version-view-modal"]').as('modal').should('be.visible');

cy.get('[data-cy="version-view-modal"]').within(() => {
const version = reportHistory.data.history_reports[0];

cy.contains('Version details').should('exist');
cy.contains(
`Modified on: ${format(fromUnixTime(version.epoch_date_modified), 'yyyy-MM-dd hh:mm a')}`
).should('exist');
cy.contains('Modified by: Sean McGregor').should('exist');
let index = 0;

cy.get('.tw-row').eq(index).contains('Report Address:').should('exist');
cy.get('.tw-row').eq(index).contains(version.url).should('exist');
cy.get('.tw-row').eq(++index).contains('Title:').should('exist');
cy.get('.tw-row').eq(index).contains(version.title).should('exist');
cy.get('.tw-row').eq(++index).contains('Author CSV:').should('exist');
cy.get('.tw-row').eq(index).contains(version.authors.join(', ')).should('exist');
cy.get('.tw-row').eq(++index).contains('Submitter CSV:').should('exist');
cy.get('.tw-row').eq(index).contains(version.submitters.join(', ')).should('exist');
cy.get('.tw-row').eq(++index).contains('Date Published:').should('exist');
cy.get('.tw-row').eq(index).contains(version.date_published).should('exist');
cy.get('.tw-row').eq(++index).contains('Date Downloaded:').should('exist');
cy.get('.tw-row').eq(index).contains(version.date_downloaded).should('exist');
cy.get('.tw-row').eq(++index).contains('Image Address:').should('exist');
cy.get('.tw-row').eq(index).contains(version.image_url).should('exist');
cy.get('.tw-row')
.eq(++index)
.find('[data-cy="cloudinary-image"]')
.should('have.attr', 'src')
.and('include', version.cloudinary_id);
cy.get('.tw-row').eq(++index).contains('Text:').should('exist');
cy.get('.tw-row').eq(index).contains('By Aimee Picchi').should('exist');
cy.get('.tw-row').eq(++index).contains('Language:').should('exist');
cy.get('.tw-row')
.eq(index)
.contains(supportedLanguages.find((l) => l.code == version.language)?.name)
.should('exist');
cy.get('.tw-row').eq(++index).contains('Tags:').should('exist');
for (const tag of version.tags) {
cy.get('.tw-row').eq(index).contains(tag).should('exist');
}
cy.get('.tw-row').eq(++index).contains('Editor Notes:').should('exist');
cy.get('.tw-row').eq(index).contains(version.editor_notes).should('exist');

cy.get('button').contains('Close').click();
});
cy.get('[data-cy="version-view-modal"]').should('not.exist');
});
});
Loading

0 comments on commit 64a9def

Please sign in to comment.