UNPKG

@awsui/components-react

Version:

On July 19th, 2022, we launched [Cloudscape Design System](https://cloudscape.design). Cloudscape is an evolution of AWS-UI. It consists of user interface guidelines, front-end components, design resources, and development tools for building intuitive, en

160 lines • 7.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FilteringGroupedTokenWrapper = exports.PropertyFilterEditorDropdownWrapper = exports.FilteringTokenWrapper = void 0; // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 const selectors_1 = require("@awsui/test-utils-core/selectors"); const autosuggest_1 = require("../autosuggest"); const button_1 = require("../button"); const button_dropdown_1 = require("../button-dropdown"); const form_field_1 = require("../form-field"); const select_1 = require("../select"); const styles_selectors_js_1 = require("../../../internal/components/token-list/styles.selectors.js"); const styles_selectors_js_2 = require("../../../popover/styles.selectors.js"); const styles_selectors_js_3 = require("../../../property-filter/styles.selectors.js"); const styles_selectors_js_4 = require("../../../property-filter/test-classes/styles.selectors.js"); const styles_selectors_js_5 = require("../../../text-filter/styles.selectors.js"); class PropertyFilterWrapper extends autosuggest_1.default { findResultsCount() { return this.findByClassName(styles_selectors_js_5.default.results); } findTokens() { return this.findAllByClassName(FilteringTokenWrapper.rootSelector).map((elementWrapper) => new FilteringTokenWrapper(elementWrapper.getElement())); } /** * Returns the button that toggles if the tokens above `tokenLimit` are visible. */ findTokenToggle() { return this.findByClassName(styles_selectors_js_1.default.toggle); } /** * Returns the button that removes all current tokens. */ findRemoveAllButton() { return this.findByClassName(styles_selectors_js_3.default['remove-all']); } /** * Returns the element containing the `customControl` slot. */ findCustomControl() { return this.findByClassName(styles_selectors_js_3.default['custom-control']); } /** * Returns the element containing the `customFilterActions` slot. */ findCustomFilterActions() { return this.findByClassName(styles_selectors_js_3.default['custom-filter-actions']); } /** * Returns the element containing the `filteringConstraintText` slot. */ findConstraint() { return this.findByClassName(styles_selectors_js_3.default.constraint); } /** * Returns custom property form cancel button. * * @param options * * expandToViewport (boolean) - Use this when the component under test is rendered with an `expandToViewport` flag. */ findPropertyCancelButton(options = { expandToViewport: false }) { return this.findDropdown(options).findComponent(`.${styles_selectors_js_4.default['property-editor-cancel']}`, button_1.default); } /** * Returns custom property form submit button. * * @param options * * expandToViewport (boolean) - Use this when the component under test is rendered with an `expandToViewport` flag. */ findPropertySubmitButton(options = { expandToViewport: false }) { return this.findDropdown(options).findComponent(`.${styles_selectors_js_4.default['property-editor-submit']}`, button_1.default); } } PropertyFilterWrapper.rootSelector = styles_selectors_js_3.default.root; exports.default = PropertyFilterWrapper; class FilteringTokenWrapper extends selectors_1.ComponentWrapper { findLabel() { return this.findByClassName(styles_selectors_js_4.default['filtering-token-content']).findByClassName(styles_selectors_js_2.default.trigger); } findRemoveButton() { return this.findByClassName(styles_selectors_js_4.default['filtering-token-dismiss-button']); } findTokenOperation() { return this.findComponent(`.${styles_selectors_js_4.default['filtering-token-select']}`, select_1.default); } /** * Returns dropdown content of editing token if opened or `null` otherwise. */ findEditorDropdown(options = { expandToViewport: false }) { const root = options.expandToViewport ? (0, selectors_1.createWrapper)() : this; const popoverBody = root.findByClassName(styles_selectors_js_2.default.body); return popoverBody ? new PropertyFilterEditorDropdownWrapper(popoverBody.getElement()) : null; } findEditButton() { return this.findByClassName(styles_selectors_js_4.default['filtering-token-edit-button']); } findGroupTokens() { return this.findAllByClassName(styles_selectors_js_4.default['filtering-token-inner']).map(w => new FilteringGroupedTokenWrapper(w.getElement())); } } exports.FilteringTokenWrapper = FilteringTokenWrapper; FilteringTokenWrapper.rootSelector = styles_selectors_js_4.default['filtering-token']; class PropertyFilterEditorDropdownWrapper extends selectors_1.ComponentWrapper { findHeader() { return this.findByClassName(styles_selectors_js_2.default.header); } findDismissButton() { return this.findComponent(`.${styles_selectors_js_2.default['dismiss-control']}`, button_1.default); } findForm() { return this.findByClassName(styles_selectors_js_3.default['token-editor-form']); } findPropertyField(index = 1) { const dataIndex = `[data-testindex="${index - 1}"]`; return this.findComponent(`.${styles_selectors_js_4.default['token-editor-field-property']}${dataIndex}`, form_field_1.default); } findOperatorField(index = 1) { const dataIndex = `[data-testindex="${index - 1}"]`; return this.findComponent(`.${styles_selectors_js_4.default['token-editor-field-operator']}${dataIndex}`, form_field_1.default); } findValueField(index = 1) { const dataIndex = `[data-testindex="${index - 1}"]`; return this.findComponent(`.${styles_selectors_js_4.default['token-editor-field-value']}${dataIndex}`, form_field_1.default); } findTokenRemoveActions(index = 1) { const dataIndex = `[data-testindex="${index - 1}"]`; const buttonDropdown = this.find(`.${styles_selectors_js_4.default['token-editor-token-remove-actions']}${dataIndex}`); return buttonDropdown ? new button_dropdown_1.default(buttonDropdown.getElement()) : null; } findTokenAddActions() { const buttonDropdown = this.find(`.${styles_selectors_js_4.default['token-editor-token-add-actions']}`); return buttonDropdown ? new button_dropdown_1.default(buttonDropdown.getElement()) : null; } findCancelButton() { return this.findComponent(`.${styles_selectors_js_4.default['token-editor-cancel']}`, button_1.default); } findSubmitButton() { return this.findComponent(`.${styles_selectors_js_4.default['token-editor-submit']}`, button_1.default); } } exports.PropertyFilterEditorDropdownWrapper = PropertyFilterEditorDropdownWrapper; class FilteringGroupedTokenWrapper extends selectors_1.ComponentWrapper { findLabel() { return this.findByClassName(styles_selectors_js_4.default['filtering-token-inner-content']); } findRemoveButton() { return this.findByClassName(styles_selectors_js_4.default['filtering-token-inner-dismiss-button']); } findTokenOperation() { return this.findComponent(`.${styles_selectors_js_4.default['filtering-token-inner-select']}`, select_1.default); } } exports.FilteringGroupedTokenWrapper = FilteringGroupedTokenWrapper; FilteringGroupedTokenWrapper.rootSelector = styles_selectors_js_4.default['filtering-token-inner']; //# sourceMappingURL=index.js.map