Files
vault/ui/tests/acceptance/access/identity/_shared-alias-tests.js
Chelsea Shaw 52c0dc812b UI: Dependency bumps 1.17.x (#26346)
* re-form yarn.lock, remove resolutions that are out of date. resolves:

- mout VAULT-25595 VAULT-25603
- follow-redirects VAULT-25605
- terser VAULT-25594 VAULT-25593
- minimatch VAULT-25591
- loader-utils VAULT-25216 VAULT-25590 VAULT-25589 VAULT-25588 VAULT-25587
- decode-uri-component VAULT-25586
- qs VAULT-25585
- @xmldom/xmldom VAULT-25217

* VAULT-25596 pin async in resolutions due to testem > fireworm

* VAULT-25606 pin nth-check due to ember-svg-jar

* fix typescript errors after bump

* update ember-template-lint to 6.0.0

* Add broken rules to template-eslintrc

* pin ansi-html

* remove ember-d3 in favor of specific d3 libraries we import

* add changelog
2024-04-12 22:13:45 +00:00

122 lines
3.6 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { currentRouteName, find, settled, waitUntil } from '@ember/test-helpers';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
import page from 'vault/tests/pages/access/identity/aliases/add';
import aliasIndexPage from 'vault/tests/pages/access/identity/aliases/index';
import aliasShowPage from 'vault/tests/pages/access/identity/aliases/show';
import createItemPage from 'vault/tests/pages/access/identity/create';
export const testAliasCRUD = async function (name, itemType, assert) {
if (itemType === 'groups') {
await createItemPage.createItem(itemType, 'external');
await settled();
} else {
await createItemPage.createItem(itemType);
await settled();
}
const itemID = await waitUntil(
function () {
return find('[data-test-row-value="ID"]').textContent.trim();
},
{ timeout: 2000 }
);
await page.visit({ item_type: itemType, id: itemID });
await settled();
await page.editForm.name(name).submit();
await settled();
assert.ok(
aliasShowPage.flashMessage.latestMessage.startsWith('Successfully saved'),
`${itemType}: shows a flash message`
);
const aliasID = await waitUntil(
function () {
return find('[data-test-row-value="ID"]').textContent.trim();
},
{ timeout: 2000 }
);
assert.strictEqual(
currentRouteName(),
'vault.cluster.access.identity.aliases.show',
'navigates to the correct route'
);
assert.ok(aliasShowPage.nameContains(name), `${itemType}: renders the name on the show page`);
await aliasIndexPage.visit({ item_type: itemType });
await settled();
assert.strictEqual(
aliasIndexPage.items.filterBy('name', name).length,
1,
`${itemType}: lists the entity in the entity list`
);
const item = aliasIndexPage.items.filterBy('name', name)[0];
await item.menu();
await settled();
await aliasIndexPage.delete();
await settled();
await aliasIndexPage.confirmDelete();
await settled();
assert.dom(GENERAL.latestFlashContent).includesText(`Successfully deleted`);
assert.strictEqual(
aliasIndexPage.items.filterBy('id', aliasID).length,
0,
`${itemType}: the row is deleted`
);
};
export const testAliasDeleteFromForm = async function (name, itemType, assert) {
if (itemType === 'groups') {
await createItemPage.createItem(itemType, 'external');
await settled();
} else {
await createItemPage.createItem(itemType);
await settled();
}
const itemID = await waitUntil(
function () {
return find('[data-test-row-value="ID"]').textContent.trim();
},
{ timeout: 2000 }
);
await page.visit({ item_type: itemType, id: itemID });
await settled();
await page.editForm.name(name).submit();
await settled();
const aliasID = await waitUntil(
function () {
return find('[data-test-row-value="ID"]').textContent.trim();
},
{ timeout: 2000 }
);
await aliasShowPage.edit();
await settled();
assert.strictEqual(
currentRouteName(),
'vault.cluster.access.identity.aliases.edit',
`${itemType}: navigates to edit on create`
);
await page.editForm.delete();
await page.editForm.waitForConfirm();
await page.editForm.confirmDelete();
await settled();
assert.dom(GENERAL.latestFlashContent).includesText(`Successfully deleted`);
assert.strictEqual(
currentRouteName(),
'vault.cluster.access.identity.aliases.index',
`${itemType}: navigates to list page on delete`
);
assert.strictEqual(
aliasIndexPage.items.filterBy('id', aliasID).length,
0,
`${itemType}: the row does not show in the list`
);
};