Repository: hashicorp/vault
File: ui/tests/acceptance/mfa-method-test.js (JavaScript)

Code before:
      currentRouteName(),
      'vault.cluster.access.mfa.methods.method.index',
      'Details more menu action transitions to method route'
    );
    await click('.hds-breadcrumb a');
    await click('[data-test-popup-menu-trigger]');
    await click('[data-test-mfa-method-menu-link="edit"]');
    assert.strictEqual(
      currentRouteName(),
      'vault.cluster.access.mfa.methods.method.edit',
      'Edit more menu action transitions to method edit route'
    );
  });

  test('it should display an empty namespace', async function (assert) {
    await visit('/vault/access/mfa');
    const methods = this.getMethods();
    const model = this.store.peekRecord('mfa-method', methods[1].id);
    assert.strictEqual(model.namespace_path, undefined, 'Namespace path is unset');
    assert
      .dom(`[data-test-mfa-method-list-item="${model.id}"]`)
      .includesText(
        `${model.name} ${model.id} Namespace:`,
        'Copy renders for list item without namespace path'
      );
  });

  test('it should display method details', async function (assert) {
    // ensure methods are tied to an enforcement
    this.server.get('/identity/mfa/login-enforcement', () => {
      const record = this.server.create('mfa-login-enforcement', {
        mfa_method_ids: this.getMethods().map((m) => m.id),
      });
      return {
        data: {
          key_info: { [record.name]: record },
          keys: [record.name],
        },
      };
    });
    await visit('/vault/access/mfa/methods');
    await click('[data-test-mfa-method-list-item]');
    assert.dom('[data-test-tab="config"]').hasClass('active', 'Configuration tab is active by default');
    await click('[data-test-delete-mfa-config]');

    assert
      .dom('[data-test-confirm-action-message]')
      .hasText(
        "This method cannot be deleted until its enforcements are deleted. This can be done from the 'Enforcements' tab."
      );


Review comment (suggestion):
Sorry if I was unclear! I think we should fix the template and wrap it in a conditional so that namespace _does not_ show when there's no namespace 

Code after:
      currentRouteName(),
      'vault.cluster.access.mfa.methods.method.index',
      'Details more menu action transitions to method route'
    );
    await click('.hds-breadcrumb a');
    await click('[data-test-popup-menu-trigger]');
    await click('[data-test-mfa-method-menu-link="edit"]');
    assert.strictEqual(
      currentRouteName(),
      'vault.cluster.access.mfa.methods.method.edit',
      'Edit more menu action transitions to method edit route'
    );
  });

  test('it should not display for the root namespace', async function (assert) {
    await visit('/vault/access/mfa');
    const methods = this.getMethods();
    const duoModel = this.store.peekRecord('mfa-method', methods[1].id);
    assert.strictEqual(duoModel.namespace_path, '', 'Namespace path is unset');
    assert
      .dom(`[data-test-mfa-method-list-item="${duoModel.id}"]`)
      .includesText(`${duoModel.name} ${duoModel.id}`, 'Copy renders for list item without namespace path')
      .doesNotContainText('Namespace:', 'Does not include the namespace label');
  });

  test('it should display method details', async function (assert) {
    // ensure methods are tied to an enforcement
    this.server.get('/identity/mfa/login-enforcement', () => {
      const record = this.server.create('mfa-login-enforcement', {
        mfa_method_ids: this.getMethods().map((m) => m.id),
      });
      return {
        data: {
          key_info: { [record.name]: record },
          keys: [record.name],
        },
      };
    });
    await visit('/vault/access/mfa/methods');
    await click('[data-test-mfa-method-list-item]');
    assert.dom('[data-test-tab="config"]').hasClass('active', 'Configuration tab is active by default');
    await click('[data-test-delete-mfa-config]');

    assert
      .dom('[data-test-confirm-action-message]')
      .hasText(
        "This method cannot be deleted until its enforcements are deleted. This can be done from the 'Enforcements' tab."
      );

    const fields = [
      ['Issuer', 'Period', 'Key size', 'QR size', 'Algorithm', 'Digits', 'Skew', 'Max validation attempts'],