Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: add support for test throttling

Abdullah Atta36584175e201
diff --git a/apps/web/__e2e__/app-lock.test.ts b/apps/web/__e2e__/app-lock.test.ts
index e03bfcbee..63e75945e 100644
--- a/apps/web/__e2e__/app-lock.test.ts
+++ b/apps/web/__e2e__/app-lock.test.ts
@@ -17,9 +17,8 @@ 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 { APP_LOCK_PASSWORD, USER } from "./utils";
+import { test, expect, APP_LOCK_PASSWORD, USER } from "./utils";
test("don't show status bar lock app button to unauthenticated user", async ({
page
diff --git a/apps/web/__e2e__/backups.test.ts b/apps/web/__e2e__/backups.test.ts
index 667c21d8d..fcbf0c395 100644
--- a/apps/web/__e2e__/backups.test.ts
+++ b/apps/web/__e2e__/backups.test.ts
@@ -16,9 +16,8 @@ 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";
+import { test, expect, USER } from "./utils";
test("create an unencrypted backup", async ({ page }) => {
const app = new AppModel(page);
diff --git a/apps/web/__e2e__/checkout.test.ts b/apps/web/__e2e__/checkout.test.ts
index c8dadf672..32b204dee 100644
--- a/apps/web/__e2e__/checkout.test.ts
+++ b/apps/web/__e2e__/checkout.test.ts
@@ -17,8 +17,8 @@ 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 { Page } from "@playwright/test";
+import { test, expect, USER } from "./utils";
import { AppModel } from "./models/app.model";
import { PriceItem } from "./models/types";
diff --git a/apps/web/__e2e__/colors.test.ts b/apps/web/__e2e__/colors.test.ts
index 547d0855f..a047051f0 100644
--- a/apps/web/__e2e__/colors.test.ts
+++ b/apps/web/__e2e__/colors.test.ts
@@ -16,9 +16,8 @@ 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 { getTestId, NOTE } from "./utils";
+import { test, expect, getTestId, NOTE } from "./utils";
test("delete the last note of a color", async ({ page }) => {
const app = new AppModel(page);
diff --git a/apps/web/__e2e__/drag-drop.test.ts b/apps/web/__e2e__/drag-drop.test.ts
index 50d0fd8c6..1be83ba46 100644
--- a/apps/web/__e2e__/drag-drop.test.ts
+++ b/apps/web/__e2e__/drag-drop.test.ts
@@ -17,7 +17,7 @@ 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 { expect, test } from "@playwright/test";
+import { test, expect } from "./utils";
import { AppModel } from "./models/app.model";
import { NotesViewModel } from "./models/notes-view.model";
diff --git a/apps/web/__e2e__/editor.test.ts b/apps/web/__e2e__/editor.test.ts
index 1a14e5e97..c87c4aa3e 100644
--- a/apps/web/__e2e__/editor.test.ts
+++ b/apps/web/__e2e__/editor.test.ts
@@ -17,9 +17,8 @@ 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 { getTestId, NOTE, TITLE_ONLY_NOTE } from "./utils";
+import { test, expect, NOTE, TITLE_ONLY_NOTE } from "./utils";
test("focus mode", async ({ page }) => {
const app = new AppModel(page);
diff --git a/apps/web/__e2e__/keyboard-list-navigation.test.ts b/apps/web/__e2e__/keyboard-list-navigation.test.ts
index f5a140eb0..40f2e0004 100644
--- a/apps/web/__e2e__/keyboard-list-navigation.test.ts
+++ b/apps/web/__e2e__/keyboard-list-navigation.test.ts
@@ -17,7 +17,8 @@ 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 { expect, Page, test } from "@playwright/test";
+import { Page } from "@playwright/test";
+import { test, expect } from "./utils";
import { AppModel } from "./models/app.model";
import { NoteItemModel } from "./models/note-item.model";
diff --git a/apps/web/__e2e__/monographs.test.ts b/apps/web/__e2e__/monographs.test.ts
index 249bb9caf..0122a73d3 100644
--- a/apps/web/__e2e__/monographs.test.ts
+++ b/apps/web/__e2e__/monographs.test.ts
@@ -17,9 +17,8 @@ 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";
+import { test, expect, USER } from "./utils";
test("don't show monographs list to unauthenticated user", async ({ page }) => {
const app = new AppModel(page);
diff --git a/apps/web/__e2e__/navigation.test.ts b/apps/web/__e2e__/navigation.test.ts
index eeda770f5..172928fd5 100644
--- a/apps/web/__e2e__/navigation.test.ts
+++ b/apps/web/__e2e__/navigation.test.ts
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* eslint-disable no-undef */
-import { test, expect } from "@playwright/test";
+import { test, expect } from "./utils";
import { AppModel } from "./models/app.model";
function createRoute(key: string, header: string) {
diff --git a/apps/web/__e2e__/notebooks.issues.test.ts b/apps/web/__e2e__/notebooks.issues.test.ts
index 2ab896bb7..f9e4928c0 100644
--- a/apps/web/__e2e__/notebooks.issues.test.ts
+++ b/apps/web/__e2e__/notebooks.issues.test.ts
@@ -17,6 +17,6 @@ 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 } from "@playwright/test";
+import { test } from "./utils";
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.ts b/apps/web/__e2e__/notebooks.test.ts
index 6bb14ddff..452a9edcf 100644
--- a/apps/web/__e2e__/notebooks.test.ts
+++ b/apps/web/__e2e__/notebooks.test.ts
@@ -17,12 +17,12 @@ 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 { Notebook } from "./models/types";
import {
+ test,
+ expect,
getTestId,
- groupByOptions,
NOTE,
NOTEBOOK,
orderByOptions,
diff --git a/apps/web/__e2e__/notehistory.test.ts b/apps/web/__e2e__/notehistory.test.ts
index 639ba5057..02ae08591 100644
--- a/apps/web/__e2e__/notehistory.test.ts
+++ b/apps/web/__e2e__/notehistory.test.ts
@@ -17,8 +17,7 @@ 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 { createHistorySession, PASSWORD } from "./utils";
+import { test, expect, createHistorySession, PASSWORD } from "./utils";
test.setTimeout(60 * 1000);
diff --git a/apps/web/__e2e__/notes.issues.test.ts b/apps/web/__e2e__/notes.issues.test.ts
index a13339aef..01ab1b92d 100644
--- a/apps/web/__e2e__/notes.issues.test.ts
+++ b/apps/web/__e2e__/notes.issues.test.ts
@@ -17,9 +17,8 @@ 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 { expect, test } from "@playwright/test";
import { AppModel } from "./models/app.model";
-import { NOTE } from "./utils";
+import { expect, test, NOTE } from "./utils";
test.skip("TODO: make sure jump to group works", () => {});
test("#1002 Can't add a tag that's a substring of an existing tag", async ({
diff --git a/apps/web/__e2e__/notes.test.ts b/apps/web/__e2e__/notes.test.ts
index 2d74b56da..f28680eb5 100644
--- a/apps/web/__e2e__/notes.test.ts
+++ b/apps/web/__e2e__/notes.test.ts
@@ -17,9 +17,10 @@ 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 {
+ test,
+ expect,
groupByOptions,
NOTE,
orderByOptions,
diff --git a/apps/web/__e2e__/reminders.test.ts b/apps/web/__e2e__/reminders.test.ts
index 552fb623e..647d24e9f 100644
--- a/apps/web/__e2e__/reminders.test.ts
+++ b/apps/web/__e2e__/reminders.test.ts
@@ -18,9 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Reminder } from "@notesnook/core";
-import { test, expect } from "@playwright/test";
import { AppModel } from "./models/app.model";
-import { getTestId } from "./utils";
+import { test, expect, getTestId } from "./utils";
const ONE_TIME_REMINDER: Partial<Reminder> = {
title: "Test reminder 1",
diff --git a/apps/web/__e2e__/search.test.ts b/apps/web/__e2e__/search.test.ts
index 7bea730ca..f26c7f1af 100644
--- a/apps/web/__e2e__/search.test.ts
+++ b/apps/web/__e2e__/search.test.ts
@@ -17,9 +17,8 @@ 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 { getTestId } from "./utils";
+import { test, expect, getTestId } from "./utils";
test("closing search via close button should clear query", async ({ page }) => {
const app = new AppModel(page);
diff --git a/apps/web/__e2e__/settings.test.ts b/apps/web/__e2e__/settings.test.ts
index 76c6b00fb..f5c444cc4 100644
--- a/apps/web/__e2e__/settings.test.ts
+++ b/apps/web/__e2e__/settings.test.ts
@@ -17,9 +17,8 @@ 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";
+import { test, expect, NOTE } from "./utils";
test("ask for image compression during image upload when 'Image Compression' setting is 'Ask every time'", async ({
page
diff --git a/apps/web/__e2e__/sync.test.ts b/apps/web/__e2e__/sync.test.ts
index d52c8b73e..54d5315cc 100644
--- a/apps/web/__e2e__/sync.test.ts
+++ b/apps/web/__e2e__/sync.test.ts
@@ -16,9 +16,9 @@ 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, Browser, expect } from "@playwright/test";
+import { Browser } from "@playwright/test";
import { AppModel } from "./models/app.model";
-import { USER } from "./utils";
+import { test, expect, USER } from "./utils";
// run this test file sequentially
test.describe.configure({ mode: "serial" });
diff --git a/apps/web/__e2e__/tabs.test.ts b/apps/web/__e2e__/tabs.test.ts
index 62c571cdc..ab8810e50 100644
--- a/apps/web/__e2e__/tabs.test.ts
+++ b/apps/web/__e2e__/tabs.test.ts
@@ -17,9 +17,8 @@ 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 { createHistorySession, NOTE } from "./utils";
+import { test, expect, createHistorySession, NOTE } from "./utils";
test("notes should open in the same tab", async ({ page }) => {
const app = new AppModel(page);
diff --git a/apps/web/__e2e__/tags.test.ts b/apps/web/__e2e__/tags.test.ts
index ccd48c61c..ddfead5ff 100644
--- a/apps/web/__e2e__/tags.test.ts
+++ b/apps/web/__e2e__/tags.test.ts
@@ -17,10 +17,16 @@ 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 { getTestId, NOTE, orderByOptions, sortByOptions } from "./utils";
+import {
+ test,
+ expect,
+ getTestId,
+ NOTE,
+ orderByOptions,
+ sortByOptions
+} from "./utils";
const TAG: Item = { title: "hello-world" };
const EDITED_TAG: Item = { title: "hello-world-2" };
diff --git a/apps/web/__e2e__/user.test.ts b/apps/web/__e2e__/user.test.ts
index 108d12f64..003d2000f 100644
--- a/apps/web/__e2e__/user.test.ts
+++ b/apps/web/__e2e__/user.test.ts
@@ -17,9 +17,8 @@ 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 { getTestId, USER } from "./utils";
+import { test, expect, USER } from "./utils";
// async function forceExpireSession() {
// await page.evaluate(() => {
diff --git a/apps/web/__e2e__/utils/index.ts b/apps/web/__e2e__/utils/index.ts
index 8b65af65b..9f6baa34e 100644
--- a/apps/web/__e2e__/utils/index.ts
+++ b/apps/web/__e2e__/utils/index.ts
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import fs from "fs";
import dotenv from "dotenv";
import path, { join } from "path";
-import { Locator, Page } from "@playwright/test";
+import { test as base, Locator, Page } from "@playwright/test";
import {
GroupByOptions,
Notebook,
@@ -30,6 +30,19 @@ import {
import { tmpdir } from "os";
import { AppModel } from "../models/app.model";
+export type { Browser, Page } from "@playwright/test";
+export { expect } from "@playwright/test";
+
+const test = base.extend<NonNullable<unknown>>({
+ page: async ({ page }, use) => {
+ const client = await page.context().newCDPSession(page);
+ await client.send("Emulation.setCPUThrottlingRate", {
+ rate: 1
+ });
+ await use(page);
+ }
+});
+
type Note = {
title: string;
content?: string;
@@ -193,6 +206,7 @@ export async function createHistorySession(page: Page, locked = false) {
}
export {
+ test,
USER,
NOTE,
TITLE_ONLY_NOTE,
diff --git a/apps/web/__e2e__/vault.test.ts b/apps/web/__e2e__/vault.test.ts
index 779d040d1..9f234d496 100644
--- a/apps/web/__e2e__/vault.test.ts
+++ b/apps/web/__e2e__/vault.test.ts
@@ -17,9 +17,8 @@ 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 { getTestId, NOTE, PASSWORD } from "./utils";
+import { test, expect, getTestId, NOTE, PASSWORD } from "./utils";
test("locking a note should show vault unlocked status", async ({ page }) => {
const app = new AppModel(page);