mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-29 01:02:03 +03:00
perf(test): speed up web logout tests
This commit is contained in:
@@ -13,9 +13,11 @@ const runtime = {
|
|||||||
describe("web logout", () => {
|
describe("web logout", () => {
|
||||||
let fixtureRoot = "";
|
let fixtureRoot = "";
|
||||||
let caseId = 0;
|
let caseId = 0;
|
||||||
|
let logoutWeb: typeof import("./auth-store.js").logoutWeb;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
fixtureRoot = await fsPromises.mkdtemp(path.join(os.tmpdir(), "openclaw-test-web-logout-"));
|
fixtureRoot = await fsPromises.mkdtemp(path.join(os.tmpdir(), "openclaw-test-web-logout-"));
|
||||||
|
({ logoutWeb } = await import("./auth-store.js"));
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
@@ -38,7 +40,6 @@ describe("web logout", () => {
|
|||||||
|
|
||||||
it("deletes cached credentials when present", { timeout: 60_000 }, async () => {
|
it("deletes cached credentials when present", { timeout: 60_000 }, async () => {
|
||||||
const authDir = await makeCaseDir();
|
const authDir = await makeCaseDir();
|
||||||
const { logoutWeb } = await import("./session.js");
|
|
||||||
fs.writeFileSync(path.join(authDir, "creds.json"), "{}");
|
fs.writeFileSync(path.join(authDir, "creds.json"), "{}");
|
||||||
const result = await logoutWeb({ authDir, runtime: runtime as never });
|
const result = await logoutWeb({ authDir, runtime: runtime as never });
|
||||||
expect(result).toBe(true);
|
expect(result).toBe(true);
|
||||||
@@ -47,7 +48,6 @@ describe("web logout", () => {
|
|||||||
|
|
||||||
it("no-ops when nothing to delete", { timeout: 60_000 }, async () => {
|
it("no-ops when nothing to delete", { timeout: 60_000 }, async () => {
|
||||||
const authDir = await makeCaseDir();
|
const authDir = await makeCaseDir();
|
||||||
const { logoutWeb } = await import("./session.js");
|
|
||||||
const result = await logoutWeb({ authDir, runtime: runtime as never });
|
const result = await logoutWeb({ authDir, runtime: runtime as never });
|
||||||
expect(result).toBe(false);
|
expect(result).toBe(false);
|
||||||
expect(runtime.log).toHaveBeenCalled();
|
expect(runtime.log).toHaveBeenCalled();
|
||||||
@@ -55,7 +55,6 @@ describe("web logout", () => {
|
|||||||
|
|
||||||
it("keeps shared oauth.json when using legacy auth dir", async () => {
|
it("keeps shared oauth.json when using legacy auth dir", async () => {
|
||||||
const credsDir = await makeCaseDir();
|
const credsDir = await makeCaseDir();
|
||||||
const { logoutWeb } = await import("./session.js");
|
|
||||||
fs.writeFileSync(path.join(credsDir, "creds.json"), "{}");
|
fs.writeFileSync(path.join(credsDir, "creds.json"), "{}");
|
||||||
fs.writeFileSync(path.join(credsDir, "oauth.json"), '{"token":true}');
|
fs.writeFileSync(path.join(credsDir, "oauth.json"), '{"token":true}');
|
||||||
fs.writeFileSync(path.join(credsDir, "session-abc.json"), "{}");
|
fs.writeFileSync(path.join(credsDir, "session-abc.json"), "{}");
|
||||||
|
|||||||
Reference in New Issue
Block a user