github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/tests/acceptance/job-services-test.js (about)

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