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

[Lens] [Datatable] toolbar tests rewritten to testing-library/react #173075

Merged
merged 10 commits into from
Jan 8, 2024
Merged
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,7 @@ src/plugins/telemetry @elastic/kibana-core
test/plugin_functional/plugins/telemetry @elastic/kibana-core
packages/kbn-telemetry-tools @elastic/kibana-core
packages/kbn-test @elastic/kibana-operations @elastic/appex-qa
packages/kbn-test-eui-helpers @elastic/kibana-visualizations
x-pack/test/licensing_plugin/plugins/test_feature_usage @elastic/kibana-security
packages/kbn-test-jest-helpers @elastic/kibana-operations @elastic/appex-qa
packages/kbn-test-subj-selector @elastic/kibana-operations @elastic/appex-qa
Expand Down
1 change: 1 addition & 0 deletions .github/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ paths-ignore:
- packages/kbn-telemetry-tools
- packages/kbn-test
- packages/kbn-test-jest-helpers
- packages/kbn-test-eui-helpers
- packages/kbn-test-subj-selector
- packages/kbn-tooling-log
- packages/kbn-ts-project-linter
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,7 @@
"@kbn/storybook": "link:packages/kbn-storybook",
"@kbn/telemetry-tools": "link:packages/kbn-telemetry-tools",
"@kbn/test": "link:packages/kbn-test",
"@kbn/test-eui-helpers": "link:packages/kbn-test-eui-helpers",
"@kbn/test-jest-helpers": "link:packages/kbn-test-jest-helpers",
"@kbn/test-subj-selector": "link:packages/kbn-test-subj-selector",
"@kbn/tooling-log": "link:packages/kbn-tooling-log",
Expand Down
9 changes: 9 additions & 0 deletions packages/kbn-test-eui-helpers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export * from './src/rtl_helpers';
13 changes: 13 additions & 0 deletions packages/kbn-test-eui-helpers/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-test-eui-helpers'],
};
6 changes: 6 additions & 0 deletions packages/kbn-test-eui-helpers/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "shared-common",
"id": "@kbn/test-eui-helpers",
"devOnly": true,
"owner": ["@elastic/kibana-visualizations"],
}
6 changes: 6 additions & 0 deletions packages/kbn-test-eui-helpers/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@kbn/test-eui-helpers",
"version": "1.0.0",
"private": true,
"license": "SSPL-1.0 OR Elastic License 2.0"
}
14 changes: 14 additions & 0 deletions packages/kbn-test-eui-helpers/src/rtl_helpers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { screen, within } from '@testing-library/react';

export const getButtonGroupInputValue = (testId: string) => () => {
const buttonGroup = screen.getByTestId(testId);
return within(buttonGroup).getByRole('button', { pressed: true });
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting. So checked didn't work, but pressed does.

Copy link
Contributor Author

@mbondyra mbondyra Jan 5, 2024

Choose a reason for hiding this comment

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

It actually did work, but the implementation from eui side changed and it stopped - they had radio inputs before and now these are buttons so I had to update it. With this eui change this helper is so simple it's questionable it makes sense to have it here but I think it's a good opportunity to start this long planned package 😁

};
15 changes: 15 additions & 0 deletions packages/kbn-test-eui-helpers/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": ["jest", "node"]
},
"include": [
"**/*.ts",
"**/*.tsx",
],
"kbn_references": [],
"exclude": [
"target/**/*",
],
}
2 changes: 2 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,8 @@
"@kbn/telemetry-tools/*": ["packages/kbn-telemetry-tools/*"],
"@kbn/test": ["packages/kbn-test"],
"@kbn/test/*": ["packages/kbn-test/*"],
"@kbn/test-eui-helpers": ["packages/kbn-test-eui-helpers"],
"@kbn/test-eui-helpers/*": ["packages/kbn-test-eui-helpers/*"],
"@kbn/test-feature-usage-plugin": ["x-pack/test/licensing_plugin/plugins/test_feature_usage"],
"@kbn/test-feature-usage-plugin/*": ["x-pack/test/licensing_plugin/plugins/test_feature_usage/*"],
"@kbn/test-jest-helpers": ["packages/kbn-test-jest-helpers"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const ToolbarPopover: React.FunctionComponent<ToolbarPopoverProps> = ({
onClick={() => {
setOpen(!open);
}}
label={title}
aria-label={title}
isDisabled={isDisabled}
groupPosition={groupPosition}
Expand Down
Loading