* chore: 🤖 replace Rose::CodeEditor with Hds::CodeEditor - Remove CodeEditor 5 dependency * chore: 🤖 Replace CodeMirror5 dep remove CodeMirror5 and replace existing editors with HDS::CodeEditor * chore: 🤖 deleting old codeeditor styles * feat: 🎸 changing code editor changing code editor ✅ Closes: 0 * removed unused export * pr cleanup * updating tests for new code editor * responding to PR feedback * added whitespace * fixing linting violations * chore: 🤖 self-review PR self-review PR in the course of switching to new HDS code editor * fix: 🐛 fix linting bug * fix: 🐛 unneeded dependency remove jslint dependency as this is handled in the new code editor from HDS * fix: 🐛 Fixing import bug Fix import bug caused by importing scss modules that no longer exist * Fix and refactor code editor acceptance test * Fix and refactor code editor acceptance test * chore: 🤖 remove codemirror dependency * refactor: 💡 fix merge conflict issues * test: 💍 update e2e test selectors * test: 💍 fix target spec click event * refactor: 💡 clean up test selectors for code editor * refactor: 💡 clean up storage bucket test selectors * chore: 🤖 remove code mirror modifiers --------- Co-authored-by: calcaide <ccorvo@hashicorp.com> Co-authored-by: cameronperera <cameron.perera@hashicorp.com>
95 lines
2.7 KiB
JavaScript
95 lines
2.7 KiB
JavaScript
/**
|
|
* Copyright IBM Corp. 2021, 2026
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import { render, click, waitFor } from '@ember/test-helpers';
|
|
import { hbs } from 'ember-cli-htmlbars';
|
|
import { setupIntl } from 'ember-intl/test-support';
|
|
import * as commonSelectors from 'admin/tests/helpers/selectors';
|
|
|
|
module('Integration | Component | form/field/json-secret', function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
setupIntl(hooks, 'en-us');
|
|
|
|
hooks.beforeEach(function () {
|
|
this.model = {
|
|
json_object: '{}',
|
|
};
|
|
});
|
|
|
|
test('it renders the active editor', async function (assert) {
|
|
await render(hbs`
|
|
<Form::Field::JsonSecret
|
|
@value={{this.model.json_object}}
|
|
@onInput={{fn (mut this.model.json_object)}}
|
|
@showEditButton={{false}}
|
|
/>
|
|
`);
|
|
|
|
assert.dom('.secret-editor').isVisible();
|
|
assert.dom('.secret-editor-json').isVisible();
|
|
|
|
await waitFor(commonSelectors.CODE_EDITOR_CM);
|
|
assert
|
|
.dom(commonSelectors.CODE_EDITOR_CONTENT)
|
|
.hasText(this.model.json_object);
|
|
});
|
|
|
|
test('it renders the disabled editor', async function (assert) {
|
|
await render(hbs`
|
|
<Form::Field::JsonSecret
|
|
@disabled={{true}}
|
|
@value={{this.model.json_object}}
|
|
@onInput={{fn (mut this.model.json_object)}}
|
|
@showEditButton={{true}}
|
|
/>
|
|
`);
|
|
|
|
assert.dom('.secret-editor').isVisible();
|
|
assert.dom('.secret-editor-json').doesNotExist();
|
|
assert
|
|
.dom('.secret-editor-skeleton-wrapper')
|
|
.hasText("This secret is saved but won't be displayed");
|
|
});
|
|
|
|
test('it renders the actionable editor', async function (assert) {
|
|
await render(hbs`
|
|
<Form::Field::JsonSecret
|
|
@disabled={{false}}
|
|
@value={{this.model.json_object}}
|
|
@onInput={{fn (mut this.model.json_object)}}
|
|
@showEditButton={{true}}
|
|
/>
|
|
`);
|
|
|
|
assert.dom('.secret-editor').isVisible();
|
|
assert.dom('.secret-editor-json').doesNotExist();
|
|
assert
|
|
.dom('.secret-editor-skeleton-wrapper')
|
|
.hasText('Click to replace this secret');
|
|
});
|
|
|
|
test('it renders the active editor from the actionable view', async function (assert) {
|
|
await render(hbs`
|
|
<Form::Field::JsonSecret
|
|
@disabled={{false}}
|
|
@value={{this.model.json_object}}
|
|
@onInput={{fn (mut this.model.json_object)}}
|
|
@showEditButton={{true}}
|
|
/>
|
|
`);
|
|
|
|
assert.dom('.secret-editor').isVisible();
|
|
assert.dom('.secret-editor-json').doesNotExist();
|
|
assert
|
|
.dom('.secret-editor-skeleton-wrapper')
|
|
.hasText('Click to replace this secret');
|
|
|
|
await click('button');
|
|
assert.dom('.secret-editor-json').isVisible();
|
|
});
|
|
});
|