Skip to content

Commit

Permalink
Merge pull request #3247 from responsible-ai-collaborative/staging
Browse files Browse the repository at this point in the history
Deploy to Production
  • Loading branch information
cesarvarela authored Dec 2, 2024
2 parents f78a48f + 824be79 commit 0ebd551
Show file tree
Hide file tree
Showing 87 changed files with 2,779 additions and 8,549 deletions.
7 changes: 4 additions & 3 deletions site/gatsby-site/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ Once you have cloned the repository, to set up a local development environment f
CLOUDFLARE_R2_SECRET_ACCESS_KEY= # Secret access key for Cloudflare R2 storage
CLOUDFLARE_R2_BUCKET_NAME= # Name of the Cloudflare R2 bucket for storage
GATSBY_CLOUDFLARE_R2_PUBLIC_BUCKET_URL= # Public URL for accessing the Cloudflare R2 bucket from the Gatsby app
MAILERSEND_API_KEY= # API key for MailerSend email service or dummy value if you don't plan to send emails
NOTIFICATIONS_SENDER_NAME=AIID Notifications # Name of the sender for email notifications
NOTIFICATIONS_SENDER=[email protected] # Email address of the sender for email notifications
MAILERSEND_API_KEY= # API key for MailerSend email service
NOTIFICATIONS_SENDER_NAME= # Name of the sender for email notifications
NOTIFICATIONS_SENDER= # Email address of the sender for email notifications
SITE_URL=http://localhost:8000
```

Expand Down Expand Up @@ -150,6 +150,7 @@ npm run codegen
### Schema and API Stitching

> [!IMPORTANT]
The API previously relied on the MongoDB Atlas Realm GraphQL API to fetch data, [but now that it has been deprecated](https://www.mongodb.com/developer/products/atlas/deprecating-mongodb-atlas-graphql-hosting-services/), we have migrated to a new API that we implement in this codebase. During the migration from Realm to our API, we stitch two GraphQL schemas: the auto-generated one from Atlas and the one defined in this codebase. These schemas can be found in the `remote.ts` and `local.ts` files respectively. The migration process involves progressively transferring GraphQL fields and functionality from the remote schema to the local one. The final combined schema is found in `schema.ts`.

### Email notifications
Expand Down
34 changes: 1 addition & 33 deletions site/gatsby-site/playwright/e2e-full/apps/incidents.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,6 @@ test.describe('Incidents App', () => {

await login(process.env.E2E_ADMIN_USERNAME, process.env.E2E_ADMIN_PASSWORD, { customData: { first_name: 'John', last_name: 'Doe', roles: ['admin'] } });

await conditionalIntercept(
page,
'**/graphql',
(req) => req.postDataJSON().operationName === 'logIncidentHistory',
{
data: {
logIncidentHistory: {
incident_id: 3,
},
},
},
'logIncidentHistory'
);

await page.goto(url);

await page.waitForSelector('[data-testid="flowbite-toggleswitch-toggle"]');
Expand All @@ -63,8 +49,6 @@ test.describe('Incidents App', () => {

await page.getByText('Update', { exact: true }).click();

await waitForRequest('logIncidentHistory');

await expect(page.locator('[data-cy="toast"]').locator('text=Incident 3 updated successfully.')).toBeVisible();

const result = await query({
Expand All @@ -88,20 +72,6 @@ test.describe('Incidents App', () => {

await login(process.env.E2E_ADMIN_USERNAME, process.env.E2E_ADMIN_PASSWORD, { customData: { first_name: 'John', last_name: 'Doe', roles: ['incident_editor'] } });

await conditionalIntercept(
page,
'**/graphql',
(req) => req.postDataJSON().operationName === 'logIncidentHistory',
{
data: {
logIncidentHistory: {
incident_id: 3,
},
},
},
'logIncidentHistory'
);

await page.goto(url);

await page.waitForSelector('[data-testid="flowbite-toggleswitch-toggle"]');
Expand Down Expand Up @@ -132,8 +102,6 @@ test.describe('Incidents App', () => {

await page.getByText('Update', { exact: true }).click();

await waitForRequest('logIncidentHistory');

await expect(page.locator('[data-cy="toast"]').locator('text=Incident 3 updated successfully.')).toBeVisible();

const result = await query({
Expand Down Expand Up @@ -284,7 +252,7 @@ test.describe('Incidents App', () => {
await page.getByText('Reports', { exact: true }).click();

await page.waitForSelector('[data-cy="row"]');
await expect(page.locator('[data-cy="row"]')).toHaveCount(3);
await expect(page.locator('[data-cy="row"]')).toHaveCount(4);

const firstCiteLink = await page.locator('[data-cy="row"] td a').first().getAttribute('href');
expect(firstCiteLink).toMatch(/^\/cite\/\d+#r\d+$/);
Expand Down
79 changes: 5 additions & 74 deletions site/gatsby-site/playwright/e2e-full/cite.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { waitForRequest, query, mockDate, test, conditionalIntercept, fillAutoComplete } from '../utils';
import { query, mockDate, test, fillAutoComplete } from '../utils';
import { format } from 'date-fns';
import { gql } from '@apollo/client';
import { expect } from '@playwright/test';
import config from '../config';
import { init } from '../memory-mongo';
import { DBIncident } from '../seeds/aiidprod/incidents';
import { DBIncident } from '../../server/interfaces';

test.describe('Cite pages', () => {
const discoverUrl = '/apps/discover';
Expand Down Expand Up @@ -108,20 +108,6 @@ test.describe('Cite pages', () => {

await init();

await conditionalIntercept(
page,
'**/graphql',
(req) => req.postDataJSON().operationName === 'logReportHistory',
{
data: {
logReportHistory: {
report_number: 3,
},
},
},
'logReportHistory'
);

await page.goto(url + '#' + _id);

await page.click(`[id="r${_id}"] [data-cy="expand-report-button"]`);
Expand All @@ -132,8 +118,6 @@ test.describe('Cite pages', () => {

await modal.locator('[data-cy="flag-toggle"]').click();

await waitForRequest('logReportHistory');

await expect(modal.locator('[data-cy="flag-toggle"]')).toBeDisabled();

await page.click('[aria-label="Close"]');
Expand Down Expand Up @@ -356,28 +340,11 @@ test.describe('Cite pages', () => {

await init();

await conditionalIntercept(
page,
'**/graphql',
(req) => req.postDataJSON().operationName === 'logIncidentHistory',
{
data: {
logIncidentHistory: {
incident_id: 3,
},
},
},
'logIncidentHistory'
);

const now = new Date('March 14 2042 13:37:11');
await mockDate(page, now);

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

await page.locator('[data-cy="similar-incidents-column"] [data-cy="flag-similar-incident"]').first().click();

await waitForRequest('logIncidentHistory');
await expect(page.getByText('Incident flagged successfully. Our editors will remove it from this list if it not relevant.')).toBeVisible();

const { data } = await query({
query: gql`{incident(filter: { incident_id: { EQ: 3 } }) {
Expand All @@ -396,31 +363,13 @@ test.describe('Cite pages', () => {

await login(config.E2E_ADMIN_USERNAME, config.E2E_ADMIN_PASSWORD, { customData: { first_name: 'Test', last_name: 'User', roles: ['admin'] } });

await conditionalIntercept(
page,
'**/graphql',
(req) => req.postDataJSON().operationName === 'logIncidentHistory',
{
data: {
logIncidentHistory: {
incident_id: 3,
},
},
},
'logIncidentHistory'
);

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

const now = new Date();
await page.addInitScript(`{
Date.now = () => ${now.getTime()};
}`);

await page.locator('[data-cy="similar-incidents-column"] [data-cy="flag-similar-incident"]').first().click();

await waitForRequest('logIncidentHistory');
await expect(page.getByText('Incident flagged successfully. Our editors will remove it from this list if it not relevant.')).toBeVisible();


const { data } = await query({
query: gql`{incident(filter: { incident_id: { EQ: 3 } }) {
flagged_dissimilar_incidents
Expand Down Expand Up @@ -545,22 +494,6 @@ test.describe('Cite pages', () => {

await login(process.env.E2E_ADMIN_USERNAME, process.env.E2E_ADMIN_PASSWORD, { customData: { first_name: 'John', last_name: 'Doe', roles: ['admin'] } });

await conditionalIntercept(
page,
'**/graphql',
(req) =>
req.postDataJSON().operationName === 'logIncidentHistory',
{
"data": {
"logIncidentHistory": {
"incident_id": 50,
"__typename": "LogIncidentHistoryPayload"
}
}
},
'logIncidentHistory'
);

await page.goto('/incidents/edit/?incident_id=3');

await fillAutoComplete(page, '#input-incidentSearch', '1 Incident', 'Incident 1');
Expand All @@ -573,8 +506,6 @@ test.describe('Cite pages', () => {

await page.getByText('Save').click();

await waitForRequest('logIncidentHistory');

await expect(page.locator('.tw-toast:has-text("Incident 3 updated successfully.")')).toBeVisible();


Expand Down
66 changes: 5 additions & 61 deletions site/gatsby-site/playwright/e2e-full/citeEdit.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { conditionalIntercept, waitForRequest, query, setEditorText, getEditorText, test } from '../utils';
import { query, setEditorText, getEditorText, test } from '../utils';
import { expect } from '@playwright/test';
import config from '../config';
import { init } from '../memory-mongo';
Expand All @@ -20,24 +20,9 @@ test.describe('Edit report', () => {

test('Should load and update report values', async ({ page, login }) => {

await login(config.E2E_ADMIN_USERNAME, config.E2E_ADMIN_PASSWORD, { customData: { roles: ['admin'] } });
await init();

// TODO: delete once we implement the new report history
// it should be done inside the report mutation resolver

await conditionalIntercept(
page,
'**/graphql',
(req) => req.postDataJSON().operationName == 'logReportHistory',
{
data: {
logReportHistory: {
report_number: 3,
},
},
},
'logReportHistory'
);
await login(config.E2E_ADMIN_USERNAME, config.E2E_ADMIN_PASSWORD, { customData: { roles: ['admin'] } });

await page.goto(url);

Expand Down Expand Up @@ -104,8 +89,6 @@ test.describe('Edit report', () => {

await page.getByRole('button', { name: 'Submit' }).click();

await waitForRequest('logReportHistory');

await expect(page.getByText('Incident report 3 updated successfully.')).toBeVisible();

const { data } = await query({
Expand Down Expand Up @@ -147,18 +130,8 @@ test.describe('Edit report', () => {

test('Should load and update Issue values', async ({ page, login }) => {



await login(config.E2E_ADMIN_USERNAME, config.E2E_ADMIN_PASSWORD, { customData: { roles: ['admin'] } });

await conditionalIntercept(
page,
'**/graphql',
(req) => req.postDataJSON().operationName == 'logReportHistory',
{ data: { logReportHistory: { report_number: 5 } } },
'logReportHistory'
);

await page.goto('/cite/edit?report_number=5');

const updates = {
Expand Down Expand Up @@ -188,8 +161,6 @@ test.describe('Edit report', () => {

await page.getByRole('button', { name: 'Submit' }).click();

await waitForRequest('logReportHistory');

await expect(page.getByText('Issue 5 updated successfully')).toBeVisible({ timeout: 45000 });


Expand Down Expand Up @@ -262,24 +233,7 @@ test.describe('Edit report', () => {

test('Should link a report to another incident', async ({ page, login }) => {



const [userId] = await login(config.E2E_ADMIN_USERNAME, config.E2E_ADMIN_PASSWORD);
await init({ customData: { users: [{ userId, first_name: 'Test', last_name: 'User', roles: ['admin'] }] } }, { drop: true });

await conditionalIntercept(
page,
'**/graphql',
(req) => req.postDataJSON().operationName == 'logReportHistory',
{
data: {
logReportHistory: {
report_number: 3,
},
},
},
'logReportHistory'
);
await login(config.E2E_ADMIN_USERNAME, config.E2E_ADMIN_PASSWORD, { customData: { roles: ['admin'] } });

await page.goto(`/cite/edit?report_number=3`);

Expand All @@ -295,7 +249,7 @@ test.describe('Edit report', () => {

await page.getByRole('button', { name: 'Submit' }).click();

await expect(page.locator('[data-cy="toast"]')).toContainText('Incident report 3 updated successfully', { timeout: 60000 });
await expect(page.locator('[data-cy="toast"]')).toContainText('Incident report 3 updated successfully');

const result = await query({
query: gql`{
Expand All @@ -321,18 +275,8 @@ test.describe('Edit report', () => {

test('Should convert an incident report to an issue', async ({ page, login }) => {



await login(config.E2E_ADMIN_USERNAME, config.E2E_ADMIN_PASSWORD, { customData: { roles: ['admin'] } });

await conditionalIntercept(
page,
'**/graphql',
(req) => req.postDataJSON().operationName == 'logReportHistory',
{ data: { logReportHistory: { report_number: 3 } } },
'logReportHistory'
);

await page.goto(`/cite/edit?report_number=3`);

await page.locator('form[data-cy="report"]').waitFor();
Expand Down
10 changes: 0 additions & 10 deletions site/gatsby-site/playwright/e2e-full/incidents/edit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,8 @@ test.describe('Incidents', () => {

await fillAutoComplete(page, '#input-editors', 'Pab', 'Pablo Costa');

await conditionalIntercept(page, '**/graphql', (req) => req.postDataJSON().operationName == 'logIncidentHistory', {
data: {
logIncidentHistory: {
incident_id: 112,
},
},
}, 'logIncidentHistory');

await page.getByText('Save', { exact: true }).click();

await waitForRequest('logIncidentHistory');

await page.locator('.tw-toast:has-text("Incident 3 updated successfully.")').isVisible();
});
});
Loading

0 comments on commit 0ebd551

Please sign in to comment.