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

Code before:
    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;
    await click(refreshListButton);
    assert.true(
      refreshNetworkRequestTriggered,
      'Get namespaces network request was made when refresh button was clicked'
    );
  });

  test('it should show button to create new namespace', async function (assert) {
    await visit('/vault/access/namespaces');
    const createNamespaceButton = 'nav.toolbar-actions a.toolbar-link';
    assert
      .dom(createNamespaceButton)
      .hasText('Create namespace', 'Create namespace button is rendered correctly');
    assert
      .dom(createNamespaceButton)
      .hasAttribute(
        'href',
        '/ui/vault/access/namespaces/create',
        'Create namespace button has the correct href attribute'
      );
  });

  test('it should filter namespaces based on search input', async function (assert) {

Review comment (suggestion):
```suggestion
    assert.dom(GENERAL.testButton("refresh-namespace-list")).hasText('Refresh list', 'Refresh button is rendered correctly');
```

Code after:
    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');

    refreshNetworkRequestTriggered = false;
    await click(refreshNamespaceButton);
    assert.true(
      refreshNetworkRequestTriggered,
      'Get namespaces network request was made when refresh button was clicked'
    );
  });

  test('it should show button to create new namespace', async function (assert) {
    const createNamespaceLink = GENERAL.linkTo('create-namespace');

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

    assert
      .dom(createNamespaceLink)
      .hasText('Create namespace', 'Create namespace button is rendered correctly');
    assert
      .dom(createNamespaceLink)
      .hasAttribute(
        'href',
        '/ui/vault/access/namespaces/create',
        'Create namespace button has the correct href attribute'
      );