Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix autocomplete after monaco-editor upgrade #1943

Merged
merged 5 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/toolpad-app/src/components/MonacoEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export default React.forwardRef<MonacoEditorHandle, MonacoEditorProps>(function
}
}
} else {
const pathUri = monaco.Uri.parse(`./scripts/${nanoid(7)}${getExtension(language)}`);
const pathUri = monaco.Uri.parse(`/scripts/${nanoid(7)}${getExtension(language)}`);
const model = monaco.editor.createModel(value || '', language, pathUri);

instance = monaco.editor.create(rootRef.current, {
Expand Down
62 changes: 0 additions & 62 deletions test/integration/editor/fixture/toolpad.yml

This file was deleted.

17 changes: 17 additions & 0 deletions test/integration/editor/fixture/toolpad/pages/page1/page.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: page
spec:
id: y4d19z0
title: Page 1
content:
- component: PageRow
name: pageRow
children:
- component: TextField
name: textField1
props:
label: textField1
- component: TextField
name: textField2
props:
label: textField2
19 changes: 19 additions & 0 deletions test/integration/editor/fixture/toolpad/pages/page2/page.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: page
spec:
id: K7SkzhT
title: page2
display: shell
content:
- component: PageRow
name: pageRow
children:
- component: TextField
name: textField
- component: PageRow
name: pageRow1
children:
- component: Text
name: text
props:
value: text-foo
25 changes: 25 additions & 0 deletions test/integration/editor/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,28 @@ test('can delete elements from page', async ({ page }) => {

await expect(canvasInputLocator).toHaveCount(0);
});

test('code editor auto-complete', async ({ page }) => {
const editorModel = new ToolpadEditor(page);

await editorModel.goToPageById('K7SkzhT');

await editorModel.waitForOverlay();

const text = editorModel.appCanvas.getByText('text-foo');

await clickCenter(page, text);

const bindingButton = editorModel.componentEditor.getByLabel('Bind property "Value"');

await bindingButton.click();

const editor = page
.getByRole('dialog', { name: 'Bind property "Value"' })
.locator('.monaco-editor');

await editor.waitFor();

await page.keyboard.type('textF');
await expect(page.getByRole('option', { name: 'textField' })).toBeVisible();
});
5 changes: 4 additions & 1 deletion test/models/ToolpadEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ export class ToolpadEditor {

async goToPage(name: string) {
await this.explorer.getByText(name).click();
this.page.waitForNavigation();
}

async goToPageById(id: string) {
await gotoIfNotCurrent(this.page, `/_toolpad/app/pages/${id}`);
}

async createComponent(name: string) {
Expand Down