Repository: hashicorp/vault
File: ui/tests/acceptance/access/namespaces/index-test.js (JavaScript)

Code before:

module('Acceptance | Enterprise | /access/namespaces', function (hooks) {
  setupApplicationTest(hooks);
  setupMirage(hooks);

  const searchInput = GENERAL.filterInputExplicit;
  const searchButton = GENERAL.filterInputExplicitSearch;

  hooks.beforeEach(function () {
    return login();
  });

  test('it navigates to namespaces page', async function (assert) {
    assert.expect(1);
    await visit('/vault/access/namespaces');
    assert.strictEqual(
      currentRouteName(),
      'vault.cluster.access.namespaces.index',
      'navigates to the correct route'
    );
  });

  test('it displays the breadcrumb trail', async function (assert) {
    await visit('/vault/access/namespaces');
    assert.dom('.hds-breadcrumb__text').exists({ count: 1 }, 'Only one breadcrumb is displayed');
    assert.dom('.hds-breadcrumb__text').hasText('Namespaces', 'Breadcrumb trail is displayed correctly');
  });

  test('it should render correct number of namespaces', async function (assert) {
    assert.expect(3);
    await visit('/vault/access/namespaces');
    const store = this.owner.lookup('service:store');
    // Default page size is 15
    assert.strictEqual(store.peekAll('namespace').length, 15, 'Store has 15 namespaces records');
    assert.dom('.list-item-row').exists({ count: 15 }, 'Should display 15 namespaces');
    assert.dom('.hds-pagination').exists();
  });

  test('it should show button to refresh namespace list', async function (assert) {
    let refreshNetworkRequestTriggered;

    this.server.get('/sys/internal/ui/namespaces', () => {
      refreshNetworkRequestTriggered = true;
      return;
    });

    await visit('/vault/access/namespaces');
    const refreshListButton = 'nav.toolbar-actions .hds-button';
    assert.dom(refreshListButton).hasText('Refresh list', 'Refresh button is rendered correctly');

    refreshNetworkRequestTriggered = false;

Review comment (suggestion):
```suggestion
    assert.dom(GENERAL.breadcrumb).exists({ count: 1 }, 'Only one breadcrumb is displayed');
    assert.dom(GENERAL.breadcrumbText("namespaces")).hasText('Namespaces', 'Breadcrumb trail is displayed correctly');
```

Code after:

module('Acceptance | Enterprise | /access/namespaces', function (hooks) {
  setupApplicationTest(hooks);
  setupMirage(hooks);

  const searchInput = GENERAL.filterInputExplicit;
  const searchButton = GENERAL.filterInputExplicitSearch;

  hooks.beforeEach(function () {
    return login();
  });

  test('it navigates to namespaces page', async function (assert) {
    assert.expect(1);
    await visit('/vault/access/namespaces');
    assert.strictEqual(
      currentRouteName(),
      'vault.cluster.access.namespaces.index',
      'navigates to the correct route'
    );
  });

  test('it displays the breadcrumb trail', async function (assert) {
    await visit('/vault/access/namespaces');
    assert.dom(GENERAL.breadcrumb).exists({ count: 1 }, 'Only one breadcrumb is displayed');
    assert.dom(GENERAL.breadcrumb).hasText('Namespaces', 'Breadcrumb trail is displayed correctly');
  });

  test('it should render correct number of namespaces', async function (assert) {
    assert.expect(3);
    await visit('/vault/access/namespaces');
    const store = this.owner.lookup('service:store');
    // Default page size is 15
    assert.strictEqual(store.peekAll('namespace').length, 15, 'Store has 15 namespaces records');
    assert.dom('.list-item-row').exists({ count: 15 }, 'Should display 15 namespaces');
    assert.dom('.hds-pagination').exists();
  });

  test('it should show button to refresh namespace list', async function (assert) {
    let refreshNetworkRequestTriggered;
    const refreshNamespaceButton = GENERAL.testButton('refresh-namespace-list');

    this.server.get('/sys/internal/ui/namespaces', () => {
      refreshNetworkRequestTriggered = true;
      return;
    });

    await visit('/vault/access/namespaces');

    assert.dom(refreshNamespaceButton).hasText('Refresh list', 'Refresh button is rendered correctly');