Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: web e2e improvements #7155

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/specs/auth.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
23 changes: 16 additions & 7 deletions e2e/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
},
};
1 change: 0 additions & 1 deletion web/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/utils/handle-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 1 addition & 7 deletions web/src/routes/auth/change-password/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
</script>

<FullscreenContainer title={data.meta.title}>
Expand All @@ -24,5 +18,5 @@
enter the new password below.
</p>

<ChangePasswordForm user={$user} on:success={onSuccessHandler} />
<ChangePasswordForm user={$user} on:success={() => goto(AppRoute.AUTH_LOGIN)} />
</FullscreenContainer>