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

[Cases] Fix flaky tests in the CaseViewPage component #172940

Merged
merged 21 commits into from
Jan 15, 2024

Conversation

cnasikas
Copy link
Member

@cnasikas cnasikas commented Dec 8, 2023

Summary

Tests:

  • renders tabs correctly: Moved to functional testing
  • renders the activity tab by default: Removed. It is being tested in functional testing
  • renders the activity tab when the query parameter tabId has activity: Moved to functional testing
  • renders the activity tab when the query parameter tabId has an unknown value: Moved to functional testing
  • navigates to the activity tab when the activity tab is clicked: Moved to functional testing
  • should show closed indicators in header when case is closed: Moved to x-pack/plugins/cases/public/components/case_action_bar/index.test.tsx
  • should push updates on button click: Moved to x-pack/plugins/cases/public/components/edit_connector/index.test.tsx
  • should disable the push button when connector is invalid: Moved to x-pack/plugins/cases/public/components/edit_connector/index.test.tsx
  • should show the rule name: Already tested in x-pack/plugins/cases/public/components/user_actions/comment/alert_event.test.tsx
  • should show the correct connector name on the push button: Moved to x-pack/plugins/cases/public/components/edit_connector/index.test.tsx
  • Callouts: Already tested in x-pack/plugins/cases/public/components/use_push_to_service/index.test.tsx
  • should display the alerts tab when the feature is enabled: Moved to x-pack/plugins/cases/public/components/case_view/case_view_tabs.test.tsx
  • should not display the alerts tab when the feature is disabled: Moved to x-pack/plugins/cases/public/components/case_view/case_view_tabs.test.tsx
  • should not show the experimental badge on the alerts table: Moved to x-pack/plugins/cases/public/components/case_view/case_view_tabs.test.tsx
  • should show the experimental badge on the alerts table: Moved to x-pack/plugins/cases/public/components/case_view/case_view_tabs.test.tsx
  • renders the alerts tab when the query parameter tabId has alerts: Unskip functional test
  • navigates to the alerts tab when the alerts tab is clicked: Removed. It is being tested in functional testing
  • shows the connectors in the sidebar: Removed. It is being tested in functional testing
  • shows the case action bar: Removed. It is being tested in functional testing
  • should show loading content when loading user actions stats: Removed. Already tested in x-pack/plugins/cases/public/components/case_view/components/case_view_activity.test.tsx
  • should call show alert details with expected arguments: Removed. Already tested in x-pack/plugins/cases/public/components/user_actions/comment/comment.test.tsx
  • should show the case tabs: Moved to functional testing
  • should display description when case is loading: Moved to x-pack/plugins/cases/public/components/description/index.test.tsx
  • renders the description correctly: Removed. Already tested in x-pack/plugins/cases/public/components/description/index.test.tsx
  • should update settings: Removed. Already tested in x-pack/plugins/cases/public/components/case_action_bar/index.test.tsx

Fixes: #149778, #149777, #149776, #170532, #171718, #149771, #173136

Flaky test runner: https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4862

Successful builds: https://buildkite.com/elastic/kibana-pull-request/builds?branch=cnasikas%3Afix_149777

Checklist

Delete any items that are not applicable to this PR.

For maintainers

describe('description', () => {
it('renders the description correctly', async () => {
appMockRenderer.render(<CaseViewPage {...caseProps} />);
describe('description', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved outside the Tabs block.

}
return CASE_VIEW_PAGE_TABS.ACTIVITY;
}, [urlParams.tabId]);
const activeTabId = getActiveTabId(urlParams?.tabId);
Copy link
Member Author

@cnasikas cnasikas Dec 8, 2023

Choose a reason for hiding this comment

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

When I removed some tests the other tests started failing. There was an issue with mocking and memorization that affected the tests. I removed the useMemo as it is redundant.

@cnasikas cnasikas marked this pull request as ready for review December 8, 2023 13:53
@cnasikas cnasikas requested a review from a team as a code owner December 8, 2023 13:53
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops-cases (Feature:Cases)

@cnasikas cnasikas added the release_note:skip Skip the PR/issue when compiling release notes label Dec 8, 2023
it('renders tabs correctly', async () => {
await testSubjects.existOrFail('case-view-tab-title-activity');
await testSubjects.existOrFail('case-view-tab-title-files');
// there are no alerts in stack management yet
Copy link
Member Author

Choose a reason for hiding this comment

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

When this PR #172217 is merged we can test the alerts table in the stack.

@cnasikas
Copy link
Member Author

cnasikas commented Dec 8, 2023

buildkite test this

@@ -191,273 +200,218 @@ describe('CaseViewPage', () => {
Object.defineProperty(window, 'getComputedStyle', originalGetComputedStyle);
});

it('shows the metrics section', async () => {
appMockRenderer.render(<CaseViewPage {...caseProps} />);
for (let index = 0; index < 50; index++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't forget to remove this

it('shows the "activity" tab by default', async () => {
await testSubjects.existOrFail('case-view-tab-title-activity');
await testSubjects.existOrFail('case-view-tab-content-activity');
});

it("shows the 'activity' tab when clicked", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this test make sense here following the previous one?

We are already in the activity tab, I don't know how relevant it is to check that nothing changes when we click it.

Maybe we could go to files and back instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. Much better.

@cnasikas
Copy link
Member Author

@elasticmachine merge upstream

@cnasikas
Copy link
Member Author

@elasticmachine merge upstream

@cnasikas
Copy link
Member Author

@elasticmachine merge upstream

@cnasikas
Copy link
Member Author

/ci

1 similar comment
@cnasikas
Copy link
Member Author

/ci

@cnasikas
Copy link
Member Author

@elasticmachine merge upstream

@cnasikas cnasikas removed the v8.12.0 label Jan 10, 2024
@cnasikas
Copy link
Member Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
cases 445.1KB 445.1KB +6.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
cases 58 57 -1

Total ESLint disabled count

id before after diff
cases 74 73 -1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @cnasikas

@cnasikas cnasikas merged commit 5b8c212 into elastic:main Jan 15, 2024
21 checks passed
@cnasikas cnasikas deleted the fix_149777 branch January 15, 2024 12:56
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment