Jelajahi Sumber

test(app): fix windows paths

Adam 3 minggu lalu
induk
melakukan
93044cc7d1

+ 9 - 2
packages/app/e2e/file-viewer.spec.ts

@@ -4,15 +4,22 @@ import { modKey } from "./utils"
 test("smoke file viewer renders real file content", async ({ page, gotoSession }) => {
   await gotoSession()
 
+  const sep = process.platform === "win32" ? "\\" : "/"
+  const file = ["packages", "app", "package.json"].join(sep)
+
   await page.keyboard.press(`${modKey}+P`)
 
   const dialog = page.getByRole("dialog")
   await expect(dialog).toBeVisible()
 
   const input = dialog.getByRole("textbox").first()
-  await input.fill("packages/app/package.json")
+  await input.fill(file)
 
-  const fileItem = dialog.locator('[data-slot="list-item"][data-key="file:packages/app/package.json"]')
+  const fileItem = dialog
+    .locator(
+      '[data-slot="list-item"][data-key^="file:"][data-key*="packages"][data-key*="app"][data-key$="package.json"]',
+    )
+    .first()
   await expect(fileItem).toBeVisible()
   await fileItem.click()
 

+ 8 - 3
packages/app/e2e/prompt-mention.spec.ts

@@ -5,16 +5,21 @@ test("smoke @mention inserts file pill token", async ({ page, gotoSession }) =>
   await gotoSession()
 
   await page.locator(promptSelector).click()
-  await page.keyboard.type("@packages/app/package.json")
+  const sep = process.platform === "win32" ? "\\" : "/"
+  const file = ["packages", "app", "package.json"].join(sep)
+  const filePattern = /packages[\\/]+app[\\/]+\s*package\.json/
 
-  const suggestion = page.getByRole("button", { name: /packages\/app\/\s*package\.json/ }).first()
+  await page.keyboard.type(`@${file}`)
+
+  const suggestion = page.getByRole("button", { name: filePattern }).first()
   await expect(suggestion).toBeVisible()
   await suggestion.hover()
 
   await page.keyboard.press("Tab")
 
-  const pill = page.locator(`${promptSelector} [data-type="file"][data-path="packages/app/package.json"]`)
+  const pill = page.locator(`${promptSelector} [data-type="file"]`).first()
   await expect(pill).toBeVisible()
+  await expect(pill).toHaveAttribute("data-path", filePattern)
 
   await page.keyboard.type(" ok")
   await expect(page.locator(promptSelector)).toContainText("ok")

+ 8 - 0
packages/app/e2e/tsconfig.json

@@ -0,0 +1,8 @@
+{
+  "extends": "../tsconfig.json",
+  "compilerOptions": {
+    "noEmit": true,
+    "types": ["node"]
+  },
+  "include": ["./**/*.ts"]
+}