mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 02:00:31 +08:00
Instrument authentication for e2e tests
This commit is contained in:
@@ -32,7 +32,8 @@ const config: PlaywrightTestConfig = {
|
||||
|
||||
webServer: [
|
||||
{
|
||||
command: "npm run start -- --strictPort --port 3001",
|
||||
command:
|
||||
"VITE_AUTH_LONG_DELAY=1000 npm run start -- --strictPort --port 3001",
|
||||
port: 3001,
|
||||
},
|
||||
],
|
||||
|
||||
+4
-1
@@ -39,7 +39,10 @@
|
||||
try {
|
||||
await invoke("authenticate");
|
||||
void router.loadFromLocation();
|
||||
void dynamicInterval(checkAuth, 30_000);
|
||||
void dynamicInterval(
|
||||
checkAuth,
|
||||
import.meta.env.VITE_AUTH_LONG_DELAY || 30_000,
|
||||
);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (e: any) {
|
||||
void router.push({
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ export async function checkAuth() {
|
||||
if (get(activeRouteStore).resource === "authenticationError") {
|
||||
window.history.back();
|
||||
}
|
||||
dynamicInterval(checkAuth, 30_000);
|
||||
dynamicInterval(checkAuth, import.meta.env.VITE_AUTH_LONG_DELAY || 30_000);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (e: any) {
|
||||
if (get(activeRouteStore).resource !== "authenticationError") {
|
||||
|
||||
+8
-5
@@ -12,11 +12,14 @@ export async function invoke<T = null>(
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(args),
|
||||
})
|
||||
.then(data => data.json())
|
||||
.catch(() => {
|
||||
throw Error(`Issue with HTTP Route: ${JSON.stringify({ cmd, args })}`);
|
||||
});
|
||||
}).then(async response => {
|
||||
const json = await response.json();
|
||||
if (!response.ok) {
|
||||
throw json;
|
||||
}
|
||||
|
||||
return json;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import { expect, test } from "@tests/support/fixtures.js";
|
||||
|
||||
test("navigate to repo issues", async ({ page }) => {
|
||||
await page.goto("/repos");
|
||||
|
||||
@@ -235,6 +235,17 @@ export class RadiclePeer {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
Removes the peers identity file from the `ssh-agent`
|
||||
**/
|
||||
public async logOut(): Promise<void> {
|
||||
await this.spawn("ssh-add", ["-d", `${this.#radHome}/keys/radicle.pub`]);
|
||||
}
|
||||
|
||||
public async authenticate(): Promise<void> {
|
||||
await this.spawn("rad", ["auth"]);
|
||||
}
|
||||
|
||||
public async startHttpd(port?: number): Promise<void> {
|
||||
if (!port) {
|
||||
port = await getPort();
|
||||
|
||||
Reference in New Issue
Block a user