github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/tests/pages/components/facet.js (about)

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