A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: rewrite the whole test suite to be more resilient
Abdullah Attad31a43b4639e
diff --git a/apps/web/__e2e__/checkout.test.js b/apps/web/__e2e__/checkout.test.jsdeleted file mode 100644index 3205930fe..000000000--- a/apps/web/__e2e__/checkout.test.js+++ /dev/null@@ -1,250 +0,0 @@-/*-This file is part of the Notesnook project (https://notesnook.com/)--Copyright (C) 2022 Streetwriters (Private) Limited--This program is free software: you can redistribute it and/or modify-it under the terms of the GNU General Public License as published by-the Free Software Foundation, either version 3 of the License, or-(at your option) any later version.--This program is distributed in the hope that it will be useful,-but WITHOUT ANY WARRANTY; without even the implied warranty of-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-GNU General Public License for more details.--You should have received a copy of the GNU General Public License-along with this program. If not, see <http://www.gnu.org/licenses/>.-*/--const { test, expect } = require("@playwright/test");-const { getTestId, loginUser } = require("./utils");--test.setTimeout(45 * 1000);-/**- * @type {import('@playwright/test').Page}- */-var page = null;-global.page = null;--test.describe.configure({ mode: "serial" });--test.beforeAll(async ({ browser, baseURL }) => {- // Create page yourself and sign in.- const _page = await browser.newPage();- global.page = _page;- page = _page;-- await page.goto(baseURL);- await page.waitForSelector(getTestId("routeHeader"));-- await loginUser();-});--test.afterAll(async () => {- await page.close();-});--const plans = [- { key: "monthly", title: "Monthly", coupon: "INTRO50" },- { key: "yearly", title: "Yearly", coupon: "YEAR15" }-];-const pricingItems = ["subtotal", "tax", "discount", "total"];--function getPaddleTestId(id) {- return `[data-testid="${id}"]`;-}--async function getPrices() {- let prices = [];- for (let item of pricingItems) {- const price = await page.innerText(getTestId(`checkout-price-${item}`));- prices.push(`${item}: ${price}`);- }- return prices;-}--/**- *- * @param {string} prices- */-function roundOffPrices(prices) {- return prices.replaceAll(/(\d+.\d+)/gm, (str, price) => {- const digits = "0".repeat(price.length - 1);- return isNaN(parseFloat(price)) ? 0 : `${price[0]}${digits}`;- // Math.ceil(Math.round(price) / 10) * 10;- });-}--async function getPaddleFrame(selector = "inlineComplianceBarContainer") {- await page.waitForSelector(`.checkout-container iframe`);-- const paddleFrame = await (- await page.$(".checkout-container iframe")- ).contentFrame();- await paddleFrame.waitForSelector(getPaddleTestId(selector));-- return paddleFrame;-}--/**- *- * @param {Page} page- * @param {*} paddleFrame- * @param {*} countryCode- * @param {*} pinCode- */-async function changeCountry(page, paddleFrame, countryCode, pinCode) {- await paddleFrame.selectOption(- getPaddleTestId("countriesSelect"),- countryCode,- { force: true }- );-- if (pinCode)- await paddleFrame.fill(getPaddleTestId("postcodeInput"), pinCode);-- await paddleFrame.click(getPaddleTestId("locationFormSubmitButton"));-- await paddleFrame.waitForSelector(- getPaddleTestId("inlineComplianceBarContainer")- );-- await page.waitForSelector(- getTestId(`checkout-plan-country-${countryCode}`),- { state: "attached" }- );-}--async function forEachPlan(action) {- for (let i = 0; i < plans.length; ++i) {- const plan = plans[i];-- const planTestId = getTestId(`checkout-plan-${plan.key}`);- await page.isEnabled(planTestId, { timeout: 10000 });-- await page.click(planTestId);-- await action(plan);-- if (i < plans.length - 1) {- await page.click(getTestId("checkout-plan-change"));- }- }-}--test("change plans", async () => {- await page.goto("/notes/#/buy/");-- await page.waitForSelector(getTestId("see-all-plans"));-- await page.click(getTestId("see-all-plans"));-- await forEachPlan(async (plan) => {- await expect(- page.innerText(getTestId("checkout-plan-title"))- ).resolves.toBe(plan.title);- });-});--test("confirm plan prices", async () => {- await page.goto("/#/buy/");-- await page.waitForSelector(getTestId("see-all-plans"));-- await page.click(getTestId("see-all-plans"));-- await forEachPlan(async (plan) => {- const prices = roundOffPrices((await getPrices()).join("\n"));- expect(prices).toMatchSnapshot(`checkout-${plan.key}-prices.txt`);- });-});--test("changing locale should show localized prices", async () => {- await page.goto("/#/buy/");-- await page.waitForSelector(getTestId("see-all-plans"));-- await page.click(getTestId("see-all-plans"));-- await forEachPlan(async (plan) => {- const paddleFrame = await getPaddleFrame();-- await changeCountry(page, paddleFrame, "IN", "110001");-- const prices = roundOffPrices((await getPrices()).join("\n"));- expect(prices).toMatchSnapshot(`checkout-${plan.key}-IN-prices.txt`);- });-});--test("applying coupon should change discount & total price", async () => {- await page.goto("/#/buy/");-- await page.waitForSelector(getTestId("see-all-plans"));-- await page.click(getTestId("see-all-plans"));-- await forEachPlan(async (plan) => {- await getPaddleFrame();-- await page.fill(getTestId("checkout-coupon-code"), plan.coupon);- await page.press(getTestId("checkout-coupon-code"), "Enter");-- await getPaddleFrame();-- await page.waitForSelector(getTestId(`checkout-plan-coupon-applied`), {- state: "attached"- });-- const prices = roundOffPrices((await getPrices()).join("\n"));-- expect(prices).toMatchSnapshot(- `checkout-${plan.key}-discounted-prices.txt`- );- });-});--test("apply coupon through url", async () => {- for (let plan of plans) {- await page.goto(`/#/buy/${plan.key}/${plan.coupon}`);-- await getPaddleFrame();-- await page.waitForSelector(getTestId(`checkout-plan-coupon-applied`), {- state: "attached"- });-- const prices = roundOffPrices((await getPrices()).join("\n"));- expect(prices).toMatchSnapshot(- `checkout-${plan.key}-discounted-prices.txt`- );- }-});--test("apply coupon after changing country", async () => {- await page.goto("/#/buy/");-- await page.waitForSelector(getTestId("see-all-plans"));-- await page.click(getTestId("see-all-plans"));-- await forEachPlan(async (plan) => {- const paddleFrame = await getPaddleFrame();-- await changeCountry(page, paddleFrame, "IN", "110001");-- await page.fill(getTestId("checkout-coupon-code"), plan.coupon);- await page.press(getTestId("checkout-coupon-code"), "Enter");-- await getPaddleFrame();-- await page.waitForSelector(getTestId(`checkout-plan-coupon-applied`), {- state: "attached"- });-- const prices = roundOffPrices((await getPrices()).join("\n"));- expect(prices).toMatchSnapshot(- `checkout-${plan.key}-IN-discounted-prices.txt`- );- });-});diff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-IN-discounted-prices-Chromium-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-IN-discounted-prices-Chromium-linux.txtdeleted file mode 100644index 756dfab45..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-IN-discounted-prices-Chromium-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: ₹300000-tax: ₹60000-discount: -₹200000-total: ₹200000-first month then ₹400000/mo\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-IN-discounted-prices-Firefox-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-IN-discounted-prices-Firefox-linux.txtdeleted file mode 100644index 756dfab45..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-IN-discounted-prices-Firefox-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: ₹300000-tax: ₹60000-discount: -₹200000-total: ₹200000-first month then ₹400000/mo\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-IN-discounted-prices-WebKit-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-IN-discounted-prices-WebKit-linux.txtdeleted file mode 100644index c1e09ab16..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-IN-discounted-prices-WebKit-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: ₹300000-tax: ₹60000-discount: -₹200000-total: ₹200000-first month then ₹400000/modiff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-IN-prices-Chromium-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-IN-prices-Chromium-linux.txtdeleted file mode 100644index e05da96b6..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-IN-prices-Chromium-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: ₹300000-tax: ₹60000-discount: ₹0000-total: ₹400000/mo-forever\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-IN-prices-Firefox-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-IN-prices-Firefox-linux.txtdeleted file mode 100644index e05da96b6..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-IN-prices-Firefox-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: ₹300000-tax: ₹60000-discount: ₹0000-total: ₹400000/mo-forever\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-IN-prices-WebKit-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-IN-prices-WebKit-linux.txtdeleted file mode 100644index 9f4c6f36f..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-IN-prices-WebKit-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: ₹300000-tax: ₹60000-discount: ₹0000-total: ₹400000/mo-foreverdiff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-discounted-prices-Chromium-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-discounted-prices-Chromium-linux.txtdeleted file mode 100644index 8cf272388..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-discounted-prices-Chromium-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: $4000-tax: $0000-discount: -$2000-total: $2000-first month then $4000/mo\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-discounted-prices-Firefox-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-discounted-prices-Firefox-linux.txtdeleted file mode 100644index 8cf272388..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-discounted-prices-Firefox-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: $4000-tax: $0000-discount: -$2000-total: $2000-first month then $4000/mo\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-discounted-prices-WebKit-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-discounted-prices-WebKit-linux.txtdeleted file mode 100644index b95202fe8..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-discounted-prices-WebKit-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: $4000-tax: $0000-discount: -$2000-total: $2000-first month then $4000/modiff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-prices-Chromium-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-prices-Chromium-linux.txtdeleted file mode 100644index 855b0ae04..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-prices-Chromium-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: $4000-tax: $0000-discount: $0000-total: $4000/mo-forever\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-prices-Firefox-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-prices-Firefox-linux.txtdeleted file mode 100644index 855b0ae04..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-prices-Firefox-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: $4000-tax: $0000-discount: $0000-total: $4000/mo-forever\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-prices-WebKit-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-prices-WebKit-linux.txtdeleted file mode 100644index b95e0f69a..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-monthly-prices-WebKit-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: $4000-tax: $0000-discount: $0000-total: $4000/mo-foreverdiff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-IN-discounted-prices-Chromium-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-IN-discounted-prices-Chromium-linux.txtdeleted file mode 100644index c0561f6db..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-IN-discounted-prices-Chromium-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: ₹4000000-tax: ₹700000-discount: -₹700000-total: ₹4000000-first year then ₹4000000/yr\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-IN-discounted-prices-Firefox-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-IN-discounted-prices-Firefox-linux.txtdeleted file mode 100644index c0561f6db..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-IN-discounted-prices-Firefox-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: ₹4000000-tax: ₹700000-discount: -₹700000-total: ₹4000000-first year then ₹4000000/yr\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-IN-discounted-prices-WebKit-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-IN-discounted-prices-WebKit-linux.txtdeleted file mode 100644index ca5b21965..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-IN-discounted-prices-WebKit-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: ₹4000000-tax: ₹700000-discount: -₹700000-total: ₹4000000-first year then ₹4000000/yrdiff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-IN-prices-Chromium-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-IN-prices-Chromium-linux.txtdeleted file mode 100644index 6229c18fc..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-IN-prices-Chromium-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: ₹4000000-tax: ₹700000-discount: ₹0000-total: ₹4000000/yr-forever\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-IN-prices-Firefox-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-IN-prices-Firefox-linux.txtdeleted file mode 100644index 6229c18fc..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-IN-prices-Firefox-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: ₹4000000-tax: ₹700000-discount: ₹0000-total: ₹4000000/yr-forever\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-IN-prices-WebKit-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-IN-prices-WebKit-linux.txtdeleted file mode 100644index 1a2edfe51..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-IN-prices-WebKit-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: ₹4000000-tax: ₹700000-discount: ₹0000-total: ₹4000000/yr-foreverdiff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-discounted-prices-Chromium-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-discounted-prices-Chromium-linux.txtdeleted file mode 100644index 056911535..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-discounted-prices-Chromium-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: $40000-tax: $0000-discount: -$7000-total: $40000-first year then $40000/yr\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-discounted-prices-Firefox-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-discounted-prices-Firefox-linux.txtdeleted file mode 100644index 056911535..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-discounted-prices-Firefox-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: $40000-tax: $0000-discount: -$7000-total: $40000-first year then $40000/yr\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-discounted-prices-WebKit-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-discounted-prices-WebKit-linux.txtdeleted file mode 100644index 06761934c..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-discounted-prices-WebKit-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: $40000-tax: $0000-discount: -$7000-total: $40000-first year then $40000/yrdiff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-prices-Chromium-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-prices-Chromium-linux.txtdeleted file mode 100644index a5b5a89e9..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-prices-Chromium-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: $40000-tax: $0000-discount: $0000-total: $40000/yr-forever\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-prices-Firefox-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-prices-Firefox-linux.txtdeleted file mode 100644index a5b5a89e9..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-prices-Firefox-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: $40000-tax: $0000-discount: $0000-total: $40000/yr-forever\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-prices-WebKit-linux.txt b/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-prices-WebKit-linux.txtdeleted file mode 100644index b80dd2c95..000000000--- a/apps/web/__e2e__/checkout.test.js-snapshots/checkout-yearly-prices-WebKit-linux.txt+++ /dev/null@@ -1,5 +0,0 @@-subtotal: $40000-tax: $0000-discount: $0000-total: $40000/yr-foreverdiff --git a/apps/web/__e2e__/checkout.test.ts b/apps/web/__e2e__/checkout.test.tsnew file mode 100644index 000000000..fa19dc813--- /dev/null+++ b/apps/web/__e2e__/checkout.test.ts@@ -0,0 +1,180 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { test, Page, expect } from "@playwright/test";+import { USER } from "./utils";+import { AppModel } from "./models/app.model";+import { PriceItem } from "./models/types";++test.setTimeout(45 * 1000);+test.describe.configure({ mode: "serial" });++let page: Page;+let app: AppModel;++test.beforeAll(async ({ browser }) => {+ const { email, key, password } = USER.CURRENT;+ if (!email || !password) throw new Error("Failed to load user credentials.");++ // Create page yourself and sign in.+ page = await browser.newPage();+ app = new AppModel(page);+ await app.auth.goto();+ await app.auth.login({ email, key, password });+});++test.afterAll(async () => {+ await page.close();+});++test.afterEach(async () => {+ await app.goto();+});++function roundOffPrices(prices: PriceItem[]) {+ return prices+ .map((p) => {+ const price = p.value.replace(/(\d+).(\d+)/gm, (_, whole, decimal) => {+ const decimalDigits = "0".repeat(decimal.length);+ const wholeDigits = "0".repeat(whole.length - 1);+ return `${whole[0]}${wholeDigits}.${decimalDigits}`;+ });+ return `${p.label}: ${price}`;+ })+ .join("\n");+}++test("change plans", async () => {+ await app.checkout.goto();+ const plans = await app.checkout.getPlans();++ const titles: string[] = [];+ for (const plan of plans) {+ const pricing = await plan.open();+ const title = await pricing.getTitle();+ if (title) titles.push(title);+ await pricing.changePlan();+ }++ expect(titles).toHaveLength(2);+ expect(titles.join("").length).toBeGreaterThan(0);+});++test("confirm plan prices", async () => {+ await app.checkout.goto();+ const plans = await app.checkout.getPlans();++ const planPrices: Record<string, string> = {};+ for (const plan of plans) {+ const pricing = await plan.open();+ const title = await pricing.getTitle();+ if (!title) continue;++ planPrices[title.toLowerCase()] = roundOffPrices(await pricing.getPrices());+ await pricing.changePlan();+ }++ for (const key in planPrices) {+ expect(planPrices[key]).toMatchSnapshot(`checkout-${key}-prices.txt`);+ }+});++test("changing locale should show localized prices", async () => {+ await app.checkout.goto();+ const plans = await app.checkout.getPlans();++ const planPrices: Record<string, string> = {};+ for (const plan of plans) {+ const pricing = await plan.open();+ const title = await pricing.getTitle();+ if (!title) continue;+ await pricing.changeCountry("IN", 110001);++ planPrices[title.toLowerCase()] = roundOffPrices(await pricing.getPrices());+ await pricing.changePlan();+ }++ for (const key in planPrices) {+ expect(planPrices[key]).toMatchSnapshot(`checkout-${key}-IN-prices.txt`);+ }+});++test("applying coupon should change discount & total price", async () => {+ await app.checkout.goto();+ const plans = await app.checkout.getPlans();++ const planPrices: Record<string, string> = {};+ for (const plan of plans) {+ const pricing = await plan.open();+ const title = await pricing.getTitle();+ if (!title) continue;+ await pricing.applyCoupon("INTRO50");++ planPrices[title.toLowerCase()] = roundOffPrices(await pricing.getPrices());+ await pricing.changePlan();+ }++ for (const key in planPrices) {+ expect(planPrices[key]).toMatchSnapshot(+ `checkout-${key}-discounted-prices.txt`+ );+ }+});++test("apply coupon through url", async () => {+ const planPrices: Record<string, string> = {};+ for (const plan of ["monthly", "yearly"] as const) {+ await app.checkout.goto(plan, "INTRO50");+ const pricing = await app.checkout.getPricing();+ await pricing.waitForCoupon();++ planPrices[plan] = roundOffPrices(await pricing.getPrices());++ await app.goto();+ }++ for (const key in planPrices) {+ expect(planPrices[key]).toMatchSnapshot(+ `checkout-${key}-discounted-prices.txt`+ );+ }+});++test("apply coupon after changing country", async () => {+ await app.checkout.goto();+ const plans = await app.checkout.getPlans();++ const planPrices: Record<string, string> = {};+ for (const plan of plans) {+ const pricing = await plan.open();+ const title = await pricing.getTitle();+ if (!title) continue;+ await pricing.changeCountry("IN", 110001);+ await pricing.applyCoupon("INTRO50");++ planPrices[title.toLowerCase()] = roundOffPrices(await pricing.getPrices());+ await pricing.changePlan();+ }++ for (const key in planPrices) {+ expect(planPrices[key]).toMatchSnapshot(+ `checkout-${key}-IN-discounted-prices.txt`+ );+ }+});diff --git a/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-monthly-IN-discounted-prices-Chromium-linux.txt b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-monthly-IN-discounted-prices-Chromium-linux.txtnew file mode 100644index 000000000..08746e7d8--- /dev/null+++ b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-monthly-IN-discounted-prices-Chromium-linux.txt@@ -0,0 +1,4 @@+Subtotal: ₹300.00+Sales tax: ₹60.00+Discount: -₹200.00+Total: ₹200.00\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-monthly-IN-prices-Chromium-linux.txt b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-monthly-IN-prices-Chromium-linux.txtnew file mode 100644index 000000000..7693f004e--- /dev/null+++ b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-monthly-IN-prices-Chromium-linux.txt@@ -0,0 +1,4 @@+Subtotal: ₹300.00+Sales tax: ₹60.00+Discount: ₹0.00+Total: ₹400.00/mo\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-monthly-discounted-prices-Chromium-linux.txt b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-monthly-discounted-prices-Chromium-linux.txtnew file mode 100644index 000000000..fb3a01927--- /dev/null+++ b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-monthly-discounted-prices-Chromium-linux.txt@@ -0,0 +1,4 @@+Subtotal: $4.00+Sales tax: $0.00+Discount: -$2.00+Total: $2.00\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-monthly-prices-Chromium-linux.txt b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-monthly-prices-Chromium-linux.txtnew file mode 100644index 000000000..002868371--- /dev/null+++ b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-monthly-prices-Chromium-linux.txt@@ -0,0 +1,4 @@+Subtotal: $4.00+Sales tax: $0.00+Discount: $0.00+Total: $4.00/mo\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-monthly-prices-Firefox-linux.txt b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-monthly-prices-Firefox-linux.txtnew file mode 100644index 000000000..002868371--- /dev/null+++ b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-monthly-prices-Firefox-linux.txt@@ -0,0 +1,4 @@+Subtotal: $4.00+Sales tax: $0.00+Discount: $0.00+Total: $4.00/mo\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-monthly-prices-WebKit-linux.txt b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-monthly-prices-WebKit-linux.txtnew file mode 100644index 000000000..002868371--- /dev/null+++ b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-monthly-prices-WebKit-linux.txt@@ -0,0 +1,4 @@+Subtotal: $4.00+Sales tax: $0.00+Discount: $0.00+Total: $4.00/mo\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-yearly-IN-discounted-prices-Chromium-linux.txt b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-yearly-IN-discounted-prices-Chromium-linux.txtnew file mode 100644index 000000000..9a76fcb40--- /dev/null+++ b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-yearly-IN-discounted-prices-Chromium-linux.txt@@ -0,0 +1,4 @@+Subtotal: ₹4000.00+Sales tax: ₹700.00+Discount: -₹2000.00+Total: ₹2000.00\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-yearly-IN-prices-Chromium-linux.txt b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-yearly-IN-prices-Chromium-linux.txtnew file mode 100644index 000000000..c1ca0e019--- /dev/null+++ b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-yearly-IN-prices-Chromium-linux.txt@@ -0,0 +1,4 @@+Subtotal: ₹4000.00+Sales tax: ₹700.00+Discount: ₹0.00+Total: ₹4000.00/yr\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-yearly-discounted-prices-Chromium-linux.txt b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-yearly-discounted-prices-Chromium-linux.txtnew file mode 100644index 000000000..0c793a1b3--- /dev/null+++ b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-yearly-discounted-prices-Chromium-linux.txt@@ -0,0 +1,4 @@+Subtotal: $40.00+Sales tax: $0.00+Discount: -$20.00+Total: $20.00\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-yearly-prices-Chromium-linux.txt b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-yearly-prices-Chromium-linux.txtnew file mode 100644index 000000000..9053fe957--- /dev/null+++ b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-yearly-prices-Chromium-linux.txt@@ -0,0 +1,4 @@+Subtotal: $40.00+Sales tax: $0.00+Discount: $0.00+Total: $40.00/yr\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-yearly-prices-Firefox-linux.txt b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-yearly-prices-Firefox-linux.txtnew file mode 100644index 000000000..9053fe957--- /dev/null+++ b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-yearly-prices-Firefox-linux.txt@@ -0,0 +1,4 @@+Subtotal: $40.00+Sales tax: $0.00+Discount: $0.00+Total: $40.00/yr\ No newline at end of filediff --git a/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-yearly-prices-WebKit-linux.txt b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-yearly-prices-WebKit-linux.txtnew file mode 100644index 000000000..9053fe957--- /dev/null+++ b/apps/web/__e2e__/checkout.test.ts-snapshots/checkout-yearly-prices-WebKit-linux.txt@@ -0,0 +1,4 @@+Subtotal: $40.00+Sales tax: $0.00+Discount: $0.00+Total: $40.00/yr\ No newline at end of filediff --git a/apps/web/__e2e__/colors.issues.test.js b/apps/web/__e2e__/colors.issues.test.jsdeleted file mode 100644index 4d54c7393..000000000--- a/apps/web/__e2e__/colors.issues.test.js+++ /dev/null@@ -1,59 +0,0 @@-/*-This file is part of the Notesnook project (https://notesnook.com/)--Copyright (C) 2022 Streetwriters (Private) Limited--This program is free software: you can redistribute it and/or modify-it under the terms of the GNU General Public License as published by-the Free Software Foundation, either version 3 of the License, or-(at your option) any later version.--This program is distributed in the hope that it will be useful,-but WITHOUT ANY WARRANTY; without even the implied warranty of-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-GNU General Public License for more details.--You should have received a copy of the GNU General Public License-along with this program. If not, see <http://www.gnu.org/licenses/>.-*/--const { test } = require("@playwright/test");-const { getTestId } = require("./utils");-const { useContextMenu, clickMenuItem } = require("./utils/actions");-const { createNoteAndCheckPresence } = require("./utils/conditions");-const Menu = require("./utils/menuitemidbuilder");--// test.skip(-// "TODO: make sure to navigate to home if there are 0 notes in a color"-// );--/**- * @type {import("@playwright/test").Page}- */-var page = null;-global.page = null;--test.beforeEach(async ({ page: _page, baseURL }) => {- global.page = _page;- page = _page;- await page.goto(baseURL);- await page.waitForSelector(getTestId("routeHeader"));-});--test("delete the last note of a color", async ({ page }) => {- const noteSelector = await createNoteAndCheckPresence();-- await useContextMenu(noteSelector, async () => {- await clickMenuItem("colors");- await clickMenuItem("red");- });-- const navItem = new Menu("navitem").item("red").build();- await page.waitForSelector(navItem);-- await useContextMenu(noteSelector, async () => {- await clickMenuItem("movetotrash");- });-- await page.click(new Menu("navitem").item("trash").build());-});diff --git a/apps/web/__e2e__/colors.test.ts b/apps/web/__e2e__/colors.test.tsnew file mode 100644index 000000000..a9560a5be--- /dev/null+++ b/apps/web/__e2e__/colors.test.ts@@ -0,0 +1,48 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/+import { test, expect } from "@playwright/test";+import { AppModel } from "./models/app.model";+import { NOTE } from "./utils";++test("delete the last note of a color", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);+ await note?.contextMenu.color("red");+ await app.navigation.findItem("red");++ await note?.contextMenu.moveToTrash();++ await app.goToTrash();+ expect(await app.getRouteHeader()).toBe("Trash");+});++test("rename color", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);+ await note?.contextMenu.color("red");+ const colorItem = await app.navigation.findItem("red");++ await colorItem?.renameColor("priority-33");++ expect(await app.navigation.findItem("priority-33"));+});diff --git a/apps/web/__e2e__/editor.test.js b/apps/web/__e2e__/editor.test.jsdeleted file mode 100644index ff06eba8f..000000000--- a/apps/web/__e2e__/editor.test.js+++ /dev/null@@ -1,349 +0,0 @@-/*-This file is part of the Notesnook project (https://notesnook.com/)--Copyright (C) 2022 Streetwriters (Private) Limited--This program is free software: you can redistribute it and/or modify-it under the terms of the GNU General Public License as published by-the Free Software Foundation, either version 3 of the License, or-(at your option) any later version.--This program is distributed in the hope that it will be useful,-but WITHOUT ANY WARRANTY; without even the implied warranty of-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-GNU General Public License for more details.--You should have received a copy of the GNU General Public License-along with this program. If not, see <http://www.gnu.org/licenses/>.-*/--const { test, expect } = require("@playwright/test");-const {- createNote,- NOTE,- getTestId,- getEditorTitle,- getEditorContent,- getEditorContentAsHTML,- editNote-} = require("./utils");-const {- checkNotePresence,- createNoteAndCheckPresence-} = require("./utils/conditions");-/**- * @type {import("@playwright/test").Page}- */-var page = null;-global.page = null;-test.beforeEach(async ({ page: _page, baseURL }) => {- global.page = _page;- page = _page;- await page.goto(baseURL);- await page.waitForSelector(getTestId("routeHeader"));-});--test("focus mode", async () => {- await createNote(NOTE, "notes");-- await page.click(getTestId("focus-mode"));-- await page.waitForTimeout(500);-- expect(- await page.screenshot({ fullPage: true, quality: 100, type: "jpeg" })- ).toMatchSnapshot("focus-mode.jpg", { threshold: 99 });-});--test("dark mode in focus mode", async () => {- await createNote(NOTE, "notes");-- await page.click(getTestId("focus-mode"));-- await page.waitForTimeout(500);-- await page.click(getTestId("dark-mode"));-- await page.waitForTimeout(1000);-- expect(- await page.screenshot({ fullPage: true, quality: 100, type: "jpeg" })- ).toMatchSnapshot("dark-focus-mode.jpg", { threshold: 99 });-- await page.click(getTestId("dark-mode"));-- await page.waitForTimeout(1000);-- expect(- await page.screenshot({ fullPage: true, quality: 100, type: "jpeg" })- ).toMatchSnapshot("light-focus-mode.jpg", { threshold: 99 });-});--test("full screen in focus mode", async () => {- await createNote(NOTE, "notes");-- await page.click(getTestId("focus-mode"));-- await page.waitForTimeout(500);-- await page.click(getTestId("enter-fullscreen"));-- await page.waitForTimeout(100);-- await page.click(getTestId("exit-fullscreen"));-});--test("normal mode from focus mode", async () => {- await createNote(NOTE, "notes");-- await page.click(getTestId("focus-mode"));-- await page.waitForTimeout(500);-- await page.click(getTestId("normal-mode"));-- await page.waitForTimeout(1000);-- expect(- await page.screenshot({ fullPage: true, quality: 100, type: "jpeg" })- ).toMatchSnapshot("normal-mode-from-focus-mode.jpg", { threshold: 99 });-});--test("creating a new note should clear the editor contents & title", async () => {- await createNoteAndCheckPresence();-- await page.click(getTestId("notes-action-button"));-- expect(await getEditorTitle()).toBe("");-- expect(await getEditorContent()).toBe("");-});--test("creating a new note should clear the word count", async () => {- const selector = await createNoteAndCheckPresence();-- await page.click(getTestId("notes-action-button"));-- await page.click(selector);-- await createNote({ title: "Hello World" }, "notes");-- await expect(page.innerText(getTestId("editor-word-count"))).resolves.toBe(- "0 words"- );-});--test("creating a new title-only note should add it to the list", async () => {- const selector = await createNoteAndCheckPresence();-- await page.click(getTestId("notes-action-button"));-- await page.click(selector);-- await createNoteAndCheckPresence({ title: "Hello World" });-});--test.skip("format changes should get saved", async () => {- const selector = await createNoteAndCheckPresence();-- await page.click(getTestId("notes-action-button"));-- await page.click(selector);-- await page.waitForSelector(".mce-content-body");-- await page.keyboard.press("Shift+End");-- await page.click(`#editorToolbar button[title="Bold"]`);-- await page.waitForTimeout(200);-- await page.click(getTestId("notes-action-button"));-- await page.click(selector);-- const content = await getEditorContentAsHTML();-- expect(content).toMatchSnapshot(`format-changes-should-get-saved.txt`);-});--test("opening an empty titled note should empty out editor contents", async () => {- await createNoteAndCheckPresence();-- const onlyTitle = await createNoteAndCheckPresence({- title: "Only a title"- });-- await page.click(getTestId("notes-action-button"));-- await page.reload();-- const fullNote = await checkNotePresence("home", 1, NOTE);-- await page.click(fullNote);-- await expect(getEditorContent()).resolves.toBe(NOTE.content);-- await expect(getEditorTitle()).resolves.toBe(NOTE.title);-- await page.click(onlyTitle);-- await expect(getEditorTitle()).resolves.toBe("Only a title");-- await expect(getEditorContent()).resolves.toBe("");-});--test("focus should not jump to editor while typing in title input", async () => {- await page.click(getTestId("notes-action-button"));-- await page.waitForSelector(".ProseMirror");-- await page.type(getTestId("editor-title"), "Hello", { delay: 200 });-- await expect(getEditorTitle()).resolves.toBe("Hello");-- await expect(getEditorContent()).resolves.toBe("");-});--test("select all & backspace should clear all content in editor", async () => {- const selector = await createNoteAndCheckPresence();-- await page.focus(".ProseMirror");-- await page.keyboard.press("Home");-- await page.keyboard.press("Shift+End");-- await page.waitForTimeout(500);-- await page.keyboard.press("Backspace");-- await page.waitForTimeout(200);-- await page.click(getTestId("notes-action-button"));-- await page.click(selector);-- await page.waitForSelector(".ProseMirror");-- await expect(getEditorContent()).resolves.toBe("");-});--test.skip("last line doesn't get saved if it's font is different", async () => {- const selector = await createNoteAndCheckPresence();-- await page.keyboard.press("Enter");-- await page.click(`#editorToolbar button[title="Fonts"]`);-- await page.click(`div[title="Serif"]`);-- await page.type(".ProseMirror", "I am another line in Serif font.");-- await page.waitForTimeout(200);-- await page.click(getTestId("notes-action-button"));-- await page.click(selector);-- const content = await getEditorContentAsHTML();-- expect(content).toMatchSnapshot(`last-line-with-different-font.txt`);-});--test("editing a note and switching immediately to another note and making an edit shouldn't overlap both notes", async ({- page-}) => {- await createNoteAndCheckPresence({- title: "Test note 1",- content: "53ad8e4e40ebebd0f400498d"- });-- await createNoteAndCheckPresence({- title: "Test note 2",- content: "f054d19e9a2f46eff7b9bb25"- });-- const selector1 = `[data-item-index="1"] div`;- const selector2 = `[data-item-index="2"] div`;-- for (let i = 0; i < 10; ++i) {- await page.click(selector2);-- await editNote(null, `Test note 1 (${i}) `);-- await page.click(selector2);-- await editNote(null, `Test note 2 (${i})`);- }-- await page.click(selector1);- expect(await getEditorContent()).toMatchSnapshot(- `fast-switch-and-edit-note-2.txt`- );-- await page.click(selector2);- expect(await getEditorContent()).toMatchSnapshot(- `fast-switch-and-edit-note-1.txt`- );-});--test("editing a note and switching immediately to another note and editing the title shouldn't overlap both notes", async ({- page-}, testInfo) => {- testInfo.setTimeout(0);- await createNoteAndCheckPresence({- title: "Test note 1",- content: "53ad8e4e40ebebd0f400498d"- });-- await createNoteAndCheckPresence({- title: "Test note 2",- content: "f054d19e9a2f46eff7b9bb25"- });-- const selector1 = `[data-item-index="1"] div`;- const selector2 = `[data-item-index="2"] div`;-- for (let i = 0; i < 10; ++i) {- await page.click(selector2);-- await editNote(`Test note 1 (${i})`, null, true);-- await page.waitForTimeout(100);-- await page.click(selector2);-- await editNote(`Test note 2 (${i})`, null, true);-- await page.waitForTimeout(100);- }-- await page.click(selector1);- expect(await getEditorTitle()).toMatchSnapshot(- `fast-switch-and-edit-note-title-2.txt`- );-- await page.click(selector2);- expect(await getEditorTitle()).toMatchSnapshot(- `fast-switch-and-edit-note-title-1.txt`- );-});--test("editing a note and toggling read-only mode should show updated content", async () => {- const selector = await createNoteAndCheckPresence();-- await page.click(getTestId("notes-action-button"));-- await page.click(selector);-- await editNote(null, `An edit I made`, false);-- await page.click(getTestId("properties"));-- await page.click(getTestId("properties-readonly"));-- await page.click(getTestId("properties-close"));-- expect(await getEditorContent()).toMatchSnapshot(`readonly-edited-note.txt`);-});diff --git a/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-title-1-Chromium-linux.txt b/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-title-1-Chromium-linux.txtdeleted file mode 100644index 3dbe7be90..000000000--- a/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-title-1-Chromium-linux.txt+++ /dev/null@@ -1 +0,0 @@-Test note 1 (9)\ No newline at end of filediff --git a/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-title-1-Firefox-linux.txt b/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-title-1-Firefox-linux.txtdeleted file mode 100644index 3dbe7be90..000000000--- a/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-title-1-Firefox-linux.txt+++ /dev/null@@ -1 +0,0 @@-Test note 1 (9)\ No newline at end of filediff --git a/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-title-1-WebKit-linux.txt b/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-title-1-WebKit-linux.txtdeleted file mode 100644index 3dbe7be90..000000000--- a/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-title-1-WebKit-linux.txt+++ /dev/null@@ -1 +0,0 @@-Test note 1 (9)\ No newline at end of filediff --git a/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-title-2-Chromium-linux.txt b/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-title-2-Chromium-linux.txtdeleted file mode 100644index c8a4b6fd3..000000000--- a/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-title-2-Chromium-linux.txt+++ /dev/null@@ -1 +0,0 @@-Test note 2 (9)\ No newline at end of filediff --git a/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-title-2-Firefox-linux.txt b/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-title-2-Firefox-linux.txtdeleted file mode 100644index c8a4b6fd3..000000000--- a/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-title-2-Firefox-linux.txt+++ /dev/null@@ -1 +0,0 @@-Test note 2 (9)\ No newline at end of filediff --git a/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-title-2-WebKit-linux.txt b/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-title-2-WebKit-linux.txtdeleted file mode 100644index c8a4b6fd3..000000000--- a/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-title-2-WebKit-linux.txt+++ /dev/null@@ -1 +0,0 @@-Test note 2 (9)\ No newline at end of filediff --git a/apps/web/__e2e__/editor.test.js-snapshots/format-changes-should-get-saved-Chromium-linux.txt b/apps/web/__e2e__/editor.test.js-snapshots/format-changes-should-get-saved-Chromium-linux.txtdeleted file mode 100644index 711bdf038..000000000--- a/apps/web/__e2e__/editor.test.js-snapshots/format-changes-should-get-saved-Chromium-linux.txt+++ /dev/null@@ -1 +0,0 @@-<p><strong>This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1</strong></p>\ No newline at end of filediff --git a/apps/web/__e2e__/editor.test.js-snapshots/format-changes-should-get-saved-Firefox-linux.txt b/apps/web/__e2e__/editor.test.js-snapshots/format-changes-should-get-saved-Firefox-linux.txtdeleted file mode 100644index 87df3d45f..000000000--- a/apps/web/__e2e__/editor.test.js-snapshots/format-changes-should-get-saved-Firefox-linux.txt+++ /dev/null@@ -1 +0,0 @@-<p><strong>This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1</strong><br></p>\ No newline at end of filediff --git a/apps/web/__e2e__/editor.test.js-snapshots/format-changes-should-get-saved-WebKit-linux.txt b/apps/web/__e2e__/editor.test.js-snapshots/format-changes-should-get-saved-WebKit-linux.txtdeleted file mode 100644index 711bdf038..000000000--- a/apps/web/__e2e__/editor.test.js-snapshots/format-changes-should-get-saved-WebKit-linux.txt+++ /dev/null@@ -1 +0,0 @@-<p><strong>This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1</strong></p>\ No newline at end of filediff --git a/apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-Chromium-linux.txt b/apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-Chromium-linux.txtdeleted file mode 100644index e29d00be4..000000000--- a/apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-Chromium-linux.txt+++ /dev/null@@ -1 +0,0 @@-<p>This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1<span id="_mce_caret" data-mce-bogus="1"><span style="font-family: serif;">I am another line in Serif font.</span></span></p>\ No newline at end of filediff --git a/apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-Firefox-linux.txt b/apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-Firefox-linux.txtdeleted file mode 100644index cd7c6a823..000000000--- a/apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-Firefox-linux.txt+++ /dev/null@@ -1 +0,0 @@-<p>This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1<span id="_mce_caret" data-mce-bogus="1"><span style="font-family: serif;">I am another line in Serif font.</span></span><br></p>\ No newline at end of filediff --git a/apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-WebKit-linux.txt b/apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-WebKit-linux.txtdeleted file mode 100644index e29d00be4..000000000--- a/apps/web/__e2e__/editor.test.js-snapshots/last-line-with-different-font-WebKit-linux.txt+++ /dev/null@@ -1 +0,0 @@-<p>This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1<span id="_mce_caret" data-mce-bogus="1"><span style="font-family: serif;">I am another line in Serif font.</span></span></p>\ No newline at end of filediff --git a/apps/web/__e2e__/editor.test.js-snapshots/normal-mode-from-focus-mode-Chromium-linux.jpg b/apps/web/__e2e__/editor.test.js-snapshots/normal-mode-from-focus-mode-Chromium-linux.jpgdeleted file mode 100644index 5921c6bf0..000000000Binary files a/apps/web/__e2e__/editor.test.js-snapshots/normal-mode-from-focus-mode-Chromium-linux.jpg and /dev/null differdiff --git a/apps/web/__e2e__/editor.test.js-snapshots/normal-mode-from-focus-mode-Firefox-linux.jpg b/apps/web/__e2e__/editor.test.js-snapshots/normal-mode-from-focus-mode-Firefox-linux.jpgdeleted file mode 100644index 0406ba5a0..000000000Binary files a/apps/web/__e2e__/editor.test.js-snapshots/normal-mode-from-focus-mode-Firefox-linux.jpg and /dev/null differdiff --git a/apps/web/__e2e__/editor.test.js-snapshots/normal-mode-from-focus-mode-WebKit-linux.jpg b/apps/web/__e2e__/editor.test.js-snapshots/normal-mode-from-focus-mode-WebKit-linux.jpgdeleted file mode 100644index 89a167e3e..000000000Binary files a/apps/web/__e2e__/editor.test.js-snapshots/normal-mode-from-focus-mode-WebKit-linux.jpg and /dev/null differdiff --git a/apps/web/__e2e__/editor.test.ts b/apps/web/__e2e__/editor.test.tsnew file mode 100644index 000000000..d4a5f5dc2--- /dev/null+++ b/apps/web/__e2e__/editor.test.ts@@ -0,0 +1,261 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { test, expect } from "@playwright/test";+import { AppModel } from "./models/app.model";+import { NOTE, TITLE_ONLY_NOTE } from "./utils";++test("focus mode", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ await notes.createNote(NOTE);++ await notes.editor.enterFocusMode();++ expect(await notes.editor.isFocusMode()).toBeTruthy();+ expect(+ await page.screenshot({ fullPage: true, quality: 100, type: "jpeg" })+ ).toMatchSnapshot("focus-mode.jpg", { maxDiffPixelRatio: 0.01 });+});++test("switch theme in focus mode", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ await notes.createNote(NOTE);+ await notes.editor.enterFocusMode();++ await notes.editor.enterDarkMode();++ expect(await notes.editor.isDarkMode()).toBeTruthy();+ expect(+ await page.screenshot({ fullPage: true, quality: 100, type: "jpeg" })+ ).toMatchSnapshot("dark-focus-mode.jpg", { maxDiffPixelRatio: 0.01 });++ await notes.editor.exitDarkMode();++ expect(await notes.editor.isDarkMode()).toBeFalsy();+ expect(+ await page.screenshot({ fullPage: true, quality: 100, type: "jpeg" })+ ).toMatchSnapshot("light-focus-mode.jpg", { maxDiffPixelRatio: 0.01 });+});++test("full screen in focus mode", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ await notes.createNote(NOTE);+ await notes.editor.enterFocusMode();++ await notes.editor.enterFullscreen();+ expect(await notes.editor.isFullscreen()).toBeTruthy();++ await notes.editor.exitFullscreen();+ expect(await notes.editor.isFullscreen()).toBeFalsy();+});++test("normal mode from focus mode", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ await notes.createNote(NOTE);+ await notes.editor.enterFocusMode();++ await notes.editor.exitFocusMode();++ expect(await notes.editor.isFocusMode()).toBeFalsy();+ expect(+ await page.screenshot({ fullPage: true, quality: 100, type: "jpeg" })+ ).toMatchSnapshot("normal-mode-from-focus-mode.jpg", {+ maxDiffPixelRatio: 0.01+ });+});++test("creating a new note should clear the editor contents & title", async ({+ page+}) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ await notes.createNote(NOTE);++ await notes.newNote();++ expect(await notes.editor.isUnloaded()).toBeTruthy();+ expect(await notes.editor.getTitle()).toBe("");+ expect(await notes.editor.getContent("text")).toBe("");+});++test("creating a new title-only note should add it to the list", async ({+ page+}) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();++ const note = await notes.createNote({ title: NOTE.title });++ expect(note).toBeDefined();+});++test("opening an empty titled note should empty out editor contents", async ({+ page+}) => {+ const app = new AppModel(page);+ await app.goto();+ let notes = await app.goToNotes();+ await notes.createNote(NOTE);+ await notes.createNote(TITLE_ONLY_NOTE);+ await notes.newNote();+ await app.goto();+ notes = await app.goToNotes();+ const fullNote = await notes.findNote(NOTE);+ await fullNote?.openNote();++ const onlyTitle = await notes.findNote(TITLE_ONLY_NOTE);+ await onlyTitle?.openNote();++ expect(await notes.editor.getContent("text")).toBe("");+ expect(await notes.editor.getTitle()).toBe(TITLE_ONLY_NOTE.title);+});++test("focus should not jump to editor while typing in title input", async ({+ page+}) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ await notes.newNote();++ await notes.editor.typeTitle("Hello", 200);++ expect(await notes.editor.getTitle()).toBe("Hello");+ expect(await notes.editor.getContent("text")).toBe("");+});++test("select all & backspace should clear all content in editor", async ({+ page+}) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);++ await notes.editor.selectAll();+ await page.keyboard.press("Backspace");+ await notes.editor.waitForSaving();++ await notes.newNote();+ await note?.openNote();+ expect(await notes.editor.getContent("text")).toBe("");+});++test("editing a note and switching immediately to another note and making an edit shouldn't overlap both notes", async ({+ page+}) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note1 = await notes.createNote({+ title: "Test note 1",+ content: "53ad8e4e40ebebd0f400498d"+ });+ const note2 = await notes.createNote({+ title: "Test note 2",+ content: "f054d19e9a2f46eff7b9bb25"+ });++ for (let i = 0; i < 10; ++i) {+ await note1?.openNote();+ await notes.editor.setContent(`Test note 1 (${i}) `);++ await note2?.openNote();+ await notes.editor.setContent(`Test note 2 (${i})`);+ }++ await notes.editor.waitForSaving();+ await notes.newNote();++ await note2?.openNote();+ expect(await notes.editor.getContent("text")).toMatchSnapshot(+ `fast-switch-and-edit-note-2.txt`+ );++ await note1?.openNote();+ expect(await notes.editor.getContent("text")).toMatchSnapshot(+ `fast-switch-and-edit-note-1.txt`+ );+});++test("editing a note and switching immediately to another note and editing the title shouldn't overlap both notes", async ({+ page+}) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note1 = await notes.createNote({+ title: "Test note 1",+ content: "53ad8e4e40ebebd0f400498d"+ });+ const note2 = await notes.createNote({+ title: "Test note 2",+ content: "f054d19e9a2f46eff7b9bb25"+ });++ for (let i = 0; i < 10; ++i) {+ await note1?.openNote();+ await notes.editor.typeTitle(`Test note 1 (${i}) `);++ await note2?.openNote();+ await notes.editor.typeTitle(`Test note 2 (${i})`);+ }++ await notes.editor.waitForSaving();+ await notes.newNote();++ await note2?.openNote();+ expect(await notes.editor.getTitle()).toMatchSnapshot(+ `fast-switch-and-edit-note-title-2.txt`+ );++ await note1?.openNote();+ expect(await notes.editor.getTitle()).toMatchSnapshot(+ `fast-switch-and-edit-note-title-1.txt`+ );+});++test("editing a note and toggling read-only mode should show updated content", async ({+ page+}) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);+ await notes.newNote();+ await note?.openNote();++ await notes.editor.setContent(`An edit I made`);+ await note?.properties.readonly();++ expect(await note?.properties.isReadonly()).toBeTruthy();+ expect(await notes.editor.getContent("text")).toMatchSnapshot(+ `readonly-edited-note.txt`+ );+});diff --git a/apps/web/__e2e__/editor.test.js-snapshots/dark-focus-mode-Chromium-linux.jpg b/apps/web/__e2e__/editor.test.ts-snapshots/dark-focus-mode-Chromium-linux.jpgsimilarity index 100%rename from apps/web/__e2e__/editor.test.js-snapshots/dark-focus-mode-Chromium-linux.jpgrename to apps/web/__e2e__/editor.test.ts-snapshots/dark-focus-mode-Chromium-linux.jpgdiff --git a/apps/web/__e2e__/editor.test.js-snapshots/dark-focus-mode-Firefox-linux.jpg b/apps/web/__e2e__/editor.test.ts-snapshots/dark-focus-mode-Firefox-linux.jpgsimilarity index 100%rename from apps/web/__e2e__/editor.test.js-snapshots/dark-focus-mode-Firefox-linux.jpgrename to apps/web/__e2e__/editor.test.ts-snapshots/dark-focus-mode-Firefox-linux.jpgdiff --git a/apps/web/__e2e__/editor.test.js-snapshots/dark-focus-mode-WebKit-linux.jpg b/apps/web/__e2e__/editor.test.ts-snapshots/dark-focus-mode-WebKit-linux.jpgsimilarity index 100%rename from apps/web/__e2e__/editor.test.js-snapshots/dark-focus-mode-WebKit-linux.jpgrename to apps/web/__e2e__/editor.test.ts-snapshots/dark-focus-mode-WebKit-linux.jpgdiff --git a/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-1-Chromium-linux.txt b/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-1-Chromium-linux.txtsimilarity index 100%rename from apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-1-Chromium-linux.txtrename to apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-1-Chromium-linux.txtdiff --git a/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-1-Firefox-linux.txt b/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-1-Firefox-linux.txtsimilarity index 100%rename from apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-1-Firefox-linux.txtrename to apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-1-Firefox-linux.txtdiff --git a/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-1-WebKit-linux.txt b/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-1-WebKit-linux.txtsimilarity index 100%rename from apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-1-WebKit-linux.txtrename to apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-1-WebKit-linux.txtdiff --git a/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-2-Chromium-linux.txt b/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-2-Chromium-linux.txtsimilarity index 100%rename from apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-2-Chromium-linux.txtrename to apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-2-Chromium-linux.txtdiff --git a/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-2-Firefox-linux.txt b/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-2-Firefox-linux.txtsimilarity index 100%rename from apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-2-Firefox-linux.txtrename to apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-2-Firefox-linux.txtdiff --git a/apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-2-WebKit-linux.txt b/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-2-WebKit-linux.txtsimilarity index 100%rename from apps/web/__e2e__/editor.test.js-snapshots/fast-switch-and-edit-note-2-WebKit-linux.txtrename to apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-2-WebKit-linux.txtdiff --git a/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-title-1-Chromium-linux.txt b/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-title-1-Chromium-linux.txtnew file mode 100644index 000000000..1b6dba491--- /dev/null+++ b/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-title-1-Chromium-linux.txt@@ -0,0 +1 @@+Test note 1Test note 1 (0) Test note 1 (1) Test note 1 (2) Test note 1 (3) Test note 1 (4) Test note 1 (5) Test note 1 (6) Test note 1 (7) Test note 1 (8) Test note 1 (9)\ No newline at end of filediff --git a/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-title-1-Firefox-linux.txt b/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-title-1-Firefox-linux.txtnew file mode 100644index 000000000..1b6dba491--- /dev/null+++ b/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-title-1-Firefox-linux.txt@@ -0,0 +1 @@+Test note 1Test note 1 (0) Test note 1 (1) Test note 1 (2) Test note 1 (3) Test note 1 (4) Test note 1 (5) Test note 1 (6) Test note 1 (7) Test note 1 (8) Test note 1 (9)\ No newline at end of filediff --git a/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-title-1-WebKit-linux.txt b/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-title-1-WebKit-linux.txtnew file mode 100644index 000000000..1b6dba491--- /dev/null+++ b/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-title-1-WebKit-linux.txt@@ -0,0 +1 @@+Test note 1Test note 1 (0) Test note 1 (1) Test note 1 (2) Test note 1 (3) Test note 1 (4) Test note 1 (5) Test note 1 (6) Test note 1 (7) Test note 1 (8) Test note 1 (9)\ No newline at end of filediff --git a/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-title-2-Chromium-linux.txt b/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-title-2-Chromium-linux.txtnew file mode 100644index 000000000..92705d03c--- /dev/null+++ b/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-title-2-Chromium-linux.txt@@ -0,0 +1 @@+Test note 2Test note 2 (0)Test note 2 (1)Test note 2 (2)Test note 2 (3)Test note 2 (4)Test note 2 (5)Test note 2 (6)Test note 2 (7)Test note 2 (8)Test note 2 (9)\ No newline at end of filediff --git a/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-title-2-Firefox-linux.txt b/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-title-2-Firefox-linux.txtnew file mode 100644index 000000000..92705d03c--- /dev/null+++ b/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-title-2-Firefox-linux.txt@@ -0,0 +1 @@+Test note 2Test note 2 (0)Test note 2 (1)Test note 2 (2)Test note 2 (3)Test note 2 (4)Test note 2 (5)Test note 2 (6)Test note 2 (7)Test note 2 (8)Test note 2 (9)\ No newline at end of filediff --git a/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-title-2-WebKit-linux.txt b/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-title-2-WebKit-linux.txtnew file mode 100644index 000000000..92705d03c--- /dev/null+++ b/apps/web/__e2e__/editor.test.ts-snapshots/fast-switch-and-edit-note-title-2-WebKit-linux.txt@@ -0,0 +1 @@+Test note 2Test note 2 (0)Test note 2 (1)Test note 2 (2)Test note 2 (3)Test note 2 (4)Test note 2 (5)Test note 2 (6)Test note 2 (7)Test note 2 (8)Test note 2 (9)\ No newline at end of filediff --git a/apps/web/__e2e__/editor.test.js-snapshots/focus-mode-Chromium-linux.jpg b/apps/web/__e2e__/editor.test.ts-snapshots/focus-mode-Chromium-linux.jpgsimilarity index 100%rename from apps/web/__e2e__/editor.test.js-snapshots/focus-mode-Chromium-linux.jpgrename to apps/web/__e2e__/editor.test.ts-snapshots/focus-mode-Chromium-linux.jpgdiff --git a/apps/web/__e2e__/editor.test.js-snapshots/focus-mode-Firefox-linux.jpg b/apps/web/__e2e__/editor.test.ts-snapshots/focus-mode-Firefox-linux.jpgsimilarity index 100%rename from apps/web/__e2e__/editor.test.js-snapshots/focus-mode-Firefox-linux.jpgrename to apps/web/__e2e__/editor.test.ts-snapshots/focus-mode-Firefox-linux.jpgdiff --git a/apps/web/__e2e__/editor.test.js-snapshots/focus-mode-WebKit-linux.jpg b/apps/web/__e2e__/editor.test.ts-snapshots/focus-mode-WebKit-linux.jpgsimilarity index 100%rename from apps/web/__e2e__/editor.test.js-snapshots/focus-mode-WebKit-linux.jpgrename to apps/web/__e2e__/editor.test.ts-snapshots/focus-mode-WebKit-linux.jpgdiff --git a/apps/web/__e2e__/editor.test.js-snapshots/light-focus-mode-Chromium-linux.jpg b/apps/web/__e2e__/editor.test.ts-snapshots/light-focus-mode-Chromium-linux.jpgsimilarity index 100%rename from apps/web/__e2e__/editor.test.js-snapshots/light-focus-mode-Chromium-linux.jpgrename to apps/web/__e2e__/editor.test.ts-snapshots/light-focus-mode-Chromium-linux.jpgdiff --git a/apps/web/__e2e__/editor.test.js-snapshots/light-focus-mode-Firefox-linux.jpg b/apps/web/__e2e__/editor.test.ts-snapshots/light-focus-mode-Firefox-linux.jpgsimilarity index 100%rename from apps/web/__e2e__/editor.test.js-snapshots/light-focus-mode-Firefox-linux.jpgrename to apps/web/__e2e__/editor.test.ts-snapshots/light-focus-mode-Firefox-linux.jpgdiff --git a/apps/web/__e2e__/editor.test.js-snapshots/light-focus-mode-WebKit-linux.jpg b/apps/web/__e2e__/editor.test.ts-snapshots/light-focus-mode-WebKit-linux.jpgsimilarity index 100%rename from apps/web/__e2e__/editor.test.js-snapshots/light-focus-mode-WebKit-linux.jpgrename to apps/web/__e2e__/editor.test.ts-snapshots/light-focus-mode-WebKit-linux.jpgdiff --git a/apps/web/__e2e__/editor.test.ts-snapshots/normal-mode-from-focus-mode-Chromium-linux.jpg b/apps/web/__e2e__/editor.test.ts-snapshots/normal-mode-from-focus-mode-Chromium-linux.jpgnew file mode 100644index 000000000..02d3d464aBinary files /dev/null and b/apps/web/__e2e__/editor.test.ts-snapshots/normal-mode-from-focus-mode-Chromium-linux.jpg differdiff --git a/apps/web/__e2e__/editor.test.ts-snapshots/normal-mode-from-focus-mode-Firefox-linux.jpg b/apps/web/__e2e__/editor.test.ts-snapshots/normal-mode-from-focus-mode-Firefox-linux.jpgnew file mode 100644index 000000000..7b17995abBinary files /dev/null and b/apps/web/__e2e__/editor.test.ts-snapshots/normal-mode-from-focus-mode-Firefox-linux.jpg differdiff --git a/apps/web/__e2e__/editor.test.ts-snapshots/normal-mode-from-focus-mode-WebKit-linux.jpg b/apps/web/__e2e__/editor.test.ts-snapshots/normal-mode-from-focus-mode-WebKit-linux.jpgnew file mode 100644index 000000000..0f02697d9Binary files /dev/null and b/apps/web/__e2e__/editor.test.ts-snapshots/normal-mode-from-focus-mode-WebKit-linux.jpg differdiff --git a/apps/web/__e2e__/editor.test.js-snapshots/readonly-edited-note-Chromium-linux.txt b/apps/web/__e2e__/editor.test.ts-snapshots/readonly-edited-note-Chromium-linux.txtsimilarity index 100%rename from apps/web/__e2e__/editor.test.js-snapshots/readonly-edited-note-Chromium-linux.txtrename to apps/web/__e2e__/editor.test.ts-snapshots/readonly-edited-note-Chromium-linux.txtdiff --git a/apps/web/__e2e__/editor.test.js-snapshots/readonly-edited-note-Firefox-linux.txt b/apps/web/__e2e__/editor.test.ts-snapshots/readonly-edited-note-Firefox-linux.txtsimilarity index 100%rename from apps/web/__e2e__/editor.test.js-snapshots/readonly-edited-note-Firefox-linux.txtrename to apps/web/__e2e__/editor.test.ts-snapshots/readonly-edited-note-Firefox-linux.txtdiff --git a/apps/web/__e2e__/editor.test.js-snapshots/readonly-edited-note-WebKit-linux.txt b/apps/web/__e2e__/editor.test.ts-snapshots/readonly-edited-note-WebKit-linux.txtsimilarity index 100%rename from apps/web/__e2e__/editor.test.js-snapshots/readonly-edited-note-WebKit-linux.txtrename to apps/web/__e2e__/editor.test.ts-snapshots/readonly-edited-note-WebKit-linux.txtdiff --git a/apps/web/__e2e__/importer.test.js b/apps/web/__e2e__/importer.test.jsindex db9dab81c..9b6eb9a75 100644--- a/apps/web/__e2e__/importer.test.js+++ b/apps/web/__e2e__/importer.test.js@@ -17,48 +17,48 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-const { test, expect } = require("@playwright/test");-const { getTestId, isTestAll, loginUser } = require("./utils");-const path = require("path");+// const { test, expect } = require("@playwright/test");+// const { getTestId, isTestAll, loginUser } = require("./utils");+// const path = require("path");-/**- * @type {import("@playwright/test").Page}- */-var page = null;-global.page = null;-test.beforeEach(async ({ page: _page, baseURL }) => {- global.page = _page;- page = _page;- await page.goto(baseURL);- await page.waitForSelector(getTestId("routeHeader"));-});+// /**+// * @type {import("@playwright/test").Page}+// */+// var page = null;+// global.page = null;+// test.beforeEach(async ({ page: _page, baseURL }) => {+// global.page = _page;+// page = _page;+// await page.goto(baseURL);+// await page.waitForSelector(getTestId("routeHeader"));+// });-if (!isTestAll()) test.skip();+// if (!isTestAll()) test.skip();-test("login user & import notes", async () => {- await loginUser();+// test("login user & import notes", async () => {+// await loginUser();- await page.click(getTestId("navitem-settings"));+// await page.click(getTestId("navitem-settings"));- await page.click(getTestId("settings-importer"));+// await page.click(getTestId("settings-importer"));- await page.click(getTestId("settings-importer-import"));+// await page.click(getTestId("settings-importer-import"));- const [fileChooser] = await Promise.all([- page.waitForEvent("filechooser"),- page.click(getTestId("import-dialog-select-files"))- ]);+// const [fileChooser] = await Promise.all([+// page.waitForEvent("filechooser"),+// page.click(getTestId("import-dialog-select-files"))+// ]);- await fileChooser.setFiles(path.join(__dirname, "data", "importer-data.zip"));+// await fileChooser.setFiles(path.join(__dirname, "data", "importer-data.zip"));- await page.click(getTestId("importer-dialog-notes"));+// await page.click(getTestId("importer-dialog-notes"));- let titles = [];- for (let i = 0; i < 6; ++i) {- const noteId = getTestId(`note-${i}-title`);- const text = await page.innerText(noteId);- titles.push(text);- }+// let titles = [];+// for (let i = 0; i < 6; ++i) {+// const noteId = getTestId(`note-${i}-title`);+// const text = await page.innerText(noteId);+// titles.push(text);+// }- expect(titles.join("\n")).toMatchSnapshot("importer-notes-titles.txt");-});+// expect(titles.join("\n")).toMatchSnapshot("importer-notes-titles.txt");+// });diff --git a/apps/web/__e2e__/importer.test.js-snapshots/importer-notes-titles-Chromium-linux.txt b/apps/web/__e2e__/importer.test.js-snapshots/importer-notes-titles-Chromium-linux.txtdeleted file mode 100644index 94de26d75..000000000--- a/apps/web/__e2e__/importer.test.js-snapshots/importer-notes-titles-Chromium-linux.txt+++ /dev/null@@ -1,6 +0,0 @@-2021-05-21T22_31_28.334+05_00-2021-11-29T10_12_57.757+05_00-2021-11-29T10_11_39.427+05_00-2021-11-29T10_08_04.344+05_00-2021-11-29T10_12_25.187+05_00-Some really amazing note\ No newline at end of filediff --git a/apps/web/__e2e__/importer.test.js-snapshots/importer-notes-titles-Firefox-linux.txt b/apps/web/__e2e__/importer.test.js-snapshots/importer-notes-titles-Firefox-linux.txtdeleted file mode 100644index 94de26d75..000000000--- a/apps/web/__e2e__/importer.test.js-snapshots/importer-notes-titles-Firefox-linux.txt+++ /dev/null@@ -1,6 +0,0 @@-2021-05-21T22_31_28.334+05_00-2021-11-29T10_12_57.757+05_00-2021-11-29T10_11_39.427+05_00-2021-11-29T10_08_04.344+05_00-2021-11-29T10_12_25.187+05_00-Some really amazing note\ No newline at end of filediff --git a/apps/web/__e2e__/importer.test.js-snapshots/importer-notes-titles-WebKit-linux.txt b/apps/web/__e2e__/importer.test.js-snapshots/importer-notes-titles-WebKit-linux.txtdeleted file mode 100644index 6788adb78..000000000--- a/apps/web/__e2e__/importer.test.js-snapshots/importer-notes-titles-WebKit-linux.txt+++ /dev/null@@ -1,11 +0,0 @@-2021-05-21T22_31_28.334+05_00--2021-11-29T10_12_57.757+05_00--2021-11-29T10_11_39.427+05_00--2021-11-29T10_08_04.344+05_00--2021-11-29T10_12_25.187+05_00--Some really amazing notediff --git a/apps/web/__e2e__/models/app.model.ts b/apps/web/__e2e__/models/app.model.tsnew file mode 100644index 000000000..66f74f3e0--- /dev/null+++ b/apps/web/__e2e__/models/app.model.ts@@ -0,0 +1,106 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Page } from "@playwright/test";+import { getTestId } from "../utils";+import { AuthModel } from "./auth.model";+import { CheckoutModel } from "./checkout.model";+import { ItemsViewModel } from "./items-view.model";+import { NavigationMenuModel } from "./navigation-menu.model";+import { NotebooksViewModel } from "./notebooks-view.model";+import { NotesViewModel } from "./notes-view.model";+import { SettingsViewModel } from "./settings-view.model";+import { ToastsModel } from "./toasts.model";+import { TrashViewModel } from "./trash-view.model";++export class AppModel {+ private readonly page: Page;+ readonly toasts: ToastsModel;+ readonly navigation: NavigationMenuModel;+ readonly auth: AuthModel;+ readonly checkout: CheckoutModel;++ constructor(page: Page) {+ this.page = page;+ this.toasts = new ToastsModel(page);+ this.navigation = new NavigationMenuModel(page);+ this.auth = new AuthModel(page);+ this.checkout = new CheckoutModel(page);+ }++ async goto() {+ await this.page.goto("/");+ await this.getRouteHeader();+ }++ async goToNotes() {+ await this.navigateTo("Notes");+ return new NotesViewModel(this.page, "home");+ }++ async goToNotebooks() {+ await this.navigateTo("Notebooks");+ return new NotebooksViewModel(this.page);+ }++ async goToFavorites() {+ await this.navigateTo("Favorites");+ return new NotesViewModel(this.page, "notes");+ }++ async goToTags() {+ await this.navigateTo("Tags");+ return new ItemsViewModel(this.page, "tags");+ }++ async goToColor(color: string) {+ await this.navigateTo(color);+ return new NotesViewModel(this.page, "notes");+ }++ async goToTrash() {+ await this.navigateTo("Trash");+ return new TrashViewModel(this.page);+ }++ async goToSettings() {+ await this.navigateTo("Settings");+ return new SettingsViewModel(this.page);+ }++ private async navigateTo(title: string) {+ if ((await this.getRouteHeader()) === title) return;+ const item = await this.navigation.findItem(title);+ await item?.click();+ await this.page.waitForTimeout(1000);+ }++ getRouteHeader() {+ return this.page.locator(getTestId("routeHeader")).inputValue();+ }++ async isSynced() {+ return (+ (await this.page+ .locator(getTestId("sync-status-completed"))+ .isVisible()) ||+ (await this.page.locator(getTestId("sync-status-synced")).isVisible())+ );+ }+}diff --git a/apps/web/__e2e__/models/auth.model.ts b/apps/web/__e2e__/models/auth.model.tsnew file mode 100644index 000000000..ea8400ab7--- /dev/null+++ b/apps/web/__e2e__/models/auth.model.ts@@ -0,0 +1,58 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Locator, Page } from "@playwright/test";+import { getTestId } from "../utils";++type User = {+ email: string;+ password: string;+ key?: string;+};++export class AuthModel {+ private readonly page: Page;+ private readonly emailInput: Locator;+ private readonly passwordInput: Locator;+ private readonly submitButton: Locator;++ constructor(page: Page) {+ this.page = page;+ this.emailInput = page.locator(getTestId("email"));+ this.passwordInput = page.locator(getTestId("password"));+ this.submitButton = page.locator(getTestId("submitButton"));+ }++ async goto() {+ await this.page.goto("/login");+ }++ async login(user: Partial<User>) {+ if (!user.email && !user.password) return;++ if (user.email) await this.emailInput.fill(user.email);+ if (user.password) await this.passwordInput.fill(user.password);++ await this.submitButton.click();++ await this.page+ .locator(getTestId("sync-status-completed"))+ .waitFor({ state: "visible" });+ }+}diff --git a/apps/web/__e2e__/models/base-item.model.ts b/apps/web/__e2e__/models/base-item.model.tsnew file mode 100644index 000000000..f9b866441--- /dev/null+++ b/apps/web/__e2e__/models/base-item.model.ts@@ -0,0 +1,57 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Locator, Page } from "@playwright/test";+import { getTestId } from "../utils";++export class BaseItemModel {+ protected readonly page: Page;+ private readonly titleText: Locator;+ readonly descriptionText: Locator;++ constructor(protected readonly locator: Locator) {+ this.page = locator.page();+ this.titleText = this.locator.locator(getTestId(`title`));+ this.descriptionText = this.locator.locator(getTestId(`description`));+ }++ async getId() {+ return await this.locator.getAttribute("id");+ }++ async getTitle() {+ if (await this.titleText.isVisible())+ return (await this.titleText.textContent()) || "";+ return "";+ }++ async getDescription() {+ if (await this.descriptionText.isVisible())+ return (await this.descriptionText.textContent()) || "";+ return "";+ }++ isPresent() {+ return this.locator.isVisible();+ }++ waitFor(state: "attached" | "detached" | "visible" | "hidden") {+ return this.locator.waitFor({ state });+ }+}diff --git a/apps/web/__e2e__/models/base-view.model.ts b/apps/web/__e2e__/models/base-view.model.tsnew file mode 100644index 000000000..e7b3c7e5d--- /dev/null+++ b/apps/web/__e2e__/models/base-view.model.ts@@ -0,0 +1,61 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Locator, Page } from "@playwright/test";+import { getTestId } from "../utils";+import { iterateList } from "./utils";++export class BaseViewModel {+ protected readonly page: Page;+ protected readonly list: Locator;++ constructor(page: Page, pageId: string) {+ this.page = page;+ this.list = page.locator(`#${pageId} >> ${getTestId("note-list")}`);+ }++ async findGroup(groupName: string) {+ const locator = this.list.locator(+ `${getTestId(`virtuoso-item-list`)} >> ${getTestId("group-header")}`+ );++ for await (const item of iterateList(locator)) {+ if ((await item.locator(getTestId("title")).textContent()) === groupName)+ return item;+ }+ return undefined;+ }++ protected async *iterateItems() {+ const locator = this.list.locator(+ `${getTestId(`virtuoso-item-list`)} >> ${getTestId("list-item")}`+ );+ for await (const _item of iterateList(locator)) {+ const id = await _item.getAttribute("id");+ if (!id) return;++ yield this.list.locator(`#${id}`);+ }+ return undefined;+ }++ async waitForItem(title: string) {+ await this.list.locator(getTestId("title"), { hasText: title }).waitFor();+ }+}diff --git a/apps/web/__e2e__/models/checkout.model.ts b/apps/web/__e2e__/models/checkout.model.tsnew file mode 100644index 000000000..556d5d248--- /dev/null+++ b/apps/web/__e2e__/models/checkout.model.ts@@ -0,0 +1,161 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Locator, Page } from "@playwright/test";+import { getTestId } from "../utils";+import { PriceItem } from "./types";+import { iterateList } from "./utils";++export class CheckoutModel {+ private readonly page: Page;+ private readonly seeAllPlansButton: Locator;++ constructor(page: Page) {+ this.page = page;+ this.seeAllPlansButton = page.locator(getTestId("see-all-plans"));+ }++ async goto(period?: "monthly" | "yearly", coupon?: string) {+ let url = "/notes/#/buy/";+ if (period) url += period;+ if (coupon) url += `/${coupon}`;+ await this.page.goto(url);+ if (!period && !coupon) await this.seeAllPlansButton.waitFor();+ }++ async getPlans() {+ await this.seeAllPlansButton.click();++ const plans: Plan[] = [];+ for await (const item of iterateList(+ this.page.locator(getTestId("checkout-plan"))+ )) {+ plans.push(new Plan(item));+ }+ return plans;+ }++ async getPricing() {+ const pricing = new PricingModel(this.page);+ await pricing.waitFor();+ return pricing;+ }+}++class Plan {+ private readonly titleText: Locator;+ constructor(private readonly locator: Locator) {+ this.titleText = locator.locator(getTestId("title"));+ }++ getTitle() {+ return this.titleText.textContent();+ }++ async open() {+ await this.locator.click();+ const pricing = new PricingModel(this.locator.page());+ await pricing.waitFor();+ return pricing;+ }+}++class PricingModel {+ private readonly title: Locator;+ private readonly changePlanButton: Locator;+ private readonly couponInput: Locator;+ constructor(private readonly page: Page) {+ this.title = page.locator(getTestId("checkout-plan-title"));+ this.changePlanButton = page.locator(getTestId("checkout-plan-change"));+ this.couponInput = page.locator(getTestId("checkout-coupon-code"));+ }++ async waitFor() {+ await this.changePlanButton.waitFor();+ }++ async waitForCoupon() {+ await getPaddleFrame(this.page);++ await this.page.locator(getTestId(`checkout-plan-coupon-applied`)).waitFor({+ state: "attached"+ });+ }++ getTitle() {+ return this.title.textContent();+ }++ async getPrices() {+ const prices: PriceItem[] = [];+ for await (const item of iterateList(+ this.page.locator(getTestId("checkout-price-item"))+ )) {+ const label = await item.locator(getTestId("label")).innerText();+ const value = await item.locator(getTestId("value")).innerText();+ prices.push({ label, value });+ }+ return prices;+ }++ async applyCoupon(couponCode: string) {+ await this.couponInput.fill(couponCode);+ await this.couponInput.press("Enter");+ await this.waitForCoupon();+ }++ async changeCountry(countryCode: string, pinCode?: number) {+ const paddle = await getPaddleFrame(this.page);++ await paddle+ .locator(getPaddleTestId("countriesSelect"))+ .selectOption(countryCode, { force: true });++ if (pinCode)+ await paddle+ .locator(getPaddleTestId("postcodeInput"))+ .fill(pinCode.toString());++ await paddle.locator(getPaddleTestId("locationFormSubmitButton")).click();++ await paddle+ .locator(getPaddleTestId("inlineComplianceBarContainer"))+ .waitFor();++ await this.page+ .locator(getTestId(`checkout-plan-country-${countryCode}`))+ .waitFor({ state: "attached" });+ }++ async changePlan() {+ await this.changePlanButton.click();+ }+}++function getPaddleTestId(id: string) {+ return `[data-testid="${id}"]`;+}++async function getPaddleFrame(page: Page) {+ const paddleFrame = page.frameLocator(`.checkout-container iframe`);+ await paddleFrame+ .locator(getPaddleTestId("inlineComplianceBarContainer"))+ .waitFor();+ return paddleFrame;+}diff --git a/apps/web/__e2e__/utils/menuitemidbuilder.js b/apps/web/__e2e__/models/context-menu.model.tssimilarity index 62%rename from apps/web/__e2e__/utils/menuitemidbuilder.jsrename to apps/web/__e2e__/models/context-menu.model.tsindex 1c26a6c7c..821c56ecb 100644--- a/apps/web/__e2e__/utils/menuitemidbuilder.js+++ b/apps/web/__e2e__/models/context-menu.model.ts@@ -17,31 +17,25 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-const { getTestId } = require(".");+import { Page, Locator } from "@playwright/test";+import { getTestId } from "../utils";-class MenuItemIDBuilder {- static new(type) {- return new MenuItemIDBuilder(type);- }- constructor(type) {- this.type = type;- this.suffix = "";+export class ContextMenuModel {+ constructor(private readonly page: Page) {}++ async open(locator: Locator) {+ await locator.click({ button: "right" });}- item(itemId) {- this.itemId = itemId;- return this;+ async clickOnItem(id: string) {+ await this.getItem(id).click();}- checked() {- this.suffix = "checked";- return this;+ getItem(id: string) {+ return this.page.locator(getTestId(`menuitem-${id}`));}- build() {- return getTestId(- `${this.type}-${this.itemId}${this.suffix ? `-${this.suffix}` : ""}`- );+ async close() {+ await this.page.keyboard.press("Escape");}}-module.exports = MenuItemIDBuilder;diff --git a/apps/web/__e2e__/models/editor.model.ts b/apps/web/__e2e__/models/editor.model.tsnew file mode 100644index 000000000..4a066d245--- /dev/null+++ b/apps/web/__e2e__/models/editor.model.ts@@ -0,0 +1,240 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Locator, Page } from "@playwright/test";+import { getTestId } from "../utils";++export class EditorModel {+ private readonly page: Page;+ private readonly title: Locator;+ private readonly content: Locator;+ private readonly tags: Locator;+ private readonly tagInput: Locator;+ private readonly focusModeButton: Locator;+ private readonly normalModeButton: Locator;+ private readonly darkModeButton: Locator;+ private readonly lightModeButton: Locator;+ private readonly enterFullscreenButton: Locator;+ private readonly exitFullscreenButton: Locator;+ private readonly wordCountText: Locator;+ private readonly dateEditedText: Locator;+ private readonly searchButton: Locator;+ private readonly previewCancelButton: Locator;+ private readonly previewRestoreButton: Locator;+ private readonly previewNotice: Locator;++ constructor(page: Page) {+ this.page = page;+ this.title = page.locator(getTestId("editor-title"));+ this.content = page.locator(".ProseMirror");+ this.tagInput = page.locator(getTestId("editor-tag-input"));+ this.tags = page.locator(`${getTestId("tags")} > ${getTestId("tag")}`);+ this.focusModeButton = page.locator(getTestId("Focus mode"));+ this.normalModeButton = page.locator(getTestId("Normal mode"));+ this.darkModeButton = page.locator(getTestId("Dark mode"));+ this.lightModeButton = page.locator(getTestId("Light mode"));+ this.enterFullscreenButton = page.locator(getTestId("Enter fullscreen"));+ this.exitFullscreenButton = page.locator(getTestId("Exit fullscreen"));+ this.wordCountText = page.locator(getTestId("editor-word-count"));+ this.dateEditedText = page.locator(getTestId("editor-date-edited"));+ this.searchButton = page.locator(getTestId("Search"));+ this.previewNotice = page.locator(getTestId("preview-notice"));+ this.previewCancelButton = page.locator(getTestId("preview-notice-cancel"));+ this.previewRestoreButton = page.locator(+ getTestId("preview-notice-restore")+ );+ }++ async waitForLoading(title?: string, content?: string) {+ await this.title.waitFor();++ await this.page.waitForFunction(+ ({ expected }) => {+ const titleInput = document.querySelector(+ `[data-test-id="editor-title"]`+ ) as HTMLInputElement | null;+ if (titleInput)+ return expected !== undefined+ ? titleInput.value === expected+ : titleInput.value.length > 0;+ return false;+ },+ { expected: title }+ );++ if (content !== undefined)+ await this.content.locator(":scope", { hasText: content }).waitFor();+ }++ async waitForUnloading() {+ await this.page.waitForURL(/#\/notes\/create\/\d+/gm);+ await this.searchButton.waitFor({ state: "hidden" });+ await this.page.locator(getTestId("tags")).waitFor({ state: "hidden" });+ await this.wordCountText.waitFor({ state: "hidden" });+ await this.waitForLoading("", "");+ }++ async waitForSaving() {+ await this.page.waitForURL(/#\/notes\/?.+\/edit/gm);+ await this.page.locator(getTestId("tags")).waitFor();+ await this.searchButton.waitFor();+ await this.wordCountText.waitFor();+ }++ async isUnloaded() {+ return (+ (await this.tagInput.isHidden()) &&+ (await this.darkModeButton.isHidden()) &&+ (await this.enterFullscreenButton.isHidden()) &&+ (await this.wordCountText.isHidden())+ );+ }++ async setTitle(text: string) {+ await this.editAndWait(async () => {+ await this.title.fill(text);+ });+ }++ async typeTitle(text: string, delay = 0) {+ await this.editAndWait(async () => {+ await this.title.focus();+ await this.title.type(text, { delay });+ });+ }++ async setContent(text: string) {+ await this.editAndWait(async () => {+ await this.content.focus();+ await this.content.type(text);+ });+ }++ private async editAndWait(action: () => Promise<void>) {+ const oldDateEdited = await this.getDateEdited();+ await action();+ await this.page.waitForFunction(+ ({ oldDateEdited }) => {+ const dateEditedText = document.querySelector(+ `[data-test-id="editor-date-edited"]`+ );+ const timestampText = dateEditedText?.getAttribute("title");+ if (!timestampText) return false;+ const timestamp = parseInt(timestampText);+ return timestamp > oldDateEdited;+ },+ { oldDateEdited }+ );+ }++ async getDateEdited() {+ if (await this.dateEditedText.isHidden()) return 0;++ const timestamp = await this.dateEditedText.getAttribute("title");+ if (timestamp) return parseInt(timestamp);+ return 0;+ }++ async selectAll() {+ await this.content.focus();+ await this.page.keyboard.press("Home");+ await this.page.keyboard.press("Shift+End");+ await this.page.waitForTimeout(500);+ }++ async setTags(tags: string[]) {+ for (const tag of tags) {+ await this.tagInput.fill(tag);+ await this.tagInput.press("Enter");+ }+ }++ async getTags() {+ const tags: string[] = [];+ const count = await this.tags.count();+ for (let i = 0; i < count; ++i) {+ const item = this.tags.nth(i);+ const tag = await item.textContent();+ if (tag) tags.push(tag);+ }+ return tags;+ }++ async getTitle() {+ return this.title.inputValue();+ }++ async getContent(format: "html" | "text") {+ return format === "html"+ ? await this.content.innerHTML()+ : (await this.content.innerText()).trim().replace(/\n+/gm, "\n");+ }++ async enterFocusMode() {+ await this.focusModeButton.click();+ await this.normalModeButton.waitFor();+ }++ async exitFocusMode() {+ await this.normalModeButton.click();+ await this.focusModeButton.waitFor();+ }++ async isFocusMode() {+ return await this.normalModeButton.isVisible();+ }++ async enterDarkMode() {+ await this.darkModeButton.click();+ await this.lightModeButton.waitFor();+ }++ async exitDarkMode() {+ await this.lightModeButton.click();+ await this.darkModeButton.waitFor();+ }++ async isDarkMode() {+ return await this.lightModeButton.isVisible();+ }++ async enterFullscreen() {+ await this.enterFullscreenButton.click();+ await this.exitFullscreenButton.waitFor();+ }++ async exitFullscreen() {+ await this.exitFullscreenButton.click();+ await this.enterFullscreenButton.waitFor();+ }++ async isFullscreen() {+ return await this.exitFullscreenButton.isVisible();+ }++ async cancelPreview() {+ await this.previewCancelButton.click();+ await this.previewNotice.waitFor({ state: "hidden" });+ }++ async restoreSession() {+ await this.previewRestoreButton.click();+ await this.previewNotice.waitFor({ state: "hidden" });+ }+}diff --git a/apps/web/__e2e__/models/item.model.ts b/apps/web/__e2e__/models/item.model.tsnew file mode 100644index 000000000..d451973dc--- /dev/null+++ b/apps/web/__e2e__/models/item.model.ts@@ -0,0 +1,72 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Locator } from "@playwright/test";+import { BaseItemModel } from "./base-item.model";+import { ContextMenuModel } from "./context-menu.model";+import { NotesViewModel } from "./notes-view.model";+import { Item } from "./types";+import { fillItemDialog } from "./utils";++export class ItemModel extends BaseItemModel {+ private readonly contextMenu: ContextMenuModel;+ constructor(locator: Locator) {+ super(locator);+ this.contextMenu = new ContextMenuModel(this.page);+ }++ async open() {+ await this.locator.click();+ return new NotesViewModel(this.page, "notes");+ }++ async delete() {+ await this.contextMenu.open(this.locator);+ await Promise.all([+ this.contextMenu.clickOnItem("delete"),+ this.waitFor("detached")+ ]);+ }++ async editItem(item: Item) {+ await this.contextMenu.open(this.locator);+ await this.contextMenu.clickOnItem("edit");++ await fillItemDialog(this.page, item);+ }++ async createShortcut() {+ await this.contextMenu.open(this.locator);+ await this.contextMenu.clickOnItem("shortcut");+ }++ async removeShortcut() {+ await this.contextMenu.open(this.locator);+ await this.contextMenu.clickOnItem("shortcut");+ }++ async isShortcut() {+ await this.contextMenu.open(this.locator);+ const state =+ (await this.contextMenu.getItem("shortcut").textContent()) ===+ "Remove shortcut";+ await this.contextMenu.close();+ return state;+ }+}diff --git a/apps/web/__e2e__/models/items-view.model.ts b/apps/web/__e2e__/models/items-view.model.tsnew file mode 100644index 000000000..7649f6d2a--- /dev/null+++ b/apps/web/__e2e__/models/items-view.model.ts@@ -0,0 +1,54 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Locator, Page } from "@playwright/test";+import { getTestId } from "../utils";+import { BaseViewModel } from "./base-view.model";+import { ItemModel } from "./item.model";+import { Item } from "./types";+import { fillItemDialog } from "./utils";++export class ItemsViewModel extends BaseViewModel {+ private readonly createButton: Locator;++ constructor(page: Page, private readonly id: "topics" | "tags") {+ super(page, id);+ this.createButton = page.locator(getTestId(`${id}-action-button`));+ }++ async createItem(item: Item) {+ const titleToCompare = this.id === "tags" ? `#${item.title}` : item.title;++ await this.createButton.first().click();+ await fillItemDialog(this.page, item);++ await this.waitForItem(titleToCompare);+ return await this.findItem(item);+ }++ async findItem(item: Item) {+ const titleToCompare = this.id === "tags" ? `#${item.title}` : item.title;+ for await (const _item of this.iterateItems()) {+ const itemModel = new ItemModel(_item);+ const title = await itemModel.getTitle();+ if (title === titleToCompare) return itemModel;+ }+ return undefined;+ }+}diff --git a/apps/web/__e2e__/models/navigation-menu.model.ts b/apps/web/__e2e__/models/navigation-menu.model.tsnew file mode 100644index 000000000..e9024921d--- /dev/null+++ b/apps/web/__e2e__/models/navigation-menu.model.ts@@ -0,0 +1,93 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Locator, Page } from "@playwright/test";+import { getTestId } from "../utils";+import { ContextMenuModel } from "./context-menu.model";+import { fillItemDialog, iterateList } from "./utils";++export class NavigationMenuModel {+ protected readonly page: Page;+ private readonly menu: Locator;++ constructor(page: Page) {+ this.page = page;+ this.menu = page.locator(getTestId("navigation-menu"));+ }++ async findItem(title: string) {+ for await (const item of this.iterateList()) {+ const menuItem = new NavigationItemModel(item);+ if ((await menuItem.getTitle()) === title) return menuItem;+ }+ }++ async getShortcuts() {+ const shortcuts: string[] = [];+ for await (const item of this.iterateList()) {+ const menuItem = new NavigationItemModel(item);+ if (await menuItem.isShortcut()) {+ const titleText = await menuItem.getTitle();+ if (titleText) shortcuts.push(titleText);+ }+ }+ return shortcuts;+ }++ private async *iterateList() {+ const locator = this.menu.locator(getTestId(`navigation-item`));+ yield* iterateList(locator);+ }+}++class NavigationItemModel {+ private readonly title: Locator;+ private readonly shortcut: Locator;+ private readonly menu: ContextMenuModel;+ private readonly page: Page;+ constructor(private readonly locator: Locator) {+ this.page = locator.page();+ this.title = locator.locator(getTestId("title"));+ this.shortcut = locator.locator(getTestId("shortcut"));+ this.menu = new ContextMenuModel(this.page);+ }++ async click() {+ await this.locator.click();+ }++ async isShortcut() {+ return await this.shortcut.isVisible();+ }++ async getTitle() {+ return await this.title.textContent();+ }++ async renameColor(alias: string) {+ await this.menu.open(this.locator);+ await this.menu.clickOnItem("rename");+ await fillItemDialog(this.page, { title: alias });+ }++ async removeShortcut() {+ await this.menu.open(this.locator);+ await this.menu.clickOnItem("remove-shortcut");+ }+}diff --git a/apps/web/__e2e__/models/note-item.model.ts b/apps/web/__e2e__/models/note-item.model.tsnew file mode 100644index 000000000..094e56215--- /dev/null+++ b/apps/web/__e2e__/models/note-item.model.ts@@ -0,0 +1,69 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Locator } from "@playwright/test";+import { getTestId } from "../utils";+import { BaseItemModel } from "./base-item.model";+import { EditorModel } from "./editor.model";+import {+ NoteContextMenuModel,+ NotePropertiesModel+} from "./note-properties.model";+import { iterateList } from "./utils";++export class NoteItemModel extends BaseItemModel {+ readonly properties: NotePropertiesModel;+ readonly contextMenu: NoteContextMenuModel;+ private readonly editor: EditorModel;+ constructor(locator: Locator) {+ super(locator);+ this.properties = new NotePropertiesModel(this.page, locator);+ this.contextMenu = new NoteContextMenuModel(this.page, locator);+ this.editor = new EditorModel(this.page);+ }++ async openNote() {+ await this.locator.click();+ const title = await this.getTitle();+ const description = await this.getDescription();++ await this.editor.waitForLoading(title, description);+ }++ async openLockedNote(password: string) {+ if (!(await this.contextMenu.isLocked())) return;++ await this.page.locator(getTestId("unlock-note-password")).fill(password);+ await this.page.locator(getTestId("unlock-note-submit")).click();++ const title = await this.getTitle();+ await this.editor.waitForLoading(title);+ }++ async getTags() {+ const tags: string[] = [];+ for await (const item of iterateList(+ this.locator.locator(getTestId("tag-item"))+ )) {+ const title = await item.textContent();+ if (title) tags.push(title.replace("#", ""));+ }+ return tags;+ }+}diff --git a/apps/web/__e2e__/models/note-properties.model.ts b/apps/web/__e2e__/models/note-properties.model.tsnew file mode 100644index 000000000..0e6c61351--- /dev/null+++ b/apps/web/__e2e__/models/note-properties.model.ts@@ -0,0 +1,333 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Locator, Page } from "@playwright/test";+import { downloadAndReadFile, getTestId } from "../utils";+import { ContextMenuModel } from "./context-menu.model";+import { ToggleModel } from "./toggle.model";+import { Notebook } from "./types";+import { fillPasswordDialog, iterateList } from "./utils";++abstract class BaseProperties {+ protected readonly page: Page;++ private readonly pinToggle: ToggleModel;+ private readonly favoriteToggle: ToggleModel;+ private readonly lockToggle: ToggleModel;++ constructor(+ page: Page,+ protected readonly noteLocator: Locator,+ private readonly itemPrefix: string+ ) {+ this.page = page;+ this.pinToggle = new ToggleModel(page, `${itemPrefix}-pin`);+ this.lockToggle = new ToggleModel(page, `${itemPrefix}-lock`);+ this.favoriteToggle = new ToggleModel(page, `${itemPrefix}-favorite`);+ }++ async isPinned() {+ await this.open();+ const state = await this.pinToggle.isToggled();+ await this.close();+ return state;+ }++ async pin() {+ await this.open();+ await this.pinToggle.on();+ await this.close();+ }++ async unpin() {+ await this.open();+ await this.pinToggle.off();+ await this.close();+ }++ async lock(password: string) {+ await this.open();+ await this.lockToggle.on(false);+ await fillPasswordDialog(this.page, password);+ await this.noteLocator+ .locator(getTestId("locked"))+ .waitFor({ state: "visible" });+ }++ async unlock(password: string) {+ await this.open();+ await this.lockToggle.off(false);++ await fillPasswordDialog(this.page, password);++ await this.noteLocator+ .locator(getTestId("locked"))+ .waitFor({ state: "hidden" });+ }++ async isLocked() {+ return (+ (await this.noteLocator.locator(getTestId("locked")).isVisible()) &&+ (await this.noteLocator.locator(getTestId(`description`)).isHidden()) &&+ (await (async () => {+ await this.noteLocator.click();+ return await this.page+ .locator(getTestId("unlock-note-title"))+ .isVisible();+ })()) &&+ (await (async () => {+ await this.open();+ const state = await this.lockToggle.isToggled();+ await this.close();+ return state;+ })())+ );+ }++ async isFavorited() {+ await this.open();+ const state = await this.favoriteToggle.isToggled();+ await this.close();+ return state;+ }++ async favorite() {+ await this.open();+ await this.favoriteToggle.on();+ await this.close();+ }++ async unfavorite() {+ await this.open();+ await this.favoriteToggle.off();+ await this.close();+ }++ abstract isColored(color: string): Promise<boolean>;+ abstract color(color: string): Promise<void>;+ abstract open(): Promise<void>;+ abstract close(): Promise<void>;+}++export class NotePropertiesModel extends BaseProperties {+ private readonly propertiesButton: Locator;+ private readonly propertiesCloseButton: Locator;+ private readonly readonlyToggle: ToggleModel;+ private readonly sessionItems: Locator;++ constructor(page: Page, noteLocator: Locator) {+ super(page, noteLocator, "properties");+ this.propertiesButton = page.locator(getTestId("Properties"));+ this.propertiesCloseButton = page.locator(getTestId("properties-close"));+ this.readonlyToggle = new ToggleModel(page, `properties-readonly`);+ this.sessionItems = page.locator(getTestId("session-item"));+ }++ async isColored(color: string): Promise<boolean> {+ await this.open();+ const state = await new ToggleModel(+ this.page,+ `properties-${color}`+ ).isToggled();+ await this.close();+ return state;+ }++ async color(color: string) {+ await this.open();+ await new ToggleModel(this.page, `properties-${color}`).on();+ await this.close();+ }++ async isReadonly() {+ await this.open();+ const state = await this.readonlyToggle.isToggled();+ await this.close();+ return state;+ }++ async readonly() {+ await this.open();+ await this.readonlyToggle.on();+ await this.close();+ }++ async editable() {+ await this.open();+ await this.readonlyToggle.off();+ await this.close();+ }++ async open() {+ await this.propertiesButton.click();+ }++ async close() {+ await this.propertiesCloseButton.click();+ }++ async getSessionHistory() {+ await this.open();+ const history: SessionHistoryItemModel[] = [];+ for await (const item of iterateList(this.sessionItems)) {+ history.push(new SessionHistoryItemModel(this, item));+ }+ await this.close();+ return history;+ }+}++export class NoteContextMenuModel extends BaseProperties {+ private readonly menu: ContextMenuModel;+ constructor(page: Page, noteLocator: Locator) {+ super(page, noteLocator, "menuitem");+ this.menu = new ContextMenuModel(page);+ }++ async isColored(color: string): Promise<boolean> {+ await this.open();+ await this.menu.clickOnItem("colors");+ const state = await new ToggleModel(+ this.page,+ `menuitem-${color}`+ ).isToggled();+ await this.close();+ return state;+ }++ async color(color: string) {+ await this.open();+ await this.menu.clickOnItem("colors");+ await new ToggleModel(this.page, `menuitem-${color}`).on();+ await this.close();+ }++ async moveToTrash() {+ await this.open();+ await Promise.all([+ this.menu.clickOnItem("movetotrash"),+ this.noteLocator.waitFor({ state: "detached" })+ ]);+ }++ async export(format: "html" | "md" | "txt") {+ await this.open();+ await this.menu.clickOnItem("export");++ // we need to override date time so+ // date created & date edited remain fixed.+ await this.noteLocator.evaluate(() => {+ // eslint-disable-next-line no-extend-native+ Date.prototype.toLocaleString = () => "xxx";+ });++ return await downloadAndReadFile(+ this.noteLocator.page(),+ this.menu.getItem(format),+ "utf-8"+ );+ }++ async addToNotebook(notebook: Notebook) {+ await this.open();+ await this.menu.clickOnItem("addtonotebook");++ const filterInput = this.page.locator(getTestId("filter-input"));+ await filterInput.type(notebook.title);+ await filterInput.press("Enter");++ await this.page.waitForSelector(getTestId("notebook"), {+ state: "visible",+ strict: false+ });++ const notebookItems = this.page.locator(getTestId("notebook"));+ for await (const item of iterateList(notebookItems)) {+ const treeItem = item.locator(getTestId(`tree-item`));+ const title = treeItem.locator(getTestId("title"));+ const newItemButton = treeItem.locator(getTestId("tree-item-new"));++ if ((await title.textContent()) === notebook.title) {+ for (const topic of notebook.topics) {+ await newItemButton.click();+ const newItemInput = item.locator(getTestId("new-tree-item-input"));++ await newItemInput.waitFor({ state: "visible" });+ await newItemInput.fill(topic);+ await newItemInput.press("Enter");+ }++ const topicItems = item.locator(getTestId("topic"));+ for await (const topicItem of iterateList(topicItems)) {+ const treeItem = topicItem.locator(getTestId(`tree-item`));+ await treeItem.click();+ }+ }+ }++ const dialogConfirm = this.page.locator(getTestId("dialog-yes"));+ await dialogConfirm.click();+ await dialogConfirm.waitFor({ state: "detached" });+ }++ async open() {+ await this.menu.open(this.noteLocator);+ }++ async close() {+ await this.menu.close();+ }+}++class SessionHistoryItemModel {+ private readonly title: Locator;+ private readonly page: Page;+ private readonly previewNotice: Locator;+ private readonly locked: Locator;+ constructor(+ private readonly properties: NotePropertiesModel,+ private readonly locator: Locator+ ) {+ this.page = locator.page();+ this.title = locator.locator(getTestId("title"));+ this.previewNotice = this.page.locator(getTestId("preview-notice"));+ this.locked = locator.locator(getTestId("locked"));+ }++ async getTitle() {+ return await this.title.textContent();+ }++ async preview(password?: string) {+ await this.properties.open();+ const isLocked = await this.locked.isVisible();+ await this.locator.click();+ if (password && isLocked) {+ await fillPasswordDialog(this.page, password);+ }+ await this.previewNotice.waitFor();+ }++ async isLocked() {+ await this.properties.open();+ const state = await this.locked.isVisible();+ await this.properties.close();+ return state;+ }+}diff --git a/apps/web/__e2e__/models/notebook-item.model.ts b/apps/web/__e2e__/models/notebook-item.model.tsnew file mode 100644index 000000000..9ebd3201a--- /dev/null+++ b/apps/web/__e2e__/models/notebook-item.model.ts@@ -0,0 +1,90 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Locator } from "@playwright/test";+import { BaseItemModel } from "./base-item.model";+import { ContextMenuModel } from "./context-menu.model";+import { ToggleModel } from "./toggle.model";+import { ItemsViewModel } from "./items-view.model";+import { Notebook } from "./types";+import { fillNotebookDialog } from "./utils";++export class NotebookItemModel extends BaseItemModel {+ private readonly contextMenu: ContextMenuModel;+ constructor(locator: Locator) {+ super(locator);+ this.contextMenu = new ContextMenuModel(this.page);+ }++ async openNotebook() {+ await this.locator.click();+ return new ItemsViewModel(this.page, "topics");+ }++ async editNotebook(notebook: Notebook) {+ await this.contextMenu.open(this.locator);+ await this.contextMenu.clickOnItem("edit");++ await fillNotebookDialog(this.page, notebook, true);+ }++ async moveToTrash() {+ await this.contextMenu.open(this.locator);+ await Promise.all([+ this.contextMenu.clickOnItem("movetotrash"),+ this.waitFor("detached")+ ]);+ }++ async pin() {+ await this.contextMenu.open(this.locator);+ await new ToggleModel(this.page, "menuitem-pin").on();+ }++ async unpin() {+ await this.contextMenu.open(this.locator);+ await new ToggleModel(this.page, "menuitem-pin").off();+ }++ async isPinned() {+ await this.contextMenu.open(this.locator);+ const state = await new ToggleModel(this.page, "menuitem-pin").isToggled();+ await this.contextMenu.close();+ return state;+ }++ async createShortcut() {+ await this.contextMenu.open(this.locator);+ await this.contextMenu.clickOnItem("shortcut");+ }++ async removeShortcut() {+ await this.contextMenu.open(this.locator);+ await this.contextMenu.clickOnItem("shortcut");+ }++ async isShortcut() {+ await this.contextMenu.open(this.locator);+ const state =+ (await this.contextMenu.getItem("shortcut").textContent()) ===+ "Remove shortcut";+ await this.contextMenu.close();+ return state;+ }+}diff --git a/apps/web/__e2e__/models/notebooks-view.model.ts b/apps/web/__e2e__/models/notebooks-view.model.tsnew file mode 100644index 000000000..25b26c3d3--- /dev/null+++ b/apps/web/__e2e__/models/notebooks-view.model.ts@@ -0,0 +1,52 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Locator, Page } from "@playwright/test";+import { getTestId } from "../utils";+import { BaseViewModel } from "./base-view.model";+import { NotebookItemModel } from "./notebook-item.model";+import { Notebook } from "./types";+import { fillNotebookDialog } from "./utils";++export class NotebooksViewModel extends BaseViewModel {+ private readonly createButton: Locator;++ constructor(page: Page) {+ super(page, "notebooks");+ this.createButton = page.locator(getTestId("notebooks-action-button"));+ }++ async createNotebook(notebook: Notebook) {+ await this.createButton.first().click();++ await fillNotebookDialog(this.page, notebook);++ await this.waitForItem(notebook.title);+ return await this.findNotebook(notebook);+ }++ async findNotebook(notebook: Partial<Notebook>) {+ for await (const item of this.iterateItems()) {+ const notebookModel = new NotebookItemModel(item);+ if ((await notebookModel.getTitle()) === notebook.title)+ return notebookModel;+ }+ return undefined;+ }+}diff --git a/apps/web/__e2e__/models/notes-view.model.ts b/apps/web/__e2e__/models/notes-view.model.tsnew file mode 100644index 000000000..3557b4e0e--- /dev/null+++ b/apps/web/__e2e__/models/notes-view.model.ts@@ -0,0 +1,63 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Locator, Page } from "@playwright/test";+import { getTestId } from "../utils";+import { BaseViewModel } from "./base-view.model";+import { EditorModel } from "./editor.model";+import { NoteItemModel } from "./note-item.model";++type Note = {+ title: string;+ content: string;+};++export class NotesViewModel extends BaseViewModel {+ private readonly createButton: Locator;+ readonly editor: EditorModel;++ constructor(page: Page, pageId: "home" | "notes") {+ super(page, pageId);+ this.createButton = page.locator(getTestId("notes-action-button"));+ this.editor = new EditorModel(page);+ }++ async newNote() {+ await this.createButton.first().click();+ await this.editor.waitForUnloading();+ }++ async createNote(note: Partial<Note>) {+ await this.newNote();+ if (note.title) await this.editor.setTitle(note.title);+ if (note.content) await this.editor.setContent(note.content);++ await this.editor.waitForSaving();+ if (note.title) await this.waitForItem(note.title);+ return await this.findNote(note);+ }++ async findNote(note: Partial<Note>) {+ for await (const item of this.iterateItems()) {+ const noteModel = new NoteItemModel(item);+ if ((await noteModel.getTitle()) === note.title) return noteModel;+ }+ return undefined;+ }+}diff --git a/apps/web/__e2e__/models/settings-view.model.ts b/apps/web/__e2e__/models/settings-view.model.tsnew file mode 100644index 000000000..00f7b7f87--- /dev/null+++ b/apps/web/__e2e__/models/settings-view.model.ts@@ -0,0 +1,62 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Locator, Page } from "@playwright/test";+import { getTestId } from "../utils";+import { confirmDialog, fillPasswordDialog, waitToHaveText } from "./utils";++export class SettingsViewModel {+ private readonly page: Page;+ private readonly logoutButton: Locator;+ private readonly accountStatusContainer: Locator;+ private readonly backupRecoveryKeyButton: Locator;+ constructor(page: Page) {+ this.page = page;+ this.logoutButton = page.locator(getTestId("settings-logout"));+ this.accountStatusContainer = page.locator(getTestId("account-status"));+ this.backupRecoveryKeyButton = page.locator(+ getTestId("backup-recovery-key")+ );+ }++ async logout() {+ await this.logoutButton.click();+ await confirmDialog(this.page);+ await this.page+ .locator(getTestId("sync-status-synced"))+ .waitFor({ state: "hidden" });+ }++ async getRecoveryKey(password: string) {+ await this.backupRecoveryKeyButton.click();+ await fillPasswordDialog(this.page, password);++ await waitToHaveText(this.page, "recovery-key");++ const key = await this.page+ .locator(getTestId("recovery-key"))+ .textContent();+ await confirmDialog(this.page);+ return key;+ }++ async isLoggedIn() {+ return await this.accountStatusContainer.isVisible();+ }+}diff --git a/apps/web/__e2e__/models/toasts.model.ts b/apps/web/__e2e__/models/toasts.model.tsnew file mode 100644index 000000000..a40cc93e1--- /dev/null+++ b/apps/web/__e2e__/models/toasts.model.ts@@ -0,0 +1,42 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Locator, Page } from "@playwright/test";+import { getTestId } from "../utils";++export class ToastsModel {+ private readonly toasts: Locator;+ private readonly toastMessage: Locator;++ constructor(page: Page) {+ this.toasts = page.locator(".toasts-container > div");+ // this.toastMessage = this.toast.locator(getTestId("toast-message"));+ }++ count() {+ return this.toasts.count();+ }++ async waitForToast(message: string) {+ await this.toasts+ .locator(getTestId("toast-message"), { hasText: message })+ .waitFor();+ return true;+ }+}diff --git a/apps/web/__e2e__/models/toggle.model.ts b/apps/web/__e2e__/models/toggle.model.tsnew file mode 100644index 000000000..ce399d13f--- /dev/null+++ b/apps/web/__e2e__/models/toggle.model.ts@@ -0,0 +1,61 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Locator, Page } from "@playwright/test";+import { getTestId } from "../utils";++export enum TOGGLE_STATES {+ ON = "on",+ OFF = "off"+}++export class ToggleModel {+ private readonly toggle: Locator;+ constructor(private readonly page: Page, private readonly id: string) {+ this.toggle = page.locator(getTestId(id));+ }++ async on(wait = true) {+ if (!(await this.isToggled())) {+ await this.toggle.click();+ if (wait) await this.waitUntilToggleState(this.toggle, TOGGLE_STATES.ON);+ }+ }++ async off(wait = true) {+ if (await this.isToggled()) {+ await this.toggle.click();+ if (wait) await this.waitUntilToggleState(this.toggle, TOGGLE_STATES.OFF);+ }+ }++ async isToggled() {+ return await this.getToggleState(this.toggle, TOGGLE_STATES.ON).isVisible();+ }++ private async waitUntilToggleState(locator: Locator, state: TOGGLE_STATES) {+ if (this.id.startsWith("menuitem")) await this.page.waitForTimeout(200);+ else+ await this.getToggleState(locator, state).waitFor({ state: "visible" });+ }++ private getToggleState(locator: Locator, state: TOGGLE_STATES) {+ return locator.locator(getTestId(`toggle-state-${state}`));+ }+}diff --git a/apps/web/__e2e__/models/trash-item.model.ts b/apps/web/__e2e__/models/trash-item.model.tsnew file mode 100644index 000000000..9c6eb40b7--- /dev/null+++ b/apps/web/__e2e__/models/trash-item.model.ts@@ -0,0 +1,45 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Locator } from "@playwright/test";+import { getTestId } from "../utils";+import { BaseItemModel } from "./base-item.model";+import { ContextMenuModel } from "./context-menu.model";++export class TrashItemModel extends BaseItemModel {+ private readonly contextMenu: ContextMenuModel;++ constructor(locator: Locator) {+ super(locator);+ this.contextMenu = new ContextMenuModel(locator.page());+ }++ async restore() {+ await this.contextMenu.open(this.locator);+ await this.contextMenu.clickOnItem("restore");+ await this.contextMenu.close();+ }++ async delete() {+ await this.contextMenu.open(this.locator);+ await this.contextMenu.clickOnItem("delete");++ await this.locator.page().locator(getTestId("dialog-yes")).click();+ }+}diff --git a/apps/web/__e2e__/models/trash-view.model.ts b/apps/web/__e2e__/models/trash-view.model.tsnew file mode 100644index 000000000..75280baf7--- /dev/null+++ b/apps/web/__e2e__/models/trash-view.model.ts@@ -0,0 +1,37 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Page } from "@playwright/test";+import { getTestId } from "../utils";+import { BaseViewModel } from "./base-view.model";+import { TrashItemModel } from "./trash-item.model";++export class TrashViewModel extends BaseViewModel {+ constructor(page: Page) {+ super(page, "trash");+ }++ async findItem(title: string) {+ for await (const item of this.iterateItems()) {+ if ((await item.locator(getTestId("title")).textContent()) === title)+ return new TrashItemModel(item);+ }+ return undefined;+ }+}diff --git a/apps/web/__e2e__/models/types.ts b/apps/web/__e2e__/models/types.tsnew file mode 100644index 000000000..bed005cd2--- /dev/null+++ b/apps/web/__e2e__/models/types.ts@@ -0,0 +1,30 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++export type Notebook = {+ title: string;+ topics: string[];+ description?: string;+};++export type Item = {+ title: string;+};++export type PriceItem = { label: string; value: string };diff --git a/apps/web/__e2e__/models/utils.ts b/apps/web/__e2e__/models/utils.tsnew file mode 100644index 000000000..ef973ee89--- /dev/null+++ b/apps/web/__e2e__/models/utils.ts@@ -0,0 +1,90 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { Locator, Page } from "@playwright/test";+import { getTestId } from "../utils";+import { Item, Notebook } from "./types";++export async function* iterateList(list: Locator) {+ const count = await list.count();+ for (let i = 0; i < count; ++i) {+ yield list.nth(i);+ }+ return null;+}++export async function fillNotebookDialog(+ page: Page,+ notebook: Notebook,+ editing = false+) {+ const titleInput = page.locator(getTestId("title-input"));+ const descriptionInput = page.locator(getTestId("description-input"));+ const topicInput = page.locator(getTestId(`edit-topic-input`));+ const topicInputAction = page.locator(getTestId(`edit-topic-action`));++ await titleInput.waitFor({ state: "visible" });++ await titleInput.fill(notebook.title);+ if (notebook.description) await descriptionInput.fill(notebook.description);++ const topicItems = page.locator(getTestId("topic-item"));+ for (let i = 0; i < notebook.topics.length; ++i) {+ if (editing) {+ const topicItem = topicItems.nth(i);+ await topicItem.click();+ }+ await topicInput.fill(notebook.topics[i]);+ await topicInputAction.click();+ }++ await confirmDialog(page);+}++export async function fillItemDialog(page: Page, item: Item) {+ const titleInput = page.locator(getTestId("title-input"));+ await titleInput.waitFor({ state: "visible" });++ await titleInput.fill(item.title);++ await confirmDialog(page);+}++export async function fillPasswordDialog(page: Page, password: string) {+ await page.locator(getTestId("dialog-password")).fill(password);+ await confirmDialog(page);+}++export async function confirmDialog(page: Page) {+ const dialogConfirm = page.locator(getTestId("dialog-yes"));+ await dialogConfirm.click();+ // await dialogConfirm.waitFor({ state: "detached" });+}++export async function waitToHaveText(page: Page, id: string) {+ await page.waitForFunction(+ ({ id }) => {+ return (+ (document.querySelector(`[data-test-id="${id}"]`)?.textContent+ ?.length || 0) > 0+ );+ },+ { id }+ );+}diff --git a/apps/web/__e2e__/navigation.test.js b/apps/web/__e2e__/navigation.test.tssimilarity index 67%rename from apps/web/__e2e__/navigation.test.jsrename to apps/web/__e2e__/navigation.test.tsindex 9d19d6893..be494369b 100644--- a/apps/web/__e2e__/navigation.test.js+++ b/apps/web/__e2e__/navigation.test.ts@@ -18,15 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*//* eslint-disable no-undef */-const { test, expect } = require("@playwright/test");-const { getTestId } = require("./utils");+import { test, expect } from "@playwright/test";+import { AppModel } from "./models/app.model";-test.beforeEach(async ({ page, baseURL }) => {- await page.goto(baseURL);- await page.waitForSelector(getTestId("routeHeader"));-});--function createRoute(key, header) {+function createRoute(key: string, header: string) {return { buttonId: `navitem-${key}`, header };}@@ -40,15 +35,14 @@ const routes = [createRoute("settings", "Settings")];-for (let route of routes) {+for (const route of routes) {test(`navigating to ${route.header}`, async ({ page }) => {- await page.waitForSelector(getTestId(route.buttonId), {- state: "visible"- });- await page.click(getTestId(route.buttonId));- await expect(page.inputValue(getTestId("routeHeader"))).resolves.toBe(- route.header- );- await page.waitForTimeout(300);+ const app = new AppModel(page);+ await app.goto();++ const item = await app.navigation.findItem(route.header);+ await item?.click();++ expect(await app.getRouteHeader()).toBe(route.header);});}diff --git a/apps/web/__e2e__/notebooks.issues.test.js b/apps/web/__e2e__/notebooks.issues.test.tssimilarity index 92%rename from apps/web/__e2e__/notebooks.issues.test.jsrename to apps/web/__e2e__/notebooks.issues.test.tsindex 8d1d8141e..35fe03085 100644--- a/apps/web/__e2e__/notebooks.issues.test.js+++ b/apps/web/__e2e__/notebooks.issues.test.ts@@ -17,6 +17,6 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-const { test } = require("@playwright/test");-test.skip("TODO: pin 3 notebooks & make sure they can be unpinned");-test.skip("TODO: pin 4 notebooks & make sure 4th pin shows an error");+import { test } from "@playwright/test";+test.skip("TODO: pin 3 notebooks & make sure they can be unpinned", () => {});+test.skip("TODO: pin 4 notebooks & make sure 4th pin shows an error", () => {});diff --git a/apps/web/__e2e__/notebooks.test.js b/apps/web/__e2e__/notebooks.test.jsdeleted file mode 100644index 2b14fdbae..000000000--- a/apps/web/__e2e__/notebooks.test.js+++ /dev/null@@ -1,244 +0,0 @@-/*-This file is part of the Notesnook project (https://notesnook.com/)--Copyright (C) 2022 Streetwriters (Private) Limited--This program is free software: you can redistribute it and/or modify-it under the terms of the GNU General Public License as published by-the Free Software Foundation, either version 3 of the License, or-(at your option) any later version.--This program is distributed in the hope that it will be useful,-but WITHOUT ANY WARRANTY; without even the implied warranty of-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-GNU General Public License for more details.--You should have received a copy of the GNU General Public License-along with this program. If not, see <http://www.gnu.org/licenses/>.-*/--/* eslint-disable no-undef */-const { test, expect } = require("@playwright/test");-const { getTestId, createNote, NOTE, NOTEBOOK } = require("./utils");-const {- navigateTo,- openContextMenu,- useContextMenu,- clickMenuItem,- confirmDialog-} = require("./utils/actions");-const List = require("./utils/listitemidbuilder");-const Menu = require("./utils/menuitemidbuilder");-const {- checkNotePresence,- isPresent,- checkMenuItemText-} = require("./utils/conditions");--/**- * @type {Page}- */-global.page = null;--test.beforeEach(async ({ page: _page, baseURL }) => {- global.page = _page;- await page.goto(baseURL);- await page.waitForSelector(getTestId("routeHeader"));-});--async function fillNotebookDialog(notebook) {- await page.fill(getTestId("and-name"), notebook.title);-- await page.fill(getTestId("and-description"), notebook.description);-- for (let i = 0; i < notebook.topics.length; ++i) {- let topic = notebook.topics[i];- await page.fill(getTestId(`and-topic`), topic);- await page.click(getTestId("and-topic-action"));- }-- await page.click(getTestId("dialog-yes"));-}--async function createNotebook(notebook) {- await page.click(getTestId("notebooks-action-button"));-- await fillNotebookDialog(notebook);-}--async function createNoteAndCheckPresence(note = NOTE) {- await createNote(note, "notes");-- // make sure the note has saved.- await page.waitForTimeout(1000);-- return await checkNotePresence("notes", undefined, note);-}--async function checkNotebookPresence(notebook) {- const notebookIdBuilder = List.new("notebook").grouped().atIndex(0);-- await expect(- page.textContent(notebookIdBuilder.title().build())- ).resolves.toBe(notebook.title);-- await expect(- page.textContent(notebookIdBuilder.body().build())- ).resolves.toBe(notebook.description);-- await page.click(List.new("notebook").grouped().atIndex(0).title().build());-- for (let i = 0; i < notebook.topics.length; ++i) {- await expect(- page.textContent(List.new("topic").grouped().atIndex(i).title().build())- ).resolves.toBeTruthy();- }-- await page.click(getTestId("go-back"));-- return notebookIdBuilder.build();-}--async function createNotebookAndCheckPresence(notebook = NOTEBOOK) {- await navigateTo("notebooks");-- await createNotebook(notebook);-- return await checkNotebookPresence(notebook);-}--async function deleteNotebookAndCheckAbsence(notebookSelector) {- await openContextMenu(notebookSelector);-- await page.click(Menu.new("menuitem").item("movetotrash").build());-- // await confirmDialog();-- await page.waitForTimeout(500);-- await expect(page.$(notebookSelector)).resolves.toBeFalsy();-- await navigateTo("trash");-- await expect(- isPresent(List.new("trash").grouped().atIndex(0).build())- ).resolves.toBeTruthy();-- await expect(- page.textContent(List.new("trash").grouped().atIndex(0).title().build())- ).resolves.toBe(NOTEBOOK.title);-- await expect(- page.textContent(List.new("trash").grouped().atIndex(0).body().build())- ).resolves.toBe(NOTEBOOK.description);-- await navigateTo("notebooks");-}--test("create a notebook", async () => await createNotebookAndCheckPresence());--test("create a note inside a notebook", async () => {- const notebookSelector = await createNotebookAndCheckPresence();-- await page.click(notebookSelector);-- await page.click(List.new("topic").grouped().atIndex(1).build());-- await createNoteAndCheckPresence();-});--test("edit a notebook", async () => {- const notebookSelector = await createNotebookAndCheckPresence();-- await useContextMenu(notebookSelector, () => clickMenuItem("edit"));-- const notebook = {- title: "An Edited Notebook",- description: "A new edited description",- topics: ["Topic 1", "Topic 2", "Topic 3"]- };-- await page.fill(getTestId("and-name"), notebook.title);-- await page.fill(getTestId("and-description"), notebook.description);-- for (var i = 0; i < notebook.topics.length; ++i) {- let id = getTestId(`and-topic-${i}-actions-edit`);- let topic = notebook.topics[i];- if ((await page.$(id)) !== null) {- await page.click(id);- }- await page.fill(getTestId("and-topic"), topic);- await page.click(getTestId("and-topic-action"));- }-- await confirmDialog();-- await page.waitForTimeout(1000);-- await checkNotebookPresence(notebook);-});--test("edit topics individually", async () => {- const notebookSelector = await createNotebookAndCheckPresence();-- await page.click(notebookSelector);-- for (let index = 0; index < NOTEBOOK.topics.length; index++) {- await openContextMenu(List.new("topic").grouped().atIndex(index).build());-- await page.click(Menu.new("menuitem").item("edit").build());-- const editedTopicTitle = "Topic " + index + " edit 1";- await page.fill(getTestId("item-dialog-title"), editedTopicTitle);-- await page.click(getTestId("dialog-yes"));-- await page.waitForTimeout(500);-- await expect(- page.textContent(List.new("topic").grouped().atIndex(0).title().build())- ).resolves.toBe(editedTopicTitle);- }-});--test("delete a notebook", async () => {- const notebookSelector = await createNotebookAndCheckPresence();-- await deleteNotebookAndCheckAbsence(notebookSelector);-});--test("permanently delete a notebook", async () => {- const notebookSelector = await createNotebookAndCheckPresence();-- await deleteNotebookAndCheckAbsence(notebookSelector);-- await navigateTo("trash");-- await openContextMenu(List.new("trash").grouped().atIndex(0).build());-- await clickMenuItem("delete");-- await confirmDialog();-- await expect(- page.$(List.new("trash").grouped().atIndex(0).build())- ).resolves.toBeFalsy();-});--test("pin a notebook", async ({ page }) => {- const notebookSelector = await createNotebookAndCheckPresence();-- await useContextMenu(notebookSelector, () => clickMenuItem("pin"));-- // wait for the menu to properly close- await page.waitForTimeout(500);-- await useContextMenu(- notebookSelector,- async () => await checkMenuItemText("pin", "Unpin")- );-- // wait for the menu to properly close- await page.waitForTimeout(500);-});diff --git a/apps/web/__e2e__/notebooks.test.ts b/apps/web/__e2e__/notebooks.test.tsnew file mode 100644index 000000000..826af403b--- /dev/null+++ b/apps/web/__e2e__/notebooks.test.ts@@ -0,0 +1,225 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { test, expect } from "@playwright/test";+import { AppModel } from "./models/app.model";+import { Item, Notebook } from "./models/types";+import { NOTE, NOTEBOOK } from "./utils";++test("create a notebook", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notebooks = await app.goToNotebooks();++ const notebook = await notebooks.createNotebook(NOTEBOOK);++ expect(notebook).toBeDefined();+});++test("create a note inside a notebook", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notebooks = await app.goToNotebooks();+ const notebook = await notebooks.createNotebook(NOTEBOOK);+ const topics = await notebook?.openNotebook();+ const topic = await topics?.findItem({ title: NOTEBOOK.topics[0] });+ const notes = await topic?.open();++ const note = await notes?.createNote(NOTE);++ expect(note).toBeDefined();+});++test("edit a notebook", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notebooks = await app.goToNotebooks();+ const notebook = await notebooks.createNotebook(NOTEBOOK);++ const item: Notebook = {+ title: "An Edited Notebook",+ description: "A new edited description",+ topics: ["Topic 1", "Topic 2", "Topic 3"]+ };+ await notebook?.editNotebook(item);++ const editedNotebook = await notebooks.findNotebook(item);+ expect(editedNotebook).toBeDefined();+ expect(await editedNotebook?.getDescription()).toBe(item.description);+});++test("edit topics individually", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notebooks = await app.goToNotebooks();+ const notebook = await notebooks.createNotebook(NOTEBOOK);+ const topics = await notebook?.openNotebook();++ const editedTopics: Item[] = [];+ for (const title of NOTEBOOK.topics) {+ const topic = await topics?.findItem({ title });+ const editedTopic: Item = { title: `${title} (edited)` };+ await topic?.editItem(editedTopic);+ editedTopics.push(editedTopic);+ }++ for (const topic of editedTopics) {+ expect(await topics?.findItem(topic)).toBeDefined();+ }+});++test("delete a notebook", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notebooks = await app.goToNotebooks();+ const notebook = await notebooks.createNotebook(NOTEBOOK);++ await notebook?.moveToTrash();++ expect(await notebook?.isPresent()).toBe(false);+ expect(await app.toasts.waitForToast("1 notebook moved to trash")).toBe(true);+ const trash = await app.goToTrash();+ expect(await trash.findItem(NOTEBOOK.title)).toBeDefined();+});++test("delete a topic", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notebooks = await app.goToNotebooks();+ const notebook = await notebooks.createNotebook(NOTEBOOK);+ const topics = await notebook?.openNotebook();+ const topic = await topics?.findItem({ title: NOTEBOOK.topics[0] });++ await topic?.delete();++ expect(await app.toasts.waitForToast("1 topic deleted")).toBe(true);+ expect(await topics?.findItem({ title: NOTEBOOK.topics[0] })).toBeUndefined();+});++test("restore a notebook", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notebooks = await app.goToNotebooks();+ const notebook = await notebooks.createNotebook(NOTEBOOK);+ await notebook?.moveToTrash();+ const trash = await app.goToTrash();+ const trashItem = await trash.findItem(NOTEBOOK.title);++ await trashItem?.restore();++ await app.goToNotebooks();+ const restoredNotebook = await notebooks.findNotebook(NOTEBOOK);+ expect(restoredNotebook).toBeDefined();+ expect(await app.toasts.waitForToast("1 item restored")).toBe(true);+});++test("permanently delete a notebook", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notebooks = await app.goToNotebooks();+ const notebook = await notebooks.createNotebook(NOTEBOOK);+ await notebook?.moveToTrash();+ const trash = await app.goToTrash();+ const trashItem = await trash.findItem(NOTEBOOK.title);++ await trashItem?.delete();++ expect(await trashItem?.isPresent()).toBe(false);+});++test("pin a notebook", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notebooks = await app.goToNotebooks();+ const notebook = await notebooks.createNotebook(NOTEBOOK);++ await notebook?.pin();++ expect(await notebook?.isPinned()).toBe(true);+});++test("unpin a notebook", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notebooks = await app.goToNotebooks();+ const notebook = await notebooks.createNotebook(NOTEBOOK);+ await notebook?.pin();++ await notebook?.unpin();++ expect(await notebook?.isPinned()).toBe(false);+});++test("create shortcut of a notebook", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notebooks = await app.goToNotebooks();+ const notebook = await notebooks.createNotebook(NOTEBOOK);++ await notebook?.createShortcut();++ expect(await notebook?.isShortcut()).toBe(true);+ const allShortcuts = await app.navigation.getShortcuts();+ expect(allShortcuts.includes(NOTEBOOK.title)).toBeTruthy();+});++test("remove shortcut of a notebook", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notebooks = await app.goToNotebooks();+ const notebook = await notebooks.createNotebook(NOTEBOOK);+ await notebook?.createShortcut();++ await notebook?.removeShortcut();++ expect(await notebook?.isShortcut()).toBe(false);+ const allShortcuts = await app.navigation.getShortcuts();+ expect(allShortcuts.includes(NOTEBOOK.title)).toBeFalsy();+});++test("create shortcut of a topic", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notebooks = await app.goToNotebooks();+ const notebook = await notebooks.createNotebook(NOTEBOOK);+ const topics = await notebook?.openNotebook();+ const topic = await topics?.findItem({ title: NOTEBOOK.topics[0] });++ await topic?.createShortcut();++ expect(await topic?.isShortcut()).toBe(true);+ const allShortcuts = await app.navigation.getShortcuts();+ expect(allShortcuts.includes(NOTEBOOK.topics[0])).toBeTruthy();+});++test("remove shortcut of a topic", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notebooks = await app.goToNotebooks();+ const notebook = await notebooks.createNotebook(NOTEBOOK);+ const topics = await notebook?.openNotebook();+ const topic = await topics?.findItem({ title: NOTEBOOK.topics[0] });+ await topic?.createShortcut();++ await topic?.removeShortcut();++ expect(await topic?.isShortcut()).toBe(false);+ const allShortcuts = await app.navigation.getShortcuts();+ expect(allShortcuts.includes(NOTEBOOK.topics[0])).toBeFalsy();+});diff --git a/apps/web/__e2e__/notehistory.test.js b/apps/web/__e2e__/notehistory.test.jsdeleted file mode 100644index 982196880..000000000--- a/apps/web/__e2e__/notehistory.test.js+++ /dev/null@@ -1,119 +0,0 @@-/*-This file is part of the Notesnook project (https://notesnook.com/)--Copyright (C) 2022 Streetwriters (Private) Limited--This program is free software: you can redistribute it and/or modify-it under the terms of the GNU General Public License as published by-the Free Software Foundation, either version 3 of the License, or-(at your option) any later version.--This program is distributed in the hope that it will be useful,-but WITHOUT ANY WARRANTY; without even the implied warranty of-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-GNU General Public License for more details.--You should have received a copy of the GNU General Public License-along with this program. If not, see <http://www.gnu.org/licenses/>.-*/--const { test, expect } = require("@playwright/test");-const { NOTE, getTestId, getEditorContent, editNote } = require("./utils");-const { createNoteAndCheckPresence, isPresent } = require("./utils/conditions");-const List = require("./utils/listitemidbuilder");--/**- * @type {import("@playwright/test").Page}- */-var page = null;-global.page = null;-test.beforeEach(async ({ page: _page, baseURL }) => {- global.page = _page;- page = _page;- await page.goto(baseURL);- await page.waitForSelector(getTestId("routeHeader"));-});--async function createAndEditNote() {- const noteSelector = await createNoteAndCheckPresence();-- await page.click(getTestId("notes-action-button"));-- await page.click(noteSelector);-- await editNote(null, "Some edited text.");-- return noteSelector;-}--test("editing a note should create a new session in its session history", async () => {- await createAndEditNote();-- await page.click(getTestId("properties"));-- for (let i = 0; i < 2; ++i) {- expect(await isPresent(List.new("session").atIndex(i).build())).toBe(true);- }-});--test("switching sessions should change editor content", async () => {- await createAndEditNote();-- await page.click(getTestId("properties"));-- await page.click(List.new("session").atIndex(1).build());-- await page.waitForTimeout(500);-- expect(await getEditorContent()).toBe(NOTE.content);-- await page.click(getTestId("properties"));-- await page.click(List.new("session").atIndex(0).build());-- await page.waitForTimeout(500);-- expect(await getEditorContent()).toBe(`Some edited text.${NOTE.content}`);-});--test("cancelling session restore should bring editor content back to original", async () => {- await createAndEditNote();-- await page.click(getTestId("properties"));-- await page.click(List.new("session").atIndex(1).build());-- await page.waitForTimeout(500);-- expect(await getEditorContent()).toBe(NOTE.content);-- await page.click(getTestId("editor-notice-cancel"));-- await page.waitForTimeout(500);-- expect(await getEditorContent()).toBe(`Some edited text.${NOTE.content}`);-});--test("restoring a session should change note's content", async () => {- const noteSelector = await createAndEditNote();-- await page.click(getTestId("properties"));-- await page.click(List.new("session").atIndex(1).build());-- await page.waitForTimeout(500);-- expect(await getEditorContent()).toBe(NOTE.content);-- await page.click(getTestId("editor-notice-action"));-- await page.waitForTimeout(500);-- expect(await getEditorContent()).toBe(NOTE.content);-- await page.click(getTestId("notes-action-button"));-- await page.click(noteSelector);-- expect(await getEditorContent()).toBe(NOTE.content);-});diff --git a/apps/web/__e2e__/notehistory.test.ts b/apps/web/__e2e__/notehistory.test.tsnew file mode 100644index 000000000..4d55e8378--- /dev/null+++ b/apps/web/__e2e__/notehistory.test.ts@@ -0,0 +1,162 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { test, expect, Page } from "@playwright/test";+import { AppModel } from "./models/app.model";+import { NOTE, PASSWORD } from "./utils";++async function createSession(page: Page, locked = false) {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);++ if (locked) await note?.contextMenu.lock(PASSWORD);++ const edits = ["Some edited text.", "Some more edited text."];++ await notes.newNote();+ locked ? await note?.openLockedNote(PASSWORD) : await note?.openNote();++ for (const edit of edits) {+ await notes.editor.setContent(edit);+ await notes.newNote();+ locked ? await note?.openLockedNote(PASSWORD) : await note?.openNote();+ }+ const contents = [+ `${edits[1]}${edits[0]}${NOTE.content}`,+ `${edits[0]}${NOTE.content}`+ ];+ await notes.editor.waitForLoading(NOTE.title, contents[0]);++ return {+ note,+ notes,+ app,+ contents+ };+}++const sessionTypes = ["locked", "unlocked"] as const;++for (const type of sessionTypes) {+ const isLocked = type === "locked";++ test(`editing a note should create a new ${type} session in its session history`, async ({+ page+ }) => {+ const { note } = await createSession(page, isLocked);++ const history = await note?.properties.getSessionHistory();+ expect(history?.length).toBeGreaterThan(1);++ if (isLocked) {+ for (const item of history || []) {+ expect(await item.isLocked()).toBeTruthy();+ }+ }+ });++ test(`switching ${type} sessions should change editor content`, async ({+ page+ }) => {+ const { note, notes, contents } = await createSession(page, isLocked);++ const history = await note?.properties.getSessionHistory();+ await history?.at(1)?.preview(PASSWORD);+ await notes.editor.waitForLoading(NOTE.title, contents[1]);+ const content1 = await notes.editor.getContent("text");+ await history?.at(0)?.preview(PASSWORD);+ await notes.editor.waitForLoading(NOTE.title, contents[0]);+ const content0 = await notes.editor.getContent("text");++ expect(content1).toBe(contents[1]);+ expect(content0).toBe(contents[0]);+ });++ test(`cancelling ${type} session restore should bring editor content back to original`, async ({+ page+ }) => {+ const { note, notes, contents } = await createSession(page, isLocked);+ const history = await note?.properties.getSessionHistory();+ await history?.at(1)?.preview(PASSWORD);+ await notes.editor.waitForLoading(NOTE.title, contents[1]);++ await notes.editor.cancelPreview();++ expect(await notes.editor.getContent("text")).toBe(contents[0]);+ });++ test(`restoring a ${type} session should change note's content`, async ({+ page+ }) => {+ const { note, notes, contents } = await createSession(page, isLocked);+ const history = await note?.properties.getSessionHistory();+ await history?.at(1)?.preview(PASSWORD);+ await notes.editor.waitForLoading(NOTE.title, contents[1]);++ await notes.editor.restoreSession();++ expect(await notes.editor.getContent("text")).toBe(contents[1]);+ await notes.newNote();+ isLocked ? await note?.openLockedNote(PASSWORD) : await note?.openNote();+ expect(await notes.editor.getContent("text")).toBe(contents[1]);+ });+}+// test("editing locked note should create locked history sessions", async ({+// page+// }) => {+// const { note } = await createLockedSession(page);++// const history = await note?.properties.getSessionHistory();+// expect(history).toHaveLength(2);+// for (const item of history || []) {+// expect(await item.isLocked()).toBeTruthy();+// }+// });++// test("switching locked sessions should change editor content", async ({+// page+// }) => {+// const { note, notes, contents } = await createLockedSession(page);++// const history = await note?.properties.getSessionHistory();+// await history?.at(1)?.previewLocked(PASSWORD);+// await notes.editor.waitForLoading(NOTE.title, contents[1]);+// const content1 = await notes.editor.getContent("text");++// await history?.at(0)?.previewLocked(PASSWORD);+// await notes.editor.waitForLoading(NOTE.title, contents[0]);+// const content0 = await notes.editor.getContent("text");++// expect(content1).toBe(contents[1]);+// expect(content0).toBe(contents[0]);+// });++// test("restore a locked session", async ({ page }) => {+// const { note, notes, contents } = await createLockedSession(page);+// const history = await note?.properties.getSessionHistory();+// await history?.at(1)?.previewLocked(PASSWORD);+// await notes.editor.waitForLoading(NOTE.title, contents[1]);++// await notes.editor.restoreSession();++// const content = await notes.editor.getContent("text");+// expect(content).toBe(contents[1]);+// });diff --git a/apps/web/__e2e__/notes.issues.test.js b/apps/web/__e2e__/notes.issues.test.tssimilarity index 87%rename from apps/web/__e2e__/notes.issues.test.jsrename to apps/web/__e2e__/notes.issues.test.tsindex 34e6736cb..b9a7c505f 100644--- a/apps/web/__e2e__/notes.issues.test.js+++ b/apps/web/__e2e__/notes.issues.test.ts@@ -17,5 +17,5 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-const { test } = require("@playwright/test");-test.skip("TODO: make sure jump to group works");+import { test } from "@playwright/test";+test.skip("TODO: make sure jump to group works", () => {});diff --git a/apps/web/__e2e__/notes.test.js b/apps/web/__e2e__/notes.test.jsdeleted file mode 100644index e46528a5f..000000000--- a/apps/web/__e2e__/notes.test.js+++ /dev/null@@ -1,510 +0,0 @@-/*-This file is part of the Notesnook project (https://notesnook.com/)--Copyright (C) 2022 Streetwriters (Private) Limited--This program is free software: you can redistribute it and/or modify-it under the terms of the GNU General Public License as published by-the Free Software Foundation, either version 3 of the License, or-(at your option) any later version.--This program is distributed in the hope that it will be useful,-but WITHOUT ANY WARRANTY; without even the implied warranty of-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-GNU General Public License for more details.--You should have received a copy of the GNU General Public License-along with this program. If not, see <http://www.gnu.org/licenses/>.-*/--/* eslint-disable no-undef */-/**- * TODO: We are still not checking if toast appears on delete/restore or not.- */-const { test, expect } = require("@playwright/test");--const {- getTestId,- NOTE,- downloadFile,- PASSWORD,- editNote,- getEditorTitle,- getEditorContent-} = require("./utils");-const {- navigateTo,- clickMenuItem,- openContextMenu,- confirmDialog,- closeContextMenu,- useContextMenu-} = require("./utils/actions");-const {- isToastPresent,- isPresent,- isAbsent,- checkNotePresence,- createNoteAndCheckPresence,- checkMenuItemText-} = require("./utils/conditions");-const List = require("./utils/listitemidbuilder");-const Menu = require("./utils/menuitemidbuilder");--/**- * @type {import("@playwright/test").Page}- */-var page = null;--async function deleteNoteAndCheckAbsence(viewId = "home") {- const noteSelector = await createNoteAndCheckPresence(undefined, viewId);-- await openContextMenu(noteSelector);-- await clickMenuItem("movetotrash");-- // await confirmDialog();-- await expect(isToastPresent()).resolves.toBeTruthy();-- await navigateTo("trash");-- const trashItemSelector = List.new("trash")- .grouped()- .atIndex(0)- .title()- .build();-- await expect(isPresent(trashItemSelector)).resolves.toBeTruthy();-- await expect(page.innerText(trashItemSelector)).resolves.toBe(NOTE.title);-- return trashItemSelector;-}--async function lockUnlockNote(noteSelector) {- await openContextMenu(noteSelector);-- await clickMenuItem("lock");-- await page.fill(getTestId("dialog-password"), PASSWORD);-- await confirmDialog();-- await expect(isToastPresent()).resolves.toBeTruthy();-}--async function openLockedNote(noteSelector, title = NOTE.title) {- await page.click(noteSelector);-- await expect(page.textContent(getTestId("unlock-note-title"))).resolves.toBe(- title- );-- await page.fill(getTestId("unlock-note-password"), PASSWORD);-- await page.click(getTestId("unlock-note-submit"));-}--async function checkNotePinned(noteSelector) {- await openContextMenu(noteSelector);-- await checkMenuItemText("pin", "Unpin");-- await closeContextMenu(noteSelector);-- // wait for the menu to properly close- await page.waitForTimeout(500);-}--async function checkNoteLocked(noteSelector) {- await page.waitForTimeout(500);-- await expect(- isPresent(List.new("note").grouped().atIndex(0).locked().build())- ).resolves.toBeTruthy();-- await expect(- isAbsent(List.new("note").grouped().atIndex(0).body().build())- ).resolves.toBeTruthy();-- await openContextMenu(noteSelector);-- await checkMenuItemText("lock", "Unlock");-- await closeContextMenu(noteSelector);-}--async function checkNoteColored(noteSelector) {- await page.waitForTimeout(1000);-- await openContextMenu(noteSelector);-- await page.click(Menu.new("menuitem").item("colors").build());-- await expect(- isPresent(Menu.new("menuitem").item("red").checked().build())- ).resolves.toBeTruthy();-- await closeContextMenu(noteSelector);-- // wait for the menu to properly close- await page.waitForTimeout(500);-- await navigateTo("red");-- // wait for the page to render and notes to populate- await page.waitForTimeout(500);-- const coloredNote = await page.$(- List.new("note").grouped().atIndex(0).build()- );- if (!coloredNote) throw new Error("Colored note not present.");-}--async function addNoteToNotebook() {- await page.type(getTestId("mnd-new-notebook-title"), "Test Notebook");-- await page.press(getTestId("mnd-new-notebook-title"), "Enter");-- await page.click(List.new("notebook").atIndex(0).build());-- await page.type(getTestId("mnd-new-topic-title"), "Topic 1");-- await page.press(getTestId("mnd-new-topic-title"), "Enter");-- await page.click(List.new("notebook").atIndex(0).topic(0).build());-- await page.click(getTestId("dialog-yes"));-- await expect(isToastPresent()).resolves.toBeTruthy();-- await navigateTo("notebooks");-- await page.click(List.new("notebook").grouped().atIndex(0).title().build());-- await page.click(List.new("topic").grouped().atIndex(0).title().build());-- await checkNotePresence("notes");-}--async function exportNote(format) {- const noteSelector = await createNoteAndCheckPresence();-- await openContextMenu(noteSelector);-- await page.click(Menu.new("menuitem").item("export").build());-- // we need to override date time so- // date created & date edited remain fixed.- await page.evaluate(() => {- // eslint-disable-next-line no-extend-native- Date.prototype.toLocaleString = () => "xxx";- });-- const output = await downloadFile(getTestId(`menuitem-${format}`), "utf-8");- expect(output).toMatchSnapshot(`export-${format}.txt`);-}--test.describe("run tests independently", () => {- test.beforeEach(async ({ page: _page, baseURL }) => {- page = _page;- global.page = _page;- await page.goto(baseURL);- await page.waitForSelector(getTestId("routeHeader"));- });-- test("create a note", async () => {- await createNoteAndCheckPresence();- });-- test("delete a note", async () => {- await deleteNoteAndCheckAbsence();- });-- test("restore a note", async () => {- const trashItemSelector = await deleteNoteAndCheckAbsence();-- await openContextMenu(trashItemSelector);-- await clickMenuItem("restore");-- await expect(isToastPresent()).resolves.toBeTruthy();-- await navigateTo("notes");-- await checkNotePresence("home");- });-- test("add a note to notebook", async () => {- const noteSelector = await createNoteAndCheckPresence();-- await openContextMenu(noteSelector);-- await clickMenuItem("addtonotebook");-- await addNoteToNotebook();- });-- test("favorite a note", async () => {- const noteSelector = await createNoteAndCheckPresence();-- await useContextMenu(noteSelector, async () => {- await clickMenuItem("favorite");- });-- await useContextMenu(- noteSelector,- async () => {- await checkMenuItemText("favorite", "Unfavorite");- },- true- );-- await navigateTo("favorites");-- await checkNotePresence("notes");-- await navigateTo("notes");- });-- test("unfavorite a note", async () => {- const noteSelector = await createNoteAndCheckPresence();-- await useContextMenu(noteSelector, async () => {- await clickMenuItem("favorite");- });-- await page.waitForTimeout(500);-- await useContextMenu(noteSelector, async () => {- await clickMenuItem("favorite");- });-- await useContextMenu(- noteSelector,- async () => {- await checkMenuItemText("favorite", "Favorite");- },- true- );- });-- test("favorite a note from properties", async () => {- let noteSelector = await createNoteAndCheckPresence();-- await page.click(getTestId("properties"));-- await page.click(getTestId("properties-favorite"));-- await page.click(getTestId("properties-close"));-- await navigateTo("favorites");-- noteSelector = await checkNotePresence("notes");-- await useContextMenu(- noteSelector,- async () => {- await checkMenuItemText("favorite", "Unfavorite");- },- true- );-- await navigateTo("notes");- });-- test("assign a color to a note", async () => {- const noteSelector = await createNoteAndCheckPresence();-- await openContextMenu(noteSelector);-- await page.click(Menu.new("menuitem").item("colors").build());- await page.click(Menu.new("menuitem").item("red").build());-- await page.click(getTestId("properties"));-- await expect(- isPresent(getTestId("properties-red-check"))- ).resolves.toBeTruthy();-- await page.click(getTestId("properties-close"));-- await checkNoteColored(noteSelector);- });-- test("pin a note", async () => {- const noteSelector = await createNoteAndCheckPresence();-- await useContextMenu(noteSelector, () => clickMenuItem("pin"));-- await checkNotePinned(noteSelector);- });-- test("unpin a note", async () => {- const noteSelector = await createNoteAndCheckPresence();-- await useContextMenu(noteSelector, () => clickMenuItem("pin"));-- await page.waitForTimeout(500);-- await useContextMenu(noteSelector, () => clickMenuItem("pin"));-- await useContextMenu(- noteSelector,- async () => await checkMenuItemText("pin", "Pin"),- true- );- });-- test("pin a note from properties", async () => {- const noteSelector = await createNoteAndCheckPresence();-- await page.click(getTestId("properties"));-- await page.click(getTestId("properties-pinned"));-- await page.click(getTestId("properties-close"));-- await checkNotePinned(noteSelector, true);- });-- test("permanently delete a note", async () => {- //editor-title //quill- const trashItemSelector = await deleteNoteAndCheckAbsence();-- await openContextMenu(trashItemSelector);-- await clickMenuItem("delete");-- await confirmDialog();-- await expect(isToastPresent()).resolves.toBeTruthy();-- await expect(page.$(trashItemSelector)).resolves.toBeFalsy();- });-- test("lock a note", async () => {- const noteSelector = await createNoteAndCheckPresence();-- await lockUnlockNote(noteSelector);-- await checkNoteLocked(noteSelector);- });-- test("unlock a note permanently", async () => {- const noteSelector = await createNoteAndCheckPresence();-- await lockUnlockNote(noteSelector, "lock");-- await page.waitForTimeout(1000);-- await lockUnlockNote(noteSelector, "unlock");-- await page.waitForTimeout(1000);-- await expect(- isAbsent(List.new("note").grouped().atIndex(0).locked().build())- ).resolves.toBeTruthy();-- await expect(- page.textContent(List.new("note").grouped().atIndex(0).body().build())- ).resolves.toContain(NOTE.content);-- await openContextMenu(noteSelector);-- await checkMenuItemText("lock", "Lock");-- await closeContextMenu(noteSelector);- });-- test("lock a note from properties", async () => {- const noteSelector = await createNoteAndCheckPresence();-- await page.click(getTestId("properties"));-- await page.click(getTestId("properties-locked"));-- await page.fill(getTestId("dialog-password"), PASSWORD);-- await confirmDialog();-- // TODO fix this: no toast is shown when locking note from properties.- //await expect(isToastPresent()).resolves.toBeTruthy();-- await checkNoteLocked(noteSelector);- });-- test("assign a color to note from properties", async () => {- const noteSelector = await createNoteAndCheckPresence();-- await page.click(getTestId("properties"));-- await page.click(getTestId("properties-red"));-- await checkNoteColored(noteSelector);- });-- test("add tags to note", async () => {- await createNoteAndCheckPresence();- const tags = ["hello", "nevermind", "what", "no-way", "gold-and-goldie"];-- for (let tag of tags) {- await page.fill(getTestId("editor-tag-input"), tag);-- await page.press(getTestId("editor-tag-input"), "Enter");-- await expect(isPresent(getTestId(`tag-${tag}`))).resolves.toBeTruthy();- }- });-- test(`export note as txt`, async () => await exportNote("txt"));- test(`export note as md`, async () => await exportNote("md"));- test(`export note as html`, async () => await exportNote("html"));-- test("unlock a note for editing", async () => {- const content = "Edits 1 2 3 ";-- const noteSelector = await createNoteAndCheckPresence();-- await lockUnlockNote(noteSelector, "lock");-- await checkNoteLocked(noteSelector);-- await openLockedNote(noteSelector);-- await editNote(null, content);-- await page.waitForTimeout(1000);-- await openLockedNote(noteSelector);-- await page.waitForTimeout(1000);-- const editorContent = await getEditorContent();- expect(editorContent).toContain(`${content}${NOTE.content}`);- });-- test("change title of a locked note", async () => {- const title = "NEW TITLE!";-- const noteSelector = await createNoteAndCheckPresence();-- await lockUnlockNote(noteSelector, "lock");-- await checkNoteLocked(noteSelector);-- await openLockedNote(noteSelector);-- await editNote(title);-- await page.waitForTimeout(1000);-- await openLockedNote(noteSelector, title);-- await page.waitForTimeout(1000);-- const editorTitle = await getEditorTitle();- expect(editorTitle).toContain(title);- });-});diff --git a/apps/web/__e2e__/notes.test.ts b/apps/web/__e2e__/notes.test.tsnew file mode 100644index 000000000..c0a8ac0ed--- /dev/null+++ b/apps/web/__e2e__/notes.test.ts@@ -0,0 +1,275 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { test, expect } from "@playwright/test";+import { AppModel } from "./models/app.model";+import { NOTE, PASSWORD } from "./utils";++test("create a note", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();++ const note = await notes.createNote(NOTE);++ expect(note).toBeDefined();+});++test("delete a note", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);++ await note?.contextMenu.moveToTrash();++ expect(await app.toasts.waitForToast("1 note moved to trash")).toBe(true);+ expect(await note?.isPresent()).toBe(false);+});++test("restore a note", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);+ await note?.contextMenu.moveToTrash();+ const trash = await app.goToTrash();++ const trashItem = await trash.findItem(NOTE.title);+ await trashItem?.restore();++ expect(await app.toasts.waitForToast("1 item restored")).toBe(true);+ await app.goToNotes();+ await notes.waitForItem(NOTE.title);+ const restoredNote = await notes.findNote(NOTE);+ expect(restoredNote).toBeDefined();+});++test("permanently delete a note", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);+ await note?.contextMenu.moveToTrash();+ const trash = await app.goToTrash();++ const trashItem = await trash.findItem(NOTE.title);+ await trashItem?.delete();++ expect(await app.toasts.waitForToast("1 item permanently deleted")).toBe(+ true+ );+ expect(await trash.findItem(NOTE.title)).toBeUndefined();+});++test("add a note to notebook", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);++ await note?.contextMenu.addToNotebook({+ title: "Notebook 1",+ topics: ["Hello", "World", "Did", "what"]+ });++ expect(await app.toasts.waitForToast("Added 1 note to 4 topics")).toBe(true);+});++const actors = ["contextMenu", "properties"] as const;++for (const actor of actors) {+ test(`favorite a note using ${actor}`, async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);++ await note?.[actor].favorite();++ const favorites = await app.goToFavorites();+ const favoritedNote = await favorites.findNote(NOTE);+ expect(await favoritedNote?.contextMenu.isFavorited()).toBe(true);+ expect(await favoritedNote?.properties.isFavorited()).toBe(true);+ });++ test(`unfavorite a note using ${actor}`, async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);+ await note?.contextMenu.favorite();++ await note?.[actor].unfavorite();++ expect(await note?.contextMenu.isFavorited()).toBe(false);+ expect(await note?.properties.isFavorited()).toBe(false);+ });++ test(`pin a note using ${actor}`, async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);++ await note?.[actor].pin();++ expect(await note?.contextMenu.isPinned()).toBe(true);+ expect(await note?.properties.isPinned()).toBe(true);+ expect(await notes.findGroup("Pinned")).toBeDefined();+ });++ test(`unpin a note using ${actor}`, async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);+ await note?.contextMenu.pin();++ await note?.[actor].unpin();++ expect(await note?.contextMenu.isPinned()).toBe(false);+ expect(await note?.properties.isPinned()).toBe(false);+ expect(await notes.findGroup("Pinned")).toBeUndefined();+ });++ test(`assign a color to a note using ${actor}`, async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);++ await note?.[actor].color("red");++ const coloredNotes = await app.goToColor("red");+ const coloredNote = await coloredNotes.findNote(NOTE);+ expect(coloredNote).toBeDefined();+ expect(await coloredNote?.contextMenu.isColored("red")).toBe(true);+ expect(await coloredNote?.properties.isColored("red")).toBe(true);+ });++ test(`lock a note using ${actor}`, async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);++ await note?.[actor].lock(PASSWORD);++ expect(await note?.contextMenu.isLocked()).toBe(true);+ });++ test(`unlock a note permanently using ${actor}`, async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);+ await note?.contextMenu.lock(PASSWORD);+ await note?.openLockedNote(PASSWORD);++ await note?.[actor].unlock(PASSWORD);++ await note?.descriptionText.waitFor();+ expect(await note?.getDescription()).toContain(NOTE.content);+ expect(await note?.contextMenu.isLocked()).toBe(false);+ });+}++test("open a locked note", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);+ await note?.contextMenu.lock(PASSWORD);++ await note?.openLockedNote(PASSWORD);++ await notes.editor.waitForLoading();+ expect(await notes.editor.getContent("text")).toBe(NOTE.content);+ expect(await note?.contextMenu.isLocked()).toBe(true);+});++test("add tags to note", async ({ page }) => {+ const tags = ["hello", "nevermind", "what", "no-way", "gold-and-goldie"];+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ await notes.createNote(NOTE);++ await notes.editor.setTags(tags);+ await page.waitForTimeout(200);++ const noteTags = await notes.editor.getTags();+ expect(noteTags).toHaveLength(tags.length);+ expect(noteTags.every((t, i) => t === tags[i])).toBe(true);+});++for (const format of ["html", "txt", "md"] as const) {+ test(`export note as ${format}`, async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);++ const output = await note?.contextMenu.export(format);++ expect(output).toMatchSnapshot(`export-${format}.txt`);+ });+}++test("unlock a note for editing", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);+ await note?.contextMenu.lock(PASSWORD);+ await note?.openLockedNote(PASSWORD);++ const content = "Edits 1 2 3 ";+ await notes.editor.setContent(content);+ await page.waitForTimeout(150);++ const newContent = `${content}${NOTE.content}`;+ const editedNote = await notes.findNote({+ title: NOTE.title,+ content: newContent+ });+ await editedNote?.openLockedNote(PASSWORD);+ await notes.editor.waitForLoading();+ expect(await notes.editor.getContent("text")).toContain(newContent);+});++test("change title of a locked note", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);+ await note?.contextMenu.lock(PASSWORD);+ await note?.openLockedNote(PASSWORD);++ const title = "NEW TITLE!";+ await notes.editor.setTitle(title);+ await page.waitForTimeout(150);++ const editedNote = await notes.findNote({ title, content: NOTE.content });+ await editedNote?.openLockedNote(PASSWORD);+ await notes.editor.waitForLoading();+ expect(await note?.getTitle()).toContain(title);+ expect(await notes.editor.getTitle()).toContain(title);+});diff --git a/apps/web/__e2e__/notes.test.js-snapshots/export-html-Chromium-linux.txt b/apps/web/__e2e__/notes.test.ts-snapshots/export-html-Chromium-linux.txtsimilarity index 100%rename from apps/web/__e2e__/notes.test.js-snapshots/export-html-Chromium-linux.txtrename to apps/web/__e2e__/notes.test.ts-snapshots/export-html-Chromium-linux.txtdiff --git a/apps/web/__e2e__/notes.test.js-snapshots/export-html-Firefox-linux.txt b/apps/web/__e2e__/notes.test.ts-snapshots/export-html-Firefox-linux.txtsimilarity index 100%rename from apps/web/__e2e__/notes.test.js-snapshots/export-html-Firefox-linux.txtrename to apps/web/__e2e__/notes.test.ts-snapshots/export-html-Firefox-linux.txtdiff --git a/apps/web/__e2e__/notes.test.js-snapshots/export-html-WebKit-linux.txt b/apps/web/__e2e__/notes.test.ts-snapshots/export-html-WebKit-linux.txtsimilarity index 100%rename from apps/web/__e2e__/notes.test.js-snapshots/export-html-WebKit-linux.txtrename to apps/web/__e2e__/notes.test.ts-snapshots/export-html-WebKit-linux.txtdiff --git a/apps/web/__e2e__/notes.test.js-snapshots/export-md-Chromium-linux.txt b/apps/web/__e2e__/notes.test.ts-snapshots/export-md-Chromium-linux.txtsimilarity index 100%rename from apps/web/__e2e__/notes.test.js-snapshots/export-md-Chromium-linux.txtrename to apps/web/__e2e__/notes.test.ts-snapshots/export-md-Chromium-linux.txtdiff --git a/apps/web/__e2e__/notes.test.js-snapshots/export-md-Firefox-linux.txt b/apps/web/__e2e__/notes.test.ts-snapshots/export-md-Firefox-linux.txtsimilarity index 100%rename from apps/web/__e2e__/notes.test.js-snapshots/export-md-Firefox-linux.txtrename to apps/web/__e2e__/notes.test.ts-snapshots/export-md-Firefox-linux.txtdiff --git a/apps/web/__e2e__/notes.test.js-snapshots/export-md-WebKit-linux.txt b/apps/web/__e2e__/notes.test.ts-snapshots/export-md-WebKit-linux.txtsimilarity index 100%rename from apps/web/__e2e__/notes.test.js-snapshots/export-md-WebKit-linux.txtrename to apps/web/__e2e__/notes.test.ts-snapshots/export-md-WebKit-linux.txtdiff --git a/apps/web/__e2e__/notes.test.js-snapshots/export-txt-Chromium-linux.txt b/apps/web/__e2e__/notes.test.ts-snapshots/export-txt-Chromium-linux.txtsimilarity index 100%rename from apps/web/__e2e__/notes.test.js-snapshots/export-txt-Chromium-linux.txtrename to apps/web/__e2e__/notes.test.ts-snapshots/export-txt-Chromium-linux.txtdiff --git a/apps/web/__e2e__/notes.test.js-snapshots/export-txt-Firefox-linux.txt b/apps/web/__e2e__/notes.test.ts-snapshots/export-txt-Firefox-linux.txtsimilarity index 100%rename from apps/web/__e2e__/notes.test.js-snapshots/export-txt-Firefox-linux.txtrename to apps/web/__e2e__/notes.test.ts-snapshots/export-txt-Firefox-linux.txtdiff --git a/apps/web/__e2e__/notes.test.js-snapshots/export-txt-WebKit-linux.txt b/apps/web/__e2e__/notes.test.ts-snapshots/export-txt-WebKit-linux.txtsimilarity index 100%rename from apps/web/__e2e__/notes.test.js-snapshots/export-txt-WebKit-linux.txtrename to apps/web/__e2e__/notes.test.ts-snapshots/export-txt-WebKit-linux.txtdiff --git a/apps/web/__e2e__/tags.test.js b/apps/web/__e2e__/tags.test.jsdeleted file mode 100644index 885133417..000000000--- a/apps/web/__e2e__/tags.test.js+++ /dev/null@@ -1,257 +0,0 @@-/*-This file is part of the Notesnook project (https://notesnook.com/)--Copyright (C) 2022 Streetwriters (Private) Limited--This program is free software: you can redistribute it and/or modify-it under the terms of the GNU General Public License as published by-the Free Software Foundation, either version 3 of the License, or-(at your option) any later version.--This program is distributed in the hope that it will be useful,-but WITHOUT ANY WARRANTY; without even the implied warranty of-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-GNU General Public License for more details.--You should have received a copy of the GNU General Public License-along with this program. If not, see <http://www.gnu.org/licenses/>.-*/--const { test, expect } = require("@playwright/test");-const { getTestId, createNote, NOTE } = require("./utils");-const {- navigateTo,- useContextMenu,- clickMenuItem-} = require("./utils/actions");-const { checkNotePresence } = require("./utils/conditions");-const List = require("./utils/listitemidbuilder");-const Menu = require("./utils/menuitemidbuilder");--/**- * @type {import("@playwright/test").Page}- */-var page = null;-global.page = null;--test.beforeEach(async ({ page: _page, baseURL }) => {- global.page = _page;- page = _page;- await page.goto(baseURL);- await page.waitForSelector(getTestId("routeHeader"));-});--async function createTag(title) {- await navigateTo("tags");-- await page.click(getTestId("tags-action-button"));-- await page.type(getTestId("item-dialog-title"), title);-- await page.click(getTestId("dialog-yes"));-}--async function checkTagPresence(title) {- let tagSelector = List.new("tag").view("tags").grouped().atIndex(0);-- await page.waitForSelector(tagSelector.build(), { state: "attached" });-- await expect(page.innerText(tagSelector.title().build())).resolves.toBe(- `#${title}`- );-- return tagSelector;-}--async function createNoteAndCheckPresence(title) {- await createNote(NOTE, "notes");-- const noteSelector = await checkNotePresence("notes");-- expect(- await page.isVisible(- new List("note").view("notes").grouped().atIndex(0).tag(title).build()- )- ).toBe(true);-- return noteSelector;-}--async function createTagAndCheckPresence(title) {- await createTag(title);-- return await checkTagPresence(title);-}--async function renameTag(tagSelector, newTitle, expected) {- await useContextMenu(tagSelector.build(), async () => {- await clickMenuItem("rename");- });-- await page.fill(getTestId("item-dialog-title"), newTitle);-- await page.click(getTestId("dialog-yes"));-- await checkTagPresence(expected);-}--test("create a tag", async () => {- await createTagAndCheckPresence("helloworld");-});--test("edit a tag", async () => {- const tagSelector = await createTagAndCheckPresence("helloworld");-- await renameTag(tagSelector, "new world", "newworld");-});--test("delete a tag", async ({ page }) => {- const tagSelector = await createTagAndCheckPresence("helloworld");-- await useContextMenu(tagSelector.build(), async () => {- await clickMenuItem("delete");- });-- await page.waitForTimeout(1000);-- expect(await page.isVisible(tagSelector.build())).toBe(false);-});--test("create a note inside a tag", async ({ page }) => {- const tagSelector = await createTagAndCheckPresence("helloworld");-- await page.click(tagSelector.build());-- await createNoteAndCheckPresence("helloworld");-});--test("edit a tag and make sure all its references on note are updated", async ({- page-}) => {- let tagSelector = await createTagAndCheckPresence("helloworld");-- await page.click(tagSelector.build());-- await createNoteAndCheckPresence("helloworld");-- await page.click(getTestId("go-back"));-- await renameTag(tagSelector, "new world", "newworld");-- await page.click(tagSelector.build());-- expect(- await page.isVisible(- new List("note")- .view("notes")- .grouped()- .atIndex(0)- .tag("newworld")- .build()- )- ).toBe(true);-});--test("delete a tag and make sure all associated notes are untagged", async ({- page-}) => {- const tagSelector = await createTagAndCheckPresence("helloworld");-- await page.click(tagSelector.build());-- await createNoteAndCheckPresence("helloworld");-- await page.click(getTestId("go-back"));-- await useContextMenu(tagSelector.build(), async () => {- await clickMenuItem("delete");- });-- await page.waitForTimeout(1000);-- expect(await page.isVisible(tagSelector.build())).toBe(false);-- await navigateTo("notes");-- expect(- await page.isVisible(- new List("note")- .view("notes")- .grouped()- .atIndex(0)- .tag("helloworld")- .build()- )- ).toBe(false);-});--test("create a shortcut of a tag", async ({ page }) => {- const tagSelector = await createTagAndCheckPresence("helloworld");-- await useContextMenu(tagSelector.build(), async () => {- await clickMenuItem("shortcut");- });-- await page.waitForTimeout(1000);-- expect(- await page.isVisible(new Menu("navitem").item("helloworld").build())- ).toBe(true);-- await navigateTo("helloworld");-- expect(await page.inputValue(getTestId("routeHeader"))).toBe("#helloworld");-});--test("delete a shortcut of a tag", async ({ page }) => {- const tagSelector = await createTagAndCheckPresence("helloworld");-- await useContextMenu(tagSelector.build(), async () => {- await clickMenuItem("shortcut");- });-- await page.waitForTimeout(1000);-- expect(- await page.isVisible(new Menu("navitem").item("helloworld").build())- ).toBe(true);-- await useContextMenu(- new Menu("navitem").item("helloworld").build(),- async () => {- await clickMenuItem("removeshortcut");- }- );-- await page.waitForTimeout(1000);-- expect(- await page.isVisible(new Menu("navitem").item("helloworld").build())- ).toBe(false);-});--test("delete the last note of a tag that is also a shortcut", async ({- page-}) => {- const tagSelector = await createTagAndCheckPresence("helloworld");-- await useContextMenu(tagSelector.build(), async () => {- await clickMenuItem("shortcut");- });-- await page.click(tagSelector.build());-- const noteSelector = await createNoteAndCheckPresence("helloworld");-- await useContextMenu(noteSelector, async () => {- await clickMenuItem("movetotrash");- });-- await page.waitForTimeout(1000);-- expect(await page.isVisible(noteSelector)).toBe(false);-- await navigateTo("notes");-- expect(await page.inputValue(getTestId("routeHeader"))).toBe("Notes");-});diff --git a/apps/web/__e2e__/tags.test.ts b/apps/web/__e2e__/tags.test.tsnew file mode 100644index 000000000..e328a90a4--- /dev/null+++ b/apps/web/__e2e__/tags.test.ts@@ -0,0 +1,178 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { test, expect } from "@playwright/test";+import { AppModel } from "./models/app.model";+import { Item } from "./models/types";+import { NOTE } from "./utils";++const TAG: Item = { title: "hello-world" };+const EDITED_TAG: Item = { title: "hello-world-2" };++test("create a tag", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const tags = await app.goToTags();++ const tag = await tags.createItem(TAG);++ expect(tag).toBeDefined();+});++test("create a note inside a tag", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const tags = await app.goToTags();+ const tag = await tags.createItem(TAG);+ const notes = await tag?.open();++ const note = await notes?.createNote(NOTE);++ expect(note).toBeDefined();+ await notes?.newNote();+ await note?.openNote();+ const assignedTags = await notes?.editor.getTags();+ expect(assignedTags?.includes("hello-world")).toBeTruthy();+});++test("edit a tag", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const tags = await app.goToTags();+ const tag = await tags.createItem(TAG);++ await tag?.editItem(EDITED_TAG);++ const editedTag = await tags.findItem(EDITED_TAG);+ expect(editedTag).toBeDefined();+});++test("delete a tag", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const tags = await app.goToTags();+ const tag = await tags.createItem(TAG);++ await tag?.delete();++ expect(await app.toasts.waitForToast("1 tag deleted")).toBe(true);+ expect(await tags?.findItem(TAG)).toBeUndefined();+});++test("create shortcut of a tag", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const tags = await app.goToTags();+ const tag = await tags.createItem(TAG);++ await tag?.createShortcut();++ expect(await tag?.isShortcut()).toBe(true);+ const allShortcuts = await app.navigation.getShortcuts();+ expect(allShortcuts.includes("hello-world")).toBeTruthy();+});++test("remove shortcut of a tag", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const tags = await app.goToTags();+ const tag = await tags.createItem(TAG);+ await tag?.createShortcut();++ await tag?.removeShortcut();++ expect(await tag?.isShortcut()).toBe(false);+ const allShortcuts = await app.navigation.getShortcuts();+ expect(allShortcuts.includes("hello-world")).toBeFalsy();+});++test("edit a tag and make sure all its references on note are updated", async ({+ page+}) => {+ const app = new AppModel(page);+ await app.goto();+ let tags = await app.goToTags();+ let tag = await tags.createItem(TAG);+ let notes = await tag?.open();+ await notes?.createNote(NOTE);+ tags = await app.goToTags();+ tag = await tags.findItem(TAG);++ await tag?.editItem(EDITED_TAG);++ notes = await tag?.open();+ await notes?.newNote();+ const note = await notes?.findNote(NOTE);+ expect((await note?.getTags())?.includes(EDITED_TAG.title)).toBeTruthy();+ await note?.openNote();+ expect(+ (await notes?.editor.getTags())?.includes(EDITED_TAG.title)+ ).toBeTruthy();+});++test("assigning tag to a note should create a tag", async ({ page }) => {+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ await notes.createNote(NOTE);++ await notes.editor.setTags([TAG.title]);++ const tags = await app.goToTags();+ expect(await tags.findItem(TAG)).toBeDefined();+});++test("delete a tag and make sure all associated notes are untagged", async ({+ page+}) => {+ const app = new AppModel(page);+ await app.goto();+ let notes = await app.goToNotes();+ await notes.createNote(NOTE);+ await notes.editor.setTags([TAG.title]);+ const tags = await app.goToTags();+ const tag = await tags.findItem(TAG);++ await tag?.delete();++ notes = await app.goToNotes();+ const note = await notes.findNote(NOTE);+ expect((await note?.getTags())?.includes(TAG.title)).toBeFalsy();+ await note?.openNote();+ expect((await notes?.editor.getTags())?.includes(TAG.title)).toBeFalsy();+});++test("delete the last note of a tag that is also a shortcut", async ({+ page+}) => {+ const app = new AppModel(page);+ await app.goto();+ let notes = await app.goToNotes();+ await notes.createNote(NOTE);+ await notes.editor.setTags([TAG.title]);+ const tags = await app.goToTags();+ const tag = await tags.findItem(TAG);+ await tag?.createShortcut();+ notes = await app.goToNotes();+ const note = await notes.findNote(NOTE);++ await note?.contextMenu.moveToTrash();++ expect(await app.getRouteHeader()).toBe("Notes");+});diff --git a/apps/web/__e2e__/user.test.js b/apps/web/__e2e__/user.test.jsdeleted file mode 100644index c4dc4921f..000000000--- a/apps/web/__e2e__/user.test.js+++ /dev/null@@ -1,268 +0,0 @@-/*-This file is part of the Notesnook project (https://notesnook.com/)--Copyright (C) 2022 Streetwriters (Private) Limited--This program is free software: you can redistribute it and/or modify-it under the terms of the GNU General Public License as published by-the Free Software Foundation, either version 3 of the License, or-(at your option) any later version.--This program is distributed in the hope that it will be useful,-but WITHOUT ANY WARRANTY; without even the implied warranty of-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-GNU General Public License for more details.--You should have received a copy of the GNU General Public License-along with this program. If not, see <http://www.gnu.org/licenses/>.-*/--const { test, expect } = require("@playwright/test");-const { getTestId, isTestAll, loginUser, USER } = require("./utils");-const { isAbsent, isPresent } = require("./utils/conditions");--/**- * @type {import("@playwright/test").Page}- */-var page = null;-global.page = null;-test.beforeEach(async ({ page: _page, baseURL }) => {- global.page = _page;- page = _page;- await page.goto(baseURL);- await page.waitForSelector(getTestId("routeHeader"));-});--if (!isTestAll()) test.skip();--async function logoutUser() {- await page.click(getTestId("navitem-settings"));-- await page.click(getTestId("settings-logout"));-- await page.waitForSelector(getTestId("dialog-yes"));-- await page.click(getTestId("dialog-yes"));-- expect(await isAbsent(getTestId("sync-status-synced"))).toBe(true);-}--async function forceExpireSession() {- await page.evaluate(() => {- window.localStorage.setItem("sessionExpired", "true");- });- await page.reload();-}--test("login user", async () => {- await loginUser();-- expect(await isPresent(getTestId("sync-status-completed"))).toBe(true);-});--test("logout user", async () => {- await loginUser();- await logoutUser();-});--test("login user and change password repeatedly", async ({- page,- browserName-}) => {- test.setTimeout(2 * 60 * 1000);- test.skip(browserName !== "chromium", "Cannot run in parallel.");-- let currentPassword = USER.CURRENT.password;- let newPassword = USER.NEW.password;- let email = USER.email;-- for (let i = 0; i < 3; i++) {- // eslint-disable-next-line no-loop-func- await test.step(`login user using password ${currentPassword} (${i})`, async () => {- await loginUser({- email,- password: currentPassword- });-- await page.waitForSelector(getTestId("sync-status-synced"));-- await page.click(getTestId("navitem-settings"));-- await page.click(getTestId("settings-change-password"));-- await page.waitForSelector(getTestId("dialog-yes"));-- await page.fill(getTestId("dialog-password"), currentPassword);-- await page.fill(getTestId("dialog-new-password"), newPassword);-- await page.click(getTestId("dialog-yes"));-- expect(await isAbsent(getTestId("dialog-yes"), 60 * 1000)).toBe(true);-- await logoutUser();-- await page.reload();-- await page.waitForTimeout(2000);-- const cPassword = currentPassword;- currentPassword = newPassword;- newPassword = cPassword;- });- }-});--test("reset user password using recovery key", async ({- page,- browserName-}) => {- test.setTimeout(2 * 60 * 1000);- test.skip(browserName !== "chromium", "Cannot run in parallel.");-- await recoverAccount(async ({ currentKey }) => {- await page.click(getTestId("step-recovery-key"));-- await page.waitForSelector(getTestId("step-recovery-key"));-- await page.fill(getTestId("recoveryKey"), currentKey);-- await page.click(getTestId("submitButton"));- });-});--test("reset user password after session expiry", async ({- page,- browserName-}) => {- test.setTimeout(2 * 60 * 1000);- test.skip(browserName !== "chromium", "Cannot run in parallel.");-- let currentPassword = USER.CURRENT.password;- let currentKey = USER.CURRENT.key;-- let newPassword = USER.NEW.password;- let newKey = USER.NEW.key;-- let email = USER.email;-- for (let i = 0; i <= 1; ++i) {- await loginUser({ email, password: currentPassword });-- await forceExpireSession();-- await page.click(getTestId("auth-forgot-password"));-- await page.click(getTestId("submitButton"));-- await page.waitForSelector(getTestId("step-new-password"));-- await page.fill(getTestId("password"), newPassword);-- await page.fill(getTestId("confirmPassword"), newPassword);-- await page.click(getTestId("submitButton"));-- await page.waitForSelector(getTestId("step-finished"));-- const actualRecoveryKey = await page.innerText(getTestId("recoveryKey"));- expect(actualRecoveryKey).toBe(newKey);-- await page.click(getTestId("dialog-yes"));-- await page.click(getTestId("submitButton"));-- await loginUser({ password: newPassword }, false);-- await page.waitForSelector(getTestId("sync-status-synced"));-- await logoutUser();-- const cPassword = currentPassword;- currentPassword = newPassword;- newPassword = cPassword;-- const cKey = currentKey;- currentKey = newKey;- newKey = cKey;- }-});--test("reset user password using old password", async ({- page,- browserName-}) => {- test.setTimeout(2 * 60 * 1000);- test.skip(browserName !== "chromium", "Cannot run in parallel.");-- await recoverAccount(async ({ currentPassword }) => {- await page.click(getTestId("step-old-password"));-- await page.waitForSelector(getTestId("step-old-password"));-- await page.fill(getTestId("old_password"), currentPassword);-- await page.click(getTestId("submitButton"));- });-});--async function recoverAccount(submitRecoveryData) {- let currentPassword = USER.CURRENT.password;- let currentKey = USER.CURRENT.key;-- let newPassword = USER.NEW.password;- let newKey = USER.NEW.key;-- let email = USER.email;-- for (let i = 0; i <= 1; ++i) {- await page.click(getTestId("navitem-login"));-- await page.click(getTestId("auth-forgot-password"));-- await page.fill(getTestId("email"), email);-- await page.click(getTestId("submitButton"));-- await page.waitForNavigation({ url: /account\/recovery/ });-- await page.waitForSelector(getTestId("step-recovery-methods"));-- await submitRecoveryData({ currentPassword, currentKey });-- await page.waitForSelector(getTestId("step-backup-data"));-- await page.click(getTestId("submitButton"));-- await page.waitForSelector(getTestId("step-new-password"));-- await page.fill(getTestId("password"), newPassword);-- await page.fill(getTestId("confirmPassword"), newPassword);-- await page.click(getTestId("submitButton"));-- await page.waitForSelector(getTestId("step-finished"));-- const actualRecoveryKey = await page.innerText(getTestId("recoveryKey"));- expect(actualRecoveryKey).toBe(newKey);-- await page.click(getTestId("dialog-yes"));-- await page.click(getTestId("submitButton"));-- await loginUser({ email, password: newPassword }, false);-- await page.waitForSelector(getTestId("sync-status-synced"));-- await logoutUser();-- const cPassword = currentPassword;- currentPassword = newPassword;- newPassword = cPassword;-- const cKey = currentKey;- currentKey = newKey;- newKey = cKey;- }-}diff --git a/apps/web/__e2e__/user.test.ts b/apps/web/__e2e__/user.test.tsnew file mode 100644index 000000000..876f97df0--- /dev/null+++ b/apps/web/__e2e__/user.test.ts@@ -0,0 +1,264 @@+/*+This file is part of the Notesnook project (https://notesnook.com/)++Copyright (C) 2022 Streetwriters (Private) Limited++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++import { test, expect } from "@playwright/test";+import { AppModel } from "./models/app.model";+import { USER } from "./utils";++// async function forceExpireSession() {+// await page.evaluate(() => {+// window.localStorage.setItem("sessionExpired", "true");+// });+// await page.reload();+// }++test("login user", async ({ page }) => {+ const app = new AppModel(page);+ await app.auth.goto();++ await app.auth.login(USER.CURRENT);++ expect(await app.isSynced()).toBeTruthy();+});++test("logout user", async ({ page }) => {+ const app = new AppModel(page);+ await app.auth.goto();+ await app.auth.login(USER.CURRENT);++ const settings = await app.goToSettings();+ await settings?.logout();++ expect(await settings.isLoggedIn()).toBeFalsy();+});++test("check recovery key of user", async ({ page }) => {+ const app = new AppModel(page);+ await app.auth.goto();+ await app.auth.login(USER.CURRENT);+ const settings = await app.goToSettings();++ const key =+ USER.CURRENT.password &&+ (await settings.getRecoveryKey(USER.CURRENT.password));++ expect(key).toBe(USER.CURRENT.key);+});++// test("login user and change password repeatedly", async ({+// page,+// browserName+// }) => {+// test.setTimeout(2 * 60 * 1000);+// test.skip(browserName !== "chromium", "Cannot run in parallel.");++// let currentPassword = USER.CURRENT.password;+// let newPassword = USER.NEW.password;+// let email = USER.email;++// for (let i = 0; i < 3; i++) {+// // eslint-disable-next-line no-loop-func+// await test.step(`login user using password ${currentPassword} (${i})`, async () => {+// await loginUser({+// email,+// password: currentPassword+// });++// await page.waitForSelector(getTestId("sync-status-synced"));++// await page.click(getTestId("navitem-settings"));++// await page.click(getTestId("settings-change-password"));++// await page.waitForSelector(getTestId("dialog-yes"));++// await page.fill(getTestId("dialog-password"), currentPassword);++// await page.fill(getTestId("dialog-new-password"), newPassword);++// await page.click(getTestId("dialog-yes"));++// expect(await isAbsent(getTestId("dialog-yes"), 60 * 1000)).toBe(true);++// await logoutUser();++// await page.reload();++// await page.waitForTimeout(2000);++// const cPassword = currentPassword;+// currentPassword = newPassword;+// newPassword = cPassword;+// });+// }+// });++// test("reset user password using recovery key", async ({+// page,+// browserName+// }) => {+// test.setTimeout(2 * 60 * 1000);+// test.skip(browserName !== "chromium", "Cannot run in parallel.");++// await recoverAccount(async ({ currentKey }) => {+// await page.click(getTestId("step-recovery-key"));++// await page.waitForSelector(getTestId("step-recovery-key"));++// await page.fill(getTestId("recoveryKey"), currentKey);++// await page.click(getTestId("submitButton"));+// });+// });++// test("reset user password after session expiry", async ({+// page,+// browserName+// }) => {+// test.setTimeout(2 * 60 * 1000);+// test.skip(browserName !== "chromium", "Cannot run in parallel.");++// let currentPassword = USER.CURRENT.password;+// let currentKey = USER.CURRENT.key;++// let newPassword = USER.NEW.password;+// let newKey = USER.NEW.key;++// let email = USER.email;++// for (let i = 0; i <= 1; ++i) {+// await loginUser({ email, password: currentPassword });++// await forceExpireSession();++// await page.click(getTestId("auth-forgot-password"));++// await page.click(getTestId("submitButton"));++// await page.waitForSelector(getTestId("step-new-password"));++// await page.fill(getTestId("password"), newPassword);++// await page.fill(getTestId("confirmPassword"), newPassword);++// await page.click(getTestId("submitButton"));++// await page.waitForSelector(getTestId("step-finished"));++// const actualRecoveryKey = await page.innerText(getTestId("recoveryKey"));+// expect(actualRecoveryKey).toBe(newKey);++// await page.click(getTestId("dialog-yes"));++// await page.click(getTestId("submitButton"));++// await loginUser({ password: newPassword }, false);++// await page.waitForSelector(getTestId("sync-status-synced"));++// await logoutUser();++// const cPassword = currentPassword;+// currentPassword = newPassword;+// newPassword = cPassword;++// const cKey = currentKey;+// currentKey = newKey;+// newKey = cKey;+// }+// });++// test("reset user password using old password", async ({+// page,+// browserName+// }) => {+// test.setTimeout(2 * 60 * 1000);+// test.skip(browserName !== "chromium", "Cannot run in parallel.");++// await recoverAccount(async ({ currentPassword }) => {+// await page.click(getTestId("step-old-password"));++// await page.waitForSelector(getTestId("step-old-password"));++// await page.fill(getTestId("old_password"), currentPassword);++// await page.click(getTestId("submitButton"));+// });+// });++// async function recoverAccount(submitRecoveryData) {+// let currentPassword = USER.CURRENT.password;+// let currentKey = USER.CURRENT.key;++// let newPassword = USER.NEW.password;+// let newKey = USER.NEW.key;++// let email = USER.email;++// for (let i = 0; i <= 1; ++i) {+// await page.click(getTestId("navitem-login"));++// await page.click(getTestId("auth-forgot-password"));++// await page.fill(getTestId("email"), email);++// await page.click(getTestId("submitButton"));++// await page.waitForNavigation({ url: /account\/recovery/ });++// await page.waitForSelector(getTestId("step-recovery-methods"));++// await submitRecoveryData({ currentPassword, currentKey });++// await page.waitForSelector(getTestId("step-backup-data"));++// await page.click(getTestId("submitButton"));++// await page.waitForSelector(getTestId("step-new-password"));++// await page.fill(getTestId("password"), newPassword);++// await page.fill(getTestId("confirmPassword"), newPassword);++// await page.click(getTestId("submitButton"));++// await page.waitForSelector(getTestId("step-finished"));++// const actualRecoveryKey = await page.innerText(getTestId("recoveryKey"));+// expect(actualRecoveryKey).toBe(newKey);++// await page.click(getTestId("dialog-yes"));++// await page.click(getTestId("submitButton"));++// await loginUser({ email, password: newPassword }, false);++// await page.waitForSelector(getTestId("sync-status-synced"));++// await logoutUser();++// const cPassword = currentPassword;+// currentPassword = newPassword;+// newPassword = cPassword;++// const cKey = currentKey;+// currentKey = newKey;+// newKey = cKey;+// }+// }diff --git a/apps/web/__e2e__/utils/actions.js b/apps/web/__e2e__/utils/actions.jsdeleted file mode 100644index 36fdde36d..000000000--- a/apps/web/__e2e__/utils/actions.js+++ /dev/null@@ -1,62 +0,0 @@-/*-This file is part of the Notesnook project (https://notesnook.com/)--Copyright (C) 2022 Streetwriters (Private) Limited--This program is free software: you can redistribute it and/or modify-it under the terms of the GNU General Public License as published by-the Free Software Foundation, either version 3 of the License, or-(at your option) any later version.--This program is distributed in the hope that it will be useful,-but WITHOUT ANY WARRANTY; without even the implied warranty of-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-GNU General Public License for more details.--You should have received a copy of the GNU General Public License-along with this program. If not, see <http://www.gnu.org/licenses/>.-*/--/* eslint-disable no-undef */-const { getTestId } = require("./index");-const Menu = require("./menuitemidbuilder");--async function navigateTo(pageId) {- await page.click(Menu.new("navitem").item(pageId).build());-}--async function clickMenuItem(itemId) {- await page.click(Menu.new("menuitem").item(itemId).build(), {- button: "left",- force: true- });-}--async function openContextMenu(selector) {- await page.click(selector, { button: "right" });-}--async function closeContextMenu() {- await page.keyboard.press("Escape");-}--async function useContextMenu(selector, action, close = false) {- await openContextMenu(selector);-- await action();-- if (close) await closeContextMenu();-}--async function confirmDialog() {- await page.click(getTestId("dialog-yes"));-}--module.exports = {- navigateTo,- clickMenuItem,- openContextMenu,- confirmDialog,- closeContextMenu,- useContextMenu-};diff --git a/apps/web/__e2e__/utils/conditions.js b/apps/web/__e2e__/utils/conditions.jsdeleted file mode 100644index 1f90df46f..000000000--- a/apps/web/__e2e__/utils/conditions.js+++ /dev/null@@ -1,94 +0,0 @@-/*-This file is part of the Notesnook project (https://notesnook.com/)--Copyright (C) 2022 Streetwriters (Private) Limited--This program is free software: you can redistribute it and/or modify-it under the terms of the GNU General Public License as published by-the Free Software Foundation, either version 3 of the License, or-(at your option) any later version.--This program is distributed in the hope that it will be useful,-but WITHOUT ANY WARRANTY; without even the implied warranty of-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-GNU General Public License for more details.--You should have received a copy of the GNU General Public License-along with this program. If not, see <http://www.gnu.org/licenses/>.-*/--/* eslint-disable no-undef */-const { expect } = require("@playwright/test");-const { getTestId, NOTE, createNote } = require(".");-const List = require("./listitemidbuilder");-const Menu = require("./menuitemidbuilder");--async function isPresent(selector) {- try {- await page.waitForSelector(selector, { state: "attached", timeout: 10000 });- return true;- } catch (e) {- console.log(e);- return false;- }-}--async function isAbsent(selector, timeout = 10000) {- try {- await page.waitForSelector(selector, { state: "detached", timeout });- return true;- } catch (e) {- console.log(e);- return false;- }-}--async function isToastPresent() {- return isPresent(getTestId("toast"));-}--async function checkNotePresence(viewId, index = 0, note = NOTE) {- let noteSelector = List.new("note").view(viewId).grouped().atIndex(index);- // noteSelector = noteSelector.build();-- await page.waitForSelector(noteSelector.build(), { state: "attached" });-- await (await page.$(noteSelector.build())).scrollIntoViewIfNeeded();-- await expect(page.innerText(noteSelector.title().build())).resolves.toBe(- note.title- );- return noteSelector.build();-}--async function createNoteAndCheckPresence(- note = NOTE,- viewId = "home",- index = 0-) {- await createNote(note, "notes");-- // make sure the note has saved.- await page.waitForTimeout(200);-- let noteSelector = await checkNotePresence(viewId, index, note);-- await page.click(noteSelector, { button: "left" });-- return noteSelector;-}--async function checkMenuItemText(itemId, expectedText) {- await expect(- page.textContent(Menu.new("menuitem").item(itemId).build())- ).resolves.toBe(expectedText);-}--module.exports = {- isPresent,- isAbsent,- isToastPresent,- checkNotePresence,- createNoteAndCheckPresence,- checkMenuItemText-};diff --git a/apps/web/__e2e__/utils/index.js b/apps/web/__e2e__/utils/index.tssimilarity index 50%rename from apps/web/__e2e__/utils/index.jsrename to apps/web/__e2e__/utils/index.tsindex e3d0a9d3d..1ddd95f59 100644--- a/apps/web/__e2e__/utils/index.js+++ b/apps/web/__e2e__/utils/index.ts@@ -17,124 +17,106 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-/* eslint-disable no-undef */-const fs = require("fs");-const dotenv = require("dotenv");-const path = require("path");+import fs from "fs";+import dotenv from "dotenv";+import path from "path";+import { Locator, Page } from "@playwright/test";++type Note = {+ title: string;+ content?: string;+};dotenv.config({ path: path.join(__dirname, ".env.local") });const USER = {- email: process.env.USER_EMAIL,NEW: {+ email: process.env.USER_EMAIL,password: process.env.NEW_USER_PASSWORD,key: process.env.NEW_USER_KEY},CURRENT: {+ email: process.env.USER_EMAIL,password: process.env.CURRENT_USER_PASSWORD,key: process.env.CURRENT_USER_KEY}};-async function loginUser(user = USER, navigate = true) {- if (navigate) await page.click(getTestId("navitem-login"));-- if (user.email) await page.fill(getTestId("email"), user.email);-- await page.fill(- getTestId("password"),- user.password || USER.CURRENT.password- );-- await page.click(getTestId("submitButton"));-- await page.waitForSelector(getTestId("sync-status-completed"));-}-const NOTEBOOK = {title: "Test notebook 1",description: "This is test notebook 1",topics: ["Topic 1", "Very long topic 2", "Topic 3"]};-const NOTE = {+const NOTE: Note = {title: "Test 1",content: "This is " + "Test 1".repeat(10)};+const TITLE_ONLY_NOTE: Note = {+ title: "Only a title"+};+const PASSWORD = "123abc123abc";-function getTestId(id) {+function getTestId<TId extends string>(id: TId): `[data-test-id="${TId}"]` {return `[data-test-id="${id}"]`;}-async function createNote(note, actionButtonId) {- await page.click(getTestId(actionButtonId + "-action-button"));+async function createNote(page: Page, note: Note) {+ await page.locator(getTestId("notes-action-button")).click();- await editNote(note.title, note.content);+ await editNote(page, note);}-async function editNote(title, content, noDelay = false) {- await page.waitForSelector(".ProseMirror");-- // await page.waitForTimeout(1000);-- if (title)- await page.fill(getTestId("editor-title"), title, {- strict: true,- force: true- });+async function editNote(page: Page, note: Partial<Note>, noDelay = false) {+ const prosemirror = page.locator(".ProseMirror");- if (content) {+ if (note.title) {+ const title = page.locator(getTestId("editor-title"));+ await title.fill(note.title);+ }+ if (note.content) {if (!noDelay) await page.waitForTimeout(100);- await page.focus(".ProseMirror");+ await prosemirror.focus();- await page.type(".ProseMirror", content);+ await prosemirror.type(note.content);}+ // a short delay so the note can be savedif (!noDelay) await page.waitForTimeout(200);}-async function downloadFile(downloadActionSelector, encoding) {- await page.waitForSelector(downloadActionSelector);-+async function downloadAndReadFile(+ page: Page,+ action: Locator,+ encoding: BufferEncoding = "utf-8"+) {const [download] = await Promise.all([page.waitForEvent("download"),- await page.click(downloadActionSelector)+ await action.click()]);- const path = await download.path();- return fs.readFileSync(path, { encoding });-}-async function getEditorTitle() {- return await page.inputValue(getTestId("editor-title"));-}--async function getEditorContent() {- return (await page.innerText(".ProseMirror")).trim().replace(/\n+/gm, "\n");-}+ const path = await download.path();+ if (!path) throw new Error("Download path not found.");-async function getEditorContentAsHTML() {- return await page.innerHTML(".ProseMirror");+ return fs.readFileSync(path, { encoding });}function isTestAll() {return process.env.TEST_ALL === "true";}-module.exports = {+export {USER,NOTE,+ TITLE_ONLY_NOTE,NOTEBOOK,PASSWORD,getTestId,createNote,editNote,- downloadFile,- getEditorTitle,- getEditorContent,- getEditorContentAsHTML,- isTestAll,- loginUser+ downloadAndReadFile,+ isTestAll};diff --git a/apps/web/__e2e__/utils/listitemidbuilder.js b/apps/web/__e2e__/utils/listitemidbuilder.jsdeleted file mode 100644index ba3b96b62..000000000--- a/apps/web/__e2e__/utils/listitemidbuilder.js+++ /dev/null@@ -1,90 +0,0 @@-/*-This file is part of the Notesnook project (https://notesnook.com/)--Copyright (C) 2022 Streetwriters (Private) Limited--This program is free software: you can redistribute it and/or modify-it under the terms of the GNU General Public License as published by-the Free Software Foundation, either version 3 of the License, or-(at your option) any later version.--This program is distributed in the hope that it will be useful,-but WITHOUT ANY WARRANTY; without even the implied warranty of-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-GNU General Public License for more details.--You should have received a copy of the GNU General Public License-along with this program. If not, see <http://www.gnu.org/licenses/>.-*/--const { getTestId } = require(".");--class ListItemIDBuilder {- static new(type) {- return new ListItemIDBuilder(type);- }-- constructor(type) {- this.type = type;- }-- view(viewId) {- this.viewId = viewId;- return this;- }-- atIndex(index) {- this.index = index;- return this;- }-- title() {- this.suffix = "title";- return this;- }-- color(color) {- this.suffix = "colors-" + color;- return this;- }-- tag(tag) {- this.suffix = `tags-${tag}`;- return this;- }-- locked() {- this.suffix = "locked";- return this;- }-- body() {- this.suffix = "body";- return this;- }-- topic(index) {- this.suffix = `topic-${index}`;- return this;- }-- grouped() {- this.isGrouped = true;- return this;- }-- build() {- if (this.isGrouped) this.index++;-- const id = getTestId(- `${this.type}-${this.index}${this.suffix ? `-${this.suffix}` : ""}`- );-- if (this.isGrouped) {- this.index--;- }- if (this.viewId) return `#${this.viewId} ${id}`;- return id;- }-}-module.exports = ListItemIDBuilder;diff --git a/apps/web/package-lock.json b/apps/web/package-lock.jsonindex 690d0a73f..075bbc9ef 100644--- a/apps/web/package-lock.json+++ b/apps/web/package-lock.json@@ -79,8 +79,7 @@"source-map-explorer": "^2.5.2","typescript": "^4.8.2","webpack-bundle-analyzer": "^4.5.0",- "worker-loader": "^3.0.8",- "zx": "^2.0.0"+ "worker-loader": "^3.0.8"}},"../../packages/core": {@@ -277,22 +276,6 @@"zx": "^7.0.7"}},- "desktop/node_modules/@types/node": {- "version": "17.0.18",- "dev": true,- "license": "MIT"- },- "desktop/node_modules/chalk": {- "version": "5.0.1",- "dev": true,- "license": "MIT",- "engines": {- "node": "^12.17.0 || ^14.13 || >=16.0.0"- },- "funding": {- "url": "https://github.com/chalk/chalk?sponsor=1"- }- },"desktop/node_modules/commander": {"version": "9.0.0","license": "MIT",@@ -300,54 +283,6 @@"node": "^12.20.0 || >=14"}},- "desktop/node_modules/fs-extra": {- "version": "10.1.0",- "dev": true,- "license": "MIT",- "dependencies": {- "graceful-fs": "^4.2.0",- "jsonfile": "^6.0.1",- "universalify": "^2.0.0"- },- "engines": {- "node": ">=12"- }- },- "desktop/node_modules/globby": {- "version": "13.1.2",- "dev": true,- "license": "MIT",- "dependencies": {- "dir-glob": "^3.0.1",- "fast-glob": "^3.2.11",- "ignore": "^5.2.0",- "merge2": "^1.4.1",- "slash": "^4.0.0"- },- "engines": {- "node": "^12.20.0 || ^14.13.1 || >=16.0.0"- },- "funding": {- "url": "https://github.com/sponsors/sindresorhus"- }- },- "desktop/node_modules/node-fetch": {- "version": "3.2.8",- "dev": true,- "license": "MIT",- "dependencies": {- "data-uri-to-buffer": "^4.0.0",- "fetch-blob": "^3.1.4",- "formdata-polyfill": "^4.0.10"- },- "engines": {- "node": "^12.20.0 || ^14.13.1 || >=16.0.0"- },- "funding": {- "type": "opencollective",- "url": "https://opencollective.com/node-fetch"- }- },"desktop/node_modules/showdown": {"version": "2.1.0","license": "MIT",@@ -362,51 +297,6 @@"url": "https://www.paypal.me/tiviesantos"}},- "desktop/node_modules/slash": {- "version": "4.0.0",- "dev": true,- "license": "MIT",- "engines": {- "node": ">=12"- },- "funding": {- "url": "https://github.com/sponsors/sindresorhus"- }- },- "desktop/node_modules/yaml": {- "version": "2.1.1",- "dev": true,- "license": "ISC",- "engines": {- "node": ">= 14"- }- },- "desktop/node_modules/zx": {- "version": "7.0.8",- "dev": true,- "license": "Apache-2.0",- "dependencies": {- "@types/fs-extra": "^9.0.13",- "@types/minimist": "^1.2.2",- "@types/node": "^18.6.3",- "@types/ps-tree": "^1.1.2",- "@types/which": "^2.0.1",- "chalk": "^5.0.1",- "fs-extra": "^10.1.0",- "globby": "^13.1.2",- "minimist": "^1.2.6",- "node-fetch": "3.2.8",- "ps-tree": "^1.2.0",- "which": "^2.0.2",- "yaml": "^2.1.1"- },- "bin": {- "zx": "build/cli.js"- },- "engines": {- "node": ">= 16.0.0"- }- },"node_modules/@ampproject/remapping": {"version": "2.2.0","license": "Apache-2.0",@@ -6855,8 +6745,9 @@},"node_modules/data-uri-to-buffer": {"version": "4.0.0",+ "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz",+ "integrity": "sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA==","dev": true,- "license": "MIT","engines": {"node": ">= 12"}@@ -8678,6 +8569,8 @@},"node_modules/fetch-blob": {"version": "3.2.0",+ "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",+ "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==","dev": true,"funding": [{@@ -8689,7 +8582,6 @@"url": "https://paypal.me/jimmywarting"}],- "license": "MIT","dependencies": {"node-domexception": "^1.0.0","web-streams-polyfill": "^3.0.3"@@ -9070,8 +8962,9 @@},"node_modules/formdata-polyfill": {"version": "4.0.10",+ "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",+ "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==","dev": true,- "license": "MIT","dependencies": {"fetch-blob": "^3.1.2"},@@ -9448,6 +9341,25 @@"url": "https://github.com/sponsors/ljharb"}},+ "node_modules/globby": {+ "version": "13.1.2",+ "resolved": "https://registry.npmjs.org/globby/-/globby-13.1.2.tgz",+ "integrity": "sha512-LKSDZXToac40u8Q1PQtZihbNdTYSNMuWe+K5l+oa6KgDzSvVrHXlJy40hUP522RjAIoNLJYBJi7ow+rbFpIhHQ==",+ "dev": true,+ "dependencies": {+ "dir-glob": "^3.0.1",+ "fast-glob": "^3.2.11",+ "ignore": "^5.2.0",+ "merge2": "^1.4.1",+ "slash": "^4.0.0"+ },+ "engines": {+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },"node_modules/goober": {"version": "2.1.11","license": "MIT",@@ -11991,6 +11903,8 @@},"node_modules/node-domexception": {"version": "1.0.0",+ "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",+ "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==","dev": true,"funding": [{@@ -12002,11 +11916,28 @@"url": "https://paypal.me/jimmywarting"}],- "license": "MIT","engines": {"node": ">=10.5.0"}},+ "node_modules/node-fetch": {+ "version": "3.2.8",+ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.2.8.tgz",+ "integrity": "sha512-KtpD1YhGszhntMpBDyp5lyagk8KIMopC1LEb7cQUAh7zcosaX5uK8HnbNb2i3NTQK3sIawCItS0uFC3QzcLHdg==",+ "dev": true,+ "dependencies": {+ "data-uri-to-buffer": "^4.0.0",+ "fetch-blob": "^3.1.4",+ "formdata-polyfill": "^4.0.10"+ },+ "engines": {+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/node-fetch"+ }+ },"node_modules/node-forge": {"version": "1.3.1","license": "(BSD-3-Clause OR GPL-2.0)",@@ -17899,6 +17830,15 @@"version": "4.0.0","license": "ISC"},+ "node_modules/yaml": {+ "version": "2.1.1",+ "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.1.1.tgz",+ "integrity": "sha512-o96x3OPo8GjWeSLF+wOAbrPfhFOGY0W00GNaxCDv+9hkcDJEnev1yh8S7pgHF0ik6zc8sQLuL8hjHjJULZp8bw==",+ "dev": true,+ "engines": {+ "node": ">= 14"+ }+ },"node_modules/yargs": {"version": "17.5.1","dev": true,@@ -17959,99 +17899,42 @@}},"node_modules/zx": {- "version": "2.1.0",+ "version": "7.0.8",+ "resolved": "https://registry.npmjs.org/zx/-/zx-7.0.8.tgz",+ "integrity": "sha512-sNjfDHzskqrSkWNj0TVhaowVK5AbpvuyuO1RBU4+LrFcgYI5u9CtyWWgUBRtRZl3bgGEF31zByszoBmwS47d1w==","dev": true,- "license": "Apache-2.0","dependencies": {- "@types/fs-extra": "^9.0.11",- "@types/minimist": "^1.2.1",- "@types/node": "^16.0",- "@types/node-fetch": "^2.5.10",- "chalk": "^4.1.1",- "fs-extra": "^10.0.0",- "globby": "^12.0.0",- "minimist": "^1.2.5",- "node-fetch": "^2.6.1",- "which": "^2.0.2"+ "@types/fs-extra": "^9.0.13",+ "@types/minimist": "^1.2.2",+ "@types/node": "^18.6.3",+ "@types/ps-tree": "^1.1.2",+ "@types/which": "^2.0.1",+ "chalk": "^5.0.1",+ "fs-extra": "^10.1.0",+ "globby": "^13.1.2",+ "minimist": "^1.2.6",+ "node-fetch": "3.2.8",+ "ps-tree": "^1.2.0",+ "which": "^2.0.2",+ "yaml": "^2.1.1"},"bin": {- "zx": "zx.mjs"+ "zx": "build/cli.js"},"engines": {- "node": ">= 14.8.0"- }- },- "node_modules/zx/node_modules/@types/node": {- "version": "16.11.56",- "dev": true,- "license": "MIT"- },- "node_modules/zx/node_modules/array-union": {- "version": "3.0.1",- "dev": true,- "license": "MIT",- "engines": {- "node": ">=12"- },- "funding": {- "url": "https://github.com/sponsors/sindresorhus"+ "node": ">= 16.0.0"}},- "node_modules/zx/node_modules/globby": {- "version": "12.2.0",+ "node_modules/zx/node_modules/chalk": {+ "version": "5.0.1",+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.0.1.tgz",+ "integrity": "sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w==","dev": true,- "license": "MIT",- "dependencies": {- "array-union": "^3.0.1",- "dir-glob": "^3.0.1",- "fast-glob": "^3.2.7",- "ignore": "^5.1.9",- "merge2": "^1.4.1",- "slash": "^4.0.0"- },"engines": {- "node": "^12.20.0 || ^14.13.1 || >=16.0.0"+ "node": "^12.17.0 || ^14.13 || >=16.0.0"},"funding": {- "url": "https://github.com/sponsors/sindresorhus"- }- },- "node_modules/zx/node_modules/node-fetch": {- "version": "2.6.7",- "dev": true,- "license": "MIT",- "dependencies": {- "whatwg-url": "^5.0.0"- },- "engines": {- "node": "4.x || >=6.0.0"- },- "peerDependencies": {- "encoding": "^0.1.0"- },- "peerDependenciesMeta": {- "encoding": {- "optional": true- }- }- },- "node_modules/zx/node_modules/tr46": {- "version": "0.0.3",- "dev": true,- "license": "MIT"- },- "node_modules/zx/node_modules/webidl-conversions": {- "version": "3.0.1",- "dev": true,- "license": "BSD-2-Clause"- },- "node_modules/zx/node_modules/whatwg-url": {- "version": "5.0.0",- "dev": true,- "license": "MIT",- "dependencies": {- "tr46": "~0.0.3",- "webidl-conversions": "^3.0.0"+ "url": "https://github.com/chalk/chalk?sponsor=1"}}},@@ -19846,78 +19729,14 @@"zx": "^7.0.7"},"dependencies": {- "@types/node": {- "version": "17.0.18",- "dev": true- },- "chalk": {- "version": "5.0.1",- "dev": true- },"commander": {"version": "9.0.0"},- "fs-extra": {- "version": "10.1.0",- "dev": true,- "requires": {- "graceful-fs": "^4.2.0",- "jsonfile": "^6.0.1",- "universalify": "^2.0.0"- }- },- "globby": {- "version": "13.1.2",- "dev": true,- "requires": {- "dir-glob": "^3.0.1",- "fast-glob": "^3.2.11",- "ignore": "^5.2.0",- "merge2": "^1.4.1",- "slash": "^4.0.0"- }- },- "node-fetch": {- "version": "3.2.8",- "dev": true,- "requires": {- "data-uri-to-buffer": "^4.0.0",- "fetch-blob": "^3.1.4",- "formdata-polyfill": "^4.0.10"- }- },"showdown": {"version": "2.1.0","requires": {"commander": "^9.0.0"}- },- "slash": {- "version": "4.0.0",- "dev": true- },- "yaml": {- "version": "2.1.1",- "dev": true- },- "zx": {- "version": "7.0.8",- "dev": true,- "requires": {- "@types/fs-extra": "^9.0.13",- "@types/minimist": "^1.2.2",- "@types/node": "^18.6.3",- "@types/ps-tree": "^1.1.2",- "@types/which": "^2.0.1",- "chalk": "^5.0.1",- "fs-extra": "^10.1.0",- "globby": "^13.1.2",- "minimist": "^1.2.6",- "node-fetch": "3.2.8",- "ps-tree": "^1.2.0",- "which": "^2.0.2",- "yaml": "^2.1.1"- }}}},@@ -22093,6 +21912,8 @@},"data-uri-to-buffer": {"version": "4.0.0",+ "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz",+ "integrity": "sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA==","dev": true},"data-urls": {@@ -23275,6 +23096,8 @@},"fetch-blob": {"version": "3.2.0",+ "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",+ "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==","dev": true,"requires": {"node-domexception": "^1.0.0",@@ -23508,6 +23331,8 @@},"formdata-polyfill": {"version": "4.0.10",+ "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",+ "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==","dev": true,"requires": {"fetch-blob": "^3.1.2"@@ -23739,6 +23564,19 @@"define-properties": "^1.1.3"}},+ "globby": {+ "version": "13.1.2",+ "resolved": "https://registry.npmjs.org/globby/-/globby-13.1.2.tgz",+ "integrity": "sha512-LKSDZXToac40u8Q1PQtZihbNdTYSNMuWe+K5l+oa6KgDzSvVrHXlJy40hUP522RjAIoNLJYBJi7ow+rbFpIhHQ==",+ "dev": true,+ "requires": {+ "dir-glob": "^3.0.1",+ "fast-glob": "^3.2.11",+ "ignore": "^5.2.0",+ "merge2": "^1.4.1",+ "slash": "^4.0.0"+ }+ },"goober": {"version": "2.1.11"},@@ -25317,8 +25155,21 @@},"node-domexception": {"version": "1.0.0",+ "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",+ "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==","dev": true},+ "node-fetch": {+ "version": "3.2.8",+ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.2.8.tgz",+ "integrity": "sha512-KtpD1YhGszhntMpBDyp5lyagk8KIMopC1LEb7cQUAh7zcosaX5uK8HnbNb2i3NTQK3sIawCItS0uFC3QzcLHdg==",+ "dev": true,+ "requires": {+ "data-uri-to-buffer": "^4.0.0",+ "fetch-blob": "^3.1.4",+ "formdata-polyfill": "^4.0.10"+ }+ },"node-forge": {"version": "1.3.1"},@@ -28866,6 +28717,12 @@"yallist": {"version": "4.0.0"},+ "yaml": {+ "version": "2.1.1",+ "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.1.1.tgz",+ "integrity": "sha512-o96x3OPo8GjWeSLF+wOAbrPfhFOGY0W00GNaxCDv+9hkcDJEnev1yh8S7pgHF0ik6zc8sQLuL8hjHjJULZp8bw==",+ "dev": true+ },"yargs": {"version": "17.5.1","dev": true,@@ -28898,63 +28755,31 @@"version": "3.7.2"},"zx": {- "version": "2.1.0",+ "version": "7.0.8",+ "resolved": "https://registry.npmjs.org/zx/-/zx-7.0.8.tgz",+ "integrity": "sha512-sNjfDHzskqrSkWNj0TVhaowVK5AbpvuyuO1RBU4+LrFcgYI5u9CtyWWgUBRtRZl3bgGEF31zByszoBmwS47d1w==","dev": true,"requires": {- "@types/fs-extra": "^9.0.11",- "@types/minimist": "^1.2.1",- "@types/node": "^16.0",- "@types/node-fetch": "^2.5.10",- "chalk": "^4.1.1",- "fs-extra": "^10.0.0",- "globby": "^12.0.0",- "minimist": "^1.2.5",- "node-fetch": "^2.6.1",- "which": "^2.0.2"+ "@types/fs-extra": "^9.0.13",+ "@types/minimist": "^1.2.2",+ "@types/node": "^18.6.3",+ "@types/ps-tree": "^1.1.2",+ "@types/which": "^2.0.1",+ "chalk": "^5.0.1",+ "fs-extra": "^10.1.0",+ "globby": "^13.1.2",+ "minimist": "^1.2.6",+ "node-fetch": "3.2.8",+ "ps-tree": "^1.2.0",+ "which": "^2.0.2",+ "yaml": "^2.1.1"},"dependencies": {- "@types/node": {- "version": "16.11.56",- "dev": true- },- "array-union": {- "version": "3.0.1",- "dev": true- },- "globby": {- "version": "12.2.0",- "dev": true,- "requires": {- "array-union": "^3.0.1",- "dir-glob": "^3.0.1",- "fast-glob": "^3.2.7",- "ignore": "^5.1.9",- "merge2": "^1.4.1",- "slash": "^4.0.0"- }- },- "node-fetch": {- "version": "2.6.7",- "dev": true,- "requires": {- "whatwg-url": "^5.0.0"- }- },- "tr46": {- "version": "0.0.3",- "dev": true- },- "webidl-conversions": {- "version": "3.0.1",+ "chalk": {+ "version": "5.0.1",+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.0.1.tgz",+ "integrity": "sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w==","dev": true- },- "whatwg-url": {- "version": "5.0.0",- "dev": true,- "requires": {- "tr46": "~0.0.3",- "webidl-conversions": "^3.0.0"- }}}}diff --git a/apps/web/package.json b/apps/web/package.jsonindex f314000bd..f412707de 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -84,7 +84,6 @@"typescript": "^4.8.2","webpack-bundle-analyzer": "^4.5.0","worker-loader": "^3.0.8",- "zx": "^2.0.0","react": "17.0.2","react-dom": "17.0.2"},@@ -97,7 +96,9 @@"scripts": {"start": "env-cmd -e all,dev,web react-scripts start","start:desktop": "env-cmd -e all,desktop react-scripts start",+ "start:test": "serve -s build/ -p 3000","build": "env-cmd -e all,web react-scripts --max_old_space_size=8092 build",+ "build:test": "env-cmd -e all,dev,web,silent react-scripts build","build:beta": "env-cmd -e all,web,beta react-scripts build","build:profile": "env-cmd -e all,web react-scripts build --profile","build:desktop": "env-cmd -e all,desktop react-scripts build",diff --git a/apps/web/playwright.config.js b/apps/web/playwright.config.jsindex 13afc915d..72d5b828d 100644--- a/apps/web/playwright.config.js+++ b/apps/web/playwright.config.js@@ -42,30 +42,30 @@ const projects = IS_CIuse: {browserName: "chromium"}+ },+ {+ name: "Firefox",+ use: { browserName: "firefox" }+ },+ {+ name: "WebKit",+ use: { browserName: "webkit" }}- // {- // name: "Firefox",- // use: { browserName: "firefox" }- // },- // {- // name: "WebKit",- // use: { browserName: "webkit" }- // }];module.exports = {webServer: {- command: "npm run debug",+ command: "npm run start:test",port: 3000,timeout: 60 * 1000,- reuseExistingServer: !IS_CI+ reuseExistingServer: true},// Look for test files in thcleare "tests" directory, relative to this configuration filetestDir: "__e2e__",// Each test is given 30 seconds- timeout: 45000,- workers: IS_CI ? 3 : 6,+ timeout: 30000,+ workers: IS_CI ? 2 : 2,reporter: "list",retries: IS_CI ? 1 : 0,fullyParallel: true,diff --git a/apps/web/src/app.js b/apps/web/src/app.jsindex 084e3fee2..3a83ebffa 100644--- a/apps/web/src/app.js+++ b/apps/web/src/app.js@@ -81,7 +81,7 @@ function App() {show={show}/>)}- <Toaster />+ <Toaster containerClassName="toasts-container" /></Flex></ThemeProvider></LazyMotion>diff --git a/apps/web/src/components/dialogs/add-notebook-dialog.js b/apps/web/src/components/dialogs/add-notebook-dialog.jsindex 6fc3c60ff..d2c53bc4e 100644--- a/apps/web/src/components/dialogs/add-notebook-dialog.js+++ b/apps/web/src/components/dialogs/add-notebook-dialog.js@@ -143,7 +143,7 @@ class AddNotebookDialog extends React.Component {<Flex sx={{ overflowY: "auto", flexDirection: "column" }}><FielddefaultValue={this.title}- data-test-id="and-name"+ data-test-id="title-input"autoFocusrequiredlabel="Title"@@ -157,7 +157,7 @@ class AddNotebookDialog extends React.Component {}}/><Field- data-test-id="and-description"+ data-test-id="description-input"label="Description"name="description"id="description"@@ -168,12 +168,12 @@ class AddNotebookDialog extends React.Component {/><FieldinputRef={(ref) => (this._topicInputRef = ref)}- data-test-id="and-topic"+ data-test-id="edit-topic-input"label="Topics"name="topic"id="topic"action={{- testId: "and-topic-action",+ testId: "edit-topic-action",onClick: () => {if (this.state.isEditting) {this.doneEditingTopic();@@ -211,7 +211,6 @@ class AddNotebookDialog extends React.Component {onEdit={() => this.editTopic(index)}onDoneEditing={() => this.doneEditingTopic()}onDelete={() => this.removeTopic(index)}- index={index}/>))}</Flex>@@ -223,15 +222,8 @@ class AddNotebookDialog extends React.Component {export default AddNotebookDialog;function TopicItem(props) {- const {- title,- onEdit,- onDoneEditing,- onDelete,- isEditing,- hideActions,- index- } = props;+ const { title, onEdit, onDoneEditing, onDelete, isEditing, hideActions } =+ props;return (<Flexp={2}@@ -246,6 +238,7 @@ function TopicItem(props) {justifyContent: "space-between"}}onClick={isEditing ? onDoneEditing : onEdit}+ data-test-id="topic-item"><Flex sx={{ alignItems: "center", justifyContent: "center" }}><Icon.Topic />@@ -265,7 +258,6 @@ function TopicItem(props) {display: "flex"}}onClick={isEditing ? onDoneEditing : onEdit}- data-test-id={`and-topic-${index}-actions-edit`}>{isEditing ? "Done" : "Edit"}</Text>diff --git a/apps/web/src/components/dialogs/buy-dialog/buy-dialog.tsx b/apps/web/src/components/dialogs/buy-dialog/buy-dialog.tsxindex a94f7eba1..1a65a15df 100644--- a/apps/web/src/components/dialogs/buy-dialog/buy-dialog.tsx+++ b/apps/web/src/components/dialogs/buy-dialog/buy-dialog.tsx@@ -505,12 +505,17 @@ function CheckoutPricing(props: CheckoutPricingProps) {key={field.key}mt={1}sx={{ justifyContent: "space-between", alignSelf: "stretch" }}+ data-test-id={`checkout-price-item`}>- <Text variant="body" sx={{ fontSize: "subtitle" }}>+ <Text+ variant="body"+ sx={{ fontSize: "subtitle" }}+ data-test-id={`label`}+ >{field.label}</Text><Text- data-test-id={`checkout-price-${field.key}`}+ data-test-id={`value`}variant="body"sx={{ fontSize: "subtitle", color: field.color || "text" }}>@@ -521,18 +526,23 @@ function CheckoutPricing(props: CheckoutPricingProps) {<Flexmt={1}sx={{ justifyContent: "space-between", alignSelf: "stretch" }}+ data-test-id={`checkout-price-item`}>- <Text variant="body" sx={{ fontSize: "heading" }}>- Total- </Text><Text- as="div"- data-test-id={`checkout-price-total`}variant="body"- sx={{ fontSize: "heading", textAlign: "end", color: "text" }}+ sx={{ fontSize: "heading" }}+ data-test-id={`label`}>- {currentTotal}- <Text as="div" sx={{ fontSize: "body" }}>+ Total+ </Text>+ <Text as="div" variant="body" sx={{ textAlign: "end" }}>+ <Text+ data-test-id={`value`}+ sx={{ fontSize: "heading", color: "text" }}+ >+ {currentTotal}+ </Text>+ <Text as="div" sx={{ fontSize: "body", color: "text" }}>{isDiscounted? "forever": `first ${getFullPeriod(period)} then ${recurringTotal}`}diff --git a/apps/web/src/components/dialogs/buy-dialog/plan-list.tsx b/apps/web/src/components/dialogs/buy-dialog/plan-list.tsxindex 8441b4e36..4e359249d 100644--- a/apps/web/src/components/dialogs/buy-dialog/plan-list.tsx+++ b/apps/web/src/components/dialogs/buy-dialog/plan-list.tsx@@ -61,7 +61,7 @@ export function PlansList(props: PlansListProps) {<Buttonkey={metadata.title}disabled={isLoading}- data-test-id={`checkout-plan-${plan.period}`}+ data-test-id={`checkout-plan`}variant="tool"mt={1}bg="transparent"@@ -81,7 +81,11 @@ export function PlansList(props: PlansListProps) {display: "flex"}}>- <Text variant="subtitle" sx={{ fontWeight: "normal" }}>+ <Text+ variant="subtitle"+ sx={{ fontWeight: "normal" }}+ data-test-id="title"+ >{metadata.title}<br /><Textdiff --git a/apps/web/src/components/dialogs/item-dialog.js b/apps/web/src/components/dialogs/item-dialog.jsindex ac94059f9..478968181 100644--- a/apps/web/src/components/dialogs/item-dialog.js+++ b/apps/web/src/components/dialogs/item-dialog.js@@ -52,7 +52,7 @@ function ItemDialog(props) {id="title"name="title"autoFocus- data-test-id="item-dialog-title"+ data-test-id="title-input"defaultValue={props.defaultValue}/></Box>diff --git a/apps/web/src/components/dialogs/recovery-key-dialog.js b/apps/web/src/components/dialogs/recovery-key-dialog.jsindex 0c2011a35..443a6bf15 100644--- a/apps/web/src/components/dialogs/recovery-key-dialog.js+++ b/apps/web/src/components/dialogs/recovery-key-dialog.js@@ -70,7 +70,7 @@ function RecoveryKeyDialog(props) {to recover your data.</Text><Text- data-test-id="recoveryKey"+ data-test-id="recovery-key"className="selectable"mt={2}bg="bgSecondary"diff --git a/apps/web/src/components/editor/header.js b/apps/web/src/components/editor/header.jsindex de049a662..f298c42ee 100644--- a/apps/web/src/components/editor/header.js+++ b/apps/web/src/components/editor/header.js@@ -37,10 +37,13 @@ function Header({ readonly }) {return (<>{!readonly && id && (- <Flex sx={{ lineHeight: 2.5, alignItems: "center", flexWrap: "wrap" }}>+ <Flex+ sx={{ lineHeight: 2.5, alignItems: "center", flexWrap: "wrap" }}+ data-test-id="tags"+ >{tags?.map((tag) => (<IconTag- testId={`tag-${tag}`}+ testId={`tag`}key={tag}text={db.tags.alias(tag)}icon={Icon.Tag}diff --git a/apps/web/src/components/editor/index.tsx b/apps/web/src/components/editor/index.tsxindex 0ad41aedd..1ad15372c 100644--- a/apps/web/src/components/editor/index.tsx+++ b/apps/web/src/components/editor/index.tsx@@ -368,6 +368,7 @@ function PreviewModeNotice(props: PreviewModeNoticeProps) {bg="bgSecondary"p={2}sx={{ alignItems: "center", justifyContent: "space-between" }}+ data-test-id="preview-notice"><Flex mr={4} sx={{ flexDirection: "column" }}><Text variant={"subtitle"}>Preview</Text>@@ -378,7 +379,7 @@ function PreviewModeNotice(props: PreviewModeNoticeProps) {</Flex><Flex><Button- data-test-id="editor-notice-cancel"+ data-test-id="preview-notice-cancel"variant={"secondary"}mr={1}px={4}@@ -387,7 +388,7 @@ function PreviewModeNotice(props: PreviewModeNoticeProps) {Cancel</Button><Button- data-test-id="editor-notice-action"+ data-test-id="preview-notice-restore"px={4}onClick={async () => {await disablePreviewMode(false);diff --git a/apps/web/src/components/editor/toolbar.js b/apps/web/src/components/editor/toolbar.jsindex 9674dbbb7..7fa138dbd 100644--- a/apps/web/src/components/editor/toolbar.js+++ b/apps/web/src/components/editor/toolbar.js@@ -88,8 +88,8 @@ function Toolbar() {const inlineTools = useMemo(() => [{- title: theme === "Dark" ? "Light mode" : "Dark mode",- icon: Icon.Theme,+ title: theme === "dark" ? "Light mode" : "Dark mode",+ icon: Icon.ThemeIcon,hidden: !isFocusMode,enabled: true,onClick: () => toggleNightMode()@@ -218,7 +218,7 @@ function Toolbar() {<Flex>{tools.map((tool) => (<Button- data-test-id={tool.title.toLowerCase().replace(/ /g, "-")}+ data-test-id={tool.title}disabled={!tool.enabled}variant="tool"title={tool.title}@@ -258,7 +258,7 @@ function Toolbar() {>{inlineTools.map((tool) => (<Button- data-test-id={tool.title.toLowerCase().replace(/ /g, "-")}+ data-test-id={tool.title}disabled={!tool.enabled}variant="tool"bg="transparent"diff --git a/apps/web/src/components/group-header/index.js b/apps/web/src/components/group-header/index.jsindex 1fbfc08e4..ce54d04ac 100644--- a/apps/web/src/components/group-header/index.js+++ b/apps/web/src/components/group-header/index.js@@ -231,8 +231,10 @@ function GroupHeader(props) {justifyContent: "space-between"}}tabIndex={0}+ data-test-id="group-header"><Text+ data-test-id="title"variant="subtitle"sx={{fontSize: "body",diff --git a/apps/web/src/components/list-item/index.js b/apps/web/src/components/list-item/index.jsindex 4d8e3934f..bd1089ef6 100644--- a/apps/web/src/components/list-item/index.js+++ b/apps/web/src/components/list-item/index.js@@ -79,6 +79,7 @@ function ListItem(props) {return (<Flex+ id={`id_${props.item.id}`}ref={listItemRef}bg={isSelected ? "shade" : background}onContextMenu={(e) => {@@ -158,12 +159,12 @@ function ListItem(props) {}}}}- data-test-id={`${props.item.type}-${props.index}`}+ data-test-id={`list-item`}>{!isCompact && props.header}<Text- data-test-id={`${props.item.type}-${props.index}-title`}+ data-test-id={`title`}variant={"subtitle"}sx={{whiteSpace: "nowrap",@@ -181,7 +182,7 @@ function ListItem(props) {<Textas="p"variant="body"- data-test-id={`${props.item.type}-${props.index}-body`}+ data-test-id={`description`}sx={{lineHeight: `1.2rem`,overflow: "hidden",diff --git a/apps/web/src/components/loaders/navigation-loader.tsx b/apps/web/src/components/loaders/navigation-loader.tsxindex 9c6fe5a6a..d2b4524e8 100644--- a/apps/web/src/components/loaders/navigation-loader.tsx+++ b/apps/web/src/components/loaders/navigation-loader.tsx@@ -25,7 +25,7 @@ import "react-loading-skeleton/dist/skeleton.css";export const NavigationLoader = memo(function NavigationLoader() {return (<Flex- id="navigationmenu"+ id="navigation-menu"sx={{height: "100%",zIndex: 1,diff --git a/apps/web/src/components/menu/menu-item.js b/apps/web/src/components/menu/menu-item.jsindex 4bcdf6dbc..831502bf2 100644--- a/apps/web/src/components/menu/menu-item.js+++ b/apps/web/src/components/menu/menu-item.js@@ -88,10 +88,8 @@ function MenuItem({ item, isFocused, onMouseEnter, onMouseLeave, onClick }) {</Text>{isPremium && <Pro size={14} color="primary" sx={{ ml: 1 }} />}</Flex>- <Flex>- {isChecked && (- <Check size={14} data-test-id={`menuitem-${key}-checked`} />- )}+ <Flex data-test-id={`toggle-state-${isChecked ? "on" : "off"}`}>+ {isChecked && <Check size={14} />}{hasSubmenu && <ChevronRight size={14} />}{modifier && (<Textdiff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.jsindex 7a3e63010..e83534e6e 100644--- a/apps/web/src/components/note/index.js+++ b/apps/web/src/components/note/index.js@@ -127,7 +127,7 @@ function Note(props) {size={11}color={"fontTertiary"}sx={{ mr: 1 }}- data-test-id={`note-${index}-locked`}+ data-test-id={`locked`}/>)}{note.favorite && (@@ -174,7 +174,7 @@ function Note(props) {size={13}color={"fontTertiary"}sx={{ mr: 1 }}- data-test-id={`note-${index}-locked`}+ data-test-id={`locked`}/>)}@@ -185,7 +185,7 @@ function Note(props) {{tags?.map((tag) => {return (<Button- data-test-id={`note-${index}-tags-${tag.alias}`}+ data-test-id={`tag-item`}key={tag.id}variant="anchor"mr={1}@@ -275,7 +275,8 @@ const notFullySyncedText =const menuItems = [{key: "pin",- title: ({ note }) => (note.pinned ? "Unpin" : "Pin"),+ title: "Pin",+ checked: ({ note }) => note.pinned,icon: Icon.Pin,onClick: async ({ note }) => {await pin(note);@@ -283,7 +284,8 @@ const menuItems = [},{key: "favorite",- title: ({ note }) => (note.favorite ? "Unfavorite" : "Favorite"),+ title: "Favorite",+ checked: ({ note }) => note.favorite,icon: Icon.StarOutline,onClick: ({ note }) => store.favorite(note.id)},@@ -310,8 +312,8 @@ const menuItems = [return "You cannot publish a locked note.";},icon: Icon.Publish,- title: ({ note }) =>- db.monographs.isPublished(note.id) ? "Unpublish" : "Publish",+ title: "Publish",+ checked: ({ note }) => db.monographs.isPublished(note.id),onClick: async ({ note }) => {const isPublished = db.monographs.isPublished(note.id);if (isPublished) await db.monographs.unpublish(note.id);@@ -371,7 +373,8 @@ const menuItems = [key: "lock",disabled: ({ note }) =>!db.notes.note(note.id).synced() ? notFullySyncedText : false,- title: ({ note }) => (note.locked ? "Unlock" : "Lock"),+ title: "Lock",+ checked: ({ note }) => note.locked,icon: Icon.Lock,onClick: async ({ note }) => {const { unlock, lock } = store.get();@@ -390,7 +393,8 @@ const menuItems = [hidden: () => !userstore.get().isLoggedIn,disabled: ({ note }) =>!db.notes.note(note.id).synced() ? notFullySyncedText : false,- title: ({ note }) => (note.localOnly ? "Enable sync" : "Disable sync"),+ title: "Disable sync",+ checked: ({ note }) => note.localOnly,icon: ({ note }) => (note.localOnly ? Icon.Sync : Icon.SyncOff),onClick: async ({ note }) => {if (diff --git a/apps/web/src/components/notebook/index.js b/apps/web/src/components/notebook/index.jsindex 22accc991..c3f44f014 100644--- a/apps/web/src/components/notebook/index.js+++ b/apps/web/src/components/notebook/index.js@@ -136,7 +136,8 @@ const menuItems = [{key: "pin",icon: Icon.Pin,- title: ({ notebook }) => (notebook.pinned ? "Unpin" : "Pin"),+ title: "Pin",+ checked: ({ notebook }) => notebook.pinned,onClick: ({ notebook }) => pin(notebook)},{diff --git a/apps/web/src/components/properties/index.js b/apps/web/src/components/properties/index.jsindex 92879513d..f0c2ea82a 100644--- a/apps/web/src/components/properties/index.js+++ b/apps/web/src/components/properties/index.js@@ -39,15 +39,26 @@ import { formatBytes } from "../../utils/filename";import { getTotalSize } from "../../common/attachments";const tools = [- { key: "pinned", icon: Icon.Pin, label: "Pin" },+ { key: "pin", property: "pinned", icon: Icon.Pin, label: "Pin" },{key: "favorite",+ property: "favorite",icon: Icon.StarOutline,label: "Favorite"},- { key: "locked", icon: Icon.Unlock, label: "Lock" },- { key: "readonly", icon: Icon.Readonly, label: "Readonly" },- { key: "localOnly", icon: Icon.SyncOff, label: "Disable sync" }+ { key: "lock", icon: Icon.Unlock, label: "Lock", property: "locked" },+ {+ key: "readonly",+ icon: Icon.Readonly,+ label: "Readonly",+ property: "readonly"+ },+ {+ key: "local-only",+ icon: Icon.SyncOff,+ label: "Disable sync",+ property: "localOnly"+ }];const metadataItems = [@@ -80,15 +91,15 @@ function Properties(props) {const changeState = useCallback(function changeState(prop) {switch (prop) {- case "locked":+ case "lock":return store.get().session.locked? noteStore.unlock(sessionId): noteStore.lock(sessionId);case "readonly":return noteStore.readonly(sessionId);- case "localOnly":+ case "local-only":return noteStore.localOnly(sessionId);- case "pinned":+ case "pin":return noteStore.pin(sessionId);case "favorite":return noteStore.favorite(sessionId);@@ -156,7 +167,7 @@ function Properties(props) {<Toggle{...tool}key={tool.key}- toggleKey={tool.key}+ toggleKey={tool.property}onToggle={(state) => changeState(tool.key, state)}testId={`properties-${tool.key}`}/>@@ -208,13 +219,20 @@ function Properties(props) {}}data-test-id={`properties-${label}`}>- <Icon.Circle size={35} color={label.toLowerCase()} />+ <Icon.Circle+ size={35}+ color={label.toLowerCase()}+ data-test-id={`toggle-state-${+ label.toLowerCase() === color?.toLowerCase()+ ? "on"+ : "off"+ }`}+ />{label.toLowerCase() === color?.toLowerCase() && (<Icon.Checkmarkcolor="static"size={18}sx={{ position: "absolute", left: "8px" }}- data-test-id={`properties-${label}-check`}/>)}</Flex>@@ -329,7 +347,7 @@ function Properties(props) {return (<Flexkey={session.id}- data-test-id={`session-${index}`}+ data-test-id={`session-item`}py={1}px={2}sx={{@@ -370,9 +388,13 @@ function Properties(props) {}}}>- <Text variant={"body"}>{label}</Text>+ <Text variant={"body"} data-test-id="title">+ {label}+ </Text><Flex sx={{ fontSize: "subBody", color: "fontTertiary" }}>- {session.locked && <Icon.Lock size={14} />}+ {session.locked && (+ <Icon.Lock size={14} data-test-id="locked" />+ )}<TimeAgolivedatetime={session.dateModified}diff --git a/apps/web/src/components/properties/toggle.js b/apps/web/src/components/properties/toggle.jsindex d893e74ed..2fdabb8d3 100644--- a/apps/web/src/components/properties/toggle.js+++ b/apps/web/src/components/properties/toggle.js@@ -40,6 +40,7 @@ function Toggle(props) {<Textvariant="body"sx={{ alignItems: "center", color: "text", display: "flex" }}+ data-test-id={`toggle-state-${isOn ? "on" : "off"}`}><ToggleIcon size={13} sx={{ flexShrink: 0, mr: 1 }} />{label}diff --git a/apps/web/src/components/tag/index.js b/apps/web/src/components/tag/index.jsindex 0c8940f87..0c8e6f3b6 100644--- a/apps/web/src/components/tag/index.js+++ b/apps/web/src/components/tag/index.js@@ -31,7 +31,7 @@ import { pluralize } from "../../utils/string";const menuItems = [{- key: "rename",+ key: "edit",title: "Rename tag",icon: Icon.Edit,onClick: ({ tag }) => {diff --git a/apps/web/src/components/time-ago/index.js b/apps/web/src/components/time-ago/index.jsindex b8bf81deb..3701ca4ce 100644--- a/apps/web/src/components/time-ago/index.js+++ b/apps/web/src/components/time-ago/index.js@@ -88,6 +88,7 @@ function TimeAgo({ datetime, live, locale, opts, sx, ...restProps }) {}}title={formatDate(datetime)}as="time"+ data-test-id="time"dateTime={toDate(datetime).toISOString()}>{format(datetime, locale, opts)}diff --git a/apps/web/src/views/settings.js b/apps/web/src/views/settings.jsindex 108efd5aa..847f7842e 100644--- a/apps/web/src/views/settings.js+++ b/apps/web/src/views/settings.js@@ -216,6 +216,7 @@ function Settings() {<><Buttonvariant="list"+ data-test-id="backup-recovery-key"onClick={async () => {if (await verifyAccount()) await showRecoveryKeyDialog();}}@@ -1055,6 +1056,7 @@ function AccountStatusContainer(props) {border: "1px solid var(--border)",flexDirection: "column"}}+ data-test-id="account-status"><Flex sx={{ flex: "1", justifyContent: "space-between" }}><Flex>diff --git a/nx.json b/nx.jsonindex f499fd3de..4dacc7494 100644--- a/nx.json+++ b/nx.json@@ -11,6 +11,9 @@"build": {"dependsOn": ["^build"]},+ "build:test": {+ "dependsOn": ["^build"]+ },"start": {"dependsOn": ["^build"]},diff --git a/package.json b/package.jsonindex 0b3888556..dcdf0d0fb 100644--- a/package.json+++ b/package.json@@ -6,6 +6,7 @@"bootstrap": "lerna bootstrap -- --legacy-peer-deps","build": "nx run-many --target=build --all --exclude=@notesnook/mobile,@notesnook/web","build:web": "nx build @notesnook/web",+ "build:test:web": "nx build:test @notesnook/web","start:web": "nx start @notesnook/web","install:web": "lerna add --scope=@notesnook/web ","install:mobile": "lerna add --scope=@notesnook/mobile ",