KV Download Value Stringify Toggle (#23747)

* adds stringify toggle to masked-input download modal

* updates stringify toggle copy and adds a test

* adds changelog entry
This commit is contained in:
Jordan Reimer
2023-10-20 08:56:14 -06:00
committed by GitHub
parent 13523b5a69
commit 01d5d1dc3a
4 changed files with 55 additions and 1 deletions

View File

@@ -130,4 +130,37 @@ module('Integration | Component | masked input', function (hooks) {
.dom('[data-test-icon="minus"]')
.exists('shows minus icon when unmasked because value is empty string');
});
test('it should render stringify toggle in download modal', async function (assert) {
assert.expect(3);
// this looks wonky but need a new line in there to test stringify adding escape character
this.value = `bar
`;
const downloadStub = sinon.stub(this.owner.lookup('service:download'), 'miscExtension');
downloadStub.callsFake((fileName, value) => {
const firstCall = downloadStub.callCount === 1;
const assertVal = firstCall ? this.value : JSON.stringify(this.value);
assert.strictEqual(assertVal, value, `Value is ${firstCall ? 'not ' : ''}stringified`);
return true;
});
await render(hbs`
<MaskedInput
@name="key"
@value={{this.value}}
@displayOnly={{true}}
@allowDownload={{true}}
/>
`);
await click('[data-test-download-icon]');
assert.dom('[data-test-stringify-toggle]').isNotChecked('Stringify toggle off as default');
await click('[data-test-download-button]');
await click('[data-test-download-icon]');
await click('[data-test-stringify-toggle]');
await click('[data-test-download-button]');
});
});