+1





![hashicorp-copywrite[bot]](/avatar/120e964899bc27ee3737fc0cc3585755e19422fe9bff82b60b4b0c13d481706c?size=40)

![dependabot[bot]](/avatar/bd5a8d6c673b738d52b0ac42a110045f3f964b3ebfc1d60ea805af743b1dc0e6?size=40)
2d5323b07a
* fix: 🐛 add model hook to host route for dynamic host catalogs (#1659) * fix: 🐛 add model hook to host route for dynamic host catalogs ✅ Closes: ICU-8594 * refactor: 💡 remove page formatting for host route * [COMPLIANCE] Add Copyright and License Headers (#1660) Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Carlos Alcaide Corvo <ccorvo@hashicorp.com> * chore(deps-dev): bump webpack from 5.59.1 to 5.76.0 (#1654) Bumps [webpack](https://github.com/webpack/webpack) from 5.59.1 to 5.76.0. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.59.1...v5.76.0) --- updated-dependencies: - dependency-name: webpack dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Randall Morey <randall@randallmorey.com> Co-authored-by: Carlos Alcaide Corvo <ccorvo@hashicorp.com> * Feature metadata (#1661) * feat: 🎸 load edition from controller-metadata.json * refactor: 💡 rename edition and add licensed features support * chore: 🤖 support dev toggling of licensed features * chore: 🤖 rename ent edition * Update ui/admin/app/services/feature-edition.js * Update ui/admin/app/instance-initializers/feature-edition.js Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> * chore: 🤖 cleanup * chore: 🤖 feature edition disabled in tests / fix test cases * test: 💍 remove feature disable calls in tests * test: 💍 fix broken tests * fix: 🐛 fix config bug * fix: 🐛 fix broken test due to feature flags --------- Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> * fix: 🐛 Fix missing translation (#1662) Fix missing translation on the toggle color theme selector * Resolutions audit: Delete 3 oldest resolutions (#1663) * Delete bl from resolutions * Delete tough-cookie from resolutions * Delete npm from resolutions * chore(deps): bump http-cache-semantics from 4.1.0 to 4.1.1 (#1665) Bumps [http-cache-semantics](https://github.com/kornelski/http-cache-semantics) from 4.1.0 to 4.1.1. - [Release notes](https://github.com/kornelski/http-cache-semantics/releases) - [Commits](https://github.com/kornelski/http-cache-semantics/compare/v4.1.0...v4.1.1) --- updated-dependencies: - dependency-name: http-cache-semantics dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: 🤖 Update electron-forge/* packages (#1666) Update electron-forge/* packages * feat: 🎸 Add support to display external name for dynamic hosts (#1664) * feat: 🎸 Add support to display external name for dynamic hosts ✅ Closes: ICU-8795 * test(admin/e2e): Add create target with address test (#1667) * chore: 🤖 update design system package (#1668) * test(admin/e2e): Define expected private key for vault credential store test (#1671) * test: 💍 (admin-e2e): Add test to create different credentials (#1670) * chore: 🤖 add json5 to resolutions per dependabot alerts (#1672) * chore: 🤖 add json5 to resolutions per dependabot alerts * fix: 🐛 remove unecessary resolutions * chore: 🤖 upgrade @storybook/ember-cli-storybook to 0.6.0 (#1669) * chore: 🤖 update @storybook/ember-cli-storybook to 0.6.0 ✅ Closes: ICU-6588 * chore: 🤖 remove css-what from resolutions * refactor: 💡 update selector for delete storage bucket test * chore: 🤖 fix yarn.lock --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: lisbet-alvarez <107949262+lisbet-alvarez@users.noreply.github.com> Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Carlos Alcaide Corvo <ccorvo@hashicorp.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Randall Morey <randall@randallmorey.com> Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> Co-authored-by: github-team-secure-boundary <hc-github-team-secure-boundary@hashicorp.com> Co-authored-by: hc-github-team-secure-boundary <82989682+hc-github-team-secure-boundary@users.noreply.github.com> Co-authored-by: Stan Ryzhov <60649800+stasryzhov@users.noreply.github.com> Co-authored-by: Dharini Jeeva <dharini@hashicorp.com>
164 lines
5.2 KiB
JavaScript
164 lines
5.2 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { visit, click, currentURL } from '@ember/test-helpers';
|
|
import { setupApplicationTest } from 'ember-qunit';
|
|
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
|
import { Response } from 'miragejs';
|
|
import { authenticateSession } from 'ember-simple-auth/test-support';
|
|
|
|
module('Acceptance | storage-buckets | delete', function (hooks) {
|
|
setupApplicationTest(hooks);
|
|
setupMirage(hooks);
|
|
|
|
let intl;
|
|
let features;
|
|
let getStorageBucketCount;
|
|
|
|
const DROPDOWN_BUTTON_SELECTOR = '.hds-dropdown-toggle-icon';
|
|
const DELETE_DROPDOWN_SELECTOR = '.hds-dropdown-list-item [type="button"]';
|
|
const DIALOG_DELETE_BTN_SELECTOR = '.rose-dialog .rose-button-primary';
|
|
const DIALOG_CANCEL_BTN_SELECTOR = '.rose-dialog .rose-button-secondary';
|
|
const DIALOG_MESSAGE_SELECTOR = '.rose-dialog-body';
|
|
const DIALOG_TITLE_SELECTOR = '.rose-dialog-header';
|
|
const NOTIFICATION_MSG_SELECTOR = '.rose-notification-body';
|
|
const NOTIFICATION_MSG_TEXT = 'Deleted successfully.';
|
|
|
|
const instances = {
|
|
scopes: {
|
|
global: null,
|
|
org: null,
|
|
},
|
|
storageBucket: null,
|
|
};
|
|
|
|
const urls = {
|
|
globalScope: null,
|
|
storageBuckets: null,
|
|
};
|
|
|
|
hooks.beforeEach(function () {
|
|
instances.scopes.global = this.server.create('scope', { id: 'global' });
|
|
instances.scopes.org = this.server.create('scope', {
|
|
type: 'org',
|
|
scope: { id: 'global', type: 'global' },
|
|
});
|
|
instances.storageBucket = this.server.create('storage-bucket', {
|
|
scope: instances.scopes.global,
|
|
});
|
|
urls.globalScope = `/scopes/global`;
|
|
urls.storageBuckets = `${urls.globalScope}/storage-buckets`;
|
|
getStorageBucketCount = () =>
|
|
this.server.schema.storageBuckets.all().models.length;
|
|
|
|
authenticateSession({});
|
|
intl = this.owner.lookup('service:intl');
|
|
features = this.owner.lookup('service:features');
|
|
features.enable('session-recording');
|
|
});
|
|
|
|
test('user can delete a storage bucket', async function (assert) {
|
|
assert.expect(2);
|
|
const storageBucketCount = getStorageBucketCount();
|
|
await visit(urls.globalScope);
|
|
|
|
await click(`[href="${urls.storageBuckets}"]`);
|
|
await click(DROPDOWN_BUTTON_SELECTOR);
|
|
await click(DELETE_DROPDOWN_SELECTOR);
|
|
|
|
assert.strictEqual(currentURL(), urls.storageBuckets);
|
|
assert.strictEqual(getStorageBucketCount(), storageBucketCount - 1);
|
|
});
|
|
|
|
test('user can accept delete storage bucket via dialog', async function (assert) {
|
|
assert.expect(4);
|
|
const confirmService = this.owner.lookup('service:confirm');
|
|
confirmService.enabled = true;
|
|
const storageBucketCount = getStorageBucketCount();
|
|
await visit(urls.globalScope);
|
|
|
|
await click(`[href="${urls.storageBuckets}"]`);
|
|
await click(DROPDOWN_BUTTON_SELECTOR);
|
|
await click(DELETE_DROPDOWN_SELECTOR);
|
|
|
|
assert
|
|
.dom(DIALOG_DELETE_BTN_SELECTOR)
|
|
.hasText(intl.t('resources.storage-bucket.actions.delete'));
|
|
|
|
await click(DIALOG_DELETE_BTN_SELECTOR);
|
|
|
|
assert.dom(NOTIFICATION_MSG_SELECTOR).hasText(NOTIFICATION_MSG_TEXT);
|
|
assert.strictEqual(currentURL(), urls.storageBuckets);
|
|
assert.strictEqual(getStorageBucketCount(), storageBucketCount - 1);
|
|
});
|
|
|
|
test('user can cancel delete storage bucket via dialog', async function (assert) {
|
|
assert.expect(4);
|
|
const confirmService = this.owner.lookup('service:confirm');
|
|
confirmService.enabled = true;
|
|
const storageBucketCount = getStorageBucketCount();
|
|
await visit(urls.globalScope);
|
|
|
|
await click(`[href="${urls.storageBuckets}"]`);
|
|
await click(DROPDOWN_BUTTON_SELECTOR);
|
|
await click(DELETE_DROPDOWN_SELECTOR);
|
|
|
|
assert
|
|
.dom(DIALOG_TITLE_SELECTOR)
|
|
.hasText(
|
|
intl.t('resources.storage-bucket.questions.delete-storage-bucket.title')
|
|
);
|
|
assert
|
|
.dom(DIALOG_MESSAGE_SELECTOR)
|
|
.hasText(
|
|
intl.t(
|
|
'resources.storage-bucket.questions.delete-storage-bucket.message'
|
|
)
|
|
);
|
|
|
|
await click(DIALOG_CANCEL_BTN_SELECTOR);
|
|
|
|
assert.strictEqual(currentURL(), urls.storageBuckets);
|
|
assert.strictEqual(getStorageBucketCount(), storageBucketCount);
|
|
});
|
|
|
|
test('user cannot delete storage bucket without proper authorization', async function (assert) {
|
|
assert.expect(1);
|
|
await visit(urls.globalScope);
|
|
instances.storageBucket.authorized_actions =
|
|
instances.storageBucket.authorized_actions.filter(
|
|
(item) => item !== 'delete'
|
|
);
|
|
|
|
await click(`[href="${urls.storageBuckets}"]`);
|
|
await click(DROPDOWN_BUTTON_SELECTOR);
|
|
|
|
assert.dom(DELETE_DROPDOWN_SELECTOR).doesNotExist();
|
|
});
|
|
|
|
test('deleting a storage bucket which errors displays error messages', async function (assert) {
|
|
assert.expect(1);
|
|
await visit(urls.globalScope);
|
|
this.server.del('/storage-buckets/:id', () => {
|
|
return new Response(
|
|
490,
|
|
{},
|
|
{
|
|
status: 490,
|
|
code: 'error',
|
|
message: 'Oops.',
|
|
}
|
|
);
|
|
});
|
|
|
|
await click(`[href="${urls.storageBuckets}"]`);
|
|
await click(DROPDOWN_BUTTON_SELECTOR);
|
|
await click(DELETE_DROPDOWN_SELECTOR);
|
|
|
|
assert.dom(NOTIFICATION_MSG_SELECTOR).hasText('Oops.');
|
|
});
|
|
});
|