Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spike for unusual test timeout for fleet #201443

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

eokoneyo
Copy link
Contributor

Summary

  • correct usages of testing library for fleet

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, uses sentence case text and includes i18n support
  • Documentation was added for features that require explanation or tutorials
  • Unit or functional tests 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
  • 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 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

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.

@elasticmachine
Copy link
Contributor

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!

Comment on lines -157 to -159
act(() => {
fireEvent.click(results.getByTestId('standaloneTab'));
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to wrap fireEvent in act

@@ -23,11 +23,8 @@ import type { FlyOutProps } from './types';
import { AgentEnrollmentFlyout } from '.';

const render = (props?: Partial<FlyOutProps>) => {
cleanup();
Copy link
Contributor Author

@eokoneyo eokoneyo Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be cleaning up just before test starts, what's more with jest this is handled automatically for us

Comment on lines -92 to -94
act(() => {
results = render();
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also there's no need to render here, if we still invoke render again in each test suite

@@ -118,7 +118,8 @@ describe('PackagePolicyActionsMenu', () => {
const agentPolicies = createMockAgentPolicies();
const packagePolicy = createMockPackagePolicy({ hasUpgrade: false });
const { utils } = renderMenu({ agentPolicies, packagePolicy });
await act(async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no need to have assertions run within an act function

@@ -129,7 +130,7 @@ describe('PackagePolicyActionsMenu', () => {
const packagePolicy = createMockPackagePolicy({ hasUpgrade: true });
const { utils } = renderMenu({ agentPolicies, packagePolicy });

await act(async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@eokoneyo eokoneyo force-pushed the fix/correct-usages-of-testing-library-for-fleet branch from 1392385 to fde6dad Compare November 22, 2024 17:40
@@ -7,7 +7,7 @@

import React from 'react';

import { act, fireEvent } from '@testing-library/react';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing instances of act wrapped around fireEvent shaved some seconds off the test running time here;

with act

Screenshot 2024-11-22 at 18 35 19 ## with waitFor Screenshot 2024-11-22 at 18 39 20


import { createFleetTestRendererMock } from '../../mock';

import { RootPrivilegesCallout } from './root_privileges_callout';

describe('RootPrivilegesCallout', () => {
function render(rootIntegrations?: Array<{ name: string; title: string }>) {
cleanup();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yields from from removing this:
Screenshot 2024-11-22 at 18 00 07

@eokoneyo eokoneyo self-assigned this Nov 22, 2024
Comment on lines +48 to +50
if (!deleteRowEl) {
throw new Error('Delete row button not found');
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should actually be an assertion

Comment on lines +128 to +130
if (deleteRowButtons.length !== 3) {
throw new Error('Delete row buttons not found');
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be an assertion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants