mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-13 01:57:03 +02:00
* Part 1: Upgrade HDS to 2.9.0 (#22311) * UI: HDS adoption replace <CopyButton> part 2 (#22356) * certificate-card.hbs: replace 1 <CopyButton> with <Hds::Copy::Button> * scope-form.hbs: replace 1 <CopyButton> with <Hds::Copy::Button> * fix tests caused by changing certificate-card. change hds copy button in certificate-card.hbs * json-editor.hbs: replace 1 <CopyButton> with <Hds::Copy::Button> * masked-input.hbs: replace 1 <CopyButton> with <Hds::Copy::Button> * fix error with certificate-card.hbs copy button * fix tests that deal with certificate-card.hbs * add class to hds copy buttons to maintain similar styling to curent UI * info-table-row.hbs: replace 2 <CopyButton> with <Hds::Copy::Button> * undo change that should instead by merged in from main * change tooltip copy button to white. cleanup * add extra tet for oidc scope form. edit css class for the white icon copy button * fix tests * UI: HDS adoption replace <CopyButton> part 3 (#22614) * encrypt.hbs: replace 2 <CopyButton> with <Hds::Copy::Button> * decrypt.hbs: replace 2 <CopyButton> with <Hds::Copy::Button> * datakey.hbs. replace 6 <CopyButton> with <Hds::Copy::Button> * rewrap.hbs: replace 2 <CopyButton> with <Hds::Copy::Button> * hmac.hbs: replace 2 <CopyButton> with <Hds::Copy::Button> * fix typo * add copy-close class to copy & close buttons * export.hbs: replace 2 <CopyButton> with <Hds::Copy::Button>. fix styling * sign.hbs: replace 2 <CopyButton> with <Hds::Copy::Button> * fix test caused by changing <pre> tag to <code> in export.hbs * rename class * add extra style to class needed for part 4 of copy button replacement * UI: HDS adoption replace <CopyButton> part 4 (#22749) * user-menu.hbs: replace 1 <CopyButton> with <Hds::Copy::Button> * transit-form-show.hbs: replace 1 <CopyButton> with <Hds::Copy::Button> * configure-ssh-secret.hbs: replace 1 <CopyButton> with <Hds::Copy::Button> * tool-hash.hbs: replace 1 <CopyButton> with <Hds::Copy::Button> * tool-random.hbs: replace 1 <CopyButton> with <Hds::Copy::Button> * tool-rewrap.hbs: replace 1 <CopyButton> with <Hds::Copy::Button> * tool-unwrap.hbs: replace 1 <CopyButton> with <Hds::Copy::Button> * tool-wrap.hbs: replace 1 <CopyButton> with <Hds::Copy::Button> * paths.hbs: replace 1 <CopyButton> with <Hds::Copy::Button> * code-snippet.hbs: replace 1 <CopyButton> with <Hds::Copy::Button> * cleanup css for code-snippet. add comments for getting rid of code-snippet and replacing with <Hds::Copy::Snippet * change code-snippet copy icon to gray to match original design * change code-snippet class * accounts.hbs: replace 1 <CopyButton> with <Hds::Copy::Button> * hover-copy-button.hbs: replace 1 <CopyButton> with <Hds::Copy::Button> * add.hbs: replace 1 <CopyButton> with <Hds::Copy::Button> * show.hbs: replace 1 <CopyButton> with <Hds::Copy::Button> * copy-secret-dropdown.hbs: replace 1 <CopyButton> with <Hds::Copy::Button> * change styling of 'link' copy buttons * generate-credentials.hbs: replace 2 <CopyButton> with <Hds::Copy::Button> * transform-show-transformation.hbs: replace 2 <CopyButton> with <Hds::Copy::Button> * sign.hbs: replace 2 <CopyButton> with <Hds::Copy::Button> * hide some copy buttons' icons and use original flash message * undo cleanup of scss file so that I can put cleanup all into one PR to be more organized * update code snippet copy button * UI: HDS adoption replace <CopyButton> part 5: Cleanup (#22884) * remove unecessary code-snippet.scssn class * remove copy classes from masked-input.scss * remove copy button class from text-file.scss * uninstall ember-cli-clipboard 0.16.0 since there is no longer structure <CopyButton> * remove copyright message from code-snippet.scss to avoid merge conflicts with main, where the file is deleted * replace 2 classes with one * remove unecessary class from copy button * cleanup classes * revert changes to avoid merge conflicts * remove is-block class * conditionally render private key * add more info to comment * remove HoverCopyButton * add missing selector * fix control group padding --------- Co-authored-by: clairebontempo@gmail.com <clairebontempo@gmail.com> Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com> * rename class to transparent background * remove unused test selectors * replace transit actions with Copy::Snippet * replace transfrom code blocks with code snippet component * revert extra css fiddling * misc cleanup, unused action * remove copy & close buttons from transit modals * remove is- from class naming * remove hds-copy-button class * add other grey class * more small cleanup * add -top to margin * add changelog --------- Co-authored-by: clairebontempo@gmail.com <clairebontempo@gmail.com> Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
105 lines
3.6 KiB
JavaScript
105 lines
3.6 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import { create } from 'ember-cli-page-object';
|
|
import { render, fillIn, find, waitUntil, click } from '@ember/test-helpers';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
import jsonEditor from '../../pages/components/json-editor';
|
|
import sinon from 'sinon';
|
|
|
|
const component = create(jsonEditor);
|
|
|
|
module('Integration | Component | json-editor', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
const JSON_BLOB = `{
|
|
"test": "test"
|
|
}`;
|
|
const BAD_JSON_BLOB = `{
|
|
"test": test
|
|
}`;
|
|
|
|
hooks.beforeEach(function () {
|
|
this.set('valueUpdated', sinon.spy());
|
|
this.set('onFocusOut', sinon.spy());
|
|
this.set('json_blob', JSON_BLOB);
|
|
this.set('bad_json_blob', BAD_JSON_BLOB);
|
|
this.set('hashi-read-only-theme', 'hashi-read-only auto-height');
|
|
});
|
|
|
|
test('it renders', async function (assert) {
|
|
await render(hbs`<JsonEditor
|
|
@value={{"{}"}}
|
|
@title={{"Test title"}}
|
|
@showToolbar={{true}}
|
|
@readOnly={{true}}
|
|
/>`);
|
|
|
|
assert.strictEqual(component.title, 'Test title', 'renders the provided title');
|
|
assert.true(component.hasToolbar, 'renders the toolbar');
|
|
assert.true(component.hasCopyButton, 'renders the copy button');
|
|
assert.true(component.hasJSONEditor, 'renders the code mirror modifier');
|
|
assert.ok(component.canEdit, 'json editor can be edited');
|
|
});
|
|
|
|
test('it handles editing and linting and styles to json', async function (assert) {
|
|
await render(hbs`<JsonEditor
|
|
@value={{this.json_blob}}
|
|
@readOnly={{false}}
|
|
@valueUpdated={{this.valueUpdated}}
|
|
@onFocusOut={{this.onFocusOut}}
|
|
/>`);
|
|
// check for json styling
|
|
assert.dom('.cm-property').hasStyle({
|
|
color: 'rgb(158, 132, 197)',
|
|
});
|
|
assert.dom('.cm-string:nth-child(2)').hasStyle({
|
|
color: 'rgb(29, 219, 163)',
|
|
});
|
|
|
|
await fillIn('textarea', this.bad_json_blob);
|
|
await waitUntil(() => find('.CodeMirror-lint-marker-error'));
|
|
assert.dom('.CodeMirror-lint-marker-error').exists('throws linting error');
|
|
assert.dom('.CodeMirror-linenumber').exists('shows line numbers');
|
|
});
|
|
|
|
test('it renders the correct theme and expected styling', async function (assert) {
|
|
await render(hbs`<JsonEditor
|
|
@value={{this.json_blob}}
|
|
@theme={{this.hashi-read-only-theme}}
|
|
@readOnly={{true}}
|
|
/>`);
|
|
|
|
assert.dom('.cm-s-hashi-read-only').hasStyle({
|
|
background: 'rgb(247, 248, 250) none repeat scroll 0% 0% / auto padding-box border-box',
|
|
});
|
|
assert.dom('.CodeMirror-linenumber').doesNotExist('on readOnly does not show line numbers');
|
|
});
|
|
|
|
test('it should render example and restore it', async function (assert) {
|
|
this.value = null;
|
|
this.example = 'this is a test example';
|
|
|
|
await render(hbs`
|
|
<JsonEditor
|
|
@value={{this.value}}
|
|
@example={{this.example}}
|
|
@mode="ruby"
|
|
@valueUpdated={{fn (mut this.value)}}
|
|
/>
|
|
`);
|
|
|
|
assert.dom('.CodeMirror-code').hasText(`1${this.example}`, 'Example renders when there is no value');
|
|
assert.dom('[data-test-restore-example]').isDisabled('Restore button disabled when showing example');
|
|
await fillIn('textarea', '');
|
|
await fillIn('textarea', 'adding a value should allow the example to be restored');
|
|
await click('[data-test-restore-example]');
|
|
assert.dom('.CodeMirror-code').hasText(`1${this.example}`, 'Example is restored');
|
|
assert.strictEqual(this.value, null, 'Value is cleared on restore example');
|
|
});
|
|
});
|