Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

fix(web): keep reading history controls reachable and refresh audit fixtures

Bingxi Zhao (Frank)c4f6b4972e26
diff --git a/web/components/reading/workspace/ReadingBar.tsx b/web/components/reading/workspace/ReadingBar.tsx
index 6fc09be46..446b20bdc 100644
--- a/web/components/reading/workspace/ReadingBar.tsx
+++ b/web/components/reading/workspace/ReadingBar.tsx
@@ -1,5 +1,7 @@
"use client";
+import "./reading-bar.css";
+
import {
Expand,
FileText,
@@ -155,8 +157,8 @@ export function ReadingBar({
{navigatorOpen ? <PanelLeftClose size={14} /> : <PanelLeftOpen size={14} />}
</BarButton>
<nav aria-label={t("navigation.location")} className="dt-reading-crumbs ml-0.5 flex min-w-0 shrink items-center">
- {feature && <span className="hidden md:contents"><FeatureCrumb section={feature.section} page={feature.page} /></span>}
- <span className="hidden min-w-[72px] max-w-[220px] shrink-[2] items-center md:inline-flex">
+ {feature && <span className="dt-reading-feature hidden md:contents"><FeatureCrumb section={feature.section} page={feature.page} /></span>}
+ <span className="dt-reading-collection hidden min-w-0 max-w-[220px] shrink-[2] items-center md:inline-flex">
<InstanceCrumb
label={title || t("Untitled collection")}
menuLabel={t("Collections")}
@@ -166,7 +168,7 @@ export function ReadingBar({
all={{ label: t("Open folder"), href: backHref }}
/>
</span>
- <span className="flex min-w-[96px] shrink items-center">
+ <span className="flex min-w-0 shrink items-center">
<InstanceCrumb
label={activeDocument?.material.title || activeDocument?.material.filename || t("Immersive reading")}
icon={FileText}
diff --git a/web/components/reading/workspace/reading-bar.css b/web/components/reading/workspace/reading-bar.css
new file mode 100644
index 000000000..33319c68e
--- /dev/null
+++ b/web/components/reading/workspace/reading-bar.css
@@ -0,0 +1,13 @@
+/* The bar shares the reader column, whose width is smaller than the viewport
+ when contents and the companion are docked. Keep history controls clickable. */
+.dt-reading-bar {
+ container-name: reader-bar;
+ container-type: inline-size;
+}
+
+@container reader-bar (max-width: 700px) {
+ .dt-reading-feature,
+ .dt-reading-collection {
+ display: none;
+ }
+}
diff --git a/web/tests/e2e/book-reader-sequential.audit.ts b/web/tests/e2e/book-reader-sequential.audit.ts
index 82334fea7..d0a335485 100644
--- a/web/tests/e2e/book-reader-sequential.audit.ts
+++ b/web/tests/e2e/book-reader-sequential.audit.ts
@@ -1,3 +1,4 @@
+import { emptyLearningIndex } from "./fixtures/learning-index";
import { expect, test } from "@playwright/test";
const BASE_URL =
@@ -99,6 +100,9 @@ test("book arrows read the current chapter before turning chapters", async ({
? new URL(requestUrl.pathname + requestUrl.search, BASE_URL)
: requestUrl;
const { pathname } = url;
+ if (pathname === "/api/dashboard/learning-index") {
+ return route.fulfill(json(emptyLearningIndex));
+ }
if (pathname === "/api/books/sequential-fixture/pages/page-1") {
return route.fulfill(json({ page: fullPage(summaries[0]) }));
}
diff --git a/web/tests/e2e/fixtures/learning-index.ts b/web/tests/e2e/fixtures/learning-index.ts
new file mode 100644
index 000000000..4bac13da0
--- /dev/null
+++ b/web/tests/e2e/fixtures/learning-index.ts
@@ -0,0 +1,6 @@
+import type { LearningSources } from "../../../lib/learning-dashboard";
+
+export const emptyLearningIndex: { sources: LearningSources; failed: string[] } = {
+ sources: { books: [], mastery: [], reading: [], watching: [], practice: [] },
+ failed: [],
+};
diff --git a/web/tests/e2e/pdf-reading-resize.audit.ts b/web/tests/e2e/pdf-reading-resize.audit.ts
index 26c0527c8..c2d8af37c 100644
--- a/web/tests/e2e/pdf-reading-resize.audit.ts
+++ b/web/tests/e2e/pdf-reading-resize.audit.ts
@@ -1,3 +1,4 @@
+import { emptyLearningIndex } from "./fixtures/learning-index";
import { expect, test, type Locator } from "@playwright/test";
import { jsPDF } from "jspdf";
import { emptyTaskBoard } from "./fixtures/task-board";
@@ -75,6 +76,7 @@ test.beforeEach(async ({ page }) => {
],
});
}
+ if (path === "/api/dashboard/learning-index") return json(emptyLearningIndex);
if (path === "/api/partners" || path === "/api/partner-groups")
return json([]);
if (path === "/api/sessions") return json({ sessions: [] });
diff --git a/web/tests/e2e/reading-citation-material.audit.ts b/web/tests/e2e/reading-citation-material.audit.ts
index 352db45d4..a6def5999 100644
--- a/web/tests/e2e/reading-citation-material.audit.ts
+++ b/web/tests/e2e/reading-citation-material.audit.ts
@@ -1,3 +1,4 @@
+import { emptyLearningIndex } from "./fixtures/learning-index";
import { readFile } from "node:fs/promises";
import { expect, test } from "@playwright/test";
import { emptyTaskBoard } from "./fixtures/task-board";
@@ -87,6 +88,7 @@ test.beforeEach(async ({ page }) => {
const json = (payload: unknown, status = 200) =>
route.fulfill({ status, json: payload });
+ if (path === "/api/dashboard/learning-index") return json(emptyLearningIndex);
if (path === "/api/partners" || path === "/api/partner-groups") return json([]);
if (path === "/api/task-board") return json(emptyTaskBoard);
if (path === "/api/auth/status") {
diff --git a/web/tests/e2e/reading-location-history.audit.ts b/web/tests/e2e/reading-location-history.audit.ts
index d72085bbd..d8fbd839f 100644
--- a/web/tests/e2e/reading-location-history.audit.ts
+++ b/web/tests/e2e/reading-location-history.audit.ts
@@ -1,3 +1,4 @@
+import { emptyLearningIndex } from "./fixtures/learning-index";
import { expect, test } from "@playwright/test";
import { emptyTaskBoard } from "./fixtures/task-board";
@@ -108,6 +109,7 @@ test.beforeEach(async ({ page }) => {
const json = (payload: unknown, status = 200) =>
route.fulfill({ status, json: payload });
+ if (path === "/api/dashboard/learning-index") return json(emptyLearningIndex);
if (path === "/api/partners" || path === "/api/partner-groups") return json([]);
if (path === "/api/task-board") return json(emptyTaskBoard);
if (path === "/api/auth/status") {
diff --git a/web/tests/e2e/reading-w3c-annotations.audit.ts b/web/tests/e2e/reading-w3c-annotations.audit.ts
index d9e7a7f71..c47cd0b1b 100644
--- a/web/tests/e2e/reading-w3c-annotations.audit.ts
+++ b/web/tests/e2e/reading-w3c-annotations.audit.ts
@@ -1,3 +1,4 @@
+import { emptyLearningIndex } from "./fixtures/learning-index";
import { expect, test } from "@playwright/test";
import { emptyTaskBoard } from "./fixtures/task-board";
@@ -83,6 +84,7 @@ test.beforeEach(async ({ page }) => {
const json = (payload: unknown, status = 200) =>
route.fulfill({ status, json: payload });
+ if (path === "/api/dashboard/learning-index") return json(emptyLearningIndex);
if (path === "/api/partners" || path === "/api/partner-groups") return json([]);
if (path === "/api/task-board") return json(emptyTaskBoard);
if (path === "/api/auth/status") {
@@ -167,6 +169,10 @@ test("a rich text annotation reflows and activates its sidebar entry", async ({
await expect(highlight).toBeVisible();
await expect(highlight).toHaveAttribute("data-annotation", "annotation-1");
+ // At this width the companion is a sheet; dismiss it before using the reader.
+ await page.getByRole("button", { name: "Put the companion away", exact: true }).click();
+ await expect(page.getByRole("button", { name: "Close panels" })).toBeHidden();
+
// The v1.6.10 reader rework moved the annotation list out of the
// companion into the contents navigator's "Annotations" tab.
await page.getByRole("button", { name: "Expand contents", exact: true }).click();
@@ -175,12 +181,6 @@ test("a rich text annotation reflows and activates its sidebar entry", async ({
.getByRole("button")
.filter({ hasText: "Wave behavior" });
await expect(sidebarEntry).toBeVisible();
- const companionToggle = page.getByRole("button", {
- name: "Reading companion",
- exact: true,
- });
- await companionToggle.click();
- await expect(companionToggle).toHaveAttribute("aria-expanded", "false");
await expect(page.getByRole("button", { name: "Collapse contents", exact: true })).toBeVisible();
await expect(page.getByRole("button", { name: "Close panels" })).toBeHidden();
const article = page.locator("article.r6o-annotatable");
diff --git a/web/tests/e2e/settings-navigation.audit.ts b/web/tests/e2e/settings-navigation.audit.ts
index 7f9ffbf68..6a9b5c195 100644
--- a/web/tests/e2e/settings-navigation.audit.ts
+++ b/web/tests/e2e/settings-navigation.audit.ts
@@ -202,7 +202,7 @@ test.describe("Independent settings", () => {
await nav(page)
.getByRole("link", { name: "Appearance", exact: true })
.click();
- await expect(page).toHaveURL(/\/settings\/appearance$/);
+ await expect(page).toHaveURL((url) => url.pathname === "/settings/appearance");
await expect(page.getByLabel("Model ID", { exact: true })).toHaveCount(0);
await nav(page)
.getByRole("link", { name: "Language models", exact: true })
@@ -348,12 +348,12 @@ test.describe("Independent settings", () => {
await nav(page)
.getByRole("link", { name: "Embedding models", exact: true })
.click();
- await expect(page).toHaveURL(/\/settings\/embedding$/);
+ await expect(page).toHaveURL((url) => url.pathname === "/settings/embedding");
await expect(page.locator("[data-settings-page]")).toHaveCount(1);
await page.goBack();
- await expect(page).toHaveURL(/\/settings\/general$/);
+ await expect(page).toHaveURL((url) => url.pathname === "/settings/general");
await page.goto("/settings#about", { waitUntil: "domcontentloaded" });
- await expect(page).toHaveURL(/\/settings\/about$/);
+ await expect(page).toHaveURL((url) => url.pathname === "/settings/about");
expect(await page.evaluate(() => window.scrollY)).toBe(0);
});
@@ -493,7 +493,7 @@ test("setup links lead to providers, language models, and runtime status", async
]) {
await page.goto("/settings/general", { waitUntil: "domcontentloaded" });
await page.getByRole("link", { name: new RegExp(label.replaceAll(".", "\\.")) }).click();
- await expect(page).toHaveURL(new RegExp(destination + "$"));
+ await expect(page).toHaveURL((url) => url.pathname === destination);
await expect(page.locator("[data-settings-page]")).toHaveCount(1);
}
});