fix(webui): make headless login self-explanatory (#5735)

* fix(webui): guide headless login

* fix(webui): correct SSH handoff and password fallback
This commit is contained in:
chengyongru authored and GitHub committed 2026-09-13 05:01:13 +08:00
1 parent 7cede64f07
commit f8c1f2ede0
15 files changed
+265 -86

No files matched your search

+20 -12
View File
@@ -349,9 +349,14 @@ describe("App layout", () => {
render(<App />);
expect(await screen.findByRole("heading", { level: 1, name: "Password" }))
expect(await screen.findByRole("heading", { level: 1, name: "Connect to nanobot" }))
.toBeInTheDocument();
const password = screen.getByLabelText("Password");
const password = screen.getByLabelText("WebUI password");
expect(screen.getByText(/channels\.websocket\.tokenIssueSecret/))
.toBeInTheDocument();
expect(password).toHaveAccessibleDescription(
/If that value is empty, use channels\.websocket\.token\./,
);
expect(password).toHaveAttribute(
"autocomplete",
"current-password",
@@ -359,7 +364,7 @@ describe("App layout", () => {
expect(password).not.toHaveAttribute("placeholder");
expect(screen.queryByText("Authentication required")).not.toBeInTheDocument();
expect(
screen.queryByText("Incorrect password. Try again."),
screen.queryByText(/WebUI password wasn't accepted/),
).not.toBeInTheDocument();
expect(connectSpy).not.toHaveBeenCalled();
});
@@ -372,7 +377,7 @@ describe("App layout", () => {
render(<App />);
const password = await screen.findByLabelText("Password");
const password = await screen.findByLabelText("WebUI password");
await user.type(password, "correct horse battery staple");
expect(password).toHaveAttribute("type", "password");
@@ -397,16 +402,19 @@ describe("App layout", () => {
render(<App />);
const password = await screen.findByLabelText("Password");
const password = await screen.findByLabelText("WebUI password");
const connect = screen.getByRole("button", { name: "Connect" });
expect(connect).toBeEnabled();
fireEvent.click(connect);
expect(await screen.findByRole("alert")).toHaveTextContent(
"Enter your password.",
"Enter the WebUI password.",
);
expect(password).toHaveAttribute("aria-invalid", "true");
expect(password).toHaveAttribute("aria-describedby", "webui-auth-error");
expect(password).toHaveAttribute(
"aria-describedby",
"webui-auth-help webui-auth-error",
);
expect(password).toHaveFocus();
expect(fetchBootstrap).toHaveBeenCalledTimes(1);
});
@@ -420,10 +428,10 @@ describe("App layout", () => {
render(<App />);
expect(await screen.findByRole("heading", { level: 1, name: "Password" }))
expect(await screen.findByRole("heading", { level: 1, name: "Connect to nanobot" }))
.toBeInTheDocument();
expect(
screen.queryByText("Incorrect password. Try again."),
screen.queryByText(/WebUI password wasn't accepted/),
).not.toBeInTheDocument();
expect(connectSpy).not.toHaveBeenCalled();
});
@@ -435,13 +443,13 @@ describe("App layout", () => {
render(<App />);
const password = await screen.findByLabelText("Password");
const password = await screen.findByLabelText("WebUI password");
fireEvent.change(password, { target: { value: "wrong-password" } });
fireEvent.click(screen.getByRole("button", { name: "Connect" }));
const retryPassword = await screen.findByLabelText("Password");
const retryPassword = await screen.findByLabelText("WebUI password");
expect(await screen.findByRole("alert")).toHaveTextContent(
"Incorrect password. Try again.",
"That WebUI password wasn't accepted. Copy it from the nanobot config and try again.",
);
expect(retryPassword).toHaveAttribute("aria-invalid", "true");
expect(retryPassword).toHaveFocus();