1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix integration test not assigning to clusterAdded correctly (#3168)

This commit is contained in:
Sebastian Malton 2021-06-24 09:21:53 -04:00 committed by GitHub
parent 7058193295
commit eba44d76aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 42 deletions

View File

@ -43,10 +43,6 @@ describe("Lens cluster pages", () => {
const ready = minikubeReady(TEST_NAMESPACE);
let clusterAdded = false;
afterEach(() => {
clusterAdded = false;
});
utils.describeIf(ready)("test common pages", () => {
const addCluster = async () => {
await waitForMinikubeDashboard(app);
@ -54,29 +50,29 @@ describe("Lens cluster pages", () => {
await app.client.waitUntilTextExists("div.TableCell", "Ready");
};
describe("cluster add", () => {
utils.beforeAllWrapped(async () => {
app = await utils.appStart();
});
utils.afterAllWrapped(async () => {
if (app?.isRunning()) {
return utils.tearDown(app);
}
});
it("allows to add a cluster", async () => {
await addCluster();
clusterAdded = true;
});
});
const appStartAddCluster = async () => {
app = await utils.appStart();
await addCluster();
clusterAdded = true;
};
const tearDown = async () => {
await utils.tearDown(app);
clusterAdded = false;
};
describe("cluster add", () => {
utils.beforeAllWrapped(async () => {
app = await utils.appStart();
});
utils.afterAllWrapped(tearDown);
it("allows to add a cluster", async () => {
await addCluster();
});
});
function getSidebarSelectors(itemId: string) {
const root = `.SidebarItem[data-test-id="${itemId}"]`;
@ -88,12 +84,7 @@ describe("Lens cluster pages", () => {
describe("cluster pages", () => {
utils.beforeAllWrapped(appStartAddCluster);
utils.afterAllWrapped(async () => {
if (app?.isRunning()) {
return utils.tearDown(app);
}
});
utils.afterAllWrapped(tearDown);
const tests: {
drawer?: string
@ -378,12 +369,7 @@ describe("Lens cluster pages", () => {
describe("viewing pod logs", () => {
utils.beforeEachWrapped(appStartAddCluster);
utils.afterEachWrapped(async () => {
if (app?.isRunning()) {
return utils.tearDown(app);
}
});
utils.afterEachWrapped(tearDown);
it(`shows a log for a pod`, async () => {
expect(clusterAdded).toBe(true);
@ -413,10 +399,10 @@ describe("Lens cluster pages", () => {
await app.client.waitForVisible(".Drawer");
const logsButton = "ul.KubeObjectMenu li.MenuItem i.Icon span[data-icon-name='subject']";
await app.client.waitForVisible(logsButton);
await app.client.click(logsButton);
// Check if controls are available
await app.client.waitForVisible(".LogList .VirtualList");
await app.client.waitForVisible(".LogResourceSelector");
@ -433,12 +419,7 @@ describe("Lens cluster pages", () => {
describe("cluster operations", () => {
utils.beforeEachWrapped(appStartAddCluster);
utils.afterEachWrapped(async () => {
if (app?.isRunning()) {
return utils.tearDown(app);
}
});
utils.afterEachWrapped(tearDown);
it("shows default namespace", async () => {
expect(clusterAdded).toBe(true);

View File

@ -105,7 +105,11 @@ export async function showCatalog(app: Application) {
type AsyncPidGetter = () => Promise<number>;
export async function tearDown(app: Application) {
export async function tearDown(app?: Application) {
if (!app?.isRunning()) {
return;
}
const pid = await (app.mainProcess.pid as any as AsyncPidGetter)();
await app.stop();