Repository: hashicorp/vault
File: ui/tests/acceptance/secrets/backend/engines-test.js (JavaScript)

Code before:

    await runCmd(mountEngineCmd('kv', enginePath1));
    await runCmd(mountEngineCmd('kv-v2', enginePath2));

    // check kv1
    await visit('/vault/secrets');
    await click(SELECTORS.backendLink(enginePath1));
    for (let i = 0; i <= 15; i++) {
      await createSecret(`secret-${i}`, 'foo', 'bar', enginePath1);
    }

    // navigate and check that details view is shown from non-nested secrets
    await click(GENERAL.pagination.next);
    assert.strictEqual(
      currentURL(),
      `/vault/secrets/${enginePath1}/list?page=2`,
      'After clicking next page in navigates to the second page.'
    );
    await click(SECRET_ENGINE_SELECTORS.secretLink(secretPath));
    assert.strictEqual(
      currentURL(),
      `/vault/secrets/${enginePath1}/show/${secretPath}`,
      'After clicking a non-nested secret, it navigates to the details view.'
    );

    // check kv2 as it follows a different pattern
    await visit('/vault/secrets');
    await click(SELECTORS.backendLink(enginePath2));
    await createKVV2Secret(`secret-test`, 'foo', 'bar');
    for (let i = 0; i <= 15; i++) {
      await createKVV2Secret(`secret-${i}`, 'foo', 'bar');
    }

    // navigate and check that details view is shown from non-nested secrets
    await click(GENERAL.pagination.next);
    assert.strictEqual(
      currentURL(),
      `/vault/secrets/${enginePath2}/kv/list?page=2`,
      'After clicking next page in navigates to the second page.'
    );

    await click(PAGE.list.item('secret-9'));

    assert.strictEqual(
      currentURL(),
      `/vault/secrets/${enginePath2}/kv/secret-9`,
      'After clicking a non-nested secret, it navigates to the details view.'
    );

    // cleanup
    await runCmd(deleteEngineCmd(enginePath1));

Review comment (bug):
I might have steered you wrong here, apologies. There is no need to test KVv2 here as it doesn't use the same route and this test file is just for this generic route (cubbyhole and KVv1 are the main engines of relevance here). All KVv2 things can be deleted, non of the code we touched should impact KVv2.

Code after:
    await click(GENERAL.pagination.next);
    assert.strictEqual(
      currentURL(),
      `/vault/secrets/${enginePath1}/list?page=2`,
      'After clicking next page in navigates to the second page.'
    );
    await click(SECRET_ENGINE_SELECTORS.secretLink(secretPath));
    assert.strictEqual(
      currentURL(),
      `/vault/secrets/${enginePath1}/show/${secretPath}`,
      'After clicking a non-nested secret, it navigates to the details view.'
    );

    // cleanup
    await runCmd(deleteEngineCmd(enginePath1));
  });

  test('it allows navigation to a nested secret with pagination', async function (assert) {
    assert.expect(2);

    const enginePath1 = `kv-v1-${this.uid}`;
    const parentPath = 'nested';

    await runCmd(mountEngineCmd('kv', enginePath1));

    // check kv1
    await visit('/vault/secrets');
    await click(SELECTORS.backendLink(enginePath1));
    for (let i = 0; i <= 15; i++) {
      await createSecret(`${parentPath}/secret-${i}`, 'foo', 'bar', enginePath1);
    }

    // navigate and check that the children list view is shown from nested secrets
    await click(SECRET_ENGINE_SELECTORS.secretLink(`${parentPath}/`));

    assert.strictEqual(
      currentURL(),
      `/vault/secrets/${enginePath1}/list/${parentPath}/`,
      'After clicking a nested secret it navigates to the children list view.'
    );

    await click(GENERAL.pagination.next);
    assert.strictEqual(
      currentURL(),
      `/vault/secrets/${enginePath1}/list/${parentPath}/?page=2`,
      'After clicking next page it navigates to the second page.'
    );

    // cleanup
    await runCmd(deleteEngineCmd(enginePath1));
  });