Replace Rose::CodeEditor with Hds::CodeEditor (#2679)
* 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>
This commit is contained in:
1 parent
fd1eba617b
commit
d469f305de
41 files changed
+354
-744
No files matched your search
@@ -1,32 +0,0 @@
|
||||
/**
|
||||
* Copyright IBM Corp. 2021, 2026
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'ember-qunit';
|
||||
import { render } from '@ember/test-helpers';
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
|
||||
module('Integration | Component | rose/code-editor', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test('it renders', async function (assert) {
|
||||
const codeValue = 'export HCP_CLIENT_ID = {place your client_id here}';
|
||||
this.set('codeValue', codeValue);
|
||||
|
||||
await render(hbs`
|
||||
<Rose::CodeEditor
|
||||
@codeValue={{this.codeValue}}
|
||||
as |c|
|
||||
>
|
||||
<c.toolbar />
|
||||
<c.fieldEditor />
|
||||
</Rose::CodeEditor>
|
||||
`);
|
||||
assert.dom('[data-test-code-editor]').isVisible();
|
||||
assert.dom('[data-test-code-editor-toolbar]').isVisible();
|
||||
assert.dom('[data-test-code-editor-field-editor]').isVisible();
|
||||
assert.dom('[data-test-code-editor-field-editor]').includesText(codeValue);
|
||||
});
|
||||
});
|
||||
@@ -1,74 +0,0 @@
|
||||
/**
|
||||
* Copyright IBM Corp. 2021, 2026
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'ember-qunit';
|
||||
import { typeIn, render, waitUntil } from '@ember/test-helpers';
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
|
||||
module(
|
||||
'Integration | Component | rose/code-editor/field-editor',
|
||||
function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
const editorSelector = '[data-test-code-editor-field-editor]';
|
||||
|
||||
test('it renders', async function (assert) {
|
||||
const codeValue = `export HCP_CLIENT_ID = {place your client_id here}`;
|
||||
this.set('codeValue', codeValue);
|
||||
await render(hbs`
|
||||
<Rose::CodeEditor::FieldEditor @value={{this.codeValue}} />
|
||||
`);
|
||||
assert.dom(editorSelector).isVisible();
|
||||
assert.dom(editorSelector).includesText(codeValue);
|
||||
|
||||
const myNewCode = 'NEW CODE';
|
||||
await typeIn(`${editorSelector} textarea`, myNewCode);
|
||||
assert.dom(editorSelector).includesText(myNewCode);
|
||||
});
|
||||
|
||||
test('it renders readonly', async function (assert) {
|
||||
const codeValue = `export HCP_CLIENT_ID = {place your client_id here}`;
|
||||
this.set('codeValue', codeValue);
|
||||
this.set('options', {
|
||||
readOnly: true,
|
||||
});
|
||||
await render(hbs`
|
||||
<Rose::CodeEditor::FieldEditor @value={{this.codeValue}} @options={{this.options}} />
|
||||
`);
|
||||
assert.dom(editorSelector).isVisible();
|
||||
assert.dom(editorSelector).includesText(codeValue);
|
||||
|
||||
const myNewCode = 'NEW CODE';
|
||||
waitUntil(async () => {
|
||||
try {
|
||||
// This should fail if the textarea is readonly
|
||||
await typeIn(`${editorSelector} textarea`, myNewCode);
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
assert.dom(editorSelector).doesNotIncludeText(myNewCode);
|
||||
});
|
||||
|
||||
test('it calls onInput on change', async function (assert) {
|
||||
const codeValue = `export HCP_CLIENT_ID = {place your client_id here}`;
|
||||
const onInput = () => {
|
||||
this.set('called', true);
|
||||
};
|
||||
this.set('codeValue', codeValue);
|
||||
this.set('onInput', onInput);
|
||||
await render(hbs`
|
||||
<Rose::CodeEditor::FieldEditor @value={{this.codeValue}} @onInput={{this.onInput}} />
|
||||
`);
|
||||
assert.dom(editorSelector).isVisible();
|
||||
assert.dom(editorSelector).includesText(codeValue);
|
||||
|
||||
const myNewCode = 'NEW CODE';
|
||||
await typeIn(`${editorSelector} textarea`, myNewCode);
|
||||
assert.dom(editorSelector).includesText(myNewCode);
|
||||
assert.true(this.called);
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -1,65 +0,0 @@
|
||||
/**
|
||||
* Copyright IBM Corp. 2021, 2026
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'ember-qunit';
|
||||
import { click, render } from '@ember/test-helpers';
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
import sinon from 'sinon';
|
||||
|
||||
module('Integration | Component | rose/code-editor/toolbar', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
const toolbarSelector = '[data-test-code-editor-toolbar]';
|
||||
const copyButtonSelector = '[data-test-code-editor-toolbar-copy-button]';
|
||||
const menuDividerSelector = '[data-test-code-editor-toolbar-menu-divider]';
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
const copyText = 'copyText';
|
||||
this.set('copyText', copyText);
|
||||
});
|
||||
|
||||
test('it renders', async function (assert) {
|
||||
await render(hbs`
|
||||
<Rose::CodeEditor::Toolbar @copyText={{this.copyText}} />
|
||||
`);
|
||||
assert.dom(toolbarSelector).isVisible();
|
||||
assert.dom(copyButtonSelector).isVisible();
|
||||
assert.dom(menuDividerSelector).doesNotExist();
|
||||
});
|
||||
|
||||
test('it displays action', async function (assert) {
|
||||
await render(hbs`
|
||||
<Rose::CodeEditor::Toolbar @onCopy={{this.copyText}}>
|
||||
<:action>
|
||||
<div data-test-my-action>Hello</div>
|
||||
</:action>
|
||||
</Rose::CodeEditor::Toolbar>
|
||||
`);
|
||||
assert.dom(toolbarSelector).isVisible();
|
||||
assert.dom(copyButtonSelector).isVisible();
|
||||
assert.dom(menuDividerSelector).doesNotExist();
|
||||
assert.dom('[data-test-my-action]').isVisible();
|
||||
});
|
||||
|
||||
test('it calls onCopy callback', async function (assert) {
|
||||
// `writeText` could fail if the document is not in focus which is common during test runs
|
||||
sinon.stub(window.navigator.clipboard, 'writeText').resolves();
|
||||
|
||||
const onCopy = () => {
|
||||
this.set('called', true);
|
||||
};
|
||||
this.set('onCopy', onCopy);
|
||||
await render(hbs`
|
||||
<Rose::CodeEditor::Toolbar @copyText={{this.copyText}} @onCopy={{this.onCopy}} />
|
||||
`);
|
||||
assert.dom(toolbarSelector).isVisible();
|
||||
assert.dom(copyButtonSelector).isVisible();
|
||||
assert.dom(menuDividerSelector).doesNotExist();
|
||||
await click(copyButtonSelector);
|
||||
assert.true(this.called);
|
||||
|
||||
sinon.restore();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user