vault/ui/tests/integration/components/ldap/page/library/details-test.js
claire bontempo 4ac07e1d97
UI: HDS adoption replace <ConfirmAction> component (#21520)
* replace confirm-action dropdown with button+modal

* add modal frame to sidebar

* fix weird paragraph indent

* pass button text as arg

* add warning color to rotate modals

* update seal action and config ssh

* cleanup confirm action

* edit form

* add dropdown arg

* put back seal text

* put back confirm button text

* fix toolbar stylinggp

* popup member group

* move up title

* finish popup- components

* keymgmt

* fix modal button logic

* remaining app template components

* add period for angel

* vault cluster items

* add button text assertion

* remaining instances

* remove arg for passing confirm text

* contextual confirm action components

* delete old components

* update docs

* ammend dropdown loading states, add getter for confirm button color

* address feedback

* remove @disabled arg and add @disabledMessage

* add changelog;

* mfa tests

* update test selectors

* lol cleanup selectors

* start confirm action tests WIP

* move dropdown class directly to component

* add default color of isInDropdown

* final cleanup

* add tests

* remove @buttonColor as arg for dropdown

* update confirm action tests

* updae modals with disabled message

* refactor provider edit test
2023-11-17 23:44:21 +00:00

80 lines
2.8 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { setupEngine } from 'ember-engines/test-support';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { render, click } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import sinon from 'sinon';
module('Integration | Component | ldap | Page::Library::Details', function (hooks) {
setupRenderingTest(hooks);
setupEngine(hooks, 'ldap');
setupMirage(hooks);
hooks.beforeEach(function () {
this.server.post('/sys/capabilities-self', () => ({
data: {
capabilities: ['root'],
},
}));
this.store = this.owner.lookup('service:store');
this.store.pushPayload('ldap/library', {
modelName: 'ldap/library',
backend: 'ldap-test',
...this.server.create('ldap-library', { name: 'test-library' }),
});
this.model = this.store.peekRecord('ldap/library', 'test-library');
this.breadcrumbs = [
{ label: 'ldap-test', route: 'overview' },
{ label: 'libraries', route: 'libraries' },
{ label: 'test-library' },
];
});
test('it should render page header, tabs and toolbar actions', async function (assert) {
assert.expect(10);
this.server.delete(`/${this.model.backend}/library/${this.model.name}`, () => {
assert.ok(true, 'Request made to delete library');
return;
});
await render(hbs`<Page::Library::Details @model={{this.model}} @breadcrumbs={{this.breadcrumbs}} />`, {
owner: this.engine,
});
assert.dom('[data-test-header-title]').hasText(this.model.name, 'Library name renders in header');
assert
.dom('[data-test-breadcrumbs] li:nth-child(1)')
.containsText(this.model.backend, 'Overview breadcrumb renders');
assert
.dom('[data-test-breadcrumbs] li:nth-child(2) a')
.containsText('libraries', 'Libraries breadcrumb renders');
assert
.dom('[data-test-breadcrumbs] li:nth-child(3)')
.containsText(this.model.name, 'Library breadcrumb renders');
assert.dom('[data-test-tab="accounts"]').hasText('Accounts', 'Accounts tab renders');
assert.dom('[data-test-tab="config"]').hasText('Configuration', 'Configuration tab renders');
assert.dom('[data-test-delete]').hasText('Delete library', 'Delete action renders');
assert.dom('[data-test-edit]').hasText('Edit library', 'Edit action renders');
const transitionStub = sinon.stub(this.owner.lookup('service:router'), 'transitionTo');
await click('[data-test-delete]');
await click('[data-test-confirm-button]');
assert.ok(
transitionStub.calledWith('vault.cluster.secrets.backend.ldap.libraries'),
'Transitions to libraries route on delete success'
);
});
});