Skip to content

Commit

Permalink
Fix/unskip playwright tests 2.0 (#3287)
Browse files Browse the repository at this point in the history
* Delete duplicated test

* Unskip Opens an archive link

* Remove skip from image error test to ensure it runs in the test suite

* Add logs in function to test cookies

* Reduce to 5 seconds for timeout

* Add error logging in response interceptor for better debugging

* Enhance axios instance configuration with timeout and improved error handling for redirects

* Add logging for fetching HTML with cookies and error handling

* Improve error logging in getHtmlWithCookies function for better debugging and response handling

* Reduce axios timeout to 5 seconds and add logging for URL fetching

* Restore parseNews to staging version
  • Loading branch information
clari182 authored Dec 23, 2024
1 parent 8494f26 commit 4874084
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 96 deletions.
3 changes: 1 addition & 2 deletions site/gatsby-site/playwright/e2e-full/cite.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,7 @@ test.describe('Cite pages', () => {
await expect(page.locator('[data-cy="timeline-text-response"]')).not.toBeVisible();
});

// the incident contains reports missing images so it will never pass
test.skip('There should not be image errors (400)', async ({ page }) => {
test('There should not be image errors (400)', async ({ page }) => {
page.on('console', (msg) => {
if (msg.type() === 'error') {
expect(msg.text()).not.toContain('the server responded with a status of 400');
Expand Down
93 changes: 0 additions & 93 deletions site/gatsby-site/playwright/e2e-full/submit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,99 +625,6 @@ test.describe('The Submit form', () => {
}
);

test.skip('Should show a preliminary checks message', async ({ page }) => {
const relatedReports = {
byURL: {
data: {
reports: [],
},
},
byDatePublished: {
data: {
reports: [],
},
},
byAuthors: {
data: { reports: [] },
},
byIncidentId: {
data: {
incidents: [],
},
},
};

await conditionalIntercept(
page,
'**/graphql',
(req) =>
req.postDataJSON().operationName == 'ProbablyRelatedReports' &&
req.postDataJSON().variables.query?.url_in?.[0] ==
'https://www.cnn.com/2021/11/02/homes/zillow-exit-ibuying-home-business/index.html',
relatedReports.byURL,
'RelatedReportsByURL'
);

await conditionalIntercept(
page,
'**/graphql',
(req) =>
req.postDataJSON().operationName == 'ProbablyRelatedReports' &&
req.postDataJSON().variables.query?.epoch_date_published_gt == 1608346800 &&
req.postDataJSON().variables.query?.epoch_date_published_lt == 1610766000,
relatedReports.byDatePublished,
'RelatedReportsByPublishedDate'
);

await conditionalIntercept(
page,
'**/graphql',
(req) =>
req.postDataJSON().operationName == 'ProbablyRelatedReports' &&
req.postDataJSON().variables.query?.authors_in?.[0] == 'test author',
relatedReports.byAuthors,
'RelatedReportsByAuthor'
);

await conditionalIntercept(
page,
'**/graphql',
(req) => req.postDataJSON().operationName == 'FindSubmissions',
{ data: { submissions: [] } },
'findSubmissions'
);

await page.goto(url);

await waitForRequest('findSubmissions');

const values = {
url: 'https://www.cnn.com/2021/11/02/homes/zillow-exit-ibuying-home-business/index.html',
authors: 'test author',
date_published: '2021-01-02',
incident_ids: '1',
};

for (const key in values) {
if (key == 'incident_ids') {
await page.locator(`input[name="${key}"]`).fill(values[key]);
await page.waitForSelector(`[role="option"]`);
await page.locator(`[role="option"]`).first().click();
} else {
await page.locator(`input[name="${key}"]`).fill(values[key]);
}
}


await waitForRequest('RelatedReportsByAuthor')
await waitForRequest('RelatedReportsByURL')
await waitForRequest('RelatedReportsByPublishedDate')

await expect(page.locator('[data-cy="no-related-reports"]').first()).toBeVisible();

await expect(page.locator('[data-cy="result"]')).not.toBeVisible();
});

test('Should *not* show semantically related reports when the text is under 256 non-space characters', async ({ page }) => {

await page.goto(url);
Expand Down
4 changes: 3 additions & 1 deletion site/gatsby-site/playwright/e2e/discover.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ test.describe('The Discover app', () => {
await expect(modal).not.toBeVisible();
});

test.skip('Opens an archive link', async ({ page, skipOnEmptyEnvironment }) => {
test('Opens an archive link', async ({ page, skipOnEmptyEnvironment }) => {

test.slow();

await page.goto(url);

Expand Down

0 comments on commit 4874084

Please sign in to comment.