{"version":3,"file":"testing.mjs","sources":["../../../../../../../src/material/stepper/testing/step-harness.ts","../../../../../../../src/material/stepper/testing/stepper-harness.ts","../../../../../../../src/material/stepper/testing/stepper-button-harnesses.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {\n ContentContainerComponentHarness,\n HarnessPredicate,\n HarnessLoader,\n} from '@angular/cdk/testing';\nimport {StepHarnessFilters} from './step-harness-filters';\n\n/** Harness for interacting with a standard Angular Material step in tests. */\nexport class MatStepHarness extends ContentContainerComponentHarness {\n /** The selector for the host element of a `MatStep` instance. */\n static hostSelector = '.mat-step-header';\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a `MatStepHarness` that meets\n * certain criteria.\n * @param options Options for filtering which steps are considered a match.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with(options: StepHarnessFilters = {}): HarnessPredicate {\n return new HarnessPredicate(MatStepHarness, options)\n .addOption('label', options.label, (harness, label) =>\n HarnessPredicate.stringMatches(harness.getLabel(), label),\n )\n .addOption(\n 'selected',\n options.selected,\n async (harness, selected) => (await harness.isSelected()) === selected,\n )\n .addOption(\n 'completed',\n options.completed,\n async (harness, completed) => (await harness.isCompleted()) === completed,\n )\n .addOption(\n 'invalid',\n options.invalid,\n async (harness, invalid) => (await harness.hasErrors()) === invalid,\n );\n }\n\n /** Gets the label of the step. */\n async getLabel(): Promise {\n return (await this.locatorFor('.mat-step-text-label')()).text();\n }\n\n /** Gets the `aria-label` of the step. */\n async getAriaLabel(): Promise {\n return (await this.host()).getAttribute('aria-label');\n }\n\n /** Gets the value of the `aria-labelledby` attribute. */\n async getAriaLabelledby(): Promise {\n return (await this.host()).getAttribute('aria-labelledby');\n }\n\n /** Whether the step is selected. */\n async isSelected(): Promise {\n const host = await this.host();\n return (await host.getAttribute('aria-selected')) === 'true';\n }\n\n /** Whether the step has been filled out. */\n async isCompleted(): Promise {\n const state = await this._getIconState();\n return state === 'done' || (state === 'edit' && !(await this.isSelected()));\n }\n\n /**\n * Whether the step is currently showing its error state. Note that this doesn't mean that there\n * are or aren't any invalid form controls inside the step, but that the step is showing its\n * error-specific styling which depends on there being invalid controls, as well as the\n * `ErrorStateMatcher` determining that an error should be shown and that the `showErrors`\n * option was enabled through the `STEPPER_GLOBAL_OPTIONS` injection token.\n */\n async hasErrors(): Promise {\n return (await this._getIconState()) === 'error';\n }\n\n /** Whether the step is optional. */\n async isOptional(): Promise {\n // If the node with the optional text is present, it means that the step is optional.\n const optionalNode = await this.locatorForOptional('.mat-step-optional')();\n return !!optionalNode;\n }\n\n /**\n * Selects the given step by clicking on the label. The step may not be selected\n * if the stepper doesn't allow it (e.g. if there are validation errors).\n */\n async select(): Promise {\n await (await this.host()).click();\n }\n\n protected override async getRootHarnessLoader(): Promise {\n const contentId = await (await this.host()).getAttribute('aria-controls');\n return this.documentRootLocatorFactory().harnessLoaderFor(`#${contentId}`);\n }\n\n /**\n * Gets the state of the step. Note that we have a `StepState` which we could use to type the\n * return value, but it's basically the same as `string`, because the type has `| string`.\n */\n private async _getIconState(): Promise {\n // The state is exposed on the icon with a class that looks like `mat-step-icon-state-{{state}}`\n const icon = await this.locatorFor('.mat-step-icon')();\n const classes = (await icon.getAttribute('class'))!;\n const match = classes.match(/mat-step-icon-state-([a-z]+)/);\n\n if (!match) {\n throw Error(`Could not determine step state from \"${classes}\".`);\n }\n\n return match[1];\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {ComponentHarness, HarnessPredicate} from '@angular/cdk/testing';\nimport {MatStepHarness} from './step-harness';\nimport {\n StepperHarnessFilters,\n StepHarnessFilters,\n StepperOrientation,\n} from './step-harness-filters';\n\n/** Harness for interacting with a standard Material stepper in tests. */\nexport class MatStepperHarness extends ComponentHarness {\n /** The selector for the host element of a `MatStepper` instance. */\n static hostSelector = '.mat-stepper-horizontal, .mat-stepper-vertical';\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a `MatStepperHarness` that meets\n * certain criteria.\n * @param options Options for filtering which stepper instances are considered a match.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with(options: StepperHarnessFilters = {}): HarnessPredicate {\n return new HarnessPredicate(MatStepperHarness, options).addOption(\n 'orientation',\n options.orientation,\n async (harness, orientation) => (await harness.getOrientation()) === orientation,\n );\n }\n\n /**\n * Gets the list of steps in the stepper.\n * @param filter Optionally filters which steps are included.\n */\n async getSteps(filter: StepHarnessFilters = {}): Promise {\n return this.locatorForAll(MatStepHarness.with(filter))();\n }\n\n /** Gets the orientation of the stepper. */\n async getOrientation(): Promise {\n const host = await this.host();\n return (await host.hasClass('mat-stepper-horizontal'))\n ? StepperOrientation.HORIZONTAL\n : StepperOrientation.VERTICAL;\n }\n\n /**\n * Selects a step in this stepper.\n * @param filter An optional filter to apply to the child steps. The first step matching the\n * filter will be selected.\n */\n async selectStep(filter: StepHarnessFilters = {}): Promise {\n const steps = await this.getSteps(filter);\n if (!steps.length) {\n throw Error(`Cannot find mat-step matching filter ${JSON.stringify(filter)}`);\n }\n await steps[0].select();\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {ComponentHarness, HarnessPredicate} from '@angular/cdk/testing';\nimport {StepperButtonHarnessFilters} from './step-harness-filters';\n\n/** Base class for stepper button harnesses. */\nabstract class StepperButtonHarness extends ComponentHarness {\n /** Gets the text of the button. */\n async getText(): Promise {\n return (await this.host()).text();\n }\n\n /** Clicks the button. */\n async click(): Promise {\n return (await this.host()).click();\n }\n}\n\n/** Harness for interacting with a standard Angular Material stepper next button in tests. */\nexport class MatStepperNextHarness extends StepperButtonHarness {\n /** The selector for the host element of a `MatStep` instance. */\n static hostSelector = '.mat-stepper-next';\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a `MatStepperNextHarness` that meets\n * certain criteria.\n * @param options Options for filtering which steps are considered a match.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with(options: StepperButtonHarnessFilters = {}): HarnessPredicate {\n return new HarnessPredicate(MatStepperNextHarness, options).addOption(\n 'text',\n options.text,\n (harness, text) => HarnessPredicate.stringMatches(harness.getText(), text),\n );\n }\n}\n\n/** Harness for interacting with a standard Angular Material stepper previous button in tests. */\nexport class MatStepperPreviousHarness extends StepperButtonHarness {\n /** The selector for the host element of a `MatStep` instance. */\n static hostSelector = '.mat-stepper-previous';\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a `MatStepperPreviousHarness`\n * that meets certain criteria.\n * @param options Options for filtering which steps are considered a match.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with(\n options: StepperButtonHarnessFilters = {},\n ): HarnessPredicate {\n return new HarnessPredicate(MatStepperPreviousHarness, options).addOption(\n 'text',\n options.text,\n (harness, text) => HarnessPredicate.stringMatches(harness.getText(), text),\n );\n }\n}\n"],"names":[],"mappings":";;AAeA;AACM,MAAO,cAAe,SAAQ,gCAAwC,CAAA;;aAEnE,IAAY,CAAA,YAAA,GAAG,kBAAkB,CAAC,EAAA;AAEzC;;;;;AAKG;AACH,IAAA,OAAO,IAAI,CAAC,OAAA,GAA8B,EAAE,EAAA;AAC1C,QAAA,OAAO,IAAI,gBAAgB,CAAC,cAAc,EAAE,OAAO,CAAC;aACjD,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,KAChD,gBAAgB,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,CAC1D;aACA,SAAS,CACR,UAAU,EACV,OAAO,CAAC,QAAQ,EAChB,OAAO,OAAO,EAAE,QAAQ,KAAK,CAAC,MAAM,OAAO,CAAC,UAAU,EAAE,MAAM,QAAQ,CACvE;aACA,SAAS,CACR,WAAW,EACX,O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