Skip to content

Commit 2a39067

Browse files
committed
test: consolidate overflow helper, trim brittle assertions and route matrix
- lift expectNoPageOverflow into cypress/support/e2e.ts (was pasted in 4 specs, plus a weaker non-retrying inline variant in 2 more) - drop track-vs-refetch call-order assertion (implementation detail) - optimizations route matrix visits 2 representative projects instead of all 8; template is shared and vllm/sglang keep dedicated deep tests
1 parent bc510d3 commit 2a39067

8 files changed

Lines changed: 30 additions & 59 deletions

File tree

‎packages/app/cypress/e2e/agentx-dataset-click-path.cy.ts‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { unlockAgenticGate } from '../support/e2e';
1+
import { expectNoPageOverflow, unlockAgenticGate } from '../support/e2e';
22

33
const SLUG = 'click-path-dataset';
44
const CONVERSATION_ID = 'click-path-conversation-0001';
@@ -87,15 +87,6 @@ function stubDatasetJourney(): void {
8787
});
8888
}
8989

90-
function expectNoPageOverflow(): void {
91-
cy.window().should((win) => {
92-
expect(win.document.body.scrollWidth, 'body scroll width').to.be.at.most(win.innerWidth);
93-
expect(win.document.documentElement.scrollWidth, 'document scroll width').to.be.at.most(
94-
win.innerWidth,
95-
);
96-
});
97-
}
98-
9990
function runClickJourney(prefix: '' | '/zh'): void {
10091
stubDatasetJourney();
10192
cy.visit(`${prefix}/agentx`, { onBeforeLoad: unlockAgenticGate });

‎packages/app/cypress/e2e/agentx-optimizations.cy.ts‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { unlockAgenticGate } from '../support/e2e';
1+
import { expectNoPageOverflow, unlockAgenticGate } from '../support/e2e';
22

33
const FRAMEWORK_SLUGS = [
44
'vllm',
@@ -27,15 +27,6 @@ const ROUTE_VIEWPORTS = [
2727
{ width: 390, height: 844 },
2828
] as const;
2929

30-
function expectNoPageOverflow(): void {
31-
cy.window().should((win) => {
32-
expect(win.document.body.scrollWidth, 'body scroll width').to.be.at.most(win.innerWidth);
33-
expect(win.document.documentElement.scrollWidth, 'document scroll width').to.be.at.most(
34-
win.innerWidth,
35-
);
36-
});
37-
}
38-
3930
describe('AgentX optimizations', () => {
4031
beforeEach(() => {
4132
cy.intercept('GET', '/api/v1/datasets', { statusCode: 200, body: [] });
@@ -116,7 +107,11 @@ describe('AgentX optimizations', () => {
116107
});
117108
});
118109

119-
it('renders the index and every project at 1440px and 390px in both locales', () => {
110+
it('renders the index and representative projects at 1440px and 390px in both locales', () => {
111+
// Project pages share one template and differ only in typechecked data, so
112+
// the route matrix visits two representatives (one with a hyphenated slug)
113+
// instead of all eight; the tests above deep-cover vllm (en) and sglang (zh).
114+
const matrixSlugs = ['tensorrt-llm', 'mooncake'] as const;
120115
for (const viewport of ROUTE_VIEWPORTS) {
121116
for (const locale of ['', '/zh']) {
122117
cy.viewport(viewport.width, viewport.height);
@@ -133,7 +128,7 @@ describe('AgentX optimizations', () => {
133128
);
134129
expectNoPageOverflow();
135130

136-
for (const slug of FRAMEWORK_SLUGS) {
131+
for (const slug of matrixSlugs) {
137132
cy.visit(`${locale}/agentx/optimizations/${slug}`, {
138133
onBeforeLoad: unlockAgenticGate,
139134
});

‎packages/app/cypress/e2e/agentx-telemetry.cy.ts‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { keepTelemetryTutorial, unlockAgenticGate } from '../support/e2e';
1+
import { expectNoPageOverflow, keepTelemetryTutorial, unlockAgenticGate } from '../support/e2e';
22

33
// This spec owns the telemetry-tutorial card's storage, so it opts out of the
44
// global suppression seeded in support/e2e.ts (which also re-seeds on reload).
@@ -26,15 +26,6 @@ const ROUTE_VIEWPORTS = [
2626
{ width: 375, height: 812 },
2727
] as const;
2828

29-
function expectNoPageOverflow(): void {
30-
cy.window().should((win) => {
31-
expect(win.document.body.scrollWidth, 'body scroll width').to.be.at.most(win.innerWidth);
32-
expect(win.document.documentElement.scrollWidth, 'document scroll width').to.be.at.most(
33-
win.innerWidth,
34-
);
35-
});
36-
}
37-
3829
describe('AgentX telemetry tutorial — English page', () => {
3930
beforeEach(() => {
4031
cy.visit('/agentx/telemetry');

‎packages/app/cypress/e2e/datasets-distributions.cy.ts‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { unlockAgenticGate } from '../support/e2e';
1+
import { expectNoPageOverflow, unlockAgenticGate } from '../support/e2e';
22

33
const distribution = (values: {
44
median: number;
@@ -179,9 +179,7 @@ describe('Dataset distribution percentiles', () => {
179179
expect(getComputedStyle(element).overflowX).to.eq('auto');
180180
expect(element.scrollWidth).to.be.greaterThan(element.clientWidth);
181181
});
182-
cy.window().then((win) => {
183-
expect(win.document.documentElement.scrollWidth).to.be.at.most(win.innerWidth);
184-
});
182+
expectNoPageOverflow();
185183
});
186184
});
187185

@@ -235,9 +233,7 @@ describe('Dataset detail loading stability', () => {
235233
cy.contains('[data-testid="dataset-detail-error"] button', '重试').click();
236234
cy.wait('@datasetRetryRequest').its('response.statusCode').should('eq', 200);
237235
cy.contains('h1', 'Layout dataset').should('be.visible');
238-
cy.window().then((win) => {
239-
expect(win.document.documentElement.scrollWidth).to.be.at.most(win.innerWidth);
240-
});
236+
expectNoPageOverflow();
241237
});
242238

243239
it('reserves the not-found state for a successful 404 response', () => {

‎packages/app/cypress/e2e/datasets-flamegraph-time.cy.ts‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { unlockAgenticGate } from '../support/e2e';
1+
import { expectNoPageOverflow, unlockAgenticGate } from '../support/e2e';
22

33
const EMPTY_CONVERSATION = {
44
conv_id: 'retry-conversation',
@@ -193,9 +193,7 @@ describe('Dataset conversation flamegraph timing', () => {
193193
expect(getComputedStyle(element).overflowX).to.eq('auto');
194194
expect(element.scrollWidth).to.be.greaterThan(element.clientWidth);
195195
});
196-
cy.window().then((win) => {
197-
expect(win.document.documentElement.scrollWidth).to.be.at.most(win.innerWidth);
198-
});
196+
expectNoPageOverflow();
199197
});
200198
});
201199

@@ -235,9 +233,7 @@ describe('Dataset conversation request states', () => {
235233
cy.contains('[data-testid="conversation-view-error"] button', '重试').click();
236234
cy.wait('@conversationRetryRequest').its('response.statusCode').should('eq', 200);
237235
cy.contains('h1', 'retry-conversation').should('be.visible');
238-
cy.window().then((win) => {
239-
expect(win.document.documentElement.scrollWidth).to.be.at.most(win.innerWidth);
240-
});
236+
expectNoPageOverflow();
241237
});
242238

243239
it('reserves the not-found state for a successful 404 response', () => {

‎packages/app/cypress/e2e/datasets-methodology.cy.ts‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { unlockAgenticGate } from '../support/e2e';
1+
import { expectNoPageOverflow, unlockAgenticGate } from '../support/e2e';
22

33
const DATASET = {
44
id: 'agentx-v1-full',
@@ -26,15 +26,6 @@ const ROUTE_VIEWPORTS = [
2626
{ width: 375, height: 812 },
2727
] as const;
2828

29-
function expectNoPageOverflow(): void {
30-
cy.window().should((win) => {
31-
expect(win.document.body.scrollWidth, 'body scroll width').to.be.at.most(win.innerWidth);
32-
expect(win.document.documentElement.scrollWidth, 'document scroll width').to.be.at.most(
33-
win.innerWidth,
34-
);
35-
});
36-
}
37-
3829
describe('AgentX dataset methodology', () => {
3930
beforeEach(() => {
4031
cy.intercept('GET', '/api/v1/datasets', { statusCode: 200, body: [DATASET] });

‎packages/app/cypress/support/e2e.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,17 @@ export function interceptDerivedAgenticMetrics(): void {
104104
});
105105
}).as('derivedAgenticMetrics');
106106
}
107+
108+
/**
109+
* Assert the page has no horizontal overflow at the current viewport — wide
110+
* content (tables, flamegraphs) must scroll inside its own container, never
111+
* the page body. Call after the route under test has rendered.
112+
*/
113+
export function expectNoPageOverflow(): void {
114+
cy.window().should((win) => {
115+
expect(win.document.body.scrollWidth, 'body scroll width').to.be.at.most(win.innerWidth);
116+
expect(win.document.documentElement.scrollWidth, 'document scroll width').to.be.at.most(
117+
win.innerWidth,
118+
);
119+
});
120+
}

‎packages/app/src/components/datasets/conversation-view.test.tsx‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ describe('ConversationView request states', () => {
6969
act(() => retry?.click());
7070
expect(track).toHaveBeenCalledWith('datasets_conversation_retry_clicked', { slug: 'trace' });
7171
expect(testState.conversation.refetch).toHaveBeenCalledOnce();
72-
expect(vi.mocked(track).mock.invocationCallOrder[0]).toBeLessThan(
73-
testState.conversation.refetch.mock.invocationCallOrder[0]!,
74-
);
7572

7673
act(() => root.unmount());
7774
});

0 commit comments

Comments
 (0)