diff --git a/libs/features/sql-editor/src/sql-editor.component.spec.ts b/libs/features/sql-editor/src/sql-editor.component.spec.ts index 27664b94c2a..e8d1286dc3b 100644 --- a/libs/features/sql-editor/src/sql-editor.component.spec.ts +++ b/libs/features/sql-editor/src/sql-editor.component.spec.ts @@ -12,6 +12,14 @@ import { SqlEditorComponent } from './sql-editor.component'; import { By } from '@angular/platform-browser'; import { CodeEditor } from '@acrodata/code-editor'; +// Simulate a user edit: dispatch a doc change without the `External` annotation +// that `writeValue`/`setValue` use, so the editor propagates it through ngModel. +const typeInEditor = (editor: CodeEditor, value: string): void => { + editor.view.dispatch({ + changes: { from: 0, to: editor.view.state.doc.length, insert: value }, + }); +}; + export class SqlEditorPage extends PageObject { readonly DT = 'ngx-datatable'; @@ -80,7 +88,7 @@ describe('SqlEditorComponent', () => { const { page, mysqlQueryService, codeEditorInstance } = setup(); const customQuery = 'SELECT col FROM table WHERE col > 10'; - codeEditorInstance.writeValue(customQuery); + typeInEditor(codeEditorInstance, customQuery); page.clickElement(page.executeBtn); expect(mysqlQueryService.query).toHaveBeenCalledWith(customQuery); @@ -175,7 +183,7 @@ describe('SqlEditorComponent', () => { const spy = vi.spyOn(TestBed.inject(ClipboardService), 'copyFromContent').mockImplementation(() => undefined); const customQuery = '-- some text that will be copied'; - codeEditorInstance.writeValue(customQuery); + typeInEditor(codeEditorInstance, customQuery); page.clickElement(page.copyBtn); expect(spy).toHaveBeenCalledWith(customQuery); diff --git a/package-lock.json b/package-lock.json index 22b1af00f8a..960cee26a3b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "3.10.5-dev", "hasInstallScript": true, "dependencies": { - "@acrodata/code-editor": "0.5.1", + "@acrodata/code-editor": "0.6.1", "@codemirror/lang-sql": "6.10.0", "@ngx-translate/core": "17.0.0", "@ngx-translate/http-loader": "17.0.0", @@ -115,9 +115,9 @@ } }, "node_modules/@acrodata/code-editor": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/@acrodata/code-editor/-/code-editor-0.5.1.tgz", - "integrity": "sha512-ta0prFRwXQgLSqBtjzpR9+eWXPpFh/+tS/BQapoA89cMnJDo6zCjkfEax41uO5xb96UJA3IAuYM22jUA6G4WRw==", + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/@acrodata/code-editor/-/code-editor-0.6.1.tgz", + "integrity": "sha512-Aw8N0hvPodMp7e07XJePhs+bZzOX+Ji8f2dMctCPgD+RSx7QIBJWC5msvtSeI8T8QFjOjrcBMlMLBJ9hruZkeg==", "license": "MIT", "dependencies": { "@codemirror/merge": "^6.0.0", diff --git a/package.json b/package.json index 4e9b04a509e..a9bc5d696e7 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "prepare": "husky install" }, "dependencies": { - "@acrodata/code-editor": "0.5.1", + "@acrodata/code-editor": "0.6.1", "@codemirror/lang-sql": "6.10.0", "@ngx-translate/core": "17.0.0", "@ngx-translate/http-loader": "17.0.0",