2021-10-05 11:39:44 +02:00
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
const { Page } = require("puppeteer");
|
2021-10-05 14:27:43 +02:00
|
|
|
const { sleep } = require("../src/util");
|
2021-10-05 11:39:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set back the correct data type for page object
|
|
|
|
* @type {Page}
|
|
|
|
*/
|
|
|
|
page;
|
2021-10-03 12:16:55 +02:00
|
|
|
|
2021-10-05 10:03:35 +02:00
|
|
|
beforeAll(() => {
|
2021-10-05 15:11:11 +02:00
|
|
|
if (process.env.JUST_FOR_TEST) {
|
|
|
|
console.log(process.env.JUST_FOR_TEST);
|
2021-10-05 11:39:44 +02:00
|
|
|
|
2021-10-05 15:11:11 +02:00
|
|
|
if (process.env.JUST_FOR_TEST === "JUST_FOR_TEST_HELLO") {
|
|
|
|
console.log("secret ok");
|
|
|
|
}
|
|
|
|
}
|
2021-10-03 12:16:55 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(() => {
|
2021-10-05 10:03:35 +02:00
|
|
|
|
2021-10-03 12:16:55 +02:00
|
|
|
});
|
|
|
|
|
2021-10-05 14:27:43 +02:00
|
|
|
const baseURL = "http://127.0.0.1:3002";
|
|
|
|
|
2021-10-05 11:39:44 +02:00
|
|
|
describe("Init", () => {
|
2021-10-03 12:16:55 +02:00
|
|
|
const title = "Uptime Kuma";
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2021-10-05 14:27:43 +02:00
|
|
|
await page.goto(baseURL);
|
2021-10-03 12:16:55 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
it(`should be titled "${title}"`, async () => {
|
|
|
|
await expect(page.title()).resolves.toMatch(title);
|
|
|
|
});
|
2021-10-05 10:03:35 +02:00
|
|
|
|
2021-10-05 11:39:44 +02:00
|
|
|
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]");
|
2021-10-05 14:27:43 +02:00
|
|
|
await sleep(3000);
|
2021-10-05 11:39:44 +02:00
|
|
|
|
|
|
|
// Go to /setup again
|
2021-10-05 14:27:43 +02:00
|
|
|
await page.goto(baseURL + "/setup");
|
|
|
|
await sleep(3000);
|
2021-10-05 11:39:44 +02:00
|
|
|
const pathname = await page.evaluate(() => location.pathname);
|
|
|
|
expect(pathname).toEqual("/dashboard");
|
|
|
|
|
|
|
|
// Go to /
|
2021-10-05 14:27:43 +02:00
|
|
|
await page.goto(baseURL);
|
2021-10-05 11:39:44 +02:00
|
|
|
expect(pathname).toEqual("/dashboard");
|
|
|
|
});
|
|
|
|
|
2021-10-05 14:27:43 +02:00
|
|
|
describe("Settings", () => {
|
|
|
|
beforeAll(async () => {
|
|
|
|
await page.goto(baseURL + "/settings");
|
|
|
|
});
|
2021-10-05 11:39:44 +02:00
|
|
|
|
2021-10-05 14:27:43 +02:00
|
|
|
it("Change Language", async () => {
|
|
|
|
await page.select("#language", "zh-HK");
|
|
|
|
let languageTitle = await page.evaluate(() => document.querySelector("[for=language]").innerText);
|
|
|
|
expect(languageTitle).toMatch("語言");
|
2021-10-05 10:03:35 +02:00
|
|
|
|
2021-10-05 14:27:43 +02:00
|
|
|
await page.select("#language", "en");
|
|
|
|
languageTitle = await page.evaluate(() => document.querySelector("[for=language]").innerText);
|
|
|
|
expect(languageTitle).toMatch("Language");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Change Theme", async () => {
|
|
|
|
// Light
|
|
|
|
await page.click(".btn[for=btncheck1]");
|
2021-10-06 07:26:43 +02:00
|
|
|
await page.waitForSelector("div.light");
|
2021-10-05 14:27:43 +02:00
|
|
|
|
|
|
|
await page.click(".btn[for=btncheck2]");
|
2021-10-06 07:26:43 +02:00
|
|
|
await page.waitForSelector("div.dark");
|
2021-10-05 14:27:43 +02:00
|
|
|
});
|
2021-10-05 10:03:35 +02:00
|
|
|
});
|
2021-10-05 14:27:43 +02:00
|
|
|
|
|
|
|
describe("Status Page", () => {
|
|
|
|
const title = "Uptime Kuma";
|
|
|
|
beforeAll(async () => {
|
|
|
|
await page.goto(baseURL + "/status");
|
|
|
|
});
|
|
|
|
it(`should be titled "${title}"`, async () => {
|
|
|
|
await expect(page.title()).resolves.toMatch(title);
|
|
|
|
});
|
2021-10-05 10:03:35 +02:00
|
|
|
});
|
2021-10-03 12:16:55 +02:00
|
|
|
});
|
|
|
|
|