Skip to content

Commit

Permalink
[Lens] [Datatable] toolbar tests rewritten to testing-library/react (#…
Browse files Browse the repository at this point in the history
…173075)

## Summary

Rewrites datatable toolbar tests to testing-library.
It also starts a new package – shared space to park EUI component test
helpers that we eventually donate to EUI for ongoing maintenance. So far
it's just one helper but hopefully we'll be adding helpers soon!
  • Loading branch information
mbondyra authored Jan 8, 2024
1 parent 64ea667 commit 30638cd
Show file tree
Hide file tree
Showing 14 changed files with 193 additions and 107 deletions.
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 });
};
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

0 comments on commit 30638cd

Please sign in to comment.