Skip to content

Commit

Permalink
Merge pull request #2282 from pdcp1/fix/parsenews-timeout
Browse files Browse the repository at this point in the history
Change `test.com` to `incidentdatabase.ai` for testing
  • Loading branch information
kepae authored Sep 14, 2023
2 parents 69d8ad4 + e79cf80 commit bcc8efc
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 36 deletions.
1 change: 0 additions & 1 deletion site/gatsby-site/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const { defineConfig } = require('cypress');

module.exports = defineConfig({
video: false,
videoUploadOnPasses: false,
chromeWebSecurity: false,
screenshotOnRunFailure: false,
retries: {
Expand Down
97 changes: 62 additions & 35 deletions site/gatsby-site/cypress/e2e/integration/submit.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,14 @@ describe('The Submit form', () => {

it('Should pull parameters form the query string and auto-fill fields', () => {
const values = {
url: 'https://test.com',
url: 'https://incidentdatabase.ai',
title: 'test title',
authors: 'test author',
submitters: 'test submitter',
incident_date: '2022-01-01',
date_published: '2021-01-02',
date_downloaded: '2021-01-03',
image_url: 'https://test.com/image.jpg',
image_url: 'https://incidentdatabase.ai/image.jpg',
incident_ids: [1],
text: '## Sit quo accusantium \n\n quia **assumenda**. Quod delectus similique labore optio quaease',
tags: 'test tag',
Expand All @@ -482,7 +482,7 @@ describe('The Submit form', () => {
date_downloaded: '2021-01-03',
incident_date: '2022-01-01',
incident_ids: [1],
image_url: 'https://test.com/image.jpg',
image_url: 'https://incidentdatabase.ai/image.jpg',
text: '## Sit quo accusantium \n\n quia **assumenda**. Quod delectus similique labore optio quaease',
tags: 'test tag',
editor_notes: 'Here are some notes',
Expand Down Expand Up @@ -544,8 +544,8 @@ describe('The Submit form', () => {
tags: [values.tags],
plain_text:
'Sit quo accusantium\n\nquia assumenda. Quod delectus similique labore optio quaease\n',
source_domain: `test.com`,
cloudinary_id: `reports/test.com/image.jpg`,
source_domain: `incidentdatabase.ai`,
cloudinary_id: `reports/incidentdatabase.ai/image.jpg`,
editor_notes: 'Here are some notes',
});

Expand All @@ -557,13 +557,13 @@ describe('The Submit form', () => {
cy.login(Cypress.env('e2eUsername'), Cypress.env('e2ePassword'));

const values = {
url: 'https://test.com',
url: 'https://incidentdatabase.ai',
title: 'test title',
authors: 'test author',
incident_date: '2022-01-01',
date_published: '2021-01-02',
date_downloaded: '2021-01-03',
image_url: 'https://test.com/image.jpg',
image_url: 'https://incidentdatabase.ai/image.jpg',
incident_ids: [1],
text: '## Sit quo accusantium \n\n quia **assumenda**. Quod delectus similique labore optio quaease',
tags: 'test tag',
Expand All @@ -577,7 +577,7 @@ describe('The Submit form', () => {
authors: 'test author',
date_published: '2021-01-02',
date_downloaded: '2021-01-03',
image_url: 'https://test.com/image.jpg',
image_url: 'https://incidentdatabase.ai/image.jpg',
text: '## Sit quo accusantium \n\n quia **assumenda**. Quod delectus similique labore optio quaease',
}).as('parseNews');

Expand Down Expand Up @@ -637,8 +637,8 @@ describe('The Submit form', () => {
tags: [values.tags],
plain_text:
'Sit quo accusantium\n\nquia assumenda. Quod delectus similique labore optio quaease\n',
source_domain: `test.com`,
cloudinary_id: `reports/test.com/image.jpg`,
source_domain: `incidentdatabase.ai`,
cloudinary_id: `reports/incidentdatabase.ai/image.jpg`,
editor_notes: 'Here are some notes',
});

Expand All @@ -647,6 +647,8 @@ describe('The Submit form', () => {
});

it('Should show a list of related reports', () => {
cy.intercept('GET', parserURL, parseNews).as('parseNews');

const relatedReports = {
byURL: {
data: {
Expand Down Expand Up @@ -871,6 +873,9 @@ describe('The Submit form', () => {
// cy.setEditorText doesn't seem to trigger a render of the relateBbyText component
it('Should show related reports based on semantic similarity', () => {
cy.visit(url);

cy.intercept('GET', parserURL, parseNews).as('parseNews');

cy.setEditorText(
`Recent news stories and blog posts highlighted the underbelly of YouTube Kids, Google's children-friendly version of the wide world of YouTube. While all content on YouTube Kids is meant to be suitable for children under the age of 13, some inappropriate videos using animations, cartoons, and child-focused keywords manage to get past YouTube's algorithms and in front of kids' eyes. Now, YouTube will implement a new policy in an attempt to make the whole of YouTube safer: it will age-restrict inappropriate videos masquerading as children's content in the main YouTube app.`
);
Expand All @@ -888,6 +893,8 @@ describe('The Submit form', () => {
it('Should *not* show semantically related reports when the text is under 256 non-space characters', () => {
cy.visit(url);

cy.intercept('GET', parserURL, parseNews).as('parseNews');

cy.setEditorText(
`Recent news stories and blog posts highlighted the underbelly of YouTube Kids, Google's children-friendly version of the wide world of YouTube.`
);
Expand All @@ -897,7 +904,7 @@ describe('The Submit form', () => {

it('Should show fallback preview image on initial load', () => {
const values = {
url: 'https://test.com',
url: 'https://incidentdatabase.ai',
title: 'test title',
authors: 'test author',
submitters: 'test submitter',
Expand Down Expand Up @@ -930,7 +937,7 @@ describe('The Submit form', () => {

it('Should update preview image when url is typed', () => {
const values = {
url: 'https://test.com',
url: 'https://incidentdatabase.ai',
title: 'test title',
authors: 'test author',
submitters: 'test submitter',
Expand Down Expand Up @@ -975,8 +982,10 @@ describe('The Submit form', () => {
it('Should show the editor notes field', () => {
cy.visit(url);

cy.intercept('GET', parserURL, parseNews).as('parseNews');

const valuesStep1 = {
url: 'https://test.com',
url: 'https://incidentdatabase.ai',
title: 'test title',
authors: 'test author',
date_published: '2021-01-02',
Expand All @@ -999,7 +1008,7 @@ describe('The Submit form', () => {

const valuesStep2 = {
submitters: 'test submitter',
image_url: 'https://test.com/image.jpg',
image_url: 'https://incidentdatabase.ai/image.jpg',
};

for (const key in valuesStep2) {
Expand All @@ -1022,6 +1031,8 @@ describe('The Submit form', () => {
it('Should show a popover', () => {
cy.visit(url);

cy.intercept('GET', parserURL, parseNews).as('parseNews');

cy.get('[data-cy="label-title"]').trigger('mouseenter');

cy.get('[data-cy="popover-title"]').should('be.visible');
Expand All @@ -1034,6 +1045,8 @@ describe('The Submit form', () => {
it('Should show a translated popover', () => {
cy.visit(`/es/apps/submit/`);

cy.intercept('GET', parserURL, parseNews).as('parseNews');

cy.get('[data-cy="label-title"]').trigger('mouseenter');

cy.get('[data-cy="popover-title"]').should('be.visible');
Expand Down Expand Up @@ -1194,6 +1207,8 @@ describe('The Submit form', () => {
{ data: { incident: null } }
);

cy.intercept('GET', parserURL, parseNews).as('parseNews');

cy.visit(url);

cy.contains('button', 'Submit').click();
Expand All @@ -1203,14 +1218,14 @@ describe('The Submit form', () => {

it('Should submit a new report response', () => {
const values = {
url: 'https://test.com',
url: 'https://incidentdatabase.ai',
title: 'test title',
authors: 'test author',
submitters: 'test submitter',
incident_date: '2022-01-01',
date_published: '2021-01-02',
date_downloaded: '2021-01-03',
image_url: 'https://test.com/image.jpg',
image_url: 'https://incidentdatabase.ai/image.jpg',
incident_ids: [1],
text: '## Sit quo accusantium \n\n quia **assumenda**. Quod delectus similique labore optio quaease',
tags: 'response',
Expand Down Expand Up @@ -1248,7 +1263,7 @@ describe('The Submit form', () => {
}
);

cy.intercept('GET', parserURL).as('parseNews');
cy.intercept('GET', parserURL, values).as('parseNews');

cy.visit(url + `?${params.toString()}`);

Expand Down Expand Up @@ -1281,8 +1296,8 @@ describe('The Submit form', () => {
tags: [values.tags],
plain_text:
'Sit quo accusantium\n\nquia assumenda. Quod delectus similique labore optio quaease\n',
source_domain: `test.com`,
cloudinary_id: `reports/test.com/image.jpg`,
source_domain: `incidentdatabase.ai`,
cloudinary_id: `reports/incidentdatabase.ai/image.jpg`,
editor_notes: 'Here are some notes',
});
});
Expand Down Expand Up @@ -1314,10 +1329,12 @@ describe('The Submit form', () => {
probablyRelatedReports
);

cy.intercept('GET', parserURL, parseNews).as('parseNews');

cy.visit(url);

const values = {
url: 'https://test.com',
url: 'https://incidentdatabase.ai',
title: 'test title',
authors: 'BBC News',
incident_date: '2022-01-01',
Expand Down Expand Up @@ -1366,7 +1383,7 @@ describe('The Submit form', () => {
authors: [values.authors],
plain_text:
'Sit quo accusantium quia assumenda. Quod delectus similique labore optio quaease\n',
source_domain: `test.com`,
source_domain: `incidentdatabase.ai`,
editor_dissimilar_incidents: [2],
editor_similar_incidents: [3],
});
Expand All @@ -1376,6 +1393,8 @@ describe('The Submit form', () => {
it('Should *not* show related reports based on author', () => {
cy.visit(url);

cy.intercept('GET', parserURL, parseNews).as('parseNews');

const valuesStep1 = {
authors: 'test author',
};
Expand Down Expand Up @@ -1421,10 +1440,12 @@ describe('The Submit form', () => {
}
);

cy.intercept('GET', parserURL, parseNews).as('parseNews');

cy.visit(url);

const valuesStep1 = {
url: 'https://test.com',
url: 'https://incidentdatabase.ai',
title: 'test title',
authors: 'test author',
date_published: '2021-01-02',
Expand Down Expand Up @@ -1457,7 +1478,7 @@ describe('The Submit form', () => {

const valuesStep2 = {
submitters: 'test submitter',
image_url: 'https://test.com/image.jpg',
image_url: 'https://incidentdatabase.ai/image.jpg',
};

for (const key in valuesStep2) {
Expand Down Expand Up @@ -1492,8 +1513,8 @@ describe('The Submit form', () => {
tags: [],
plain_text:
'Sit quo accusantium quia assumenda. Quod delectus similique labore optio quaease\n',
source_domain: `test.com`,
cloudinary_id: `reports/test.com/image.jpg`,
source_domain: `incidentdatabase.ai`,
cloudinary_id: `reports/incidentdatabase.ai/image.jpg`,
editor_notes: 'Here are some notes',
});
});
Expand Down Expand Up @@ -1580,18 +1601,18 @@ describe('The Submit form', () => {

it('Should load from localstorage', () => {
const values = {
url: 'https://test.com',
url: 'https://incidentdatabase.ai',
authors: ['test author'],
title: 'test title',
date_published: '2021-01-02',
date_downloaded: '2021-01-03',
image_url: 'https://test.com/image.jpg',
image_url: 'https://incidentdatabase.ai/image.jpg',
incident_ids: [1],
text: '## Sit quo accusantium \n\n quia **assumenda**. Quod delectus similique labore optio quaease',
submitters: ['test submitters'],
tags: ['test tags'],
source_domain: `test.com`,
cloudinary_id: `reports/test.com/image.jpg`,
source_domain: `incidentdatabase.ai`,
cloudinary_id: `reports/incidentdatabase.ai/image.jpg`,
editor_notes: 'Here are some notes',
};

Expand Down Expand Up @@ -1627,18 +1648,20 @@ describe('The Submit form', () => {
tags: values.tags,
plain_text:
'Sit quo accusantium\n\nquia assumenda. Quod delectus similique labore optio quaease\n',
source_domain: `test.com`,
cloudinary_id: `reports/test.com/image.jpg`,
source_domain: `incidentdatabase.ai`,
cloudinary_id: `reports/incidentdatabase.ai/image.jpg`,
editor_notes: 'Here are some notes',
});
});
});

it('Should save form data in local storage', () => {
cy.intercept('GET', parserURL, parseNews).as('parseNews');

cy.visit(url);

const valuesStep1 = {
url: 'https://test.com',
url: 'https://incidentdatabase.ai',
title: 'test title',
authors: 'test author',
date_published: '2021-01-02',
Expand Down Expand Up @@ -1671,7 +1694,7 @@ describe('The Submit form', () => {

const valuesStep2 = {
submitters: 'test submitter',
image_url: 'https://test.com/image.jpg',
image_url: 'https://incidentdatabase.ai/image.jpg',
language: 'en',
};

Expand Down Expand Up @@ -1710,7 +1733,7 @@ describe('The Submit form', () => {
deployers: [valuesStep3.deployers],
harmed_parties: [valuesStep3.harmed_parties],
nlp_similar_incidents: [],
cloudinary_id: `reports/test.com/image.jpg`,
cloudinary_id: `reports/incidentdatabase.ai/image.jpg`,
text: 'Sit quo accusantium quia assumenda. Quod delectus similique labore optio quaease',
incident_ids: [],
incident_editors: [],
Expand All @@ -1722,7 +1745,7 @@ describe('The Submit form', () => {
cy.intercept('GET', parserURL, parseNews).as('parseNews');

const values = {
url: 'https://test.com',
url: 'https://incidentdatabase.ai',
authors: 'test author',
title: 'test title',
date_published: '2021-01-02',
Expand Down Expand Up @@ -1756,6 +1779,8 @@ describe('The Submit form', () => {
});

it('Should display an error message if Date Published is not in the past', () => {
cy.intercept('GET', parserURL, parseNews).as('parseNews');

cy.visit(url);

cy.waitForStableDOM();
Expand All @@ -1770,6 +1795,8 @@ describe('The Submit form', () => {
});

it('Should display an error message if Date Downloaded is not in the past', () => {
cy.intercept('GET', parserURL, parseNews).as('parseNews');

cy.visit(url);

cy.waitForStableDOM();
Expand Down

0 comments on commit bcc8efc

Please sign in to comment.