From a24f3805c97f1ed992c24d1efa04ad3d1cf16f06 Mon Sep 17 00:00:00 2001
From: Jason Rasmussen
Date: Fri, 16 Feb 2024 16:31:22 -0500
Subject: [PATCH] chore: web e2e improvements (#7155)
---
e2e/specs/auth.e2e-spec.ts | 2 +-
e2e/test-utils.ts | 23 +++++++++++++------
web/src/lib/constants.ts | 1 -
web/src/lib/utils/handle-error.ts | 2 +-
.../routes/auth/change-password/+page.svelte | 8 +------
5 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/e2e/specs/auth.e2e-spec.ts b/e2e/specs/auth.e2e-spec.ts
index 4c55d67ac1..134e0241d8 100644
--- a/e2e/specs/auth.e2e-spec.ts
+++ b/e2e/specs/auth.e2e-spec.ts
@@ -2,7 +2,7 @@ import { test, expect } from '@playwright/test';
import { app } from '../test-utils';
test.describe('Registration', () => {
- test.beforeAll(async () => {
+ test.beforeEach(async () => {
await app.reset();
});
diff --git a/e2e/test-utils.ts b/e2e/test-utils.ts
index f0d13be816..41ef01a3e7 100644
--- a/e2e/test-utils.ts
+++ b/e2e/test-utils.ts
@@ -63,17 +63,26 @@ export const app = {
return response;
},
reset: async () => {
- if (!connected) {
- await client.connect();
- }
+ try {
+ if (!connected) {
+ await client.connect();
+ connected = true;
+ }
- for (const table of ['users', 'system_metadata']) {
- await client.query(`DELETE FROM ${table} CASCADE;`);
+ for (const table of ['user_token', 'users', 'system_metadata']) {
+ await client.query(`DELETE FROM ${table} CASCADE;`);
+ }
+ } catch (error) {
+ console.error('Failed to reset database', error);
}
},
teardown: async () => {
- if (connected) {
- await client.end();
+ try {
+ if (connected) {
+ await client.end();
+ }
+ } catch (error) {
+ console.error('Failed to teardown database', error);
}
},
};
diff --git a/web/src/lib/constants.ts b/web/src/lib/constants.ts
index 295bd99433..83f6476ba7 100644
--- a/web/src/lib/constants.ts
+++ b/web/src/lib/constants.ts
@@ -35,7 +35,6 @@ export enum AppRoute {
PARTNERS = '/partners',
AUTH_LOGIN = '/auth/login',
- AUTH_LOGOUT = '/auth/logout',
AUTH_REGISTER = '/auth/register',
AUTH_CHANGE_PASSWORD = '/auth/change-password',
AUTH_ONBOARDING = '/auth/onboarding',
diff --git a/web/src/lib/utils/handle-error.ts b/web/src/lib/utils/handle-error.ts
index 8164f716a1..3337dbb475 100644
--- a/web/src/lib/utils/handle-error.ts
+++ b/web/src/lib/utils/handle-error.ts
@@ -20,7 +20,7 @@ export async function handleError(error: unknown, message: string) {
return;
}
- console.error(`[handleError]: ${message}`, error);
+ console.error(`[handleError]: ${message}`, error, (error as Error)?.stack);
let serverMessage = await getServerErrorMessage(error);
if (serverMessage) {
diff --git a/web/src/routes/auth/change-password/+page.svelte b/web/src/routes/auth/change-password/+page.svelte
index 08446c8923..f56169ddb7 100644
--- a/web/src/routes/auth/change-password/+page.svelte
+++ b/web/src/routes/auth/change-password/+page.svelte
@@ -7,12 +7,6 @@
import type { PageData } from './$types';
export let data: PageData;
-
- const onSuccessHandler = async () => {
- await fetch(AppRoute.AUTH_LOGOUT, { method: 'POST' });
-
- goto(AppRoute.AUTH_LOGIN);
- };
@@ -24,5 +18,5 @@
enter the new password below.
-
+ goto(AppRoute.AUTH_LOGIN)} />