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: add a couple more tests for basic plan
Abdullah Attaedb2e3a0edbf
diff --git a/apps/web/__e2e__/colors.test.ts b/apps/web/__e2e__/colors.test.tsindex 7ad7d3b2a..5ef46c88d 100644--- a/apps/web/__e2e__/colors.test.ts+++ b/apps/web/__e2e__/colors.test.ts@@ -60,3 +60,21 @@ test("rename color", async ({ page }) => {expect(await app.navigation.findItem("priority-33")).toBeDefined();});++test("creating a color shouldn't be possible on basic plan", async ({+ page+}) => {+ await page.exposeBinding("isBasic", () => true);+ const app = new AppModel(page);+ await app.goto();+ const notes = await app.goToNotes();+ const note = await notes.createNote(NOTE);++ await note?.contextMenu.newColor({ title: "red", color: "#ff0000" });++ expect(+ await app.toasts.waitForToast(+ "Please upgrade your account to Pro to add colors."+ )+ ).toBe(true);+});diff --git a/apps/web/__e2e__/models/note-properties.model.ts b/apps/web/__e2e__/models/note-properties.model.tsindex dfb4ebae6..c53e73bd3 100644--- a/apps/web/__e2e__/models/note-properties.model.ts+++ b/apps/web/__e2e__/models/note-properties.model.ts@@ -29,7 +29,6 @@ import {fillPasswordDialog,iterateList} from "./utils";-import { ZipReader, TextWriter, Uint8ArrayReader } from "@zip.js/zip.js";import { SessionHistoryItemModel } from "./session-history-item-model";abstract class BaseProperties {@@ -256,18 +255,11 @@ export class NoteContextMenuModel extends BaseProperties {await this.open();await this.menu.clickOnItem("export");- const zip = await downloadAndReadFile(+ const content = (await downloadAndReadFile(this.noteLocator.page(),() => this.menu.getItem(format).click(),- null- );-- const entries = await new ZipReader(- new Uint8ArrayReader(new Uint8Array(zip as Buffer))- ).getEntries();- const writer = new TextWriter();- await entries[0].getData?.(writer);- const content = await writer.getData();+ "utf-8"+ )) as string;if (format === "html") {return contentdiff --git a/apps/web/__e2e__/notebooks.test.ts b/apps/web/__e2e__/notebooks.test.tsindex ac557449c..3db3c6e44 100644--- a/apps/web/__e2e__/notebooks.test.ts+++ b/apps/web/__e2e__/notebooks.test.ts@@ -222,6 +222,26 @@ test("delete all notes within a notebook", async ({ page }) => {// expect(await notes.isEmpty()).toBe(true);// });+test("creating more than 20 notebooks shouldn't be possible on basic plan", async ({+ page+}) => {+ await page.exposeBinding("isBasic", () => true);+ const app = new AppModel(page);+ await app.goto();+ const notebooks = await app.goToNotebooks();+ for (let i = 0; i < 20; ++i) {+ await notebooks.createNotebook({ title: `Notebook ${i}` });+ }++ const result = await Promise.race([+ notebooks.createNotebook(NOTEBOOK),+ app.toasts.waitForToast(+ "Please upgrade your account to Pro to add more notebooks."+ )+ ]);+ expect(result).toBe(true);+});+test(`sort notebooks`, async ({ page }, info) => {info.setTimeout(2 * 60 * 1000);diff --git a/apps/web/__e2e__/tags.test.ts b/apps/web/__e2e__/tags.test.tsindex 4e8e2fe64..e06312f92 100644--- a/apps/web/__e2e__/tags.test.ts+++ b/apps/web/__e2e__/tags.test.ts@@ -35,6 +35,21 @@ test("create a tag", async ({ page }) => {expect(tag).toBeDefined();});+test("creating a tag with name of an existing tag should give an error", async ({+ page+}) => {+ const app = new AppModel(page);+ await app.goto();+ const tags = await app.goToTags();+ await tags.createItem(TAG);++ await tags.createItem(TAG);++ expect(+ await app.toasts.waitForToast("Tag with this title already exists.")+ ).toBe(true);+});+test("create a note inside a tag", async ({ page }) => {const app = new AppModel(page);await app.goto();@@ -206,3 +221,23 @@ test(`sort tags`, async ({ page }, info) => {}}});++test("creating more than 5 tags shouldn't be possible on basic plan", async ({+ page+}) => {+ await page.exposeBinding("isBasic", () => true);+ const app = new AppModel(page);+ await app.goto();+ const tags = await app.goToTags();+ for (const tag of ["tag1", "tag2", "tag3", "tag4", "tag5"]) {+ await tags.createItem({ title: tag });+ }++ const result = await Promise.race([+ tags.createItem({ title: "tag6" }),+ app.toasts.waitForToast(+ "Please upgrade your account to Pro to add more tags."+ )+ ]);+ expect(result).toBe(true);+});diff --git a/apps/web/src/hooks/use-is-user-premium.ts b/apps/web/src/hooks/use-is-user-premium.tsindex 4660ac583..533e09db1 100644--- a/apps/web/src/hooks/use-is-user-premium.ts+++ b/apps/web/src/hooks/use-is-user-premium.ts@@ -30,7 +30,7 @@ export function useIsUserPremium() {}export function isUserPremium(user?: User) {- if (IS_TESTING) return true;+ if (IS_TESTING) return !("isBasic" in window);if (!user) user = userstore.get().user;if (!user) return false;