Repository: hashicorp/vault
File: ui/tests/acceptance/secret-engine-list-view-test.js (JavaScript)

Code before:
    await visit('/vault/secrets');

    await page.enableEngine();
    await click(MOUNT_BACKEND_FORM.mountType('kv'));
    await fillIn(GENERAL.inputByAttr('path'), `kv-${this.uid}`);
    await click(GENERAL.submitButton);
    await click(GENERAL.breadcrumbLink('Secrets'));

    await selectChoose(GENERAL.searchSelect.trigger('filter-by-engine-name'), `kv-${this.uid}`);
    await triggerEvent('.hds-tooltip-button', 'mouseenter');
    assert.dom('.hds-tooltip-container').hasText('KV version 2', 'shows tooltip for kv version 2');

    // cleanup
    await runCmd(deleteEngineCmd('kv'));
  });

  test('enterprise: cannot view list without permissions inside namespace', async function (assert) {
    this.version = 'enterprise';
    this.backend = `bk-${this.uid}`;
    this.namespace = `ns-${this.uid}`;
    await runCmd([`write sys/namespaces/${this.namespace} -force`]);
    await loginNs(this.namespace, ' ');

    await visit('/vault/secrets');
    assert.dom(SES.secretsBackendLink('cubbyhole')).doesNotExist();

    await logout();
  });

  test('enterprise: can view list with permissions inside namespace', async function (assert) {
    this.version = 'enterprise';
    this.backend = `bk-${this.uid}`;
    this.namespace = `ns-${this.uid}`;
    await runCmd([`write sys/namespaces/${this.namespace} -force`]);
    await loginNs(this.namespace);
    await visit('/vault/secrets');

    assert.dom(SES.secretsBackendLink('cubbyhole')).exists();
  });

  test('after disabling it stays on the list view', async function (assert) {
    // first mount an engine so we can disable it.
    const enginePath = `alicloud-disable-${this.uid}`;
    await runCmd(mountEngineCmd('alicloud', enginePath));
    await visit('/vault/secrets');
    // to reduce flakiness, searching by engine name first in case there are pagination issues
    await selectChoose(GENERAL.searchSelect.trigger('filter-by-engine-name'), enginePath);
    assert.dom(SES.secretsBackendLink(enginePath)).exists('the alicloud engine is mounted');

    await click(GENERAL.menuTrigger);
    await click(GENERAL.menuItem('disable-engine'));

Review comment (suggestion):
No need to change, but I think it makes a little more sense to say "creates a token with a default policy" 

Code after:

    // cleanup
    await runCmd(deleteEngineCmd('ssh'));
  });

  test('hovering over the icon of a kv engine shows engine name and version', async function (assert) {
    await visit('/vault/secrets');

    await page.enableEngine();
    await click(MOUNT_BACKEND_FORM.mountType('kv'));
    await fillIn(GENERAL.inputByAttr('path'), `kv-${this.uid}`);
    await click(GENERAL.submitButton);
    await click(GENERAL.breadcrumbLink('Secrets'));

    await selectChoose(GENERAL.searchSelect.trigger('filter-by-engine-name'), `kv-${this.uid}`);
    await triggerEvent('.hds-tooltip-button', 'mouseenter');
    assert.dom('.hds-tooltip-container').hasText('KV version 2', 'shows tooltip for kv version 2');

    // cleanup
    await runCmd(deleteEngineCmd('kv'));
  });

  test('enterprise: cannot view list without permissions inside a namespace', async function (assert) {
    this.namespace = `ns-${this.uid}`;
    const enginePath1 = `kv-t1-${this.uid}`;
    const userDefault = await runCmd(createTokenCmd()); // creates a default user token

    await runCmd([`write sys/namespaces/${this.namespace} -force`]); // creates a namespace
    await loginNs(this.namespace); //logs into namespace with root token
    await runCmd(mountEngineCmd('kv', enginePath1)); // mounts a kv engine in namespace

    await loginNs(this.namespace, userDefault); // logs into that same namespace with a default user token

    await visit(`/vault/secrets?namespace=${this.namespace}`); // nav to specified namespace list
    assert.strictEqual(
      currentURL(),
      `/vault/secrets?namespace=${this.namespace}`,
      'Should be on main secret engines list page within namespace.'
    );
    assert.dom(SES.secretsBackendLink(enginePath1)).doesNotExist(); // without permissions, engine should not show for this user

    // cleanup namespace
    await login();
    await runCmd(`delete sys/namespaces/${this.namespace}`);
  });

  test('enterprise: can view list with permissions inside a namespace', async function (assert) {
    this.namespace = `ns-${this.uid}`;
    const enginePath1 = `kv-t2-${this.uid}`;
    const userToken = await runCmd(
      tokenWithPolicyCmd(