# Backport
This will backport the following commits from `main` to `8.9`:
- [[FTR] Implement browser network condition utils
(#163633)](https://github.com/elastic/kibana/pull/163633)
<!--- Backport version: 8.9.7 -->
### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)
<!--BACKPORT [{"author":{"name":"Marco Antonio
Ghiani","email":"marcoantonio.ghiani01@gmail.com"},"sourceCommit":{"committedDate":"2023-08-11T12:24:06Z","message":"[FTR]
Implement browser network condition utils (#163633)\n\n## 📓
Summary\r\n\r\nThe PR implements some utilities into the `browser`
service to allow\r\ncontrolling the network conditions during the
execution of a functional\r\ntest.\r\n\r\n###
`getNetworkConditions`\r\n\r\nReturns the current network simulation
options. If none conditions are\r\npreviously set, it returns
`undefined`\r\n\r\n**N.B.**: _if the testing environment is not a
Chromium browser, it\r\nthrows an error that can be easily caught to
manually skip the test or\r\nhandle a fallback
scenario._\r\n\r\n\r\n```ts\r\nit('should display a loading skeleton
while loading', async function () {\r\n // Skip the test in case network
condition utils are not available\r\n try {\r\n const networkConditions
= await browser.getNetworkConditions(); // undefined\r\n\r\n await
browser.setNetworkConditions('SLOW_3G');\r\n\r\n const networkConditions
= await browser.getNetworkConditions();\r\n // {\r\n // offline:
false,\r\n // latency: 2000,\r\n // download_throughput: 50000,\r\n //
upload_throughput: 50000,\r\n // }\r\n } catch (error) {\r\n
this.skip();\r\n }\r\n});\r\n```\r\n\r\n###
`setNetworkConditions`\r\n\r\nSet the desired network conditions.\r\nIt
supports different presets that match the [network profiles
provided\r\nby
Chrome\r\ndebugger](da276a3fae/front_end/core/sdk/NetworkManager.ts (L363-L393)):\r\n-
`NO_THROTTLING`\r\n- `FAST_3G`\r\n- `SLOW_3G`\r\n- `OFFLINE`\r\n-
`CLOUD_USER` (pre-existing)\r\nIt also accepts ad-hoc options to
configure more specifically the\r\nnetwork conditions.\r\n\r\n**N.B.**:
_if the testing environment is not a Chromium browser, it\r\nthrows an
error that can be easily caught to manually skip the test or\r\nhandle a
fallback scenario._\r\n\r\n```ts\r\nit('should display a loading
skeleton while loading', async function () {\r\n // Skip the test in
case network condition utils are not available\r\n try {\r\n await
browser.setNetworkConditions('NO_THROTTLING');\r\n await
browser.setNetworkConditions('FAST_3G');\r\n await
browser.setNetworkConditions('SLOW_3G');\r\n await
browser.setNetworkConditions('OFFLINE');\r\n await
browser.setNetworkConditions('CLOUD_USER');\r\n await
browser.setNetworkConditions({\r\n offline: false,\r\n latency: 5, //
Additional latency (ms).\r\n download_throughput: 500 * 1024, // Maximal
aggregated download throughput.\r\n upload_throughput: 500 * 1024, //
Maximal aggregated upload throughput.\r\n });\r\n } catch (error) {\r\n
this.skip();\r\n }\r\n});\r\n```\r\n\r\n###
restoreNetworkConditions\r\n\r\nRestore the original network conditions,
setting to `NO_THROTTLING`.\r\nThe native implementation of
`deleteNetworkConditions` exposed by\r\nselenium is unofficial and
didn't consistently work, the recommended\r\napproach by the google dev
tools team is to restore the connection\r\nsetting the no throttling
profile.\r\n\r\n**N.B.**: _if the testing environment is not a Chromium
browser, it\r\nthrows an error that can be easily caught to manually
skip the test or\r\nhandle a fallback
scenario._\r\n\r\n```ts\r\nit('should display a loading skeleton while
loading', async function () {\r\n // Skip the test in case network
condition utils are not available\r\n try {\r\n await
browser.setNetworkConditions('SLOW_3G'); // Slow down network
conditions\r\n \r\n // Do your assertions\r\n\r\n await
browser.restoreNetworkConditions(); // Restore network conditions\r\n }
catch (error) {\r\n this.skip();\r\n
}\r\n});\r\n```\r\n\r\nCo-authored-by: Marco Antonio Ghiani
<marcoantonio.ghiani@elastic.co>\r\nCo-authored-by: Dzmitry Lemechko
<dzmitry.lemechko@elastic.co>","sha":"aa45152a4e787f36014675b864fcc0fce7bd6758","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v8.10.0","v7.17.13","v8.9.2"],"number":163633,"url":"https://github.com/elastic/kibana/pull/163633","mergeCommit":{"message":"[FTR]
Implement browser network condition utils (#163633)\n\n## 📓
Summary\r\n\r\nThe PR implements some utilities into the `browser`
service to allow\r\ncontrolling the network conditions during the
execution of a functional\r\ntest.\r\n\r\n###
`getNetworkConditions`\r\n\r\nReturns the current network simulation
options. If none conditions are\r\npreviously set, it returns
`undefined`\r\n\r\n**N.B.**: _if the testing environment is not a
Chromium browser, it\r\nthrows an error that can be easily caught to
manually skip the test or\r\nhandle a fallback
scenario._\r\n\r\n\r\n```ts\r\nit('should display a loading skeleton
while loading', async function () {\r\n // Skip the test in case network
condition utils are not available\r\n try {\r\n const networkConditions
= await browser.getNetworkConditions(); // undefined\r\n\r\n await
browser.setNetworkConditions('SLOW_3G');\r\n\r\n const networkConditions
= await browser.getNetworkConditions();\r\n // {\r\n // offline:
false,\r\n // latency: 2000,\r\n // download_throughput: 50000,\r\n //
upload_throughput: 50000,\r\n // }\r\n } catch (error) {\r\n
this.skip();\r\n }\r\n});\r\n```\r\n\r\n###
`setNetworkConditions`\r\n\r\nSet the desired network conditions.\r\nIt
supports different presets that match the [network profiles
provided\r\nby
Chrome\r\ndebugger](da276a3fae/front_end/core/sdk/NetworkManager.ts (L363-L393)):\r\n-
`NO_THROTTLING`\r\n- `FAST_3G`\r\n- `SLOW_3G`\r\n- `OFFLINE`\r\n-
`CLOUD_USER` (pre-existing)\r\nIt also accepts ad-hoc options to
configure more specifically the\r\nnetwork conditions.\r\n\r\n**N.B.**:
_if the testing environment is not a Chromium browser, it\r\nthrows an
error that can be easily caught to manually skip the test or\r\nhandle a
fallback scenario._\r\n\r\n```ts\r\nit('should display a loading
skeleton while loading', async function () {\r\n // Skip the test in
case network condition utils are not available\r\n try {\r\n await
browser.setNetworkConditions('NO_THROTTLING');\r\n await
browser.setNetworkConditions('FAST_3G');\r\n await
browser.setNetworkConditions('SLOW_3G');\r\n await
browser.setNetworkConditions('OFFLINE');\r\n await
browser.setNetworkConditions('CLOUD_USER');\r\n await
browser.setNetworkConditions({\r\n offline: false,\r\n latency: 5, //
Additional latency (ms).\r\n download_throughput: 500 * 1024, // Maximal
aggregated download throughput.\r\n upload_throughput: 500 * 1024, //
Maximal aggregated upload throughput.\r\n });\r\n } catch (error) {\r\n
this.skip();\r\n }\r\n});\r\n```\r\n\r\n###
restoreNetworkConditions\r\n\r\nRestore the original network conditions,
setting to `NO_THROTTLING`.\r\nThe native implementation of
`deleteNetworkConditions` exposed by\r\nselenium is unofficial and
didn't consistently work, the recommended\r\napproach by the google dev
tools team is to restore the connection\r\nsetting the no throttling
profile.\r\n\r\n**N.B.**: _if the testing environment is not a Chromium
browser, it\r\nthrows an error that can be easily caught to manually
skip the test or\r\nhandle a fallback
scenario._\r\n\r\n```ts\r\nit('should display a loading skeleton while
loading', async function () {\r\n // Skip the test in case network
condition utils are not available\r\n try {\r\n await
browser.setNetworkConditions('SLOW_3G'); // Slow down network
conditions\r\n \r\n // Do your assertions\r\n\r\n await
browser.restoreNetworkConditions(); // Restore network conditions\r\n }
catch (error) {\r\n this.skip();\r\n
}\r\n});\r\n```\r\n\r\nCo-authored-by: Marco Antonio Ghiani
<marcoantonio.ghiani@elastic.co>\r\nCo-authored-by: Dzmitry Lemechko
<dzmitry.lemechko@elastic.co>","sha":"aa45152a4e787f36014675b864fcc0fce7bd6758"}},"sourceBranch":"main","suggestedTargetBranches":["7.17","8.9"],"targetPullRequestStates":[{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/163633","number":163633,"mergeCommit":{"message":"[FTR]
Implement browser network condition utils (#163633)\n\n## 📓
Summary\r\n\r\nThe PR implements some utilities into the `browser`
service to allow\r\ncontrolling the network conditions during the
execution of a functional\r\ntest.\r\n\r\n###
`getNetworkConditions`\r\n\r\nReturns the current network simulation
options. If none conditions are\r\npreviously set, it returns
`undefined`\r\n\r\n**N.B.**: _if the testing environment is not a
Chromium browser, it\r\nthrows an error that can be easily caught to
manually skip the test or\r\nhandle a fallback
scenario._\r\n\r\n\r\n```ts\r\nit('should display a loading skeleton
while loading', async function () {\r\n // Skip the test in case network
condition utils are not available\r\n try {\r\n const networkConditions
= await browser.getNetworkConditions(); // undefined\r\n\r\n await
browser.setNetworkConditions('SLOW_3G');\r\n\r\n const networkConditions
= await browser.getNetworkConditions();\r\n // {\r\n // offline:
false,\r\n // latency: 2000,\r\n // download_throughput: 50000,\r\n //
upload_throughput: 50000,\r\n // }\r\n } catch (error) {\r\n
this.skip();\r\n }\r\n});\r\n```\r\n\r\n###
`setNetworkConditions`\r\n\r\nSet the desired network conditions.\r\nIt
supports different presets that match the [network profiles
provided\r\nby
Chrome\r\ndebugger](da276a3fae/front_end/core/sdk/NetworkManager.ts (L363-L393)):\r\n-
`NO_THROTTLING`\r\n- `FAST_3G`\r\n- `SLOW_3G`\r\n- `OFFLINE`\r\n-
`CLOUD_USER` (pre-existing)\r\nIt also accepts ad-hoc options to
configure more specifically the\r\nnetwork conditions.\r\n\r\n**N.B.**:
_if the testing environment is not a Chromium browser, it\r\nthrows an
error that can be easily caught to manually skip the test or\r\nhandle a
fallback scenario._\r\n\r\n```ts\r\nit('should display a loading
skeleton while loading', async function () {\r\n // Skip the test in
case network condition utils are not available\r\n try {\r\n await
browser.setNetworkConditions('NO_THROTTLING');\r\n await
browser.setNetworkConditions('FAST_3G');\r\n await
browser.setNetworkConditions('SLOW_3G');\r\n await
browser.setNetworkConditions('OFFLINE');\r\n await
browser.setNetworkConditions('CLOUD_USER');\r\n await
browser.setNetworkConditions({\r\n offline: false,\r\n latency: 5, //
Additional latency (ms).\r\n download_throughput: 500 * 1024, // Maximal
aggregated download throughput.\r\n upload_throughput: 500 * 1024, //
Maximal aggregated upload throughput.\r\n });\r\n } catch (error) {\r\n
this.skip();\r\n }\r\n});\r\n```\r\n\r\n###
restoreNetworkConditions\r\n\r\nRestore the original network conditions,
setting to `NO_THROTTLING`.\r\nThe native implementation of
`deleteNetworkConditions` exposed by\r\nselenium is unofficial and
didn't consistently work, the recommended\r\napproach by the google dev
tools team is to restore the connection\r\nsetting the no throttling
profile.\r\n\r\n**N.B.**: _if the testing environment is not a Chromium
browser, it\r\nthrows an error that can be easily caught to manually
skip the test or\r\nhandle a fallback
scenario._\r\n\r\n```ts\r\nit('should display a loading skeleton while
loading', async function () {\r\n // Skip the test in case network
condition utils are not available\r\n try {\r\n await
browser.setNetworkConditions('SLOW_3G'); // Slow down network
conditions\r\n \r\n // Do your assertions\r\n\r\n await
browser.restoreNetworkConditions(); // Restore network conditions\r\n }
catch (error) {\r\n this.skip();\r\n
}\r\n});\r\n```\r\n\r\nCo-authored-by: Marco Antonio Ghiani
<marcoantonio.ghiani@elastic.co>\r\nCo-authored-by: Dzmitry Lemechko
<dzmitry.lemechko@elastic.co>","sha":"aa45152a4e787f36014675b864fcc0fce7bd6758"}},{"branch":"7.17","label":"v7.17.13","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.9","label":"v8.9.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
Co-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani01@gmail.com>