Files
threshold-ui/ui/desktop/tests/integration/components/hidden-secret-test.js
T
Devon AndersonandCameron Perera 1bd057bb4c refactor: 💡 desktop display of complex nested secrets (#1551)
* refactor: 💡 desktop display of complex nested secrets

A quick solution for displaying JSON secret objects in connection modal.

✅ Closes: ICU-7409

* refactor: 💡 refactor hidden-secret.js and test

Guard against null for in `typeof` return.

✅ Closes: ICU-7409

* Update ui/desktop/app/styles/app.scss

Co-authored-by: Cameron Perera <cameron.perera@hashicorp.com>

* refactor: 💡 test

Changed test to check for secret output after clicking on reveal

* refactor: 💡 fix style for hidden-secret and test

Refactor hidden-secret span styling to have content centered and
refactored testing for assert.dom instead of find

Co-authored-by: Cameron Perera <cameron.perera@hashicorp.com>
2023-01-10 12:56:52 -05:00

47 lines
1.4 KiB
JavaScript

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, click } from '@ember/test-helpers';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { hbs } from 'ember-cli-htmlbars';
import { setupIntl } from 'ember-intl/test-support';
module('Integration | Component | hidden-secret', function (hooks) {
setupRenderingTest(hooks);
setupIntl(hooks);
setupMirage(hooks);
// Global Secret for mocking
this.secret = `{
"secret_key": "QWERTYUIOP",
"secret_access_key": "QWERT.YUIOP234567890",
"nested_secret": {
"session_token": "ZXCVBNMLKJHGFDSAQWERTYUIOP0987654321",
"complex_nest": {
"hash": "qazxswedcvfrtgbnjhyujm.1234567890"
}
}
}`;
async function renderComponent() {
return render(hbs`
<HiddenSecret
@secret={{this.secret}}
/>
`);
}
test('it renders with a secret', async function (assert) {
assert.expect(1);
await renderComponent();
assert
.dom('.hidden-secret > span > span')
.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);
});
});