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:
branches:
- master
- pulsejet/*
env:
APP_NAME: memories

View File

@ -1,23 +1,23 @@
import { test, expect } from "@playwright/test";
import { login } from "./login";
import { test, expect } from '@playwright/test';
import { login } from './login';
test.beforeEach(login("/folders"));
test.beforeEach(login('/folders'));
test.describe("Open", () => {
test.describe('Open', () => {
test.beforeEach(async ({ page }) => {
await page.waitForSelector(".big-icon");
await page.waitForSelector('.big-icon');
await page.waitForTimeout(500);
});
test("Look for Folders", async ({ page }) => {
const ct = await page.locator(".big-icon").count();
expect(ct, "Number of folders").toBe(2);
test('Look for Folders', async ({ page }) => {
const ct = await page.locator('.big-icon').count();
expect(ct, 'Number of folders').toBe(2);
});
test("Open folder", async ({ page }) => {
await page.locator("text=Local").click();
test('Open folder', async ({ page }) => {
await page.locator('text=Local').click();
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);
});
});

View File

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

View File

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