test: load the preview route once before its cases, so a slow import can't spill into them

This commit is contained in:
Linus Rath
2026-11-04 03:13:59 +01:00
parent 97b3ddefae
commit 149d08d87b
@@ -1,4 +1,4 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { beforeAll, describe, it, expect, vi, beforeEach } from 'vitest';
// The push names only the JMAP account id, and ids repeat: Stalwart numbers
// accounts alike on every install, and a group account is listed in the
@@ -93,6 +93,12 @@ async function callRoute(accountId: string, login?: string) {
const mailCalls = () => fetchJmapServer.mock.calls.filter(([url]) => !url.endsWith('/.well-known/jmap'));
// The route's first import can take longer than a test's limit on a busy machine,
// and a test that times out keeps running into the next one's state.
beforeAll(async () => {
await import('@/app/api/push/preview/route');
}, 60_000);
describe('push preview after the browser was closed', () => {
it('reads the login from the remembered session when the context cookie is gone', async () => {
remembered.value = { serverUrl: 'https://one.example', authHeader: 'Basic remembered', username: 'alice@one.example' };