Skip to content

Commit

Permalink
test: Fix issues with playwright tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kiosion committed Feb 9, 2024
1 parent 24648e8 commit 7fa50d6
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.
3 changes: 2 additions & 1 deletion svelte-app/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@
"*.spec.ts"
],
"rules": {
"@typescript-eslint/no-empty-function": ["off"]
"@typescript-eslint/no-empty-function": ["off"],
"no-restricted-imports": ["off"]
}
}
],
Expand Down
24 changes: 12 additions & 12 deletions svelte-app/src/routes/+layout.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { DEFAULT_APP_LANG } from '$lib/consts';
import { handleLoadError } from '$lib/data';
import { ENV } from '$lib/env';
import Logger from '$lib/logger';
import { findOne } from '$lib/store';

import { error } from '@sveltejs/kit';

import type { LayoutLoad } from './$types';
import type { SiteConfig } from '$types';

Expand All @@ -12,17 +13,16 @@ export const trailingSlash = 'ignore';
export const ssr = ENV !== 'testing';

export const load = (async ({ params, url, fetch }) => {
const config = handleLoadError(
await findOne(fetch, 'config', {
lang: params.lang || DEFAULT_APP_LANG
}).catch((e: Error) => {
Logger.error('Failed to load layout data:', e);
throw new Error('Sorry, something went wrong during load.', {
cause: e?.cause,
stack: e?.stack
});
})
) satisfies SiteConfig;
const config = (await findOne(fetch, 'config', {
lang: params.lang || DEFAULT_APP_LANG
}).catch((e: Error) => {
Logger.error('Failed to load layout data:', e);
throw error(500, {
message: 'Sorry, something went wrong during load.',
cause: e?.cause,
stack: e?.stack
});
})) as SiteConfig;

return {
pathname: url.pathname,
Expand Down
6 changes: 3 additions & 3 deletions svelte-app/tests/routes/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { STUB_CONFIG, STUB_POST } from '$tests/fixtures';
import { stubResponse } from '$tests/utils';

import { expect, test } from '@playwright/test';

import { STUB_CONFIG, STUB_POST } from '../fixtures';
import { stubResponse } from '../utils';

const API_CONFIG_ROUTE = /.*\/api\/get\/config.*/,
API_POST_ROUTE = /.*\/api\/get\/post.*/,
API_POST_MANY_ROUTE = /.*\/api\/get\/post\/many.*/;
Expand Down
6 changes: 3 additions & 3 deletions svelte-app/tests/routes/post.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { STUB_CONFIG, STUB_POST } from '$tests/fixtures';
import { API_CONFIG_ROUTE, API_POST_ROUTE, stubResponse } from '$tests/utils';

import { expect, test } from '@playwright/test';

import { STUB_CONFIG, STUB_POST } from '../fixtures';
import { API_CONFIG_ROUTE, API_POST_ROUTE, stubResponse } from '../utils';

test.beforeEach(async ({ context }) => {
await context.route(API_CONFIG_ROUTE, (route) =>
route.fulfill(stubResponse({ data: STUB_CONFIG }))
Expand Down
8 changes: 4 additions & 4 deletions svelte-app/tests/routes/work.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { STUB_CONFIG, STUB_PROJECT } from '$tests/fixtures';
import { expect, test } from '@playwright/test';

import { STUB_CONFIG, STUB_PROJECT } from '../fixtures';
import {
API_CONFIG_ROUTE,
API_PROJECT_MANY_ROUTE,
API_PROJECT_ROUTE,
stubResponse
} from '$tests/utils';

import { expect, test } from '@playwright/test';
} from '../utils';

test.beforeEach(async ({ context }) => {
await context.route(API_CONFIG_ROUTE, (route) =>
Expand Down

0 comments on commit 7fa50d6

Please sign in to comment.