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;
|
let app: Application;
|
||||||
|
|
||||||
describe("app start", () => {
|
describe("app start", () => {
|
||||||
beforeAll(utils.wrapJestLifecycle(async () => {
|
utils.beforeAllWrapped(async () => {
|
||||||
app = await utils.appStart();
|
app = await utils.appStart();
|
||||||
}));
|
});
|
||||||
|
|
||||||
afterAll(utils.wrapJestLifecycle(async () => {
|
utils.afterAllWrapped(async () => {
|
||||||
if (app?.isRunning()) {
|
if (app?.isRunning()) {
|
||||||
await utils.tearDown(app);
|
await utils.tearDown(app);
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
it('shows "whats new"', async () => {
|
it('shows "whats new"', async () => {
|
||||||
await utils.clickWhatsNew(app);
|
await utils.clickWhatsNew(app);
|
||||||
|
|||||||
@ -32,15 +32,15 @@ describe("Lens cluster pages", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
describe("cluster add", () => {
|
describe("cluster add", () => {
|
||||||
beforeAll(utils.wrapJestLifecycle(async () => {
|
utils.beforeAllWrapped(async () => {
|
||||||
app = await utils.appStart();
|
app = await utils.appStart();
|
||||||
}));
|
});
|
||||||
|
|
||||||
afterAll(utils.wrapJestLifecycle(async () => {
|
utils.afterAllWrapped(async () => {
|
||||||
if (app && app.isRunning()) {
|
if (app?.isRunning()) {
|
||||||
return utils.tearDown(app);
|
return utils.tearDown(app);
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
it("allows to add a cluster", async () => {
|
it("allows to add a cluster", async () => {
|
||||||
await addCluster();
|
await addCluster();
|
||||||
@ -56,14 +56,13 @@ describe("Lens cluster pages", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
describe("cluster pages", () => {
|
describe("cluster pages", () => {
|
||||||
|
utils.beforeAllWrapped(appStartAddCluster);
|
||||||
|
|
||||||
beforeAll(utils.wrapJestLifecycle(appStartAddCluster));
|
utils.afterAllWrapped(async () => {
|
||||||
|
if (app?.isRunning()) {
|
||||||
afterAll(utils.wrapJestLifecycle(async () => {
|
|
||||||
if (app && app.isRunning()) {
|
|
||||||
return utils.tearDown(app);
|
return utils.tearDown(app);
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
const tests: {
|
const tests: {
|
||||||
drawer?: string
|
drawer?: string
|
||||||
@ -339,13 +338,13 @@ describe("Lens cluster pages", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("viewing pod logs", () => {
|
describe("viewing pod logs", () => {
|
||||||
beforeEach(utils.wrapJestLifecycle(appStartAddCluster));
|
utils.beforeEachWrapped(appStartAddCluster);
|
||||||
|
|
||||||
afterEach(utils.wrapJestLifecycle(async () => {
|
utils.afterEachWrapped(async () => {
|
||||||
if (app?.isRunning()) {
|
if (app?.isRunning()) {
|
||||||
return utils.tearDown(app);
|
return utils.tearDown(app);
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
it(`shows a logs for a pod`, async () => {
|
it(`shows a logs for a pod`, async () => {
|
||||||
expect(clusterAdded).toBe(true);
|
expect(clusterAdded).toBe(true);
|
||||||
@ -389,13 +388,13 @@ describe("Lens cluster pages", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("cluster operations", () => {
|
describe("cluster operations", () => {
|
||||||
beforeEach(utils.wrapJestLifecycle(appStartAddCluster));
|
utils.beforeEachWrapped(appStartAddCluster);
|
||||||
|
|
||||||
afterEach(utils.wrapJestLifecycle(async () => {
|
utils.afterEachWrapped(async () => {
|
||||||
if (app?.isRunning()) {
|
if (app?.isRunning()) {
|
||||||
return utils.tearDown(app);
|
return utils.tearDown(app);
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
it("shows default namespace", async () => {
|
it("shows default namespace", async () => {
|
||||||
expect(clusterAdded).toBe(true);
|
expect(clusterAdded).toBe(true);
|
||||||
|
|||||||
@ -7,15 +7,15 @@ describe("Lens command palette", () => {
|
|||||||
let app: Application;
|
let app: Application;
|
||||||
|
|
||||||
describe("menu", () => {
|
describe("menu", () => {
|
||||||
beforeAll(utils.wrapJestLifecycle(async () => {
|
utils.beforeAllWrapped(async () => {
|
||||||
app = await utils.appStart();
|
app = await utils.appStart();
|
||||||
}));
|
});
|
||||||
|
|
||||||
afterAll(utils.wrapJestLifecycle(async () => {
|
utils.afterAllWrapped(async () => {
|
||||||
if (app?.isRunning()) {
|
if (app?.isRunning()) {
|
||||||
await utils.tearDown(app);
|
await utils.tearDown(app);
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
it("opens command dialog from menu", async () => {
|
it("opens command dialog from menu", async () => {
|
||||||
await utils.clickWhatsNew(app);
|
await utils.clickWhatsNew(app);
|
||||||
|
|||||||
@ -13,16 +13,16 @@ describe("Lens integration tests", () => {
|
|||||||
const ready = minikubeReady("workspace-int-tests");
|
const ready = minikubeReady("workspace-int-tests");
|
||||||
|
|
||||||
utils.describeIf(ready)("workspaces", () => {
|
utils.describeIf(ready)("workspaces", () => {
|
||||||
beforeAll(utils.wrapJestLifecycle(async () => {
|
utils.beforeAllWrapped(async () => {
|
||||||
app = await utils.appStart();
|
app = await utils.appStart();
|
||||||
await utils.clickWhatsNew(app);
|
await utils.clickWhatsNew(app);
|
||||||
}));
|
});
|
||||||
|
|
||||||
afterAll(utils.wrapJestLifecycle(async () => {
|
utils.afterAllWrapped(async () => {
|
||||||
if (app?.isRunning()) {
|
if (app?.isRunning()) {
|
||||||
return utils.tearDown(app);
|
return utils.tearDown(app);
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
const switchToWorkspace = async (name: string) => {
|
const switchToWorkspace = async (name: string) => {
|
||||||
await app.client.click("[data-test-id=current-workspace]");
|
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) {
|
export function itIf(condition: boolean) {
|
||||||
return condition ? it : it.skip;
|
return condition ? it : it.skip;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user