Skip to content

Commit 569cfcc

Browse files
cauemarcondesclaudecursoragent
authored
[Discover][Metrics] Fix flaky fullscreen interaction Scout test (elastic#270775)
## Summary Fixes the flaky `fullscreen.spec.ts` Scout test ("should interact with metrics in fullscreen mode"). **Two failure modes were identified:** 1. **Chrome header interception** (~65 failures, Apr 3–18): Already fixed by PR elastic#264932 which added `chromeHeader.waitFor({ state: 'hidden' })` to `toggleFullscreen()`. No recurrence since. 2. **`viewDetails` action not found** (2 failures, May 20): After `clearSearch()`, the grid re-renders with the full unfiltered metric set. The test immediately opened the context menu without waiting for the grid to settle — the Lens embeddable hadn't finished re-mounting and registering its actions. **Fix:** Add `await expect(metricsExperience.pagination.container).toBeVisible()` after `clearSearch()` to wait for the grid to finish re-rendering before opening the context menu. This matches the pattern used in `grid.navigation.spec.ts`. Closes elastic#261199 ## Test plan - [ ] Run `node scripts/scout run-tests --arch stateful --domain classic --testFiles src/platform/plugins/shared/discover/test/scout/ui/parallel_tests/metrics_experience/fullscreen.spec.ts` locally - [ ] Verify CI passes on stateful and serverless targets 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 974c42a commit 569cfcc

3 files changed

Lines changed: 43 additions & 9 deletions

File tree

src/dev/run_check.test.ts

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ jest.mock('@kbn/test', () => ({
6666
jest.mock('fs', () => ({
6767
...jest.requireActual('fs'),
6868
existsSync: jest.fn(),
69+
readdirSync: jest.fn(),
6970
}));
7071

7172
const mockExecaFn = jest.fn();
@@ -81,6 +82,7 @@ const mockExecuteTypeCheckValidation = jest.requireMock('./type_check_validation
8182
const mockExecuteEslintValidation = jest.requireMock('./eslint/run_eslint_contract')
8283
.executeEslintValidation as jest.Mock;
8384
const mockExistsSync = jest.requireMock('fs').existsSync as jest.Mock;
85+
const mockReaddirSync = jest.requireMock('fs').readdirSync as jest.Mock;
8486
const mockExeca = mockExecaFn;
8587

8688
let handler: (args: {
@@ -148,6 +150,7 @@ describe('run_check', () => {
148150
(p: string) =>
149151
p === '/repo/packages/foo/jest.config.js' || p === '/repo/packages/bar/jest.config.js'
150152
);
153+
mockReaddirSync.mockReturnValue([]);
151154
mockExecuteEslintValidation.mockResolvedValue({
152155
fileCount: 3,
153156
fixedFiles: [],
@@ -289,10 +292,35 @@ describe('run_check', () => {
289292
},
290293
});
291294

292-
mockExistsSync.mockImplementation(
293-
(p: string) =>
294-
p ===
295-
'/repo/x-pack/platform/plugins/shared/saved_objects_tagging/test/scout/api/playwright.config.ts'
295+
mockExistsSync.mockReturnValue(false);
296+
mockReaddirSync.mockImplementation((dir: string) =>
297+
dir === '/repo/x-pack/platform/plugins/shared/saved_objects_tagging/test/scout/api'
298+
? ['playwright.config.ts']
299+
: []
300+
);
301+
302+
await handler(createArgs());
303+
304+
expect(mockExeca).not.toHaveBeenCalled();
305+
expect(mockRunJestViaMoon).toHaveBeenCalled();
306+
});
307+
308+
it('skips fast path for Scout test files with parallel playwright config', async () => {
309+
mockResolveValidationBaseContext.mockResolvedValue({
310+
...baseContext,
311+
runContext: {
312+
...baseContext.runContext,
313+
changedFiles: [
314+
'src/platform/plugins/shared/discover/test/scout/ui/parallel_tests/metrics_experience/fullscreen.spec.ts',
315+
],
316+
},
317+
});
318+
319+
mockExistsSync.mockReturnValue(false);
320+
mockReaddirSync.mockImplementation((dir: string) =>
321+
dir === '/repo/src/platform/plugins/shared/discover/test/scout/ui'
322+
? ['parallel.playwright.config.ts']
323+
: []
296324
);
297325

298326
await handler(createArgs());

src/dev/run_check.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
import { existsSync } from 'fs';
10+
import { existsSync, readdirSync } from 'fs';
11+
12+
const dirHasPlaywrightConfig = (dir: string): boolean => {
13+
try {
14+
return readdirSync(dir).some((f) => f.endsWith('playwright.config.ts'));
15+
} catch {
16+
return false;
17+
}
18+
};
1119
import Path from 'path';
1220

1321
import { run } from '@kbn/dev-cli-runner';
@@ -142,10 +150,7 @@ const isTestFile = (filePath: string) => TEST_FILE_RE.test(filePath);
142150
const findJestUnitConfig = (filePath: string): string | undefined => {
143151
let dir = Path.dirname(Path.resolve(REPO_ROOT, filePath));
144152
while (true) {
145-
if (
146-
existsSync(Path.join(dir, 'jest.integration.config.js')) ||
147-
existsSync(Path.join(dir, 'playwright.config.ts'))
148-
) {
153+
if (existsSync(Path.join(dir, 'jest.integration.config.js')) || dirHasPlaywrightConfig(dir)) {
149154
return undefined;
150155
}
151156
for (const configName of JEST_CONFIG_NAMES) {

src/platform/plugins/shared/discover/test/scout/ui/parallel_tests/metrics_experience/fullscreen.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ spaceTest.describe(
115115

116116
await spaceTest.step('open context menu in fullscreen', async () => {
117117
await metricsExperience.clearSearch();
118+
await expect(metricsExperience.pagination.container).toBeVisible();
118119
await metricsExperience.openCardContextMenu(0);
119120
await expect(metricsExperience.chartActions.viewDetails).toBeVisible();
120121
});

0 commit comments

Comments
 (0)