Skip to content

Commit 2261c1e

Browse files
committed
Handle query params suddenly being on graphql requests
1 parent 47d4c8e commit 2261c1e

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

frontend/tests/errorHandling.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ test('client-side gql 500 does not break the application', async ({ page }) => {
6161
await loginAs(page.request, 'admin');
6262
await new SandboxPage(page).goto();
6363
// Create promise first before triggering the action
64-
const responsePromise = page.waitForResponse('/api/graphql');
64+
const responsePromise = page.waitForResponse(/\/api\/graphql/);
6565
await page.getByText('GQL 500').click();
6666
await responsePromise.catch(() => { });// Ignore the error
6767
await expect(page.locator(':text-matches("Unexpected Execution Error", "g")').first()).toBeVisible();
@@ -95,7 +95,7 @@ test('client page load 401 is redirected to login', async ({ page }) => {
9595
// Now mess up the login cookie and watch the redirect
9696

9797
await page.context().addCookies([{name: testEnv.authCookieName, value: testEnv.invalidJwt, url: testEnv.serverBaseUrl}]);
98-
const responsePromise = page.waitForResponse('/api/graphql');
98+
const responsePromise = page.waitForResponse(/\/api\/graphql/);
9999
await adminDashboardPage.clickProject('Sena 3');
100100
const graphqlResponse = await responsePromise;
101101
expect(graphqlResponse.status()).toBe(401);
@@ -162,7 +162,7 @@ test('page load 403 on home page is redirected to login', async ({ page, tempUse
162162
// (3) Update cookie with the reset-password JWT and try to go home
163163
await page.context().addCookies([{name: testEnv.authCookieName, value: forgotPasswordJwt, url: testEnv.serverBaseUrl}]);
164164

165-
const responsePromise = page.waitForResponse('/api/graphql');
165+
const responsePromise = page.waitForResponse(/\/api\/graphql/);
166166
await userAccountPage.clickHome();
167167
const response = await responsePromise;
168168
expect(response.status()).toBe(403);

frontend/tests/fixtures.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function addUnexpectedResponseListener(context: BrowserContext): void {
8888
if (response.request().isNavigationRequest()) {
8989
if (status >= 400) expect.soft(status, unexpectedResponseMessage).toBeLessThan(400);
9090
}
91-
if (url.endsWith('/api/graphql') && response.ok()) { // response.ok() filters out redirects, which don't have a response body
91+
if (url.includes('/api/graphql') && response.ok()) { // response.ok() filters out redirects, which don't have a response body
9292
const result = await response.json() as GqlResult;
9393
expect.soft(result.errors?.[0]?.message).not.toBe('Unexpected Execution Error');
9494
}

0 commit comments

Comments
 (0)