memories/e2e/timeline.spec.ts

60 lines
2.0 KiB
TypeScript
Raw Normal View History

2022-11-06 07:03:01 +00:00
import { test, expect } from "@playwright/test";
import { login } from "./login";
2022-09-14 18:18:57 +00:00
2022-11-06 07:03:01 +00:00
test.beforeEach(login("/"));
2022-09-14 18:18:57 +00:00
2022-11-06 07:03:01 +00:00
test.describe("Open", () => {
test("Look for Images", async ({ page }) => {
expect(
2022-12-03 05:04:31 +00:00
await page.locator('img[src*="api/image/preview"]').count(),
2022-11-06 07:03:01 +00:00
"Number of previews"
).toBeGreaterThan(4);
2022-09-14 18:18:57 +00:00
await page.waitForTimeout(1000);
});
2022-11-06 07:03:01 +00:00
test("Open one image", async ({ page }) => {
await page
.locator("div:nth-child(2) > .p-outer > .img-outer > img")
.first()
.click();
2022-09-14 18:18:57 +00:00
await page.waitForTimeout(1000);
2022-11-06 07:03:01 +00:00
await page.locator('button[title="Close"]').first().click();
2022-09-14 18:18:57 +00:00
});
2022-11-06 07:03:01 +00:00
test("Select two images and delete", async ({ page }) => {
2022-10-17 01:07:15 +00:00
const i1 = "div:nth-child(2) > div:nth-child(1) > .p-outer";
const i2 = "div:nth-child(2) > div:nth-child(2) > .p-outer";
2022-09-14 18:18:57 +00:00
2022-11-06 07:03:01 +00:00
const src1 = await page
.locator(`${i1} > .img-outer > img`)
.first()
.getAttribute("src");
const src2 = await page
.locator(`${i2} > .img-outer > img`)
.first()
.getAttribute("src");
2022-09-14 18:18:57 +00:00
expect(await page.locator(`img[src="${src1}"]`).count()).toBe(1);
expect(await page.locator(`img[src="${src2}"]`).count()).toBe(1);
2022-10-13 03:16:50 +00:00
await page.locator(`${i1}`).hover();
2022-09-16 03:31:21 +00:00
await page.locator(`${i1} > .select`).click();
2022-09-14 18:18:57 +00:00
await page.locator(`${i2}`).click();
await page.waitForTimeout(1000);
2022-09-16 23:26:29 +00:00
await page.locator('[aria-label="Delete"]').click();
2022-09-14 18:18:57 +00:00
await page.waitForTimeout(4000);
expect(await page.locator(`img[src="${src1}"]`).count()).toBe(0);
expect(await page.locator(`img[src="${src2}"]`).count()).toBe(0);
// refresh page
await page.reload();
await page.waitForTimeout(4000); // cache
2022-12-07 23:50:51 +00:00
await page.reload(); // prevent stale cache issues
await page.waitForTimeout(4000); // cache
2022-12-03 05:04:31 +00:00
await page.waitForSelector('img[src*="api/image/preview"]');
2022-09-14 18:18:57 +00:00
expect(await page.locator(`img[src="${src1}"]`).count()).toBe(0);
expect(await page.locator(`img[src="${src2}"]`).count()).toBe(0);
});
2022-11-06 07:03:01 +00:00
});