Skip to content

Commit f3bf285

Browse files
tsullivantkajtochelasticmachine
authored
[Emotion] Use patched Emotion library to resolve Flyout System issue (elastic#256086)
## Summary Closes elastic#255318 ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - ~[ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)~ - ~[ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials~ - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - ~[ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)~ - ~[ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations.~ - ~[ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed~ - ~[ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)~ - ~[ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels.~ ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [x] Added a `resolution` field for `@emotion/sheet` to use an [Elastic fork](https://github.com/elastic/emotion) ([see diff](emotion-js/emotion@main...elastic:emotion:main)). We trust any issue this may add can be caught by functional tests, especially the new one added. --------- Co-authored-by: Tomasz Kajtoch <tomasz.kajtoch@elastic.co> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent 0cb9239 commit f3bf285

13 files changed

Lines changed: 212 additions & 68 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
},
8080
"resolutions": {
8181
"**/@babel/parser": "7.24.7",
82+
"**/@emotion/sheet": "npm:@elastic/emotion-sheet@1.4.1",
8283
"**/@hello-pangea/dnd": "18.0.1",
8384
"**/@langchain/core": "0.3.80",
8485
"**/@langchain/google-common": "0.2.18",

src/core/packages/chrome/browser-components/src/classic/__snapshots__/collapsible_nav.test.tsx.snap

Lines changed: 2 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/platform/packages/shared/kbn-scout/src/playwright/page_objects/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { createLazyPageObject } from './utils';
2323
import { Inspector } from './inspector';
2424
import { LensApp } from './lens_app';
2525
import { LoginPage } from './login_page';
26+
import { OverlaysPage } from './overlays';
2627
import type { KibanaUrl } from '../../common/services/kibana_url';
2728

2829
export interface PageObjectsFixtures {
@@ -45,6 +46,7 @@ export interface PageObjects {
4546
inspector: Inspector;
4647
lens: LensApp;
4748
login: LoginPage;
49+
overlays: OverlaysPage;
4850
}
4951

5052
/**
@@ -67,6 +69,6 @@ export function createCorePageObjects(fixtures: PageObjectsFixtures): PageObject
6769
inspector: createLazyPageObject(Inspector, fixtures.page),
6870
lens: createLazyPageObject(LensApp, fixtures.page),
6971
login: createLazyPageObject(LoginPage, fixtures.page, fixtures.kbnUrl),
70-
// Add new page objects here
72+
overlays: createLazyPageObject(OverlaysPage, fixtures.page),
7173
};
7274
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
import type { ScoutPage } from '..';
11+
import { expect } from '..';
12+
13+
export class OverlaysPage {
14+
constructor(private readonly page: ScoutPage) {}
15+
16+
public get docViewerFlyout() {
17+
return this.page.testSubj.locator('docViewerFlyout');
18+
}
19+
20+
public get newsfeedButton() {
21+
return this.page.testSubj.locator('newsfeed');
22+
}
23+
24+
public get newsfeedFlyout() {
25+
return this.page.testSubj.locator('NewsfeedFlyout');
26+
}
27+
28+
public get newsfeedFlyoutCloseButton() {
29+
return this.page.testSubj
30+
.locator('NewsfeedFlyout')
31+
.locator('[data-test-subj="euiFlyoutCloseButton"]');
32+
}
33+
34+
public async openNewsfeedFlyout() {
35+
await this.newsfeedButton.click();
36+
await expect(this.newsfeedFlyout).toBeVisible();
37+
}
38+
39+
public async closeNewsfeedFlyout() {
40+
await this.newsfeedFlyoutCloseButton.click();
41+
await expect(this.newsfeedFlyout).toBeHidden();
42+
}
43+
}

src/platform/plugins/shared/chart_expressions/expression_legacy_metric/public/components/__snapshots__/with_auto_scale.test.tsx.snap

Lines changed: 1 addition & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
export const LOGSTASH = {
11+
DEFAULT_START_TIME: 'Sep 19, 2015 @ 06:31:44.000',
12+
DEFAULT_END_TIME: 'Sep 23, 2015 @ 18:31:44.000',
13+
DATA_VIEW_NAME: 'logstash-*',
14+
KBN_ARCHIVE:
15+
'src/platform/plugins/shared/discover/test/scout/ui/fixtures/flyout_stability/kbn_archives/logstash_data_view.json',
16+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
export { LOGSTASH } from './constants';
11+
export { setupFlyoutStability, teardownFlyoutStability } from './setup';
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"attributes": {
3+
"name": "logstash-*",
4+
"timeFieldName": "@timestamp",
5+
"title": "logstash-*"
6+
},
7+
"coreMigrationVersion": "8.8.0",
8+
"created_at": "2025-01-01T00:00:00.000Z",
9+
"id": "logstash-data-view",
10+
"managed": false,
11+
"references": [],
12+
"type": "index-pattern",
13+
"typeMigrationVersion": "7.11.0",
14+
"updated_at": "2025-01-01T00:00:00.000Z"
15+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
import type { ScoutParallelWorkerFixtures } from '@kbn/scout';
11+
import { LOGSTASH } from './constants';
12+
13+
export async function setupFlyoutStability(scoutSpace: ScoutParallelWorkerFixtures['scoutSpace']) {
14+
await scoutSpace.savedObjects.load(LOGSTASH.KBN_ARCHIVE);
15+
await scoutSpace.uiSettings.setDefaultIndex(LOGSTASH.DATA_VIEW_NAME);
16+
await scoutSpace.uiSettings.setDefaultTime({
17+
from: LOGSTASH.DEFAULT_START_TIME,
18+
to: LOGSTASH.DEFAULT_END_TIME,
19+
});
20+
}
21+
22+
export async function teardownFlyoutStability(
23+
scoutSpace: ScoutParallelWorkerFixtures['scoutSpace']
24+
) {
25+
await scoutSpace.uiSettings.unset('defaultIndex', 'timepicker:timeDefaults');
26+
await scoutSpace.savedObjects.cleanStandardList();
27+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
import { tags, spaceTest } from '@kbn/scout';
11+
import { expect } from '@kbn/scout/ui';
12+
import { setupFlyoutStability, teardownFlyoutStability } from '../../fixtures/flyout_stability';
13+
14+
spaceTest.describe('Flyout system Emotion cache stability', { tag: tags.stateful.classic }, () => {
15+
spaceTest.beforeAll(async ({ scoutSpace }) => {
16+
await setupFlyoutStability(scoutSpace);
17+
});
18+
19+
spaceTest.beforeEach(async ({ browserAuth, pageObjects }) => {
20+
await browserAuth.loginAsViewer();
21+
await pageObjects.discover.goto();
22+
});
23+
24+
spaceTest.afterAll(async ({ scoutSpace }) => {
25+
await teardownFlyoutStability(scoutSpace);
26+
});
27+
28+
spaceTest(
29+
'opening a flyout after a cascade close does not corrupt the Emotion style cache',
30+
async ({ page, pageObjects }) => {
31+
const consoleErrors: string[] = [];
32+
page.on('console', (msg) => {
33+
if (msg.type() === 'error') {
34+
consoleErrors.push(msg.text());
35+
}
36+
});
37+
38+
await spaceTest.step('open a document flyout', async () => {
39+
await pageObjects.discover.waitUntilSearchingHasFinished();
40+
await pageObjects.discover.openDocumentDetails({ rowIndex: 0 });
41+
await expect(pageObjects.overlays.docViewerFlyout).toBeVisible();
42+
});
43+
44+
await spaceTest.step('open a second flyout from a different domain', async () => {
45+
await pageObjects.overlays.openNewsfeedFlyout();
46+
});
47+
48+
await spaceTest.step('close the second flyout, triggering a cascade close', async () => {
49+
await pageObjects.overlays.closeNewsfeedFlyout();
50+
await expect(pageObjects.overlays.docViewerFlyout).toBeHidden();
51+
});
52+
53+
await spaceTest.step('open a new flyout after the cascade close', async () => {
54+
await pageObjects.discover.openDocumentDetails({ rowIndex: 0 });
55+
await expect(pageObjects.overlays.docViewerFlyout).toBeVisible();
56+
});
57+
58+
await spaceTest.step(
59+
'verify no insertBefore errors from stale Emotion cache refs',
60+
async () => {
61+
await expect(page.testSubj.locator('discoverDocumentsTable')).toBeVisible();
62+
63+
const hasInsertBeforeError = consoleErrors.some((msg) => msg.includes('insertBefore'));
64+
expect(hasInsertBeforeError).toBe(false);
65+
}
66+
);
67+
}
68+
);
69+
});

0 commit comments

Comments
 (0)