mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-28 20:22:45 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48e5a69845 |
@@ -27,6 +27,8 @@ import {
|
|||||||
openCompactSettingsHost,
|
openCompactSettingsHost,
|
||||||
expectAddHostMethodOptions,
|
expectAddHostMethodOptions,
|
||||||
fillDirectHostUri,
|
fillDirectHostUri,
|
||||||
|
fillDirectHostFields,
|
||||||
|
connectDirectHost,
|
||||||
expectDirectHostFormValues,
|
expectDirectHostFormValues,
|
||||||
expectDirectHostSslEnabled,
|
expectDirectHostSslEnabled,
|
||||||
expectDirectHostUriValue,
|
expectDirectHostUriValue,
|
||||||
@@ -112,6 +114,36 @@ test.describe("Settings sidebar navigation", () => {
|
|||||||
await expectDirectHostUriHidden(page);
|
await expectDirectHostUriHidden(page);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("direct connection connects to the open Advanced URI when Host is blank", async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await gotoAppShell(page);
|
||||||
|
await openSettings(page);
|
||||||
|
await openAddHostFlow(page);
|
||||||
|
await selectHostConnectionType(page, "direct");
|
||||||
|
|
||||||
|
await toggleHostAdvanced(page);
|
||||||
|
await fillDirectHostUri(page, `tcp://127.0.0.1:${getE2EDaemonPort()}`);
|
||||||
|
|
||||||
|
await connectDirectHost(page);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("direct connection connects to an edited Advanced URI instead of the fields", async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await gotoAppShell(page);
|
||||||
|
await openSettings(page);
|
||||||
|
await openAddHostFlow(page);
|
||||||
|
await selectHostConnectionType(page, "direct");
|
||||||
|
|
||||||
|
await fillDirectHostFields(page, { host: "127.0.0.1", port: "9" });
|
||||||
|
await toggleHostAdvanced(page);
|
||||||
|
await expectDirectHostUriValue(page, "tcp://127.0.0.1:9");
|
||||||
|
await fillDirectHostUri(page, `tcp://127.0.0.1:${getE2EDaemonPort()}`);
|
||||||
|
|
||||||
|
await connectDirectHost(page);
|
||||||
|
});
|
||||||
|
|
||||||
test("Escape lets settings dropdowns and modals close before leaving settings", async ({
|
test("Escape lets settings dropdowns and modals close before leaving settings", async ({
|
||||||
page,
|
page,
|
||||||
}) => {
|
}) => {
|
||||||
|
|||||||
@@ -253,6 +253,19 @@ export async function fillDirectHostUri(page: Page, uri: string): Promise<void>
|
|||||||
await page.getByTestId("direct-host-uri-input").fill(uri);
|
await page.getByTestId("direct-host-uri-input").fill(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function fillDirectHostFields(
|
||||||
|
page: Page,
|
||||||
|
fields: { host: string; port: string },
|
||||||
|
): Promise<void> {
|
||||||
|
await page.getByTestId("direct-host-input").fill(fields.host);
|
||||||
|
await page.getByTestId("direct-port-input").fill(fields.port);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function connectDirectHost(page: Page): Promise<void> {
|
||||||
|
await page.getByTestId("direct-host-submit").click();
|
||||||
|
await expect(page.getByTestId("add-host-modal")).toHaveCount(0, { timeout: 30_000 });
|
||||||
|
}
|
||||||
|
|
||||||
export async function expectDirectHostFormValues(
|
export async function expectDirectHostFormValues(
|
||||||
page: Page,
|
page: Page,
|
||||||
fields: { host: string; port: string; password: string },
|
fields: { host: string; port: string; password: string },
|
||||||
|
|||||||
@@ -195,6 +195,12 @@ function draftFromConnectionUri(uri: string): DirectConnectionDraft {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The Password field stays visible under Advanced, so it fills in a URI that carries none.
|
||||||
|
function draftFromAdvancedUri(uri: string, fieldPassword: string): DirectConnectionDraft {
|
||||||
|
const draft = draftFromConnectionUri(uri);
|
||||||
|
return draft.password ? draft : { ...draft, password: fieldPassword };
|
||||||
|
}
|
||||||
|
|
||||||
function normalizeTransportMessage(message: string | null | undefined): string | null {
|
function normalizeTransportMessage(message: string | null | undefined): string | null {
|
||||||
if (!message) return null;
|
if (!message) return null;
|
||||||
const trimmed = message.trim();
|
const trimmed = message.trim();
|
||||||
@@ -405,18 +411,18 @@ export function AddHostModal({ visible, onClose, onCancel, onSaved }: AddHostMod
|
|||||||
const handleSave = useCallback(async () => {
|
const handleSave = useCallback(async () => {
|
||||||
if (isSaving) return;
|
if (isSaving) return;
|
||||||
|
|
||||||
const relayUri = isAdvancedOpen ? advancedUri.trim() : "";
|
const advancedInput = isAdvancedOpen ? advancedUri.trim() : "";
|
||||||
if (relayUri.startsWith("relay://") || relayUri.includes("#connect=")) {
|
if (advancedInput.startsWith("relay://") || advancedInput.includes("#connect=")) {
|
||||||
await handleSaveRelay(relayUri);
|
await handleSaveRelay(advancedInput);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let connection: PreparedDirectConnection;
|
let connection: PreparedDirectConnection;
|
||||||
try {
|
try {
|
||||||
connection = prepareDirectConnection(
|
const draft = advancedInput
|
||||||
{ host, port, useTls, password },
|
? draftFromAdvancedUri(advancedInput, password)
|
||||||
directConnectionLabels,
|
: { host, port, useTls, password };
|
||||||
);
|
connection = prepareDirectConnection(draft, directConnectionLabels);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message =
|
const message =
|
||||||
error instanceof Error ? error.message : directConnectionLabels.invalidConnection;
|
error instanceof Error ? error.message : directConnectionLabels.invalidConnection;
|
||||||
|
|||||||
Reference in New Issue
Block a user