github.com/hernad/nomad@v1.6.112/ui/tests/pages/components/facet.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  import { clickable, collection, text, attribute } from 'ember-cli-page-object';
     7  import {
     8    selectChoose,
     9    clickTrigger,
    10  } from 'ember-power-select/test-support/helpers';
    11  
    12  export const multiFacet = (scope) => ({
    13    scope,
    14  
    15    toggle: clickable('[data-test-dropdown-trigger]'),
    16  
    17    options: collection('[data-test-dropdown-option]', {
    18      testContainer: '#ember-testing .ember-basic-dropdown-content',
    19      resetScope: true,
    20      label: text(),
    21      key: attribute('data-test-dropdown-option'),
    22      toggle: clickable('label'),
    23    }),
    24  });
    25  
    26  export const singleFacet = (scope) => ({
    27    scope,
    28  
    29    async toggle() {
    30      await clickTrigger(this.scope);
    31    },
    32  
    33    options: collection('.ember-power-select-option', {
    34      testContainer: '#ember-testing .ember-basic-dropdown-content',
    35      resetScope: true,
    36      label: text('[data-test-dropdown-option]'),
    37      key: attribute('data-test-dropdown-option', '[data-test-dropdown-option]'),
    38      async select() {
    39        // __parentTreeNode is clearly meant to be private in the page object API,
    40        // but it seems better to use that and keep the API symmetry across singleFacet
    41        // and multiFacet compared to moving select to the parent.
    42        const parentScope = this.__parentTreeNode.scope;
    43        await selectChoose(parentScope, this.label);
    44      },
    45    }),
    46  });