From 94dab9a1ff7f50ab8a914f4f9063b12bd000a8c4 Mon Sep 17 00:00:00 2001 From: Andrei Zhaleznichenka Date: Thu, 9 Apr 2026 16:52:17 +0200 Subject: [PATCH] wip --- src/converter/generate-component-finders.ts | 17 +- src/converter/generate-test-utils.ts | 14 +- src/converter/interfaces.ts | 12 + .../test/generate-component-finders.test.tsx | 17 + .../test/generate-test-utils.test.ts | 21 + .../dom/index.ts | 122 ++++ .../dom/test-component-a/index.ts | 12 + .../dom/test-component-b/child-wrapper.ts | 11 + .../dom/test-component-b/index.ts | 12 + .../my-lib-test-utils-core/dom.ts | 6 + .../test/test-utils-generator.test.tsx | 23 + src/core/dom.ts | 3 +- src/core/selectors.ts | 3 +- .../__snapshots__/documenter.test.ts.snap | 637 ++++++++++++++++++ vite.config.mts | 1 + 15 files changed, 901 insertions(+), 10 deletions(-) create mode 100644 src/converter/test/mock-test-utils-custom-namespace/dom/index.ts create mode 100644 src/converter/test/mock-test-utils-custom-namespace/dom/test-component-a/index.ts create mode 100644 src/converter/test/mock-test-utils-custom-namespace/dom/test-component-b/child-wrapper.ts create mode 100644 src/converter/test/mock-test-utils-custom-namespace/dom/test-component-b/index.ts create mode 100644 src/converter/test/mock-test-utils-custom-namespace/my-lib-test-utils-core/dom.ts diff --git a/src/converter/generate-component-finders.ts b/src/converter/generate-component-finders.ts index 9a21ef4..bc9087b 100644 --- a/src/converter/generate-component-finders.ts +++ b/src/converter/generate-component-finders.ts @@ -99,12 +99,22 @@ export default function wrapper(root: string = 'body') { export interface GenerateFindersParams { components: ComponentWrapperMetadata[]; testUtilType: TestUtilType; + namespace?: string; } -export const generateComponentFinders = ({ components, testUtilType }: GenerateFindersParams) => ` +const DEFAULT_NAMESPACES: Record = { + dom: '@cloudscape-design/test-utils-core/dist/dom', + selectors: '@cloudscape-design/test-utils-core/dist/selectors', +}; + +export const generateComponentFinders = ({ components, testUtilType, namespace }: GenerateFindersParams) => { + const declareModuleTarget = namespace ?? DEFAULT_NAMESPACES[testUtilType]; + const importPath = namespace ?? `@cloudscape-design/test-utils-core/${testUtilType}`; + + return ` // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { ElementWrapper } from '@cloudscape-design/test-utils-core/${testUtilType}'; +import { ElementWrapper } from '${importPath}'; import { appendSelector } from '@cloudscape-design/test-utils-core/utils'; export { ElementWrapper }; @@ -112,7 +122,7 @@ ${components.map(componentWrapperImport).join('')} ${components.map(componentWrapperExport).join('')} -declare module '@cloudscape-design/test-utils-core/dist/${testUtilType}' { +declare module '${declareModuleTarget}' { interface ElementWrapper { ${components.map(componentFindersInterfaces[testUtilType]).join('')} } @@ -122,3 +132,4 @@ ${components.map(componentFinders).join('')} ${testUtilType === 'dom' ? components.map(componentClosestFinder).join('') : ''} ${defaultExport[testUtilType]} `; +}; diff --git a/src/converter/generate-test-utils.ts b/src/converter/generate-test-utils.ts index 2d387c1..773eef9 100644 --- a/src/converter/generate-test-utils.ts +++ b/src/converter/generate-test-utils.ts @@ -13,7 +13,7 @@ interface GenerateIndexFilesParams extends GenerateTestUtilsParams { testUtilType: TestUtilType; } -function generateIndexFile({ testUtilsPath, components, testUtilType }: GenerateIndexFilesParams) { +function generateIndexFile({ testUtilsPath, components, testUtilType, namespace }: GenerateIndexFilesParams) { const componenWrappersMetadata: ComponentWrapperMetadata[] = components.map( ({ name, pluralName, testUtilsFolderName }) => ({ name, @@ -23,7 +23,11 @@ function generateIndexFile({ testUtilsPath, components, testUtilType }: Generate }), ); - const content = generateComponentFinders({ testUtilType, components: componenWrappersMetadata }); + const content = generateComponentFinders({ + testUtilType, + components: componenWrappersMetadata, + namespace: namespace?.[testUtilType], + }); const indexFilePath = path.join(testUtilsPath, testUtilType, 'index.ts'); writeSourceFile(indexFilePath, content); } @@ -53,8 +57,8 @@ function generateSelectorUtils(testUtilsPath: string) { /** * Generates test utils index files for dom and selector and converts the dom test utils to selectors. */ -export function generateTestUtils({ components, testUtilsPath }: GenerateTestUtilsParams) { +export function generateTestUtils({ components, testUtilsPath, namespace }: GenerateTestUtilsParams) { generateSelectorUtils(testUtilsPath); - generateIndexFile({ components, testUtilsPath, testUtilType: 'dom' }); - generateIndexFile({ components, testUtilsPath, testUtilType: 'selectors' }); + generateIndexFile({ components, testUtilsPath, testUtilType: 'dom', namespace }); + generateIndexFile({ components, testUtilsPath, testUtilType: 'selectors', namespace }); } diff --git a/src/converter/interfaces.ts b/src/converter/interfaces.ts index fc34c90..bc20ebb 100644 --- a/src/converter/interfaces.ts +++ b/src/converter/interfaces.ts @@ -39,6 +39,18 @@ export interface GenerateTestUtilsParams { * */ testUtilsPath: string; + + /** + * Custom namespace for the ElementWrapper module augmentation and import. + * When provided, the generated index files will import ElementWrapper from the custom namespace + * and augment it instead of the default @cloudscape-design/test-utils-core namespace. + * This allows custom component libraries to declare an isolated ElementWrapper that does not + * inherit augmentations from @cloudscape-design/components. + */ + namespace?: { + dom: string; + selectors: string; + }; } export interface ComponentWrapperMetadata extends ComponentMetadata { diff --git a/src/converter/test/generate-component-finders.test.tsx b/src/converter/test/generate-component-finders.test.tsx index e92a6ac..22a18b4 100644 --- a/src/converter/test/generate-component-finders.test.tsx +++ b/src/converter/test/generate-component-finders.test.tsx @@ -73,4 +73,21 @@ describe(`${generateComponentFinders.name}`, () => { } }); }); + + describe.each(testUtilTypes)('%s with custom namespace', testUtilType => { + const customNamespace = `@my-lib/test-utils-core/dist/${testUtilType}`; + const sourceFileContent = generateComponentFinders({ components: mockComponents, testUtilType, namespace: customNamespace }); + + test('it imports ElementWrapper from the custom namespace', () => { + expect(sourceFileContent).toMatch(`import { ElementWrapper } from '${customNamespace}'`); + }); + + test('it augments the custom namespace', () => { + expect(sourceFileContent).toMatch(`declare module '${customNamespace}'`); + }); + + test('it does not augment the default cloudscape namespace', () => { + expect(sourceFileContent).not.toMatch(`declare module '@cloudscape-design/test-utils-core/dist`); + }); + }); }); diff --git a/src/converter/test/generate-test-utils.test.ts b/src/converter/test/generate-test-utils.test.ts index e3f6d62..ebdc392 100644 --- a/src/converter/test/generate-test-utils.test.ts +++ b/src/converter/test/generate-test-utils.test.ts @@ -64,4 +64,25 @@ describe(`${generateTestUtils.name}`, () => { expect.stringMatching(testUtilsFilePartialContent), ); }); + + test.each(testUtilsType)('uses custom namespace in generated %s index file', testUtilType => { + const customNamespace = `@my-lib/test-utils-core/dist/${testUtilType}`; + generateTestUtils({ + components: mockComponents, + testUtilsPath: './test/mock-test-utils', + namespace: { + dom: '@my-lib/test-utils-core/dist/dom', + selectors: '@my-lib/test-utils-core/dist/selectors', + }, + }); + + expect(writeFileSync).toHaveBeenCalledWith( + `test/mock-test-utils/${testUtilType}/index.ts`, + expect.stringMatching(`declare module '${customNamespace}'`), + ); + expect(writeFileSync).toHaveBeenCalledWith( + `test/mock-test-utils/${testUtilType}/index.ts`, + expect.stringMatching(`from '${customNamespace}'`), + ); + }); }); diff --git a/src/converter/test/mock-test-utils-custom-namespace/dom/index.ts b/src/converter/test/mock-test-utils-custom-namespace/dom/index.ts new file mode 100644 index 0000000..9344761 --- /dev/null +++ b/src/converter/test/mock-test-utils-custom-namespace/dom/index.ts @@ -0,0 +1,122 @@ + +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +import { ElementWrapper } from '@my-lib/test-utils-core/dom'; +import { appendSelector } from '@cloudscape-design/test-utils-core/utils'; + +export { ElementWrapper }; + +import TestComponentAWrapper from './test-component-a'; +import TestComponentBWrapper from './test-component-b'; + + +export { TestComponentAWrapper }; +export { TestComponentBWrapper }; + +declare module '@my-lib/test-utils-core/dist/dom' { + interface ElementWrapper { + +/** + * Returns the wrapper of the first TestComponentA that matches the specified CSS selector. + * If no CSS selector is specified, returns the wrapper of the first TestComponentA. + * If no matching TestComponentA is found, returns `null`. + * + * @param {string} [selector] CSS Selector + * @returns {TestComponentAWrapper | null} + */ +findTestComponentA(selector?: string): TestComponentAWrapper | null; + +/** + * Returns an array of TestComponentA wrapper that matches the specified CSS selector. + * If no CSS selector is specified, returns all of the TestComponentAs inside the current wrapper. + * If no matching TestComponentA is found, returns an empty array. + * + * @param {string} [selector] CSS Selector + * @returns {Array} + */ +findAllTestComponentAs(selector?: string): Array; + +/** + * Returns the wrapper of the closest parent TestComponentA for the current element, + * or the element itself if it is an instance of TestComponentA. + * If no TestComponentA is found, returns `null`. + * + * @returns {TestComponentAWrapper | null} + */ +findClosestTestComponentA(): TestComponentAWrapper | null; +/** + * Returns the wrapper of the first TestComponentB that matches the specified CSS selector. + * If no CSS selector is specified, returns the wrapper of the first TestComponentB. + * If no matching TestComponentB is found, returns `null`. + * + * @param {string} [selector] CSS Selector + * @returns {TestComponentBWrapper | null} + */ +findTestComponentB(selector?: string): TestComponentBWrapper | null; + +/** + * Returns an array of TestComponentB wrapper that matches the specified CSS selector. + * If no CSS selector is specified, returns all of the TestComponentBs inside the current wrapper. + * If no matching TestComponentB is found, returns an empty array. + * + * @param {string} [selector] CSS Selector + * @returns {Array} + */ +findAllTestComponentBs(selector?: string): Array; + +/** + * Returns the wrapper of the closest parent TestComponentB for the current element, + * or the element itself if it is an instance of TestComponentB. + * If no TestComponentB is found, returns `null`. + * + * @returns {TestComponentBWrapper | null} + */ +findClosestTestComponentB(): TestComponentBWrapper | null; + } +} + + +ElementWrapper.prototype.findTestComponentA = function(selector) { + let rootSelector = `.${TestComponentAWrapper.rootSelector}`; + if("legacyRootSelector" in TestComponentAWrapper && TestComponentAWrapper.legacyRootSelector){ + rootSelector = `:is(.${TestComponentAWrapper.rootSelector}, .${TestComponentAWrapper.legacyRootSelector})`; + } + // casting to 'any' is needed to avoid this issue with generics + // https://github.com/microsoft/TypeScript/issues/29132 + return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, TestComponentAWrapper); +}; + +ElementWrapper.prototype.findAllTestComponentAs = function(selector) { + return this.findAllComponents(TestComponentAWrapper, selector); +}; +ElementWrapper.prototype.findTestComponentB = function(selector) { + let rootSelector = `.${TestComponentBWrapper.rootSelector}`; + if("legacyRootSelector" in TestComponentBWrapper && TestComponentBWrapper.legacyRootSelector){ + rootSelector = `:is(.${TestComponentBWrapper.rootSelector}, .${TestComponentBWrapper.legacyRootSelector})`; + } + // casting to 'any' is needed to avoid this issue with generics + // https://github.com/microsoft/TypeScript/issues/29132 + return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, TestComponentBWrapper); +}; + +ElementWrapper.prototype.findAllTestComponentBs = function(selector) { + return this.findAllComponents(TestComponentBWrapper, selector); +}; + +ElementWrapper.prototype.findClosestTestComponentA = function() { + // casting to 'any' is needed to avoid this issue with generics + // https://github.com/microsoft/TypeScript/issues/29132 + return (this as any).findClosestComponent(TestComponentAWrapper); +}; +ElementWrapper.prototype.findClosestTestComponentB = function() { + // casting to 'any' is needed to avoid this issue with generics + // https://github.com/microsoft/TypeScript/issues/29132 + return (this as any).findClosestComponent(TestComponentBWrapper); +}; + +export default function wrapper(root: Element = document.body) { + if (document && document.body && !document.body.contains(root)) { + console.warn('[AwsUi] [test-utils] provided element is not part of the document body, interactions may work incorrectly') + }; + return new ElementWrapper(root); +} diff --git a/src/converter/test/mock-test-utils-custom-namespace/dom/test-component-a/index.ts b/src/converter/test/mock-test-utils-custom-namespace/dom/test-component-a/index.ts new file mode 100644 index 0000000..fad14e5 --- /dev/null +++ b/src/converter/test/mock-test-utils-custom-namespace/dom/test-component-a/index.ts @@ -0,0 +1,12 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +import { ComponentWrapper, createWrapper } from '@cloudscape-design/test-utils-core/dom'; + +export default class TestComponentAWrapper extends ComponentWrapper { + static rootSelector = 'awsui_button_1ueyk_1xee3_5'; + static legacyRootSelector = 'awsui_button_2oldf_2oldf_5'; + + findChild() { + return createWrapper().find('.test-component-a-child'); + } +} diff --git a/src/converter/test/mock-test-utils-custom-namespace/dom/test-component-b/child-wrapper.ts b/src/converter/test/mock-test-utils-custom-namespace/dom/test-component-b/child-wrapper.ts new file mode 100644 index 0000000..9f72569 --- /dev/null +++ b/src/converter/test/mock-test-utils-custom-namespace/dom/test-component-b/child-wrapper.ts @@ -0,0 +1,11 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +import { ComponentWrapper, createWrapper } from '@cloudscape-design/test-utils-core/dom'; + +export class ChildWrapper extends ComponentWrapper { + static rootSelector = 'test-component-b-child'; + + findContent() { + return createWrapper().find('.test-component-b-child-content'); + } +} diff --git a/src/converter/test/mock-test-utils-custom-namespace/dom/test-component-b/index.ts b/src/converter/test/mock-test-utils-custom-namespace/dom/test-component-b/index.ts new file mode 100644 index 0000000..4fecf06 --- /dev/null +++ b/src/converter/test/mock-test-utils-custom-namespace/dom/test-component-b/index.ts @@ -0,0 +1,12 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +import { ComponentWrapper, createWrapper } from '@cloudscape-design/test-utils-core/dom'; +import { ChildWrapper } from './child-wrapper'; + +export default class TestComponentBWrapper extends ComponentWrapper { + static rootSelector = 'test-component-b-root'; + + findChild(): ChildWrapper { + return createWrapper().find(`.${ChildWrapper.rootSelector}`); + } +} diff --git a/src/converter/test/mock-test-utils-custom-namespace/my-lib-test-utils-core/dom.ts b/src/converter/test/mock-test-utils-custom-namespace/my-lib-test-utils-core/dom.ts new file mode 100644 index 0000000..f6d8efb --- /dev/null +++ b/src/converter/test/mock-test-utils-custom-namespace/my-lib-test-utils-core/dom.ts @@ -0,0 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +import { BaseElementWrapper, ComponentWrapper, createWrapper } from '@cloudscape-design/test-utils-core/dom'; + +export { ComponentWrapper, createWrapper }; +export class ElementWrapper extends BaseElementWrapper {} diff --git a/src/converter/test/test-utils-generator.test.tsx b/src/converter/test/test-utils-generator.test.tsx index 001d912..abeb58d 100644 --- a/src/converter/test/test-utils-generator.test.tsx +++ b/src/converter/test/test-utils-generator.test.tsx @@ -98,4 +98,27 @@ describe(`${generateTestUtils.name}`, () => { expect(container.querySelector(componentBChildSelector).textContent).toBe('First Component B'); }); }); + + describe('custom namespace generated dom index file', () => { + test('component finders work on the custom ElementWrapper', async () => { + const { default: createWrapper } = await import('./mock-test-utils-custom-namespace/dom'); + const container = renderTestNode(); + const wrapper = createWrapper(container); + + expect(wrapper.findTestComponentA().getElement().textContent).toBe('First Component A'); + expect(wrapper.findTestComponentB().getElement().textContent).toBe('First Component B'); + }); + + test('custom ElementWrapper prototype is independent from the cloudscape ElementWrapper prototype', async () => { + const { ElementWrapper: CustomElementWrapper } = await import('./mock-test-utils-custom-namespace/dom'); + const { ElementWrapper: CloudscapeElementWrapper } = await import('./mock-test-utils/dom'); + + // The two ElementWrapper classes are distinct — prototype mutations on one don't affect the other + expect(CustomElementWrapper.prototype).not.toBe(CloudscapeElementWrapper.prototype); + // Both share BaseElementWrapper as their parent, but their own prototypes are separate + expect(Object.getPrototypeOf(CustomElementWrapper.prototype)).toBe( + Object.getPrototypeOf(CloudscapeElementWrapper.prototype), + ); + }); + }); }); diff --git a/src/core/dom.ts b/src/core/dom.ts index 0a16057..3dae005 100644 --- a/src/core/dom.ts +++ b/src/core/dom.ts @@ -197,7 +197,8 @@ export class AbstractWrapper } } -export class ElementWrapper extends AbstractWrapper {} +export class BaseElementWrapper extends AbstractWrapper {} +export class ElementWrapper extends BaseElementWrapper {} export class ComponentWrapper extends AbstractWrapper {} export function createWrapper(root: Element = document.body) { if (document && document.body && !document.body.contains(root)) { diff --git a/src/core/selectors.ts b/src/core/selectors.ts index 538cbb7..ed421f9 100644 --- a/src/core/selectors.ts +++ b/src/core/selectors.ts @@ -91,7 +91,8 @@ export class AbstractWrapper implements IElementWrapper", + }, + ], + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.findAllByClassName", + }, + "name": "findAllByClassName", + "parameters": [ + { + "flags": { + "isOptional": false, + }, + "name": "className", + "typeName": "string", + }, + ], + "returnType": { + "isNullable": false, + "name": "Array", + "typeArguments": [ + { + "name": "ElementWrapper", + }, + ], + }, + }, + { + "description": "Returns the wrappers of all components that match the specified component type and the specified CSS selector. +If no CSS selector is specified, returns all of the components that match the specified component type. +If no matching component is found, returns an empty array.", + "inheritedFrom": { + "name": "AbstractWrapper.findAllComponents", + }, + "name": "findAllComponents", + "parameters": [ + { + "description": "Component's wrapper class", + "flags": { + "isOptional": false, + }, + "name": "ComponentClass", + "typeName": "ComponentWrapperClass", + }, + { + "description": "CSS selector", + "flags": { + "isOptional": true, + }, + "name": "selector", + "typeName": "string", + }, + ], + "returnType": { + "isNullable": false, + "name": "Array", + "typeArguments": [ + { + "name": "Wrapper", + }, + ], + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.findAny", + }, + "name": "findAny", + "parameters": [ + { + "flags": { + "isOptional": false, + }, + "name": "selectors", + "typeName": "Array", + }, + ], + "returnType": { + "isNullable": true, + "name": "ElementWrapper", + "typeArguments": [ + { + "name": "NewElementType", + }, + ], + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.findByClassName", + }, + "name": "findByClassName", + "parameters": [ + { + "flags": { + "isOptional": false, + }, + "name": "className", + "typeName": "string", + }, + ], + "returnType": { + "isNullable": true, + "name": "ElementWrapper", + "typeArguments": [ + { + "name": "NewElementType", + }, + ], + }, + }, + { + "description": "Returns the closest ancestor element (or self) that matches the specified component type. +If no matching component is found, returns \`null\`.", + "inheritedFrom": { + "name": "AbstractWrapper.findClosestComponent", + }, + "name": "findClosestComponent", + "parameters": [ + { + "description": "Component's wrapper class", + "flags": { + "isOptional": false, + }, + "name": "ComponentClass", + "typeName": "ComponentWrapperClass", + }, + ], + "returnType": { + "isNullable": true, + "name": "Wrapper", + }, + }, + { + "description": "Returns the component wrapper matching the specified selector. +If the specified selector doesn't match any element, it returns \`null\`. + +Note: This function returns the specified component's wrapper even if the specified selector points to a different component type.", + "inheritedFrom": { + "name": "AbstractWrapper.findComponent", + }, + "name": "findComponent", + "parameters": [ + { + "description": "CSS selector", + "flags": { + "isOptional": false, + }, + "name": "selector", + "typeName": "string", + }, + { + "description": "Component's wrapper class", + "flags": { + "isOptional": false, + }, + "name": "ComponentClass", + "typeName": "WrapperClass", + }, + ], + "returnType": { + "isNullable": true, + "name": "Wrapper", + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.fireEvent", + }, + "name": "fireEvent", + "parameters": [ + { + "flags": { + "isOptional": false, + }, + "name": "event", + "typeName": "Event", + }, + ], + "returnType": { + "isNullable": false, + "name": "void", + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.focus", + }, + "name": "focus", + "parameters": [], + "returnType": { + "isNullable": false, + "name": "void", + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.getElement", + }, + "name": "getElement", + "parameters": [], + "returnType": { + "isNullable": false, + "name": "ElementType", + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.keydown", + }, + "name": "keydown", + "parameters": [ + { + "flags": { + "isOptional": false, + }, + "name": "keyCode", + "typeName": "KeyCode", + }, + ], + "returnType": { + "isNullable": false, + "name": "void", + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.keydown", + }, + "name": "keydown", + "parameters": [ + { + "flags": { + "isOptional": false, + }, + "name": "keyboardEventProps", + "typeName": "KeyboardEventInit", + }, + ], + "returnType": { + "isNullable": false, + "name": "void", + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.keypress", + }, + "name": "keypress", + "parameters": [ + { + "flags": { + "isOptional": false, + }, + "name": "keyCode", + "typeName": "KeyCode", + }, + ], + "returnType": { + "isNullable": false, + "name": "void", + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.keypress", + }, + "name": "keypress", + "parameters": [ + { + "flags": { + "isOptional": false, + }, + "name": "keyboardEventProps", + "typeName": "KeyboardEventInit", + }, + ], + "returnType": { + "isNullable": false, + "name": "void", + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.keyup", + }, + "name": "keyup", + "parameters": [ + { + "flags": { + "isOptional": false, + }, + "name": "keyCode", + "typeName": "KeyCode", + }, + ], + "returnType": { + "isNullable": false, + "name": "void", + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.keyup", + }, + "name": "keyup", + "parameters": [ + { + "flags": { + "isOptional": false, + }, + "name": "keyboardEventProps", + "typeName": "KeyboardEventInit", + }, + ], + "returnType": { + "isNullable": false, + "name": "void", + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.matches", + }, + "name": "matches", + "parameters": [ + { + "flags": { + "isOptional": false, + }, + "name": "selector", + "typeName": "string", + }, + ], + "returnType": { + "isNullable": true, + "name": "this", + }, + }, + ], "name": "ElementWrapper", }, { @@ -1543,6 +1964,222 @@ If no CSS selector is specified, returns a multi-element wrapper that matches th { "description": "Returns a wrapper that matches the specified component type with the specified CSS selector. +Note: This function returns the specified component's wrapper even if the specified selector points to a different component type.", + "inheritedFrom": { + "name": "AbstractWrapper.findComponent", + }, + "name": "findComponent", + "parameters": [ + { + "description": "CSS selector", + "flags": { + "isOptional": false, + }, + "name": "selector", + "typeName": "string", + }, + { + "description": "Component's wrapper class", + "flags": { + "isOptional": false, + }, + "name": "ComponentClass", + "typeName": "WrapperClass", + }, + ], + "returnType": { + "isNullable": false, + "name": "Wrapper", + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.getElement", + }, + "name": "getElement", + "parameters": [], + "returnType": { + "isNullable": false, + "name": "string", + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.matches", + }, + "name": "matches", + "parameters": [ + { + "flags": { + "isOptional": false, + }, + "name": "selector", + "typeName": "string", + }, + ], + "returnType": { + "isNullable": false, + "name": "ElementWrapper", + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.toSelector", + }, + "name": "toSelector", + "parameters": [], + "returnType": { + "isNullable": false, + "name": "string", + }, + }, + ], + "name": "BaseElementWrapper", + }, + { + "methods": [ + { + "inheritedFrom": { + "name": "AbstractWrapper.find", + }, + "name": "find", + "parameters": [ + { + "flags": { + "isOptional": false, + }, + "name": "selector", + "typeName": "string", + }, + ], + "returnType": { + "isNullable": false, + "name": "ElementWrapper", + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.findAll", + }, + "name": "findAll", + "parameters": [ + { + "flags": { + "isOptional": false, + }, + "name": "selector", + "typeName": "string", + }, + ], + "returnType": { + "isNullable": false, + "name": "MultiElementWrapper", + "typeArguments": [ + { + "name": "ElementWrapper", + }, + ], + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.findAllByClassName", + }, + "name": "findAllByClassName", + "parameters": [ + { + "flags": { + "isOptional": false, + }, + "name": "className", + "typeName": "string", + }, + ], + "returnType": { + "isNullable": false, + "name": "MultiElementWrapper", + "typeArguments": [ + { + "name": "ElementWrapper", + }, + ], + }, + }, + { + "description": "Returns a multi-element wrapper that matches the specified component type with the specified CSS selector. +If no CSS selector is specified, returns a multi-element wrapper that matches the specified component type.", + "inheritedFrom": { + "name": "AbstractWrapper.findAllComponents", + }, + "name": "findAllComponents", + "parameters": [ + { + "flags": { + "isOptional": false, + }, + "name": "ComponentClass", + "typeName": "ComponentWrapperClass", + }, + { + "description": "CSS Selector", + "flags": { + "isOptional": true, + }, + "name": "selector", + "typeName": "string", + }, + ], + "returnType": { + "isNullable": false, + "name": "MultiElementWrapper", + "typeArguments": [ + { + "name": "Wrapper", + }, + ], + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.findAny", + }, + "name": "findAny", + "parameters": [ + { + "flags": { + "isOptional": false, + }, + "name": "selectors", + "typeName": "Array", + }, + ], + "returnType": { + "isNullable": false, + "name": "ElementWrapper", + }, + }, + { + "inheritedFrom": { + "name": "AbstractWrapper.findByClassName", + }, + "name": "findByClassName", + "parameters": [ + { + "flags": { + "isOptional": false, + }, + "name": "className", + "typeName": "string", + }, + ], + "returnType": { + "isNullable": false, + "name": "ElementWrapper", + }, + }, + { + "description": "Returns a wrapper that matches the specified component type with the specified CSS selector. + Note: This function returns the specified component's wrapper even if the specified selector points to a different component type.", "inheritedFrom": { "name": "AbstractWrapper.findComponent", diff --git a/vite.config.mts b/vite.config.mts index f09c94d..a45632d 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -16,6 +16,7 @@ export default defineConfig({ resolve: { alias: { '@cloudscape-design/test-utils-core': path.resolve(__dirname, './lib/core'), + '@my-lib/test-utils-core': path.resolve(__dirname, './src/converter/test/mock-test-utils-custom-namespace/my-lib-test-utils-core'), }, }, });