Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🥾 test: Wait for Palette Completion and Stable Quote Geometry

Lia37df3c1146a7
diff --git a/e2e/specs/mock/quotes.spec.ts b/e2e/specs/mock/quotes.spec.ts
index 480b46e2a0..620895cd28 100644
--- a/e2e/specs/mock/quotes.spec.ts
+++ b/e2e/specs/mock/quotes.spec.ts
@@ -465,16 +465,19 @@ test.describe('quote references', () => {
// A short viewport guarantees the reply overflows and can actually scroll.
await page.setViewportSize({ width: 900, height: 500 });
await seedParagraphReply(page);
+ await expect(page.getByRole('button', { name: 'Stop generating' })).toBeHidden();
+ await waitForReplyToSettle(page, CLOSING_PARAGRAPH);
+ let beforeY = 0;
await expect(async () => {
await scrollSelectionTo(page, OPENING_PARAGRAPH, 0.75);
await selectMessageText(page, OPENING_PARAGRAPH);
await expect(addToChat(page)).toBeVisible({ timeout: 3000 });
+ const before = await addToChat(page).boundingBox();
+ expect(before).not.toBeNull();
+ beforeY = before!.y;
}).toPass({ timeout: 30000 });
- const before = await addToChat(page).boundingBox();
- expect(before).not.toBeNull();
-
// Scrolling used to dismiss the popup on the first event, which the chat's
// own auto-scroll fires constantly while streaming. It now follows instead.
const moved = await scrollSelectionTo(page, OPENING_PARAGRAPH, 0.25);
@@ -484,7 +487,7 @@ test.describe('quote references', () => {
await expect(async () => {
const after = await addToChat(page).boundingBox();
expect(after).not.toBeNull();
- expect(Math.abs(after!.y - before!.y)).toBeGreaterThan(Math.abs(moved) / 2);
+ expect(Math.abs(after!.y - beforeY)).toBeGreaterThan(Math.abs(moved) / 2);
}).toPass({ timeout: 5000 });
// Still the right excerpt after travelling with the text.
diff --git a/packages/client/src/components/PixelCard.spec.tsx b/packages/client/src/components/PixelCard.spec.tsx
index f47698feea..7ad66ea52a 100644
--- a/packages/client/src/components/PixelCard.spec.tsx
+++ b/packages/client/src/components/PixelCard.spec.tsx
@@ -1,4 +1,4 @@
-import { render, waitFor } from '@testing-library/react';
+import { render, cleanup, waitFor } from '@testing-library/react';
import PixelCard from './PixelCard';
/** The canvas draws with whatever the palette resolved to, so the test reads what the card
@@ -39,6 +39,7 @@ describe('PixelCard palette', () => {
});
afterEach(() => {
+ cleanup();
jest.restoreAllMocks();
document.documentElement.className = '';
});
@@ -55,10 +56,13 @@ describe('PixelCard palette', () => {
jest
.spyOn(HTMLElement.prototype, 'getBoundingClientRect')
.mockReturnValue({ width: 200, height: 200 } as DOMRect);
+ let sample = 0;
+ jest.spyOn(Math, 'random').mockImplementation(() => ((sample++ % 3) + 0.5) / 3);
render(<PixelCard progress={1} />);
- await waitFor(() => expect(fillStyles.length).toBeGreaterThan(0));
- expect(new Set(fillStyles)).toEqual(new Set(['rgb(1 1 1)', 'rgb(2 2 2)', 'currentColor']));
+ await waitFor(() =>
+ expect(new Set(fillStyles)).toEqual(new Set(['rgb(1 1 1)', 'rgb(2 2 2)', 'currentColor'])),
+ );
});
it('keeps an explicit colors prop as given', async () => {