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

[React@18] Run jest tests #206411

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,13 @@ export async function pickTestGroupRunOrder() {
* For example in code coverage pipeline definition, it is "limited"
* to 'unit,integration'. This means FTR tests will not be executed.
*/
const LIMIT_CONFIG_TYPE = process.env.LIMIT_CONFIG_TYPE
? process.env.LIMIT_CONFIG_TYPE.split(',')
.map((t) => t.trim())
.filter(Boolean)
: ['unit', 'integration', 'functional'];
// const LIMIT_CONFIG_TYPE = process.env.LIMIT_CONFIG_TYPE
// ? process.env.LIMIT_CONFIG_TYPE.split(',')
// .map((t) => t.trim())
// .filter(Boolean)
// : ['unit', 'integration', 'functional'];

const LIMIT_CONFIG_TYPE = ['unit'];

const FTR_CONFIG_PATTERNS = process.env.FTR_CONFIG_PATTERNS
? process.env.FTR_CONFIG_PATTERNS.split(',')
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1213,10 +1213,10 @@
"rbush": "^3.0.1",
"re-resizable": "^6.9.9",
"re2js": "0.4.3",
"react": "^17.0.2",
"react": "~18.2.0",
"react-18": "npm:react@~18.2.0",
"react-diff-view": "^3.2.1",
"react-dom": "^17.0.2",
"react-dom": "~18.2.0",
"react-dom-18": "npm:react-dom@~18.2.0",
"react-dropzone": "^4.2.9",
"react-fast-compare": "^2.0.4",
Expand Down Expand Up @@ -1648,7 +1648,7 @@
"@types/react-router": "^5.1.20",
"@types/react-router-config": "^5.0.7",
"@types/react-router-dom": "^5.3.3",
"@types/react-test-renderer": "^17.0.2",
"@types/react-test-renderer": "~18.0.0",
"@types/react-virtualized": "^9.21.30",
"@types/react-window": "^1.8.8",
"@types/react-window-infinite-loader": "^1.0.9",
Expand Down Expand Up @@ -1820,7 +1820,7 @@
"proxy": "^2.1.1",
"raw-loader": "^3.1.0",
"react-is": "^17.0.2",
"react-test-renderer": "^17.0.2",
"react-test-renderer": "~18.2.0",
"recast": "^0.23.9",
"regenerate": "^1.4.0",
"resolve": "^1.22.0",
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-test/src/jest/setup/enzyme.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ configure({ adapter: new Adapter() });
/* eslint-env jest */

/**
* This is a workaround to fix snapshot serialization of emotion classes when rendering React@18 using `import { render } from 'enzyme'`
* With React@18 emotion uses `useInsertionEffect` to insert styles into the DOM, which enzyme `render` does not trigger because it is using ReactDomServer.renderToString.
* With React@17 emotion fell back to sync cb, so it was working with enzyme `render`.
* Without those styles in DOM the custom snapshot serializer is not able to replace the emotion class names.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { renderHook, act } from '@testing-library/react';
import { renderHook, act, waitFor } from '@testing-library/react';
import { sessionViewIOEventsMock } from '../../../common/mocks/responses/session_view_io_events.mock';
import { useIOLines, useXtermPlayer, XtermPlayerDeps } from './hooks';
import type { ProcessEventsPage } from '../../../common';
Expand Down Expand Up @@ -179,21 +179,25 @@ describe('TTYPlayer/hooks', () => {

rerender({ ...initialProps, isPlaying: false });

expect(result.current.terminal.buffer.active.getLine(0)?.translateToString(true)).toBe('256');
expect(result.current.terminal.buffer.active.getLine(1)?.translateToString(true)).toBe(',');
expect(result.current.terminal.buffer.active.getLine(2)?.translateToString(true)).toBe(
' Some Companies Puppet instance'
);
expect(result.current.terminal.buffer.active.getLine(3)?.translateToString(true)).toBe(
' | | | CentOS Stream release 8 on x86_64'
);
expect(result.current.terminal.buffer.active.getLine(4)?.translateToString(true)).toBe(
' *********************** Load average: 1.23, 1.01, 0.63'
);
expect(result.current.terminal.buffer.active.getLine(5)?.translateToString(true)).toBe(
' ************************ '
);
expect(result.current.currentLine).toBe(LOOPS);
await waitFor(() => {
expect(result.current.terminal.buffer.active.getLine(0)?.translateToString(true)).toBe(
'256'
);
expect(result.current.terminal.buffer.active.getLine(1)?.translateToString(true)).toBe(',');
expect(result.current.terminal.buffer.active.getLine(2)?.translateToString(true)).toBe(
' Some Companies Puppet instance'
);
expect(result.current.terminal.buffer.active.getLine(3)?.translateToString(true)).toBe(
' | | | CentOS Stream release 8 on x86_64'
);
expect(result.current.terminal.buffer.active.getLine(4)?.translateToString(true)).toBe(
' *********************** Load average: 1.23, 1.01, 0.63'
);
expect(result.current.terminal.buffer.active.getLine(5)?.translateToString(true)).toBe(
' ************************ '
);
expect(result.current.currentLine).toBe(LOOPS);
});
});

it('will allow a plain text search highlight on the last line printed', async () => {
Expand Down
33 changes: 20 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12297,12 +12297,12 @@
"@types/history" "^4.7.11"
"@types/react" "*"

"@types/react-test-renderer@^17.0.2":
version "17.0.2"
resolved "https://registry.yarnpkg.com/@types/react-test-renderer/-/react-test-renderer-17.0.2.tgz#5f800a39b12ac8d2a2149e7e1885215bcf4edbbf"
integrity sha512-+F1KONQTBHDBBhbHuT2GNydeMpPuviduXIVJRB7Y4nma4NR5DrTJfMMZ+jbhEHbpwL+Uqhs1WXh4KHiyrtYTPg==
"@types/react-test-renderer@~18.0.0":
version "18.0.7"
resolved "https://registry.yarnpkg.com/@types/react-test-renderer/-/react-test-renderer-18.0.7.tgz#2cfe657adb3688cdf543995eceb2e062b5a68728"
integrity sha512-1+ANPOWc6rB3IkSnElhjv6VLlKg2dSv/OWClUyZimbLsQyBn8Js9Vtdsi3UICJ2rIQ3k2la06dkB+C92QfhKmg==
dependencies:
"@types/react" "^17"
"@types/react" "*"

"@types/react-transition-group@^4.4.0":
version "4.4.5"
Expand Down Expand Up @@ -12334,7 +12334,7 @@
dependencies:
"@types/react" "*"

"@types/react@*", "@types/react@16 || 17 || 18", "@types/react@^17", "@types/react@~18.2.0":
"@types/react@*", "@types/react@16 || 17 || 18", "@types/react@~18.2.0":
version "18.2.79"
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.79.tgz#c40efb4f255711f554d47b449f796d1c7756d865"
integrity sha512-RwGAGXPl9kSXwdNTafkOEuFrTBD5SA2B3iEB96xi8+xu5ddUa/cpvyVCSNn+asgLCTHkb5ZxN8gbuibYJi4s1w==
Expand Down Expand Up @@ -27462,8 +27462,7 @@ re2js@0.4.3:
resolved "https://registry.yarnpkg.com/re2js/-/re2js-0.4.3.tgz#1318cd0c12aa6ed3ba56d5e012311ffbfb2aef35"
integrity sha512-EuNmh7jurhHEE8Ge/lBo9JuMLb3qf866Xjjfyovw3wPc7+hlqDkZq4LwhrCQMEI+ARWfrKrHozEndzlpNT0WDg==

"react-18@npm:react@~18.2.0", "react@^17.0.0 || ^18.2.0":
name react-18
"react-18@npm:react@~18.2.0", "react@^17.0.0 || ^18.2.0", react@~18.2.0:
version "18.2.0"
resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5"
integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==
Expand Down Expand Up @@ -27513,16 +27512,15 @@ react-docgen@^5.0.0:
node-dir "^0.1.10"
strip-indent "^3.0.0"

"react-dom-18@npm:react-dom@~18.2.0", "react-dom@^17.0.0 || ^18.2.0":
name react-dom-18
"react-dom-18@npm:react-dom@~18.2.0", "react-dom@^17.0.0 || ^18.2.0", react-dom@~18.2.0:
version "18.2.0"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.2.0.tgz#22aaf38708db2674ed9ada224ca4aa708d821e3d"
integrity sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==
dependencies:
loose-envify "^1.1.0"
scheduler "^0.23.0"

react-dom@^17.0.1, react-dom@^17.0.2:
react-dom@^17.0.1:
version "17.0.2"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-17.0.2.tgz#ecffb6845e3ad8dbfcdc498f0d0a939736502c23"
integrity sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==
Expand Down Expand Up @@ -27894,7 +27892,7 @@ react-tabs@^6.0.2:
clsx "^2.0.0"
prop-types "^15.5.0"

"react-test-renderer@^16.8.0 || ^17.0.0", react-test-renderer@^17.0.0, react-test-renderer@^17.0.2:
"react-test-renderer@^16.8.0 || ^17.0.0", react-test-renderer@^17.0.0:
version "17.0.2"
resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-17.0.2.tgz#4cd4ae5ef1ad5670fc0ef776e8cc7e1231d9866c"
integrity sha512-yaQ9cB89c17PUb0x6UfWRs7kQCorVdHlutU1boVPEsB8IDZH6n9tHxMacc3y0JoXOJUsZb/t/Mb8FUWMKaM7iQ==
Expand All @@ -27904,6 +27902,15 @@ react-tabs@^6.0.2:
react-shallow-renderer "^16.13.1"
scheduler "^0.20.2"

react-test-renderer@~18.2.0:
version "18.2.0"
resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-18.2.0.tgz#1dd912bd908ff26da5b9fca4fd1c489b9523d37e"
integrity sha512-JWD+aQ0lh2gvh4NM3bBM42Kx+XybOxCpgYK7F8ugAlpaTSnWsX+39Z4XkOykGZAHrjwwTZT3x3KxswVWxHPUqA==
dependencies:
react-is "^18.2.0"
react-shallow-renderer "^16.15.0"
scheduler "^0.23.0"

react-transition-group@^4.3.0:
version "4.4.1"
resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-4.4.1.tgz#63868f9325a38ea5ee9535d828327f85773345c9"
Expand Down Expand Up @@ -27969,7 +27976,7 @@ react-window@^1.8.10:
"@babel/runtime" "^7.0.0"
memoize-one ">=3.1.1 <6"

react@^17.0.1, react@^17.0.2:
react@^17.0.1:
version "17.0.2"
resolved "https://registry.yarnpkg.com/react/-/react-17.0.2.tgz#d0b5cc516d29eb3eee383f75b62864cfb6800037"
integrity sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==
Expand Down