mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-02 00:14:23 +00:00
fix: drop the errors endpoint from the Bulwark Lite bundle for real
This commit is contained in:
@@ -1,16 +1,12 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
vi.mock('@/lib/lite', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import('@/lib/lite')>()),
|
||||
IS_LITE: true,
|
||||
}));
|
||||
|
||||
import { captureException, configureErrorReporting, resetErrorReportingForTests } from '../client';
|
||||
|
||||
const DSN = 'https://6f0b9c79ed3a4315b76595bc2536ac40@bugsink.example.org/3';
|
||||
let fetchSpy: ReturnType<typeof vi.fn>;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.stubEnv('NEXT_PUBLIC_BULWARK_LITE', '1');
|
||||
resetErrorReportingForTests();
|
||||
sessionStorage.clear();
|
||||
fetchSpy = vi.fn().mockResolvedValue(new Response(null, { status: 200 }));
|
||||
@@ -18,6 +14,7 @@ beforeEach(() => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs();
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { apiFetch, getPathPrefix } from '@/lib/browser-navigation';
|
||||
import { IS_LITE } from '@/lib/lite';
|
||||
import { scrubRoutePath } from '@/lib/route-groups';
|
||||
import { debugIdsByPath } from './debug-ids';
|
||||
import {
|
||||
@@ -201,9 +200,10 @@ function deliver(report: ErrorReport): void {
|
||||
mode: 'cors',
|
||||
});
|
||||
}
|
||||
// Lite has no server: the bundler drops this branch, and the endpoint
|
||||
// with it (scripts/lite/verify.mjs fails on undocumented /api strings).
|
||||
if (!IS_LITE && settings.collect) {
|
||||
// Lite has no server. Read here, not through IS_LITE: the bundler inlines
|
||||
// the variable only in this module, so the branch and the endpoint string
|
||||
// leave the Lite bundle (scripts/lite/verify.mjs).
|
||||
if (process.env.NEXT_PUBLIC_BULWARK_LITE !== '1' && settings.collect) {
|
||||
send('/api/errors', JSON.stringify({
|
||||
name: report.name,
|
||||
message: report.message,
|
||||
|
||||
Reference in New Issue
Block a user