mirror of
https://github.com/zadam/trilium.git
synced 2026-01-03 05:04:23 +01:00
e2e(server): wrong import
This commit is contained in:
parent
c2f59c4b6c
commit
053812e5f0
@ -1,5 +1,4 @@
|
||||
import test, { BrowserContext, expect, Page } from "@playwright/test";
|
||||
import { describe } from "vitest";
|
||||
|
||||
import App from "../support/app";
|
||||
|
||||
@ -9,92 +8,88 @@ test.beforeEach(async ({ page, context }) => {
|
||||
});
|
||||
test.afterEach(async ({ page, context }) => await setLayout({ page, context }, false));
|
||||
|
||||
describe("PDF sidebar", () => {
|
||||
test("Table of contents works", async ({ page, context }) => {
|
||||
const app = new App(page, context);
|
||||
await app.goto();
|
||||
await app.goToNoteInNewTab("Dacia Logan.pdf");
|
||||
|
||||
test("Table of contents works", async ({ page, context }) => {
|
||||
const app = new App(page, context);
|
||||
await app.goto();
|
||||
await app.goToNoteInNewTab("Dacia Logan.pdf");
|
||||
const toc = app.sidebar.locator(".toc");
|
||||
|
||||
const toc = app.sidebar.locator(".toc");
|
||||
await expect(toc.locator("li")).toHaveCount(48);
|
||||
await expect(toc.locator("li", { hasText: "Logan Van" })).toHaveCount(1);
|
||||
|
||||
await expect(toc.locator("li")).toHaveCount(48);
|
||||
await expect(toc.locator("li", { hasText: "Logan Van" })).toHaveCount(1);
|
||||
const pdfHelper = new PdfHelper(app);
|
||||
await toc.locator("li", { hasText: "Logan Pick-Up" }).click();
|
||||
await pdfHelper.expectPageToBe(13);
|
||||
|
||||
const pdfHelper = new PdfHelper(app);
|
||||
await toc.locator("li", { hasText: "Logan Pick-Up" }).click();
|
||||
await pdfHelper.expectPageToBe(13);
|
||||
|
||||
await app.clickNoteOnNoteTreeByTitle("Layers test.pdf");
|
||||
await expect(toc.locator("li")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("Page navigation works", async ({ page, context }) => {
|
||||
const app = new App(page, context);
|
||||
await app.goto();
|
||||
await app.goToNoteInNewTab("Dacia Logan.pdf");
|
||||
|
||||
const pagesList = app.sidebar.locator(".pdf-pages-list");
|
||||
|
||||
// Check count is correct.
|
||||
await expect(app.sidebar).toContainText("28 pages");
|
||||
expect(await pagesList.locator(".pdf-page-item").count()).toBe(28);
|
||||
|
||||
// Go to page 3.
|
||||
await pagesList.locator(".pdf-page-item").nth(2).click();
|
||||
|
||||
const pdfHelper = new PdfHelper(app);
|
||||
await pdfHelper.expectPageToBe(3);
|
||||
|
||||
await app.clickNoteOnNoteTreeByTitle("Layers test.pdf");
|
||||
await expect(pagesList.locator(".pdf-page-item")).toHaveCount(1);
|
||||
});
|
||||
|
||||
test("Attachments listing works", async ({ page, context }) => {
|
||||
const app = new App(page, context);
|
||||
await app.goto();
|
||||
await app.goToNoteInNewTab("Dacia Logan.pdf");
|
||||
|
||||
const attachmentsList = app.sidebar.locator(".pdf-attachments-list");
|
||||
await expect(app.sidebar).toContainText("2 attachments");
|
||||
await expect(attachmentsList.locator(".pdf-attachment-item")).toHaveCount(2);
|
||||
|
||||
const attachmentInfo = attachmentsList.locator(".pdf-attachment-item", { hasText: "Note.trilium" });
|
||||
await expect(attachmentInfo).toContainText("3.36 MiB");
|
||||
|
||||
// Download the attachment and check its size.
|
||||
const [ download ] = await Promise.all([
|
||||
page.waitForEvent("download"),
|
||||
attachmentInfo.locator(".bx-download").click()
|
||||
]);
|
||||
expect(download).toBeDefined();
|
||||
|
||||
await app.clickNoteOnNoteTreeByTitle("Layers test.pdf");
|
||||
await expect(attachmentsList.locator(".pdf-attachment-item")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("Layers listing works", async ({ page, context }) => {
|
||||
const app = new App(page, context);
|
||||
await app.goto();
|
||||
await app.goToNoteInNewTab("Layers test.pdf");
|
||||
|
||||
// Check count is correct.
|
||||
await expect(app.sidebar).toContainText("2 layers");
|
||||
const layersList = app.sidebar.locator(".pdf-layers-list");
|
||||
await expect(layersList.locator(".pdf-layer-item")).toHaveCount(2);
|
||||
|
||||
// Toggle visibility of the first layer.
|
||||
const firstLayer = layersList.locator(".pdf-layer-item").first();
|
||||
await expect(firstLayer).toContainText("Tongue out");
|
||||
await expect(firstLayer).toContainClass("hidden");
|
||||
await firstLayer.click();
|
||||
await expect(firstLayer).not.toContainClass("visible");
|
||||
|
||||
await app.clickNoteOnNoteTreeByTitle("Dacia Logan.pdf");
|
||||
await expect(layersList.locator(".pdf-layer-item")).toHaveCount(0);
|
||||
});
|
||||
await app.clickNoteOnNoteTreeByTitle("Layers test.pdf");
|
||||
await expect(toc.locator("li")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("Page navigation works", async ({ page, context }) => {
|
||||
const app = new App(page, context);
|
||||
await app.goto();
|
||||
await app.goToNoteInNewTab("Dacia Logan.pdf");
|
||||
|
||||
const pagesList = app.sidebar.locator(".pdf-pages-list");
|
||||
|
||||
// Check count is correct.
|
||||
await expect(app.sidebar).toContainText("28 pages");
|
||||
expect(await pagesList.locator(".pdf-page-item").count()).toBe(28);
|
||||
|
||||
// Go to page 3.
|
||||
await pagesList.locator(".pdf-page-item").nth(2).click();
|
||||
|
||||
const pdfHelper = new PdfHelper(app);
|
||||
await pdfHelper.expectPageToBe(3);
|
||||
|
||||
await app.clickNoteOnNoteTreeByTitle("Layers test.pdf");
|
||||
await expect(pagesList.locator(".pdf-page-item")).toHaveCount(1);
|
||||
});
|
||||
|
||||
test("Attachments listing works", async ({ page, context }) => {
|
||||
const app = new App(page, context);
|
||||
await app.goto();
|
||||
await app.goToNoteInNewTab("Dacia Logan.pdf");
|
||||
|
||||
const attachmentsList = app.sidebar.locator(".pdf-attachments-list");
|
||||
await expect(app.sidebar).toContainText("2 attachments");
|
||||
await expect(attachmentsList.locator(".pdf-attachment-item")).toHaveCount(2);
|
||||
|
||||
const attachmentInfo = attachmentsList.locator(".pdf-attachment-item", { hasText: "Note.trilium" });
|
||||
await expect(attachmentInfo).toContainText("3.36 MiB");
|
||||
|
||||
// Download the attachment and check its size.
|
||||
const [ download ] = await Promise.all([
|
||||
page.waitForEvent("download"),
|
||||
attachmentInfo.locator(".bx-download").click()
|
||||
]);
|
||||
expect(download).toBeDefined();
|
||||
|
||||
await app.clickNoteOnNoteTreeByTitle("Layers test.pdf");
|
||||
await expect(attachmentsList.locator(".pdf-attachment-item")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("Layers listing works", async ({ page, context }) => {
|
||||
const app = new App(page, context);
|
||||
await app.goto();
|
||||
await app.goToNoteInNewTab("Layers test.pdf");
|
||||
|
||||
// Check count is correct.
|
||||
await expect(app.sidebar).toContainText("2 layers");
|
||||
const layersList = app.sidebar.locator(".pdf-layers-list");
|
||||
await expect(layersList.locator(".pdf-layer-item")).toHaveCount(2);
|
||||
|
||||
// Toggle visibility of the first layer.
|
||||
const firstLayer = layersList.locator(".pdf-layer-item").first();
|
||||
await expect(firstLayer).toContainText("Tongue out");
|
||||
await expect(firstLayer).toContainClass("hidden");
|
||||
await firstLayer.click();
|
||||
await expect(firstLayer).not.toContainClass("visible");
|
||||
|
||||
await app.clickNoteOnNoteTreeByTitle("Dacia Logan.pdf");
|
||||
await expect(layersList.locator(".pdf-layer-item")).toHaveCount(0);
|
||||
});
|
||||
|
||||
async function setLayout({ page, context}: { page: Page; context: BrowserContext }, newLayout: boolean) {
|
||||
const app = new App(page, context);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user