Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

feat(web): Add `matchBrackets` and `autoCloseBrackets` to CodeMirror (#37927)

Chris10bcf9006f18
diff --git a/packages/web/src/components/codeMirrorModule.tsx b/packages/web/src/components/codeMirrorModule.tsx
index f398032f02..96e8bd07c8 100644
--- a/packages/web/src/components/codeMirrorModule.tsx
+++ b/packages/web/src/components/codeMirrorModule.tsx
@@ -26,7 +26,8 @@ import 'codemirror/mode/clike/clike';
import 'codemirror/mode/markdown/markdown';
import 'codemirror/addon/display/placeholder';
import 'codemirror/addon/mode/simple';
-import 'codemirror/mode/yaml/yaml';
+import 'codemirror/addon/edit/matchbrackets';
+import 'codemirror/addon/edit/closebrackets';
export type CodeMirror = typeof codemirrorType;
export default codemirror;
diff --git a/packages/web/src/components/codeMirrorWrapper.tsx b/packages/web/src/components/codeMirrorWrapper.tsx
index 53a7814740..7b70651b9d 100644
--- a/packages/web/src/components/codeMirrorWrapper.tsx
+++ b/packages/web/src/components/codeMirrorWrapper.tsx
@@ -106,6 +106,8 @@ export const CodeMirrorWrapper: React.FC<SourceProps> = ({
lineNumbers,
lineWrapping: wrapLines,
placeholder,
+ matchBrackets: true,
+ autoCloseBrackets: true,
});
codemirrorRef.current = { cm };
if (isFocused)
diff --git a/tests/library/inspector/cli-codegen-aria.spec.ts b/tests/library/inspector/cli-codegen-aria.spec.ts
index a11cf33342..6db0d6df5b 100644
--- a/tests/library/inspector/cli-codegen-aria.spec.ts
+++ b/tests/library/inspector/cli-codegen-aria.spec.ts
@@ -137,8 +137,8 @@ test.describe(() => {
await recorder.recorderPage.locator('.tab-aria .CodeMirror').click();
await recorder.recorderPage.keyboard.press('Backspace');
- // 3 highlighted tokens.
- await expect(recorder.recorderPage.locator('.source-line-error-underline')).toHaveCount(3);
+ // 1 highlighted token
+ await expect(recorder.recorderPage.locator('.source-line-error-underline')).toHaveCount(1);
});
test('should generate valid javascript with multiline snapshot assertion', async ({ openRecorder }) => {
diff --git a/tests/playwright-test/ui-mode-test-attachments.spec.ts b/tests/playwright-test/ui-mode-test-attachments.spec.ts
index 4984afd9fc..deabe4f6c9 100644
--- a/tests/playwright-test/ui-mode-test-attachments.spec.ts
+++ b/tests/playwright-test/ui-mode-test-attachments.spec.ts
@@ -142,7 +142,7 @@ test('should linkify string attachments', async ({ runUITest, server }) => {
await attachmentsPane.getByLabel('Third').click();
const url = server.PREFIX + '/three.html';
const promise = page.waitForEvent('popup');
- await attachmentsPane.getByText('[markdown link]').click();
+ await attachmentsPane.getByText('markdown link').dblclick();
const popup = await promise;
await expect(popup).toHaveURL(url);
}