uptime-kuma/test/test.spec.js

67 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-10-05 09:39:44 +00:00
// eslint-disable-next-line no-unused-vars
const { Page } = require("puppeteer");
/**
* Set back the correct data type for page object
* @type {Page}
*/
page;
2021-10-03 10:16:55 +00:00
2021-10-05 08:03:35 +00:00
beforeAll(() => {
2021-10-05 09:39:44 +00:00
2021-10-03 10:16:55 +00:00
});
afterAll(() => {
2021-10-05 08:03:35 +00:00
2021-10-03 10:16:55 +00:00
});
2021-10-05 09:39:44 +00:00
describe("Init", () => {
2021-10-03 10:16:55 +00:00
const title = "Uptime Kuma";
beforeAll(async () => {
await page.goto("http://127.0.0.1:3002");
});
it(`should be titled "${title}"`, async () => {
await expect(page.title()).resolves.toMatch(title);
});
2021-10-05 08:03:35 +00:00
2021-10-05 09:39:44 +00: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]");
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", () => {
2021-10-05 08:03:35 +00:00
});
});
describe("Status Page", () => {
const title = "Uptime Kuma";
beforeAll(async () => {
await page.goto("http://127.0.0.1:3002/status");
});
it(`should be titled "${title}"`, async () => {
await expect(page.title()).resolves.toMatch(title);
});
2021-10-03 10:16:55 +00:00
});