From d940aa573e691a13752983575f67d2fe42575fb6 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Sun, 6 Nov 2022 00:03:01 -0700 Subject: [PATCH] Update tests --- e2e/folders.spec.ts | 20 +++++++++++--------- e2e/login.ts | 22 ++++++++++++---------- e2e/timeline.spec.ts | 38 +++++++++++++++++++++++++------------- 3 files changed, 48 insertions(+), 32 deletions(-) diff --git a/e2e/folders.spec.ts b/e2e/folders.spec.ts index c6ac18a7..dd33a760 100644 --- a/e2e/folders.spec.ts +++ b/e2e/folders.spec.ts @@ -1,15 +1,17 @@ -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('Look for Folders', async ({ page }) => { - expect(await page.locator('.big-icon').count(), 'Number of folders').toBe(2); +test.describe("Open", () => { + test("Look for Folders", async ({ page }) => { + expect(await page.locator(".big-icon").count(), "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.waitForSelector('img[src*="core/preview"]'); }); -}); \ No newline at end of file +}); diff --git a/e2e/login.ts b/e2e/login.ts index 13779632..2278626d 100644 --- a/e2e/login.ts +++ b/e2e/login.ts @@ -1,16 +1,18 @@ -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.setViewportSize({ width: 800, height: 600 }); + 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 + ); await page.waitForSelector('img[src*="core/preview"]'); - } -} \ No newline at end of file + }; +} diff --git a/e2e/timeline.spec.ts b/e2e/timeline.spec.ts index 59cfc98a..06430ae7 100644 --- a/e2e/timeline.spec.ts +++ b/e2e/timeline.spec.ts @@ -1,26 +1,38 @@ -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('Look for Images', async ({ page }) => { - expect(await page.locator('img[src*="core/preview"]').count(), 'Number of previews').toBeGreaterThan(4); +test.describe("Open", () => { + test("Look for Images", async ({ page }) => { + expect( + await page.locator('img[src*="core/preview"]').count(), + "Number of previews" + ).toBeGreaterThan(4); await page.waitForTimeout(1000); }); - test('Open one image', async ({ page }) => { - await page.locator('div:nth-child(2) > .p-outer > .img-outer > img').first().click(); + test("Open one image", async ({ page }) => { + await page + .locator("div:nth-child(2) > .p-outer > .img-outer > img") + .first() + .click(); await page.waitForTimeout(1000); - await page.locator('button.header-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 i1 = "div:nth-child(2) > div:nth-child(1) > .p-outer"; const i2 = "div:nth-child(2) > div:nth-child(2) > .p-outer"; - const src1 = await page.locator(`${i1} > .img-outer > img`).first().getAttribute('src'); - const src2 = await page.locator(`${i2} > .img-outer > img`).first().getAttribute('src'); + const src1 = await page + .locator(`${i1} > .img-outer > img`) + .first() + .getAttribute("src"); + const src2 = await page + .locator(`${i2} > .img-outer > img`) + .first() + .getAttribute("src"); expect(await page.locator(`img[src="${src1}"]`).count()).toBe(1); expect(await page.locator(`img[src="${src2}"]`).count()).toBe(1); @@ -42,4 +54,4 @@ test.describe('Open', () => { expect(await page.locator(`img[src="${src1}"]`).count()).toBe(0); expect(await page.locator(`img[src="${src2}"]`).count()).toBe(0); }); -}); \ No newline at end of file +});