setup unit test for setup

This commit is contained in:
LouisLam
2021-10-05 17:39:44 +08:00
parent e6ff957d9d
commit 79e0c9e1f1
6 changed files with 3078 additions and 77 deletions

5
test/prepare-jest.js Normal file
View File

@@ -0,0 +1,5 @@
const fs = require("fs");
fs.rmdirSync("./data/test-chrome-profile", {
recursive: true,
});

View File

@@ -0,0 +1,5 @@
const fs = require("fs");
fs.rmdirSync("./data/test", {
recursive: true,
});

View File

@@ -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", () => {
});
});