Explicitly test for console warnings & errors (#6502)

# Description of Changes
Disallow warnings and errors from being thrown in the browser console
during tests unless explicitly expected in the test. Also adds a
Playwright test to prod around some main UI areas and checks that no
warnings/errors have been thrown.
This commit is contained in:
James Brunton
2026-06-09 08:34:02 +00:00
committed by GitHub
parent 002de06411
commit 0e3cbb3cf2
28 changed files with 544 additions and 213 deletions
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from "react";
import React, { useEffect, useMemo, useState } from "react";
import { Modal, Button, Text, Alert, Loader, Stack } from "@mantine/core";
import { useTranslation } from "react-i18next";
import { loadStripe } from "@stripe/stripe-js";
@@ -9,7 +9,7 @@ import {
import { supabase } from "@app/auth/supabase";
import { Z_INDEX_OVER_SETTINGS_MODAL } from "@app/styles/zIndex";
const stripePromise = loadStripe(import.meta.env.VITE_STRIPE_PUBLISHABLE_KEY);
const STRIPE_KEY = import.meta.env.VITE_STRIPE_PUBLISHABLE_KEY;
export type PurchaseType = "subscription" | "credits";
export type CreditsPack = "xsmall" | "small" | "medium" | "large" | null;
@@ -68,6 +68,11 @@ const StripeCheckout: React.FC<StripeCheckoutProps> = ({
}) => {
const { t } = useTranslation();
const [state, setState] = useState<CheckoutState>({ status: "idle" });
// Load Stripe.js lazily, only when this checkout component mounts. Loading
// at module scope pulled the Stripe script into every page that imports
// this file, which triggered the dev "HTTPS required" warning on every
// non-payment route.
const stripePromise = useMemo(() => loadStripe(STRIPE_KEY), []);
const createCheckoutSession = async () => {
try {
@@ -1,6 +1,7 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import type { Session, AuthError } from "@supabase/supabase-js";
import { supabase } from "@app/auth/supabase";
import { expectConsole } from "@app/tests/failOnConsole";
// Mock supabase
vi.mock("@app/auth/supabase", () => ({
@@ -177,6 +178,7 @@ describe("apiClient", () => {
});
it("should handle refresh token failure", async () => {
expectConsole.error(/\[API Client\] Token refresh failed/);
const oldToken = "old-token";
const oldSession = {
+3
View File
@@ -1,5 +1,8 @@
import "@testing-library/jest-dom";
import { vi } from "vitest";
import { installFailOnConsole } from "@app/tests/failOnConsole";
installFailOnConsole();
// Mock localStorage for tests
const localStorageMock = (() => {