Skip to content

Commit 05eb745

Browse files
committed
Tests: Revert to conditionally mocking credentials
1 parent 1bd2869 commit 05eb745

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

tests/src/coveo.spec.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { expect, test } from '@playwright/test';
2-
import { COVEO_CREDENTIALS_ENDPOINT } from './constants';
32
import { mockCoveoCredentials, mockCoveoData } from './mock';
43
import {
54
buildURLFragment,
@@ -19,14 +18,20 @@ async function submitSearchQuery(page, query) {
1918

2019
test.describe('Coveo test', () => {
2120
test.beforeEach(async ({ page, request }) => {
21+
// Setup to start on landing page
2222
await page.goto('/');
2323
await page.waitForLoadState('load');
2424
await waitFor(async () => await handleConsentPopup(page));
25-
await mockCoveoCredentials(page, request);
25+
26+
// Conditionally mock credentials
27+
const excludedTests = ['missing coveo credentials'];
28+
if (!excludedTests.includes(test.info().title)) {
29+
await mockCoveoCredentials(page, request);
30+
}
2631
});
2732

2833
test.afterEach(async ({ page }) => {
29-
// Run basic smoke tests on all valid queries
34+
// Conditionally run a smoke test only on valid queries
3035
const excludedTests = ['invalid search query', 'missing coveo credentials'];
3136
if (!excludedTests.includes(test.info().title)) {
3237
await runSmokeTestCoveo(page);
@@ -62,14 +67,6 @@ test.describe('Coveo test', () => {
6267

6368
test('missing coveo credentials', async ({ page }) => {
6469
const searchEndpoint = 'search.html';
65-
await page.unroute(`**/${COVEO_CREDENTIALS_ENDPOINT}`);
66-
await page.evaluate(() => window.localStorage.clear());
67-
await page.route(`**/${COVEO_CREDENTIALS_ENDPOINT}`, async (route) => {
68-
await route.fulfill({
69-
status: 404,
70-
contentType: 'text/html; charset=utf-8',
71-
});
72-
});
7370
await page.goto(`/${searchEndpoint}`);
7471

7572
const coveoErrorContent = page.getByTestId('coveo-error-content');

0 commit comments

Comments
 (0)