refactor: 💡 Adopt HDS copy snippet Desktop UI (#2146)

* refactor: 💡 Adopt HDS copy snippet Desktop UI

Adopt HDS copy snippet and delete usage of Copyable custom component
This commit is contained in:
Carlos Alcaide Corvo authored and GitHub committed 2024-02-22 13:56:56 -08:00
1 parent 912be13744
commit 956f6fd04d
16 files changed
+135 -350

No files matched your search

@@ -1,23 +0,0 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, find } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | copyable', function (hooks) {
setupRenderingTest(hooks);
test('it renders', async function (assert) {
this.set('actionText', 'text');
await render(
hbs`<Copyable @buttonText="Copy me" @text="foo">{{this.actionText}}</Copyable>`,
);
assert.ok(find('.copyable'));
assert.strictEqual(find('.copyable-content').textContent.trim(), 'text');
assert.strictEqual(find('.copyable-button').textContent.trim(), 'Copy me');
});
});
@@ -60,6 +60,6 @@ module('Integration | Component | credentials-panel', function (hooks) {
await click('[data-test-toggle-credentials]');
assert.dom("[data-test-raw-secret]").isVisible();
assert.dom('[data-test-raw-secret]').isVisible();
});
});
@@ -14,6 +14,9 @@ module('Integration | Component | hidden-secret', function (hooks) {
setupIntl(hooks);
setupMirage(hooks);
const HIDDEN_SECRET_TOGGLE = '.hidden-secret > button:first-child';
const HIDDEN_SECRET_CONTENT = '.hidden-secret > .secret-content';
// Global Secret for mocking
this.secret = `{
"secret_key": "QWERTYUIOP",
@@ -37,15 +40,13 @@ module('Integration | Component | hidden-secret', function (hooks) {
test('it renders with a secret', async function (assert) {
assert.expect(1);
await renderComponent();
assert
.dom('.hidden-secret > span > span')
.hasText('■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■');
assert.dom(HIDDEN_SECRET_CONTENT).hasText('■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■');
});
test('it reveals secret when button is clicked', async function (assert) {
assert.expect(1);
await renderComponent();
await click('.hidden-secret > button');
assert.dom('.hidden-secret > span > span').hasText(this.secret);
await click(HIDDEN_SECRET_TOGGLE);
assert.dom(HIDDEN_SECRET_CONTENT).hasText(this.secret);
});
});