Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/dual-editor-worker-on-storybook.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@openworkflowspec/dual-editor": minor
---

Fix the YAML autocomplete getting stuck on «Loading» in the Dual Editor Storybook.
13 changes: 13 additions & 0 deletions packages/dual-editor/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ import * as React from "react";
import type { Preview } from "@storybook/react-vite";
import type { Decorator } from "@storybook/react-vite";
import { useArgs, useGlobals } from "storybook/preview-api";
import EditorWorker from "@openworkflowspec/text-editor/editor-worker?worker";

// Monaco uses its editor worker for word-based suggestions.
Object.assign(self, {
MonacoEnvironment: {
getWorker(_workerId: string, label: string) {
if (label === "editorWorkerService") {
return new EditorWorker();
}
throw new Error(`Unexpected Monaco worker: ${label}`);
},
},
});

const withColorMode: Decorator = (Story) => {
const [{ colorMode: argColorMode }, updateArgs] = useArgs();
Expand Down
17 changes: 17 additions & 0 deletions packages/dual-editor/tests-e2e/dual-editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ test("YAML workflows render in the text and diagram panes", async ({ page }) =>
await expect(page.getByTestId("rf__node-/do/greet")).toContainText("greet");
});

test("YAML autocomplete shows suggestions after deleting the HTTP method", async ({ page }) => {
await page.goto("/iframe.html?id=dual-editor--yaml-editor");

const methodLine = page.locator(".monaco-editor .view-line").filter({ hasText: "method:" });
await expect(methodLine).toHaveText("method: GET");
await methodLine.click();
await page.keyboard.press("End");
for (let index = 0; index < "GET".length; index++) {
await page.keyboard.press("Shift+ArrowLeft");
}
await page.keyboard.press("Backspace");
await expect(methodLine).toHaveText("method:");

await page.keyboard.press("Control+Space");
await expect(page.locator(".suggest-widget .monaco-list-row").first()).toBeVisible();
});

test("text edits update the diagram", async ({ page }) => {
await openDualEditor(page);
const editor = page.locator(".monaco-editor").first();
Expand Down
Loading