mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
test: remove timeout from login test
This commit is contained in:
@@ -3,8 +3,8 @@
|
|||||||
const { test, expect } = require("@playwright/test");
|
const { test, expect } = require("@playwright/test");
|
||||||
const { getTestId } = require("./utils");
|
const { getTestId } = require("./utils");
|
||||||
|
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page, baseURL }) => {
|
||||||
await page.goto("http://localhost:3000");
|
await page.goto(baseURL);
|
||||||
});
|
});
|
||||||
|
|
||||||
function createRoute(key, header) {
|
function createRoute(key, header) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const { Page, test, expect } = require("@playwright/test");
|
const { Page, test, expect } = require("@playwright/test");
|
||||||
const { getTestId } = require("./utils");
|
const { getTestId } = require("./utils");
|
||||||
const { isAbsent } = require("./utils/conditions");
|
const { isAbsent, isPresent } = require("./utils/conditions");
|
||||||
const dotenv = require("dotenv");
|
const dotenv = require("dotenv");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
@@ -11,10 +11,10 @@ dotenv.config({ path: path.join(__dirname, ".env.local") });
|
|||||||
*/
|
*/
|
||||||
var page = null;
|
var page = null;
|
||||||
global.page = null;
|
global.page = null;
|
||||||
test.beforeEach(async ({ page: _page }) => {
|
test.beforeEach(async ({ page: _page, baseURL }) => {
|
||||||
global.page = _page;
|
global.page = _page;
|
||||||
page = _page;
|
page = _page;
|
||||||
await page.goto("http://localhost:3000/");
|
await page.goto(baseURL);
|
||||||
});
|
});
|
||||||
|
|
||||||
const USER = {
|
const USER = {
|
||||||
@@ -31,11 +31,13 @@ async function loginUser() {
|
|||||||
|
|
||||||
await page.click(getTestId("submitButton"));
|
await page.click(getTestId("submitButton"));
|
||||||
|
|
||||||
await page.waitForNavigation();
|
await page.waitForSelector(getTestId("navitem-sync"));
|
||||||
|
|
||||||
expect(await isAbsent(getTestId("navitem-login"))).toBe(true);
|
expect(await isPresent(getTestId("navitem-sync"))).toBe(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
test("login user", async () => {
|
test("login user", async ({}, info) => {
|
||||||
|
info.setTimeout(0);
|
||||||
|
|
||||||
await loginUser();
|
await loginUser();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
"build:desktop": "env-cmd -e all,desktop react-scripts build",
|
"build:desktop": "env-cmd -e all,desktop react-scripts build",
|
||||||
"deploy": "./scripts/deploy.sh",
|
"deploy": "./scripts/deploy.sh",
|
||||||
"debug": "env-cmd -e all,dev,web,silent react-scripts start",
|
"debug": "env-cmd -e all,dev,web,silent react-scripts start",
|
||||||
"test": "yarn zx ./scripts/run-tests.mjs",
|
"test": "npm exec playwright test",
|
||||||
"test:debug": "env-cmd -e dev,debug,silent jest -c jest.e2e.config.js",
|
"test:debug": "env-cmd -e dev,debug,silent jest -c jest.e2e.config.js",
|
||||||
"eject": "react-scripts eject",
|
"eject": "react-scripts eject",
|
||||||
"update": "npm i @streetwriters/editor@latest @streetwriters/notesnook-core@latest @streetwriters/theme@latest",
|
"update": "npm i @streetwriters/editor@latest @streetwriters/notesnook-core@latest @streetwriters/theme@latest",
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
const IS_CI = !!process.env.CI;
|
const IS_CI = !!process.env.CI;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// Look for test files in the "tests" directory, relative to this configuration file
|
webServer: {
|
||||||
|
command: "npm run debug",
|
||||||
|
port: 3000,
|
||||||
|
timeout: 120 * 1000,
|
||||||
|
reuseExistingServer: false, //!IS_CI,
|
||||||
|
},
|
||||||
|
// Look for test files in thcleare "tests" directory, relative to this configuration file
|
||||||
testDir: "__e2e__",
|
testDir: "__e2e__",
|
||||||
|
|
||||||
// Each test is given 30 seconds
|
// Each test is given 30 seconds
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
const find = require("find-process");
|
|
||||||
|
|
||||||
const { p, updateSnapshots, file, noServer } = argv;
|
|
||||||
|
|
||||||
if (!noServer) {
|
|
||||||
await killServer();
|
|
||||||
const res = nothrow($`yarn debug -p ${p || 3000}`);
|
|
||||||
res.stdout.on("data", async (data) => {
|
|
||||||
const message = data.toString();
|
|
||||||
if (
|
|
||||||
message.includes("create a production build, use yarn build.") ||
|
|
||||||
message.includes("Compiled with warnings")
|
|
||||||
) {
|
|
||||||
const testRes = await startTestRunner();
|
|
||||||
await killServer();
|
|
||||||
process.exit(testRes.exitCode);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
const testRes = await startTestRunner();
|
|
||||||
process.exit(testRes.exitCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function killServer() {
|
|
||||||
const nodeProcesses = await find("name", "node");
|
|
||||||
const reactServerProcesses = nodeProcesses.filter((p) =>
|
|
||||||
p.cmd.includes("react-scripts")
|
|
||||||
);
|
|
||||||
for (let rprocess of reactServerProcesses) {
|
|
||||||
process.kill(rprocess.pid, "SIGINT");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function startTestRunner() {
|
|
||||||
if (!updateSnapshots && !file) return $`yarn playwright test`;
|
|
||||||
else if (updateSnapshots && file) return $`yarn playwright test -u ${file}`;
|
|
||||||
else if (file) return $`yarn playwright test ${file}`;
|
|
||||||
else if (updateSnapshots) return $`yarn playwright test -u`;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user