Repository: hashicorp/vault
File: ui/tests/acceptance/config-ui/login-settings-test.js (JavaScript)

Code before:
    // Visit the login settings list index page
    await visit('vault/config-ui/login-settings');

    // verify fetched rules are rendered in list
    assert.dom('.linked-block-item').exists({ count: 2 });
  });

  test('delete rule from list view', async function (assert) {
    // Visit the login settings list index page
    await visit('vault/config-ui/login-settings');

    await click(GENERAL.menuTrigger);
    await click(GENERAL.menuItem('delete-rule'));

    assert.dom(GENERAL.confirmationModal).exists();
    await click(GENERAL.confirmButton);

    // verify success message from deletion
    assert.dom(GENERAL.latestFlashContent).includesText('Successfully deleted rule testRule.');
  });

  test('navigate to rule details page and renders rule data', async function (assert) {
    // visit individual rule page
    await visit('vault/config-ui/login-settings');

    await click(GENERAL.menuTrigger);
    await click(GENERAL.menuItem('view-rule'));

    // verify that user is redirected to the rule details page
    assert.strictEqual(
      currentRouteName(),
      'vault.cluster.config-ui.login-settings.rule.details',
      'goes to rule details page'
    );

    // verify fetched rule data is rendered
    assert.dom(GENERAL.infoRowLabel('Name')).exists();
    assert.dom(GENERAL.infoRowValue('Name')).hasText('testRule');
    assert.dom(GENERAL.infoRowLabel('Namespace')).exists();
    assert.dom(GENERAL.infoRowValue('Namespace')).hasText('ns1/');
  });
});


Review comment (suggestion):
normally I'd say this would be best as an integration test since we're just testing display logic, but this test is small enough I think it's okay to leave as is. Acceptance tests are really best for navigation (anything with routing) assertions and/or complex functionality. 

Code after:
    // Visit the login settings list index page
    await visit('vault/config-ui/login-settings');

    // verify fetched rules are rendered in list
    assert.dom('.linked-block-item').exists({ count: 2 });
    // verify rule data namespaces render
    assert.dom('[data-test-rule-path="ns1/"]').exists();
    assert.dom('[data-test-rule-path="ns2/"]').exists();
  });

  test('delete rule from list view', async function (assert) {
    // Visit the login settings list index page
    await visit('vault/config-ui/login-settings');

    await click(GENERAL.menuTrigger);
    await click(GENERAL.menuItem('delete-rule'));

    assert.dom(GENERAL.confirmationModal).exists();
    await click(GENERAL.confirmButton);

    // verify success message from deletion
    assert.dom(GENERAL.latestFlashContent).includesText('Successfully deleted rule testRule.');
    assert.dom('[data-test-rule-name="testRule"]').doesNotExist();
  });

  test('navigate to rule details page and renders rule data', async function (assert) {
    // visit individual rule page
    await visit('vault/config-ui/login-settings');

    await click(GENERAL.menuTrigger);
    await click(GENERAL.menuItem('view-rule'));

    // verify that user is redirected to the rule details page
    assert.strictEqual(
      currentRouteName(),
      'vault.cluster.config-ui.login-settings.rule.details',
      'goes to rule details page'
    );

    // verify fetched rule data is rendered
    assert.dom(GENERAL.infoRowValue('Name')).hasText('testRule');
    assert.dom(GENERAL.infoRowValue('Namespace')).hasText('ns1/');
    assert.dom(GENERAL.infoRowValue('Backup methods')).hasText('userpass');
    assert.dom(GENERAL.infoRowValue('Inheritance')).hasText('true');
  });
});