Skip to content

Commit

Permalink
LXD-UI e2e test for operations
Browse files Browse the repository at this point in the history
Signed-off-by: Nkeiruka <[email protected]>
  • Loading branch information
Kxiru committed Jun 10, 2024
1 parent a42ff46 commit ce8d2e6
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/helpers/operations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Page } from "@playwright/test";
import { expect } from "../fixtures/lxd-test";

export const validateOperation = async (
page: Page,
title: string,
instance: string,
) => {
await expect(
page.getByLabel("Action", { exact: true }).getByText(title + instance),
).toBeVisible();
};
47 changes: 47 additions & 0 deletions tests/operations.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { test } from "./fixtures/lxd-test";
import {
createInstance,
deleteInstance,
randomInstanceName,
visitAndStartInstance,
visitAndStopInstance,
} from "./helpers/instances";
import { assertTextVisible } from "./helpers/permissions";
import {
checkNotificationExists,
dismissNotification,
} from "./helpers/notification";
import { validateOperation } from "./helpers/operations";

test("instance operations are recognised on the Operations page", async ({
page,
}) => {
const instance = randomInstanceName();
await createInstance(page, instance);

// validate create operation is in operation list
await page.goto("/ui/operations");
await validateOperation(page, "Creating Instance", instance);

// start instance and wait for the notification instance was started
await visitAndStartInstance(page, instance);
await checkNotificationExists(page);
await assertTextVisible(page, "Instance " + instance + " started");

// click on the “x operations” link in the status bar
await dismissNotification(page);

// validate the operation to start the instance is in the operation list
await page.goto("/ui/operations");
await validateOperation(page, "Starting Instance", instance);

// stop instance and validate stop operation is in operation list
await visitAndStopInstance(page, instance);
await page.goto("/ui/operations");
await validateOperation(page, "Stopping Instance", instance);

// delete instance and validate delete operation is in operation list
await deleteInstance(page, instance);
await page.goto("/ui/operations");
await validateOperation(page, "Deleting Instance", instance);
});

0 comments on commit ce8d2e6

Please sign in to comment.