Skip to content

Commit 0061fcb

Browse files
[9.2] [Fleet] fix flaky UI test (#241146) (#241272)
# Backport This will backport the following commits from `main` to `9.2`: - [[Fleet] fix flaky UI test (#241146)](#241146) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Julia Bardi","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-10-30T11:45:47Z","message":"[Fleet] fix flaky UI test (#241146)\n\n## Summary\n\nCloses https://github.com/elastic/kibana/issues/237961\n\nSometimes the UI test finds the prerelease callout rendered twice.\nI couldn't figure out what is causing this, but it seems to help to\nremove the unnecessary renders by merging many testcases to one, where\nwe are just asserting different things on the same component.\nAlso changed to use `getAllByTestId` in case the button is rendered\ntwice to be on the safe side.\nTested locally by running the test a few hundred times.\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n- [ ] This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [ ] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"436b0bce6642bcb3beec215b5cec900edea00472","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","backport:version","v9.3.0","v9.2.1"],"title":"[Fleet] fix flaky UI test","number":241146,"url":"https://github.com/elastic/kibana/pull/241146","mergeCommit":{"message":"[Fleet] fix flaky UI test (#241146)\n\n## Summary\n\nCloses https://github.com/elastic/kibana/issues/237961\n\nSometimes the UI test finds the prerelease callout rendered twice.\nI couldn't figure out what is causing this, but it seems to help to\nremove the unnecessary renders by merging many testcases to one, where\nwe are just asserting different things on the same component.\nAlso changed to use `getAllByTestId` in case the button is rendered\ntwice to be on the safe side.\nTested locally by running the test a few hundred times.\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n- [ ] This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [ ] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"436b0bce6642bcb3beec215b5cec900edea00472"}},"sourceBranch":"main","suggestedTargetBranches":["9.2"],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/241146","number":241146,"mergeCommit":{"message":"[Fleet] fix flaky UI test (#241146)\n\n## Summary\n\nCloses https://github.com/elastic/kibana/issues/237961\n\nSometimes the UI test finds the prerelease callout rendered twice.\nI couldn't figure out what is causing this, but it seems to help to\nremove the unnecessary renders by merging many testcases to one, where\nwe are just asserting different things on the same component.\nAlso changed to use `getAllByTestId` in case the button is rendered\ntwice to be on the safe side.\nTested locally by running the test a few hundred times.\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [ ] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n- [ ] This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.\n- [ ] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [ ] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"436b0bce6642bcb3beec215b5cec900edea00472"}},{"branch":"9.2","label":"v9.2.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Julia Bardi <[email protected]>
1 parent 2c17eea commit 0061fcb

File tree

1 file changed

+15
-12
lines changed
  • x-pack/platform/plugins/shared/fleet/public/applications/integrations/sections/epm/screens/detail

1 file changed

+15
-12
lines changed

x-pack/platform/plugins/shared/fleet/public/applications/integrations/sections/epm/screens/detail/index.test.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ const TESTS_TIMEOUT = 8000;
4242
// @ts-ignore this saves us having to define all experimental features
4343
ExperimentalFeaturesService.init({});
4444

45-
// Failing: See https://github.com/elastic/kibana/issues/237961
46-
describe.skip('When on integration detail', () => {
45+
describe('When on integration detail', () => {
4746
const pkgkey = 'nginx-0.3.7';
4847
const detailPageUrlPath = pagePathGetters.integration_details_overview({ pkgkey })[1];
4948
let testRenderer: TestRenderer;
@@ -61,9 +60,10 @@ describe.skip('When on integration detail', () => {
6160
};
6261

6362
beforeEach(async () => {
63+
jest.clearAllMocks();
6464
testRenderer = createIntegrationsTestRendererMock();
6565
mockedApi = mockApiCalls(testRenderer.startServices.http);
66-
await act(() => testRenderer.mountHistory.push(detailPageUrlPath));
66+
act(() => testRenderer.mountHistory.push(detailPageUrlPath));
6767
});
6868

6969
describe('and the package is installed', () => {
@@ -114,24 +114,17 @@ describe.skip('When on integration detail', () => {
114114
await act(() => mockedApi.waitForApi());
115115
}, TESTS_TIMEOUT);
116116

117-
it('should NOT display policy usage count', async () => {
117+
it('should display expected version and prerelease elements', async () => {
118118
expect(renderResult.queryByTestId('policyCount')).toBeNull();
119-
});
120-
121-
it('should NOT display the Policies tab', async () => {
122119
expect(renderResult.queryByTestId('tab-policies')).toBeNull();
123-
});
124120

125-
it('should display version select if prerelease setting enabled and prererelase version available', async () => {
126121
const versionSelect = renderResult.queryByTestId('versionSelect');
127122
expect(versionSelect?.textContent).toEqual('1.0.0-beta1.0.0');
128123
expect((versionSelect as any)?.value).toEqual('1.0.0-beta');
129-
});
130124

131-
it('should display prerelease callout if prerelease setting enabled and prerelease version available', async () => {
132125
const calloutTitle = renderResult.getByTestId('prereleaseCallout');
133126
expect(calloutTitle).toBeInTheDocument();
134-
const calloutGABtn = renderResult.getByTestId('switchToGABtn');
127+
const calloutGABtn = renderResult.getAllByTestId('switchToGABtn')[0];
135128
expect((calloutGABtn as any)?.href).toEqual(
136129
'http://localhost/mock/app/integrations/detail/nginx-1.0.0/overview'
137130
);
@@ -935,6 +928,16 @@ On Windows, the module was tested with Nginx installed from the Chocolatey repos
935928
if (path === '/api/fleet/epm/verification_key_id') {
936929
return mockedApiInterface.responseProvider.getVerificationKeyId();
937930
}
931+
if (path === '/api/fleet/space_settings') {
932+
return Promise.resolve({
933+
item: {
934+
allowed_namespace_prefixes: [],
935+
},
936+
});
937+
}
938+
if (path.endsWith('/changelog.yml')) {
939+
return Promise.resolve();
940+
}
938941

939942
const err = new Error(`API [GET ${path}] is not MOCKED!`);
940943
// eslint-disable-next-line no-console

0 commit comments

Comments
 (0)