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

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  import {
     7    attribute,
     8    collection,
     9    clickable,
    10    isPresent,
    11    text,
    12  } from 'ember-cli-page-object';
    13  import { singularize } from 'ember-inflector';
    14  
    15  export default function (
    16    selector = '[data-test-allocation]',
    17    propKey = 'allocations'
    18  ) {
    19    const lookupKey = `${singularize(propKey)}For`;
    20    // Remove the bracket notation
    21    const attr = selector.substring(1, selector.length - 1);
    22  
    23    return {
    24      [propKey]: collection(selector, {
    25        id: attribute(attr),
    26        shortId: text('[data-test-short-id]'),
    27        createTime: text('[data-test-create-time]'),
    28        createTooltip: attribute(
    29          'aria-label',
    30          '[data-test-create-time] .tooltip'
    31        ),
    32        modifyTime: text('[data-test-modify-time]'),
    33        health: text('[data-test-health]'),
    34        status: text('[data-test-client-status]'),
    35        job: text('[data-test-job]'),
    36        taskGroup: text('[data-test-task-group]'),
    37        client: text('[data-test-client]'),
    38        clientTooltip: attribute('aria-label', '[data-test-client] .tooltip'),
    39        jobVersion: text('[data-test-job-version]'),
    40        volume: text('[data-test-volume]'),
    41        cpu: text('[data-test-cpu]'),
    42        cpuTooltip: attribute('aria-label', '[data-test-cpu] .tooltip'),
    43        mem: text('[data-test-mem]'),
    44        memTooltip: attribute('aria-label', '[data-test-mem] .tooltip'),
    45        rescheduled: isPresent(
    46          '[data-test-indicators] [data-test-icon="reschedule"]'
    47        ),
    48  
    49        visit: clickable('[data-test-short-id] a'),
    50        visitRow: clickable(),
    51        visitJob: clickable('[data-test-job]'),
    52        visitClient: clickable('[data-test-client] a'),
    53      }),
    54  
    55      [lookupKey]: function (id) {
    56        return this[propKey].toArray().find((allocation) => allocation.id === id);
    57      },
    58    };
    59  }