Skip to content

[8.x] [scout] adding test helper @kbn/scout-oblt package and uptate onboarding tests (#209761)#211490

Merged
dmlemeshko merged 4 commits intoelastic:8.xfrom
dmlemeshko:backport/8.x/pr-209761
Feb 17, 2025
Merged

[8.x] [scout] adding test helper @kbn/scout-oblt package and uptate onboarding tests (#209761)#211490
dmlemeshko merged 4 commits intoelastic:8.xfrom
dmlemeshko:backport/8.x/pr-209761

Conversation

@dmlemeshko
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 8.x:

Questions ?

Please refer to the Backport tool documentation

\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sqren/backport)\n\n\n\nCo-authored-by: Dzmitry Lemechko "}},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com//pull/209761","number":209761,"mergeCommit":{"message":"[scout] adding test helper `@kbn/scout-oblt` package and uptate onboarding tests (#209761)\n\n## Summary\r\n\r\n`@kbn/scout-oblt` is a test library that extends `@kbn/scout` with test\r\nhelpers specifically designed to test `Observability` applications in\r\nKibana. All Oblt plugins should only import from `@kbn/scout-oblt`\r\n\r\nIts primary goal is to simplify the test development experience for\r\nteams working on `Observability` plugins by providing custom Playwright\r\nfixtures, page objects, and utilities tailored for Observability-related\r\ntesting scenarios.\r\n\r\nContributing:\r\n- when Fixture/Page Object is sharable across all Solutions and Platform\r\n(`fleetApi` fixture), it should be added in `@kbn/scout`\r\n- when Fixture/Page Object is Oblt-specific but is shared across tests\r\nunder the multiple plugins (`OnboardingHome` page), it should be added\r\nin `@kbn/scout-oblt`\r\n- when Fixture/Page Object is only used in a single plugin (`onboarding`\r\ninternal APIs ?), it should be added in this plugin.\r\n\r\nI also re-worked existing tests with few ideas in mind:\r\n- Scout is **e2e testing tool** and should target primary e2e test\r\nscenarios; We have _API integration tests_ to test multiple short\r\nscenarios for APIs behavior (response, status code) and _jest/React\r\ntesting library_ to test components in isolation (elements rendering,\r\nfields validation). Doing all the testing with e2e tool like Playwright\r\nwill dramatically affect cost efficiency and stability of tests, but\r\nalso slows overall CI execution and PRs delivery. The goal is to follow\r\ntesting pyramid and keep in mind its principles.\r\n- We on purpose spin up new browser context for each `test` block to\r\nmake sure our **tests are independent**. Having too many short `test`\r\nblocks in the file significantly slows down the execution: every block\r\ntriggers browser context, saml authentication, adding/removing Fleet\r\nintegrations (each call up to 2 seconds) and other beforeEach/afterEach\r\nhooks. Real browser-based testing is expensive. It is not about putting\r\nevery step into 1 `test` block, but also not a Jest unit-test-style\r\ndesign. When it is possible to group similar actions on the same page\r\nand if it is a part of the same user flow - we should do it. It also\r\ndoesn't bring the testing value repeating the same UI steps multiple\r\ntimes in different scenarios. _Our CI costs are critical to cut when it\r\nis possible_\r\n- Avoid **nesting describe** blocks: it complicates test readability and\r\nalso complicates for CI bot to properly skip the failing block (it will\r\nskip the top level one). We encourage **Scout parallel test execution**\r\nbased on running test spec files in multiple workers, not the `test`\r\nblocks within the same file. Having too many `test` blocks in the same\r\nfile will be slowly run in the single thread and in case of flakiness,\r\nit means Team lose more test coverage than they probably expect.\r\n\r\nBefore (**59** test blocks - **8-8.5 min** per distro):\r\n

\"Screenshot

\r\n\r\nAfter (**15** test blocks - **3.5-4 min** per distro):\r\n

\"Screenshot

\r\n\r\nFor reviewers: updated tests are possible to run in 2 parallel workers\r\nagainst the same Kibana/ES instance and run time is dropping to **2.5-3\r\nmin** 🚀 . It is up to UX-Logs team to decide if you want to keep\r\nparallel run (new tests can be added either to parallel or sequential\r\nrun)\r\n

\"Screenshot

\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"bd13e829498032c07bf8490f770a563f34e9f856"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->

…rding tests (elastic#209761)

## Summary

`@kbn/scout-oblt` is a test library that extends `@kbn/scout` with test
helpers specifically designed to test `Observability` applications in
Kibana. All Oblt plugins should only import from `@kbn/scout-oblt`

Its primary goal is to simplify the test development experience for
teams working on `Observability` plugins by providing custom Playwright
fixtures, page objects, and utilities tailored for Observability-related
testing scenarios.

Contributing:
- when Fixture/Page Object is sharable across all Solutions and Platform
(`fleetApi` fixture), it should be added in `@kbn/scout`
- when Fixture/Page Object is Oblt-specific but is shared across tests
under the multiple plugins (`OnboardingHome` page), it should be added
in `@kbn/scout-oblt`
- when Fixture/Page Object is only used in a single plugin (`onboarding`
internal APIs ?), it should be added in this plugin.

I also re-worked existing tests with few ideas in mind:
- Scout is **e2e testing tool** and should target primary e2e test
scenarios; We have _API integration tests_ to test multiple short
scenarios for APIs behavior (response, status code) and _jest/React
testing library_ to test components in isolation (elements rendering,
fields validation). Doing all the testing with e2e tool like Playwright
will dramatically affect cost efficiency and stability of tests, but
also slows overall CI execution and PRs delivery. The goal is to follow
testing pyramid and keep in mind its principles.
- We on purpose spin up new browser context for each `test` block to
make sure our **tests are independent**. Having too many short `test`
blocks in the file significantly slows down the execution: every block
triggers browser context, saml authentication, adding/removing Fleet
integrations (each call up to 2 seconds) and other beforeEach/afterEach
hooks. Real browser-based testing is expensive. It is not about putting
every step into 1 `test` block, but also not a Jest unit-test-style
design. When it is possible to group similar actions on the same page
and if it is a part of the same user flow - we should do it. It also
doesn't bring the testing value repeating the same UI steps multiple
times in different scenarios. _Our CI costs are critical to cut when it
is possible_
- Avoid **nesting describe** blocks: it complicates test readability and
also complicates for CI bot to properly skip the failing block (it will
skip the top level one). We encourage **Scout parallel test execution**
based on running test spec files in multiple workers, not the `test`
blocks within the same file. Having too many `test` blocks in the same
file will be slowly run in the single thread and in case of flakiness,
it means Team lose more test coverage than they probably expect.

Before (**59** test blocks - **8-8.5 min** per distro):
<img width="1709" alt="Screenshot 2025-02-08 at 18 01 40"
src="https://github.com/user-attachments/assets/5fd65a1c-85f9-4594-9dae-3f8e99a005ab"
/>

After (**15** test blocks - **3.5-4 min** per distro):
<img width="1578" alt="Screenshot 2025-02-10 at 18 14 42"
src="https://github.com/user-attachments/assets/6846898f-7dd2-4f6b-8bc5-d06741b0b120"
/>

For reviewers: updated tests are possible to run in 2 parallel workers
against the same Kibana/ES instance and run time is dropping to **2.5-3
min** 🚀 . It is up to UX-Logs team to decide if you want to keep
parallel run (new tests can be added either to parallel or sequential
run)
<img width="1578" alt="Screenshot 2025-02-11 at 12 14 30"
src="https://github.com/user-attachments/assets/e94113f2-d7f1-470e-a6d5-cb5154d99c41"
/>

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit bd13e82)

# Conflicts:
#	.buildkite/scripts/steps/functional/scout_ui_tests.sh
#	.github/CODEOWNERS
#	x-pack/solutions/observability/plugins/observability_onboarding/ui_tests/tests/custom_logs/install_elastic_agent.spec.ts
@elasticmachine
Copy link
Copy Markdown
Contributor

⏳ Build in-progress, with failures

Failed CI Steps

Test Failures

  • [job] [logs] Scout UI Tests / stateful - Observability Onboarding - Elastic Agent - should ship logs to Elastic

@dmlemeshko dmlemeshko merged commit 9754851 into elastic:8.x Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants