From 62e541c00bfaf0a07a0d30e3cd2bea65e44a1fd1 Mon Sep 17 00:00:00 2001 From: Chris Amico Date: Mon, 20 Nov 2023 16:13:01 -0500 Subject: [PATCH] Add more tests for the manager view --- tests/anonymous/manager/app.spec.js | 42 ++++++++++++++++++++++--- tests/anonymous/pages/home.spec.js | 8 +++++ tests/anonymous/viewer/document.spec.js | 6 +--- 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/tests/anonymous/manager/app.spec.js b/tests/anonymous/manager/app.spec.js index 5d02c4903..41703742b 100644 --- a/tests/anonymous/manager/app.spec.js +++ b/tests/anonymous/manager/app.spec.js @@ -2,11 +2,43 @@ import { test, expect } from "@playwright/test"; -test("basic manager rendering", async ({ page }) => { - await page.goto("/app"); +test.describe("manager tests", () => { + test("rendering", async ({ page }) => { + await page.goto("/app"); - const url = new URL(page.url()); - expect(url.pathname).toBe("/app"); + const url = new URL(page.url()); + expect(url.pathname).toBe("/app"); - await expect(page).toHaveTitle("DocumentCloud"); + await expect(page).toHaveTitle("DocumentCloud"); + + // anonymous message header + await expect( + page.getByRole("heading", { + name: "Welcome to DocumentCloud, an open document archive from MuckRock!", + }), + ).toBeVisible(); + + // close the overlay + await page.getByRole("button").nth(3).click(); + + // can we see documents? + await expect(page.locator(".outer > div").first()).toBeVisible(); + }); + + test("menus", async ({ page }) => { + await page.goto("/app"); + + // help + await page.getByText("Help ▼").click(); + await expect(page.getByRole("button", { name: "FAQ" })).toBeVisible(); + + // close the menu + await page.locator(".shim").click(); + + // language + await page.getByText("Language ▼").click(); + await expect(page.getByRole("button", { name: "English ✓" })).toBeVisible(); + + await page.locator(".shim").click(); + }); }); diff --git a/tests/anonymous/pages/home.spec.js b/tests/anonymous/pages/home.spec.js index 08cf99803..699c9aecc 100644 --- a/tests/anonymous/pages/home.spec.js +++ b/tests/anonymous/pages/home.spec.js @@ -6,4 +6,12 @@ test("basic homepage test", async ({ page }) => { await page.goto("/home"); await expect(page).toHaveTitle("Home | DocumentCloud"); + + // go to the app + await page.getByRole("banner").getByRole("link").first().click(); + + // and back + await page.getByRole("link", { name: "Home" }).click(); + + await expect(page).toHaveTitle("Home | DocumentCloud"); }); diff --git a/tests/anonymous/viewer/document.spec.js b/tests/anonymous/viewer/document.spec.js index 01c11840b..69c6aacb9 100644 --- a/tests/anonymous/viewer/document.spec.js +++ b/tests/anonymous/viewer/document.spec.js @@ -49,11 +49,7 @@ test.describe("document tests", () => { .selectOption("text"); // check that text view loaded - /* - await expect(page.locator(".text").first()).toHaveText( - text.pages[0].contents, - ); - */ + await expect(page.locator(".text").first()).toBeVisible(); // switch to thumbnail view, click the first image await page.getByRole("combobox").selectOption("thumbnail");