-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Cloud Security] 10973 migrate flaky e2e tests to jest #208345
Conversation
89b295b
to
25177ad
Compare
Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security) |
💔 Build Failed
Failed CI StepsHistory
|
Pinging @elastic/fleet (Team:Fleet) |
remove flaky test cases related to vulnerabilities empty states
…ve the correct URL flaky test case
…file add retry.try wrapper to assertion in when adding CIS_AWS with manual assume role
2edd63d
to
c1c07e2
Compare
|
||
it('Vulnerabilities - `Add Wiz integration`: should have link element to CNVM integration installation page', async () => { | ||
await waitFor(() => | ||
expect(screen.getByText(/Already using a\s+cloud security product?/i)).toBeInTheDocument() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexreal1314 checking the exact text makes the test quite brittle. Every change to the wording would mean a failing test. Ideally, we should adda test id for every selector we use in the tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maxcold agree, I'll convert it to test id in the next PR that should fix some more flaky tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maxcold I see your point about avoiding brittle tests due to wording changes, and I agree that test IDs can provide a stable way to locate elements. However, I believe there’s value in also asserting visible text, especially for key user-facing elements.
Relying solely on test IDs can make tests less reflective of the real user experience since test IDs are not part of what the user actually interacts with. By checking for meaningful text in assertions (like in this case with getByText), we ensure that the UI presents the correct messaging, which is a crucial part of user expectations.
A balanced approach could be to use test IDs for structural assertions (e.g., ensuring an element exists or checking attributes like href), while still verifying key text content where appropriate. In this case, the assertion for the message ensures that users see the correct prompt, while the button's testId allows for stable selection.
What do you think about maintaining a mix of both approaches based on what’s being tested rather than applying test IDs universally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@opauloh I think tests should avoid testing implementation details. For me the litmus test of a good test is when I change the implementation and the test is still green if the business logic didn't change. In the case of the wording, you will be updating test with every wording change. Another way to check if it makes sense is to push it to the absurd level: imagine we test for every visible text in Kibana, does it make sense to you? I believe it will make tests maintenance unbearable.
Plus you don't test for what's really important when it comes to texts anyway. Does it have typos? Does it provide outdated information that is not relevant anymore? etc.
Maybe in the future with the help of AI we will be testing texts in the way it makes sense, eg. screen.prompt('check that text promoting connecting existing 3p product integration is present ')
But we are not there yet :)
* 2.0. | ||
*/ | ||
|
||
export const testSubjectIds = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice initiative concentrating the test subject ids!
|
||
it('Vulnerabilities - `Add Wiz integration`: should have link element to CNVM integration installation page', async () => { | ||
await waitFor(() => | ||
expect(screen.getByText(/Already using a\s+cloud security product?/i)).toBeInTheDocument() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maxcold I see your point about avoiding brittle tests due to wording changes, and I agree that test IDs can provide a stable way to locate elements. However, I believe there’s value in also asserting visible text, especially for key user-facing elements.
Relying solely on test IDs can make tests less reflective of the real user experience since test IDs are not part of what the user actually interacts with. By checking for meaningful text in assertions (like in this case with getByText), we ensure that the UI presents the correct messaging, which is a crucial part of user expectations.
A balanced approach could be to use test IDs for structural assertions (e.g., ensuring an element exists or checking attributes like href), while still verifying key text content where appropriate. In this case, the assertion for the message ensures that users see the correct prompt, while the button's testId allows for stable selection.
What do you think about maintaining a mix of both approaches based on what’s being tested rather than applying test IDs universally?
…210746) # Backport This will backport the following commits from `main` to `8.x`: - #208345) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)
Friendly reminder: Looks like this PR hasn’t been backported yet. |
13 similar comments
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Summary
This PR tries to fix the following issues - which are flaky FTR tests:
No integrations installed
prompt action button -install CNVM
: navigates to the CNVM integration installation page #197143 - convert to unit testThere will be an RFC document which is going to be released to help us better understand and decide which tests are more suitable to make as E2E tests and which as unit tests.
Checklist
Closes
this PR closes the above mentioned issues in relation for this ticket - https://github.com/elastic/security-team/issues/10973