11import { expect , test } from '@playwright/test' ;
2- import { COVEO_CREDENTIALS_ENDPOINT } from './constants' ;
32import { mockCoveoCredentials , mockCoveoData } from './mock' ;
43import {
54 buildURLFragment ,
@@ -19,14 +18,20 @@ async function submitSearchQuery(page, query) {
1918
2019test . 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