mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-13 08:02:35 +02:00
Test: improve create monitor, add screenshots
This commit is contained in:
parent
9f0c66d775
commit
4af7d00620
4 changed files with 31 additions and 2 deletions
8
.github/workflows/auto-test.yml
vendored
8
.github/workflows/auto-test.yml
vendored
|
@ -33,3 +33,11 @@ jobs:
|
|||
env:
|
||||
HEADLESS_TEST: 1
|
||||
JUST_FOR_TEST: ${{ secrets.JUST_FOR_TEST }}
|
||||
- name: Upload test artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
if: always()
|
||||
with:
|
||||
name: test-screenshots ${{ matrix.os }} ${{ matrix.node-version }}
|
||||
path: |
|
||||
test/screenshots
|
||||
!test/screenshots/.gitkeep
|
||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -13,3 +13,5 @@ dist-ssr
|
|||
/out
|
||||
/tmp
|
||||
.env
|
||||
|
||||
test/screenshots/
|
||||
|
|
|
@ -14,6 +14,10 @@ page;
|
|||
*/
|
||||
browser;
|
||||
|
||||
function convertToValidFilename(string) {
|
||||
return (string.replace(/[/|\\:*?"<>]/g, " "));
|
||||
}
|
||||
|
||||
beforeAll(async () => {
|
||||
await page.setViewport({
|
||||
width: 1280,
|
||||
|
@ -26,6 +30,13 @@ afterAll(() => {
|
|||
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
const testName = convertToValidFilename(expect.getState().currentTestName);
|
||||
await page.screenshot({
|
||||
path: `./test/screenshots/${testName}.png`,
|
||||
type: "png" });
|
||||
});
|
||||
|
||||
const baseURL = "http://127.0.0.1:3002";
|
||||
|
||||
describe("Init", () => {
|
||||
|
@ -69,10 +80,17 @@ describe("Init", () => {
|
|||
await page.goto(baseURL + "/add");
|
||||
await page.waitForSelector("#name");
|
||||
|
||||
await sleep(1000);
|
||||
|
||||
await page.type("#name", "Myself");
|
||||
await page.waitForSelector("#url");
|
||||
await page.click("#url", { clickCount: 3 });
|
||||
await page.keyboard.type(baseURL);
|
||||
await page.evaluate(() => {
|
||||
const urlInput = document.querySelector("#url");
|
||||
urlInput.value = "";
|
||||
});
|
||||
await page.type("#url", baseURL);
|
||||
|
||||
await page.focus("#url");
|
||||
await page.keyboard.press("Enter");
|
||||
|
||||
await page.waitForFunction(() => {
|
||||
|
@ -247,6 +265,7 @@ describe("Init", () => {
|
|||
newPage.close();
|
||||
|
||||
await click(page, "#enableAuth-btn");
|
||||
|
||||
await login("admin", "admin123");
|
||||
await page.waitForSelector("#disableAuth-btn", { timeout: 3000 });
|
||||
});
|
||||
|
|
0
test/screenshots/.gitkeep
Normal file
0
test/screenshots/.gitkeep
Normal file
Loading…
Add table
Reference in a new issue