github.com/hernad/nomad@v1.6.112/ui/tests/acceptance/job-services-test.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  import { module, test } from 'qunit';
     7  import { find, findAll, currentURL, settled } from '@ember/test-helpers';
     8  import { setupApplicationTest } from 'ember-qunit';
     9  import { setupMirage } from 'ember-cli-mirage/test-support';
    10  import { allScenarios } from '../../mirage/scenarios/default';
    11  
    12  import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
    13  import Services from 'nomad-ui/tests/pages/jobs/job/services';
    14  
    15  module('Acceptance | job services', function (hooks) {
    16    setupApplicationTest(hooks);
    17    setupMirage(hooks);
    18    hooks.beforeEach(async function () {
    19      allScenarios.servicesTestCluster(server);
    20      await Services.visit({ id: 'service-haver@default' });
    21    });
    22  
    23    test('Visiting job services', async function (assert) {
    24      assert.expect(3);
    25      assert.dom('.tabs.is-subnav a.is-active').hasText('Services');
    26      assert.dom('.service-list table').exists();
    27      await a11yAudit(assert);
    28    });
    29  
    30    test('it shows both consul and nomad, and both task and group services', async function (assert) {
    31      assert.dom('table tr[data-test-service-provider="consul"]').exists();
    32      assert.dom('table tr[data-test-service-provider="nomad"]').exists();
    33      assert.dom('table tr[data-test-service-level="task"]').exists();
    34      assert.dom('table tr[data-test-service-level="group"]').exists();
    35    });
    36  
    37    test('Digging into a service', async function (assert) {
    38      const expectedNumAllocs = find(
    39        '[data-test-service-level="group"]'
    40      ).getAttribute('data-test-num-allocs');
    41      const serviceName = find(
    42        '[data-test-service-level="group"][data-test-service-provider="nomad"]'
    43      ).getAttribute('data-test-service-name');
    44  
    45      await find(
    46        '[data-test-service-level="group"][data-test-service-provider="nomad"] a'
    47      ).click();
    48      await settled();
    49  
    50      assert.ok(
    51        currentURL().includes(`services/${serviceName}?level=group`),
    52        'correctly traverses to a service instance list'
    53      );
    54  
    55      assert.equal(
    56        findAll('tr[data-test-service-row]').length,
    57        expectedNumAllocs,
    58        'Same number of alloc rows as the index shows'
    59      );
    60    });
    61  });