Skip to content

Commit

Permalink
Test fix attempt #1
Browse files Browse the repository at this point in the history
  • Loading branch information
pulsejet committed Sep 30, 2023
1 parent 917020d commit 4db8818
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 44 deletions.
22 changes: 11 additions & 11 deletions e2e/folders.spec.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
16 changes: 7 additions & 9 deletions e2e/login.ts
Original file line number Diff line number Diff line change
@@ -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);
};
}
41 changes: 17 additions & 24 deletions e2e/timeline.spec.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down

0 comments on commit 4db8818

Please sign in to comment.