mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-16 05:01:03 +03:00
98 lines
5.6 KiB
TypeScript
98 lines
5.6 KiB
TypeScript
import { expect, story } from "../../stories/playwright/story"
|
|
|
|
story("settings menu reconnect retains its prompt handler across server updates", async ({ mount, page }) => {
|
|
const component = await mount("app-dialog-ssh--settings-reconnect")
|
|
await component.getByRole("button", { name: "More options" }).click()
|
|
await page.getByRole("menuitem", { name: "Connect", exact: true }).click()
|
|
const dialog = page.getByRole("dialog")
|
|
await expect(dialog.getByRole("textbox")).toBeVisible()
|
|
await dialog.getByRole("textbox").fill("fixture-password")
|
|
await dialog.getByRole("button", { name: "Continue" }).click()
|
|
await expect(dialog.getByRole("textbox", { name: "Verification code:" })).toBeVisible()
|
|
await dialog.getByRole("textbox").fill("123456")
|
|
await dialog.getByRole("button", { name: "Continue" }).click()
|
|
await expect(dialog).toHaveCount(0)
|
|
await expect(component.getByRole("button", { name: "Authenticate", exact: true })).toHaveCount(0)
|
|
})
|
|
|
|
story("cancelling a sign-in from Home offers it again at once", async ({ mount, page }) => {
|
|
const component = await mount("app-dialog-ssh--authentication-required")
|
|
const projects = component.getByRole("button", { name: "Projects" })
|
|
const authenticate = page.getByRole("button", { name: "Authenticate", exact: true })
|
|
const dialog = page.getByRole("dialog", { name: "Connect to linuxbook" })
|
|
await projects.click()
|
|
await authenticate.click()
|
|
await expect(dialog.getByRole("textbox")).toBeVisible()
|
|
await dialog.getByRole("button", { name: "Cancel", exact: true }).click()
|
|
await expect(dialog).toHaveCount(0)
|
|
// The sign-in that waited on the dialog ends with it, instead of showing the server as connecting.
|
|
await projects.click()
|
|
await expect(authenticate).toBeEnabled()
|
|
await authenticate.click()
|
|
await expect(dialog.getByRole("textbox")).toBeVisible()
|
|
})
|
|
|
|
story("cancelling a version mismatch permits reconnecting again", async ({ mount, page }) => {
|
|
const component = await mount("app-dialog-ssh--incompatible-session")
|
|
await component.getByRole("button", { name: "Reconnect", exact: true }).click()
|
|
const dialog = page.getByRole("dialog")
|
|
await expect(dialog.getByRole("status")).toContainText("Server update required")
|
|
await expect(dialog.getByRole("textbox")).toHaveCount(0)
|
|
await dialog.getByRole("button", { name: "Cancel", exact: true }).click()
|
|
await expect(dialog).toHaveCount(0)
|
|
await component.getByRole("button", { name: "Reconnect", exact: true }).click()
|
|
await expect(dialog.getByRole("status")).toContainText("Server update required")
|
|
await expect(dialog.getByRole("textbox")).toHaveCount(0)
|
|
await dialog.getByRole("button", { name: "Cancel", exact: true }).click()
|
|
await expect(dialog).toHaveCount(0)
|
|
})
|
|
|
|
story("adding a server keeps all SSH challenges in the original connection dialog", async ({ mount, page }) => {
|
|
await mount("app-dialog-ssh--host")
|
|
const dialog = page.getByRole("dialog")
|
|
await dialog.getByRole("textbox", { name: "Host or SSH command" }).fill("ssh devbox")
|
|
await dialog.getByRole("button", { name: "Add server", exact: true }).click()
|
|
await expect(dialog).toHaveCount(1)
|
|
await expect(dialog.getByRole("button", { name: "Cancel", exact: true })).toBeFocused()
|
|
await dialog.getByRole("button", { name: "Trust and connect" }).click()
|
|
await dialog.getByRole("textbox").fill("fixture-password")
|
|
await dialog.getByRole("button", { name: "Continue", exact: true }).click()
|
|
await dialog.getByRole("textbox", { name: "Verification code:" }).fill("123456")
|
|
await dialog.getByRole("button", { name: "Continue", exact: true }).click()
|
|
await expect(dialog).toHaveCount(0)
|
|
})
|
|
|
|
story("adding an incompatible server advances to a dedicated update step", async ({ mount, page }) => {
|
|
await mount("app-dialog-ssh--incompatible-host")
|
|
const dialog = page.getByRole("dialog")
|
|
await dialog.getByRole("textbox", { name: "Host or SSH command" }).fill("ssh devbox")
|
|
await dialog.getByRole("button", { name: "Add server", exact: true }).click()
|
|
await expect(dialog.getByRole("status")).toContainText("Server update required")
|
|
await expect(dialog.getByRole("textbox")).toHaveCount(0)
|
|
await expect(dialog.getByRole("alert")).toHaveCount(0)
|
|
await expect(dialog.getByRole("button", { name: "Update and reconnect", exact: true })).toBeVisible()
|
|
})
|
|
|
|
story("updating an incompatible connection continues authentication in the same dialog", async ({ mount, page }) => {
|
|
const component = await mount("app-dialog-ssh--incompatible-session")
|
|
await component.getByRole("button", { name: "Reconnect", exact: true }).click()
|
|
const dialog = page.getByRole("dialog")
|
|
await dialog.getByRole("button", { name: "Update and reconnect", exact: true }).click()
|
|
await expect(dialog).toHaveCount(1)
|
|
await dialog.getByRole("textbox").fill("fixture-password")
|
|
await dialog.getByRole("button", { name: "Continue", exact: true }).click()
|
|
await dialog.getByRole("textbox", { name: "Verification code:" }).fill("123456")
|
|
await dialog.getByRole("button", { name: "Continue", exact: true }).click()
|
|
await expect(dialog).toHaveCount(0)
|
|
await expect(component.getByText("Session connected")).toBeVisible()
|
|
})
|
|
|
|
story("key-based reconnect completes without opening an authentication dialog", async ({ mount, page }) => {
|
|
const component = await mount("app-dialog-ssh--key-reconnect")
|
|
await component.getByRole("button", { name: "Reconnect", exact: true }).click()
|
|
await expect(component.getByRole("button", { name: "Connecting to SSH server" })).toBeDisabled()
|
|
await expect(page.getByRole("dialog")).toHaveCount(0)
|
|
await expect(component.getByText("Session connected")).toBeVisible()
|
|
await expect(page.getByRole("dialog")).toHaveCount(0)
|
|
})
|