2023-03-01 09:39:41 -06:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2021-06-24 13:54:42 -07:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
|
import { setupRenderingTest } from 'ember-qunit';
|
2023-01-10 12:56:52 -05:00
|
|
|
import { render, click } from '@ember/test-helpers';
|
|
|
|
|
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
2021-06-24 13:54:42 -07:00
|
|
|
import { hbs } from 'ember-cli-htmlbars';
|
2022-11-07 16:18:02 -08:00
|
|
|
import { setupIntl } from 'ember-intl/test-support';
|
2021-06-24 13:54:42 -07:00
|
|
|
module('Integration | Component | hidden-secret', function (hooks) {
|
|
|
|
|
setupRenderingTest(hooks);
|
2022-11-07 16:18:02 -08:00
|
|
|
setupIntl(hooks);
|
2023-01-10 12:56:52 -05:00
|
|
|
setupMirage(hooks);
|
2021-06-24 13:54:42 -07:00
|
|
|
|
2023-01-10 12:56:52 -05:00
|
|
|
// 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}}
|
|
|
|
|
/>
|
2021-06-24 13:54:42 -07:00
|
|
|
`);
|
2023-01-10 12:56:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test('it renders with a secret', async function (assert) {
|
|
|
|
|
assert.expect(1);
|
|
|
|
|
await renderComponent();
|
|
|
|
|
assert
|
|
|
|
|
.dom('.hidden-secret > span > span')
|
|
|
|
|
.hasText('■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■');
|
|
|
|
|
});
|
2021-06-24 13:54:42 -07:00
|
|
|
|
2023-01-10 12:56:52 -05:00
|
|
|
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);
|
2021-06-24 13:54:42 -07:00
|
|
|
});
|
|
|
|
|
});
|