fix(chat): make Home pass react-hooks lint after the split
eslint-plugin-react-hooks now analyzes the smaller Home, so render-time ref writes and sync effect setState were failing the staging gate. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { createElement, createRef } from "react";
|
||||
import { renderToString } from "react-dom/server";
|
||||
import test from "node:test";
|
||||
@@ -11,10 +12,9 @@ import {
|
||||
test("a closed account overlay does not render profile or logout content", () => {
|
||||
const overlayRef = createRef<HTMLElement | null>() as AccountOverlayModel["overlayRef"];
|
||||
const closeButtonRef = createRef<HTMLButtonElement | null>() as AccountOverlayModel["closeButtonRef"];
|
||||
const modelRef = createRef<AccountOverlayModel | null>() as { current: AccountOverlayModel | null };
|
||||
let profileRenders = 0;
|
||||
let logoutRenders = 0;
|
||||
modelRef.current = {
|
||||
const model: AccountOverlayModel = {
|
||||
title: "个人资料",
|
||||
dialogClass: "profile-modal",
|
||||
signingOut: false,
|
||||
@@ -42,11 +42,22 @@ test("a closed account overlay does not render profile or logout content", () =>
|
||||
const html = renderToString(createElement(AccountDialogOverlay, {
|
||||
open: false,
|
||||
dialog: null,
|
||||
openEpoch: 0,
|
||||
modelRef,
|
||||
model,
|
||||
}));
|
||||
|
||||
assert.equal(html, "");
|
||||
assert.equal(profileRenders, 0);
|
||||
assert.equal(logoutRenders, 0);
|
||||
});
|
||||
|
||||
test("home does not write overlay epoch or chat actions during render", () => {
|
||||
const page = readFileSync(new URL("../src/app/page.tsx", import.meta.url), "utf8");
|
||||
const overlay = readFileSync(new URL("../src/components/account-dialog-overlay.tsx", import.meta.url), "utf8");
|
||||
assert.match(overlay, /model: AccountOverlayModel \| null/);
|
||||
assert.doesNotMatch(overlay, /openEpoch/);
|
||||
assert.doesNotMatch(overlay, /modelRef/);
|
||||
assert.doesNotMatch(page, /accountOverlayEpochRef/);
|
||||
assert.doesNotMatch(page, /sessionsRef\.current = sessions/);
|
||||
assert.match(page, /queueMicrotask\(\(\) => setActiveChartId\(storedChartId\)\)/);
|
||||
assert.match(page, /useEffect\(\(\) => \{\s*chatActionsRef\.current = \{/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user