mirror of
https://gitee.com/zhangsken/opencode.git
synced 2026-10-16 10:30:01 +08:00
4261fe749d
Co-authored-by: Brendonovich <14191578+Brendonovich@users.noreply.github.com>
81 lines
4.7 KiB
TypeScript
81 lines
4.7 KiB
TypeScript
import { expect, story } from "../../storybook/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 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)
|
|
})
|