diff --git a/ui/desktop/app/components/hidden-secret/index.hbs b/ui/desktop/app/components/hidden-secret/index.hbs index 67d6baae8..a2159cea8 100644 --- a/ui/desktop/app/components/hidden-secret/index.hbs +++ b/ui/desktop/app/components/hidden-secret/index.hbs @@ -11,12 +11,12 @@ {{t 'actions.toggle-secret'}} {{#if this.isHidden}} - {{@secret}} +
{{this.displaySecretValue}}
{{else}} {{this.textMask}} {{/if}} diff --git a/ui/desktop/app/components/hidden-secret/index.js b/ui/desktop/app/components/hidden-secret/index.js index 2541c81fb..5b991aa6b 100644 --- a/ui/desktop/app/components/hidden-secret/index.js +++ b/ui/desktop/app/components/hidden-secret/index.js @@ -7,6 +7,14 @@ export default class HiddenSecretComponent extends Component { @tracked isHidden = false; + get displaySecretValue() { + if (typeof this.args.secret === 'object' && this.args.secret !== null) { + return JSON.stringify(this.args.secret, null, 2); + } else { + return this.args.secret; + } + } + @action toggleSecretVisibility() { this.isHidden = !this.isHidden; diff --git a/ui/desktop/app/styles/app.scss b/ui/desktop/app/styles/app.scss index 405853544..812f9cff5 100644 --- a/ui/desktop/app/styles/app.scss +++ b/ui/desktop/app/styles/app.scss @@ -467,6 +467,16 @@ $chevron-down: url("data:image/svg+xml;utf-8, + `); + } test('it renders with a secret', async function (assert) { - assert.expect(2); - await render(hbs` - - `); + assert.expect(1); + await renderComponent(); + assert + .dom('.hidden-secret > span > span') + .hasText('■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■'); + }); - assert.ok(find('.hidden-secret')); - assert.strictEqual( - find('.hidden-secret > span > span').textContent.trim(), - '■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■' - ); + 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); }); });