test: fix E2E

dexie
Varun Patil 2023-09-30 11:56:55 -07:00
parent 917020d426
commit f76703ee7f
4 changed files with 36 additions and 44 deletions

View File

@ -4,6 +4,7 @@ on:
push: push:
branches: branches:
- master - master
- pulsejet/*
env: env:
APP_NAME: memories APP_NAME: memories

View File

@ -1,23 +1,23 @@
import { test, expect } from "@playwright/test"; import { test, expect } from '@playwright/test';
import { login } from "./login"; import { login } from './login';
test.beforeEach(login("/folders")); test.beforeEach(login('/folders'));
test.describe("Open", () => { test.describe('Open', () => {
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
await page.waitForSelector(".big-icon"); await page.waitForSelector('.big-icon');
await page.waitForTimeout(500); await page.waitForTimeout(500);
}); });
test("Look for Folders", async ({ page }) => { test('Look for Folders', async ({ page }) => {
const ct = await page.locator(".big-icon").count(); const ct = await page.locator('.big-icon').count();
expect(ct, "Number of folders").toBe(2); expect(ct, 'Number of folders').toBe(2);
}); });
test("Open folder", async ({ page }) => { test('Open folder', async ({ page }) => {
await page.locator("text=Local").click(); await page.locator('text=Local').click();
await page.waitForTimeout(2000); await page.waitForTimeout(2000);
const elems = await page.locator(".img-outer").all(); const elems = await page.locator('.img-outer').all();
expect(elems.length).toBeGreaterThanOrEqual(3); expect(elems.length).toBeGreaterThanOrEqual(3);
}); });
}); });

View File

@ -1,17 +1,15 @@
import { expect, PlaywrightTestArgs } from "@playwright/test"; import { expect, PlaywrightTestArgs } from '@playwright/test';
export function login(route: string) { export function login(route: string) {
return async ({ page }: PlaywrightTestArgs) => { return async ({ page }: PlaywrightTestArgs) => {
await page.setViewportSize({ width: 800, height: 600 }); await page.setViewportSize({ width: 800, height: 600 });
await page.goto("http://localhost:8080/index.php/apps/memories" + route); await page.goto('http://localhost:8080/index.php/apps/memories' + route);
await page.locator("#user").click(); await page.locator('#user').click();
await page.locator("#user").fill("admin"); await page.locator('#user').fill('admin');
await page.locator("#user").press("Tab"); await page.locator('#user').press('Tab');
await page.locator("#password").fill("password"); await page.locator('#password').fill('password');
await page.locator('button[type="submit"]').click(); await page.locator('button[type="submit"]').click();
await expect(page).toHaveURL( await expect(page).toHaveURL('http://localhost:8080/index.php/apps/memories' + route);
"http://localhost:8080/index.php/apps/memories" + route
);
}; };
} }

View File

@ -1,46 +1,39 @@
import { test, expect } from "@playwright/test"; import { test, expect } from '@playwright/test';
import { login } from "./login"; import { login } from './login';
test.beforeEach(login("/")); test.beforeEach(login('/'));
test.describe("Open", () => { test.describe('Open', () => {
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
await page.waitForSelector(".img-outer"); await page.waitForSelector('.img-outer');
await page.waitForTimeout(500); await page.waitForTimeout(500);
}); });
test("Look for Images", async ({ page }) => { test('Look for Images', async ({ page }) => {
expect( expect(await page.locator('.img-outer').count(), 'Number of previews').toBeGreaterThan(4);
await page.locator(".img-outer").count(),
"Number of previews"
).toBeGreaterThan(4);
}); });
test("Open one image", async ({ page }) => { test('Open one image', async ({ page }) => {
await page.locator(".img-outer").first().click(); await page.locator('.img-outer').first().click();
await page.waitForTimeout(1000); await page.waitForTimeout(1000);
await page.locator('button[title="Close"]').first().click(); await page.locator('button[title="Close"]').first().click();
}); });
test("Select two images and delete", async ({ page }) => { test('Select two images and delete', async ({ page }) => {
const src1 = await page const src1 = await page.locator('.img-outer > img').nth(1).getAttribute('src');
.locator(".img-outer > img") const src2 = await page.locator('.img-outer > img').nth(2).getAttribute('src');
.nth(1)
.getAttribute("src");
const src2 = await page
.locator(".img-outer > img")
.nth(2)
.getAttribute("src");
expect(await page.locator(`img[src="${src1}"]`).count()).toBe(1); expect(await page.locator(`img[src="${src1}"]`).count()).toBe(1);
expect(await page.locator(`img[src="${src2}"]`).count()).toBe(1); expect(await page.locator(`img[src="${src2}"]`).count()).toBe(1);
await page.locator(".img-outer").nth(1).hover(); await page.locator('.img-outer').nth(1).hover();
await page.locator(".p-outer > .select").nth(1).click(); await page.locator('.p-outer > .select').nth(1).click();
await page.locator(".img-outer").nth(2).click(); await page.locator('.img-outer').nth(2).click();
await page.waitForTimeout(1000); await page.waitForTimeout(1000);
await page.locator('[aria-label="Delete"]').click(); await page.locator('[aria-label="Delete"]').click();
await page.waitForTimeout(1000);
await page.locator('.oc-dialog button.error').click();
await page.waitForTimeout(2000); await page.waitForTimeout(2000);
expect(await page.locator(`img[src="${src1}"]`).count()).toBe(0); expect(await page.locator(`img[src="${src1}"]`).count()).toBe(0);
expect(await page.locator(`img[src="${src2}"]`).count()).toBe(0); expect(await page.locator(`img[src="${src2}"]`).count()).toBe(0);