mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-26 03:16:19 +03:00
setup unit test for setup
This commit is contained in:
parent
e6ff957d9d
commit
79e0c9e1f1
6 changed files with 3078 additions and 77 deletions
|
@ -1,5 +1,6 @@
|
|||
module.exports = {
|
||||
"launch": {
|
||||
"headless": false
|
||||
"headless": false,
|
||||
"userDataDir": "./data/test-chrome-profile",
|
||||
}
|
||||
};
|
||||
|
|
3091
package-lock.json
generated
3091
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -20,8 +20,8 @@
|
|||
"start-server": "node server/server.js",
|
||||
"start-server-dev": "cross-env NODE_ENV=development node server/server.js",
|
||||
"build": "vite build",
|
||||
"prepare-test": "npm run build && node server/server.js --port=3002 --data-dir=./data/test/",
|
||||
"test": "jest",
|
||||
"prepare-test-server": "node test/prepare-test-server.js && node server/server.js --port=3002 --data-dir=./data/test/",
|
||||
"test": "node test/prepare-jest.js && jest",
|
||||
"tsc": "tsc",
|
||||
"vite-preview-dist": "vite preview --host",
|
||||
"build-docker": "npm run build-docker-debian && npm run build-docker-alpine",
|
||||
|
@ -101,8 +101,6 @@
|
|||
"@vitejs/plugin-legacy": "~1.5.3",
|
||||
"@vitejs/plugin-vue": "~1.9.1",
|
||||
"@vue/compiler-sfc": "~3.2.16",
|
||||
"@vue/test-utils": "next",
|
||||
"@vue/vue3-jest": "^27.0.0-alpha.1",
|
||||
"core-js": "~3.18.0",
|
||||
"cross-env": "~7.0.3",
|
||||
"dns2": "~2.0.1",
|
||||
|
@ -124,6 +122,7 @@
|
|||
"__DEV__": true
|
||||
},
|
||||
"testRegex": "./test/*.spec.js",
|
||||
"rootDir": "."
|
||||
"rootDir": ".",
|
||||
"testTimeout": 15000
|
||||
}
|
||||
}
|
||||
|
|
5
test/prepare-jest.js
Normal file
5
test/prepare-jest.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
const fs = require("fs");
|
||||
|
||||
fs.rmdirSync("./data/test-chrome-profile", {
|
||||
recursive: true,
|
||||
});
|
5
test/prepare-test-server.js
Normal file
5
test/prepare-test-server.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
const fs = require("fs");
|
||||
|
||||
fs.rmdirSync("./data/test", {
|
||||
recursive: true,
|
||||
});
|
|
@ -1,16 +1,21 @@
|
|||
const fs = require("fs");
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { Page } = require("puppeteer");
|
||||
|
||||
/**
|
||||
* Set back the correct data type for page object
|
||||
* @type {Page}
|
||||
*/
|
||||
page;
|
||||
|
||||
beforeAll(() => {
|
||||
fs.rmdirSync("./data/test", {
|
||||
recursive: true,
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
||||
});
|
||||
|
||||
describe("Very Simple Test", () => {
|
||||
describe("Init", () => {
|
||||
const title = "Uptime Kuma";
|
||||
|
||||
beforeAll(async () => {
|
||||
|
@ -21,8 +26,31 @@ describe("Very Simple Test", () => {
|
|||
await expect(page.title()).resolves.toMatch(title);
|
||||
});
|
||||
|
||||
it("Create an admin account", async () => {
|
||||
await page.evaluate(() => document.);
|
||||
it("Setup", async () => {
|
||||
// Create an Admin
|
||||
await page.waitForSelector("#floatingInput");
|
||||
await page.waitForSelector("#repeat");
|
||||
await page.click("#floatingInput");
|
||||
await page.type("#floatingInput", "admin");
|
||||
await page.type("#floatingPassword", "admin123");
|
||||
await page.type("#repeat", "admin123");
|
||||
await page.click(".btn-primary[type=submit]");
|
||||
await page.waitFor(3000);
|
||||
|
||||
// Go to /setup again
|
||||
await page.goto("http://127.0.0.1:3002/setup");
|
||||
await page.waitFor(3000);
|
||||
const pathname = await page.evaluate(() => location.pathname);
|
||||
expect(pathname).toEqual("/dashboard");
|
||||
|
||||
// Go to /
|
||||
await page.goto("http://127.0.0.1:3002");
|
||||
expect(pathname).toEqual("/dashboard");
|
||||
expect(pathname).toEqual("/dashboard");
|
||||
});
|
||||
|
||||
describe("Init", () => {
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue