mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
export and use distict lifecycle wrappers
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
2e38938331
commit
cbe52fefcc
@ -10,15 +10,15 @@ describe("Lens integration tests", () => {
|
||||
let app: Application;
|
||||
|
||||
describe("app start", () => {
|
||||
beforeAll(utils.wrapJestLifecycle(async () => {
|
||||
utils.beforeAllWrapped(async () => {
|
||||
app = await utils.appStart();
|
||||
}));
|
||||
});
|
||||
|
||||
afterAll(utils.wrapJestLifecycle(async () => {
|
||||
utils.afterAllWrapped(async () => {
|
||||
if (app?.isRunning()) {
|
||||
await utils.tearDown(app);
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
it('shows "whats new"', async () => {
|
||||
await utils.clickWhatsNew(app);
|
||||
|
||||
@ -32,15 +32,15 @@ describe("Lens cluster pages", () => {
|
||||
};
|
||||
|
||||
describe("cluster add", () => {
|
||||
beforeAll(utils.wrapJestLifecycle(async () => {
|
||||
utils.beforeAllWrapped(async () => {
|
||||
app = await utils.appStart();
|
||||
}));
|
||||
});
|
||||
|
||||
afterAll(utils.wrapJestLifecycle(async () => {
|
||||
if (app && app.isRunning()) {
|
||||
utils.afterAllWrapped(async () => {
|
||||
if (app?.isRunning()) {
|
||||
return utils.tearDown(app);
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
it("allows to add a cluster", async () => {
|
||||
await addCluster();
|
||||
@ -56,14 +56,13 @@ describe("Lens cluster pages", () => {
|
||||
};
|
||||
|
||||
describe("cluster pages", () => {
|
||||
utils.beforeAllWrapped(appStartAddCluster);
|
||||
|
||||
beforeAll(utils.wrapJestLifecycle(appStartAddCluster));
|
||||
|
||||
afterAll(utils.wrapJestLifecycle(async () => {
|
||||
if (app && app.isRunning()) {
|
||||
utils.afterAllWrapped(async () => {
|
||||
if (app?.isRunning()) {
|
||||
return utils.tearDown(app);
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
const tests: {
|
||||
drawer?: string
|
||||
@ -339,13 +338,13 @@ describe("Lens cluster pages", () => {
|
||||
});
|
||||
|
||||
describe("viewing pod logs", () => {
|
||||
beforeEach(utils.wrapJestLifecycle(appStartAddCluster));
|
||||
utils.beforeEachWrapped(appStartAddCluster);
|
||||
|
||||
afterEach(utils.wrapJestLifecycle(async () => {
|
||||
utils.afterEachWrapped(async () => {
|
||||
if (app?.isRunning()) {
|
||||
return utils.tearDown(app);
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
it(`shows a logs for a pod`, async () => {
|
||||
expect(clusterAdded).toBe(true);
|
||||
@ -389,13 +388,13 @@ describe("Lens cluster pages", () => {
|
||||
});
|
||||
|
||||
describe("cluster operations", () => {
|
||||
beforeEach(utils.wrapJestLifecycle(appStartAddCluster));
|
||||
utils.beforeEachWrapped(appStartAddCluster);
|
||||
|
||||
afterEach(utils.wrapJestLifecycle(async () => {
|
||||
utils.afterEachWrapped(async () => {
|
||||
if (app?.isRunning()) {
|
||||
return utils.tearDown(app);
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
it("shows default namespace", async () => {
|
||||
expect(clusterAdded).toBe(true);
|
||||
|
||||
@ -7,15 +7,15 @@ describe("Lens command palette", () => {
|
||||
let app: Application;
|
||||
|
||||
describe("menu", () => {
|
||||
beforeAll(utils.wrapJestLifecycle(async () => {
|
||||
utils.beforeAllWrapped(async () => {
|
||||
app = await utils.appStart();
|
||||
}));
|
||||
});
|
||||
|
||||
afterAll(utils.wrapJestLifecycle(async () => {
|
||||
utils.afterAllWrapped(async () => {
|
||||
if (app?.isRunning()) {
|
||||
await utils.tearDown(app);
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
it("opens command dialog from menu", async () => {
|
||||
await utils.clickWhatsNew(app);
|
||||
|
||||
@ -13,16 +13,16 @@ describe("Lens integration tests", () => {
|
||||
const ready = minikubeReady("workspace-int-tests");
|
||||
|
||||
utils.describeIf(ready)("workspaces", () => {
|
||||
beforeAll(utils.wrapJestLifecycle(async () => {
|
||||
utils.beforeAllWrapped(async () => {
|
||||
app = await utils.appStart();
|
||||
await utils.clickWhatsNew(app);
|
||||
}));
|
||||
});
|
||||
|
||||
afterAll(utils.wrapJestLifecycle(async () => {
|
||||
utils.afterAllWrapped(async () => {
|
||||
if (app?.isRunning()) {
|
||||
return utils.tearDown(app);
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
const switchToWorkspace = async (name: string) => {
|
||||
await app.client.click("[data-test-id=current-workspace]");
|
||||
|
||||
@ -25,6 +25,22 @@ export function wrapJestLifecycle(fn: () => Promise<void>): (done: DoneCallback)
|
||||
};
|
||||
}
|
||||
|
||||
export function beforeAllWrapped(fn: () => Promise<void>): void {
|
||||
beforeAll(wrapJestLifecycle(fn));
|
||||
}
|
||||
|
||||
export function beforeEachWrapped(fn: () => Promise<void>): void {
|
||||
beforeEach(wrapJestLifecycle(fn));
|
||||
}
|
||||
|
||||
export function afterAllWrapped(fn: () => Promise<void>): void {
|
||||
afterAll(wrapJestLifecycle(fn));
|
||||
}
|
||||
|
||||
export function afterEachWrapped(fn: () => Promise<void>): void {
|
||||
afterEach(wrapJestLifecycle(fn));
|
||||
}
|
||||
|
||||
export function itIf(condition: boolean) {
|
||||
return condition ? it : it.skip;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user