mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-08 06:29:57 +08:00
setup unit test for setup
This commit is contained in:
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", () => {
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user