[test] github action please ok

pull/567/head
LouisLam 3 years ago
parent 2c19aef4dc
commit 34586d7b8f

@ -132,18 +132,18 @@ describe("Init", () => {
// Status Page // Status Page
await click(page, "#entryPageNo"); await click(page, "#entryPageNo");
await click(page, "form > div > .btn[type=submit]"); await click(page, "form > div > .btn[type=submit]");
await sleep(2000); await sleep(4000);
await newPage.goto(baseURL); await newPage.goto(baseURL);
await sleep(3000); await sleep(4000);
pathname = await newPage.evaluate(() => location.pathname); pathname = await newPage.evaluate(() => location.pathname);
expect(pathname).toEqual("/status"); expect(pathname).toEqual("/status");
// Back to Dashboard // Back to Dashboard
await click(page, "#entryPageYes"); await click(page, "#entryPageYes");
await click(page, "form > div > .btn[type=submit]"); await click(page, "form > div > .btn[type=submit]");
await sleep(2000); await sleep(4000);
await newPage.goto(baseURL); await newPage.goto(baseURL);
await sleep(3000); await sleep(4000);
pathname = await newPage.evaluate(() => location.pathname); pathname = await newPage.evaluate(() => location.pathname);
expect(pathname).toEqual("/dashboard"); expect(pathname).toEqual("/dashboard");
@ -157,17 +157,17 @@ describe("Init", () => {
await page.type("#current-password", "wrong_passw$$d"); await page.type("#current-password", "wrong_passw$$d");
await page.type("#new-password", "new_password123"); await page.type("#new-password", "new_password123");
await page.type("#repeat-new-password", "new_password123"); await page.type("#repeat-new-password", "new_password123");
// Save
await click(page, "form > div > .btn[type=submit]", 1); await click(page, "form > div > .btn[type=submit]", 1);
await sleep(3000); await sleep(4000);
await click(page, ".btn-danger.btn.me-1"); await click(page, ".btn-danger.btn.me-1");
await sleep(2000);
await login("admin", "new_password123"); await login("admin", "new_password123");
await sleep(2000);
let elementCount = await page.evaluate(() => document.querySelectorAll("#floatingPassword").length); let elementCount = await page.evaluate(() => document.querySelectorAll("#floatingPassword").length);
expect(elementCount).toEqual(1); expect(elementCount).toEqual(1);
await login("admin", "admin123"); await login("admin", "admin123");
await sleep(3000);
}); });
it("Change Password (wrong repeat)", async () => { it("Change Password (wrong repeat)", async () => {
@ -177,12 +177,13 @@ describe("Init", () => {
await page.type("#current-password", "admin123"); await page.type("#current-password", "admin123");
await page.type("#new-password", "new_password123"); await page.type("#new-password", "new_password123");
await page.type("#repeat-new-password", "new_password1234567898797898"); await page.type("#repeat-new-password", "new_password1234567898797898");
await click(page, "form > div > .btn[type=submit]", 1); await click(page, "form > div > .btn[type=submit]", 1);
await sleep(3000); await sleep(4000);
await click(page, ".btn-danger.btn.me-1"); await click(page, ".btn-danger.btn.me-1");
await sleep(2000);
await login("admin", "new_password123"); await login("admin", "new_password123");
await sleep(2000);
let elementCount = await page.evaluate(() => document.querySelectorAll("#floatingPassword").length); let elementCount = await page.evaluate(() => document.querySelectorAll("#floatingPassword").length);
expect(elementCount).toEqual(1); expect(elementCount).toEqual(1);
@ -226,17 +227,22 @@ async function login(username, password) {
await input(page, "#floatingInput", username); await input(page, "#floatingInput", username);
await input(page, "#floatingPassword", password); await input(page, "#floatingPassword", password);
await page.click(".btn-primary[type=submit]"); await page.click(".btn-primary[type=submit]");
await sleep(5000);
} }
async function click(page, selector, elementIndex = 0) { async function click(page, selector, elementIndex = 0) {
await page.waitForSelector(selector); await page.waitForSelector(selector, {
timeout: 5000,
});
return await page.evaluate((s, i) => { return await page.evaluate((s, i) => {
return document.querySelectorAll(s)[i].click(); return document.querySelectorAll(s)[i].click();
}, selector, elementIndex); }, selector, elementIndex);
} }
async function input(page, selector, text) { async function input(page, selector, text) {
await page.waitForSelector(selector); await page.waitForSelector(selector, {
timeout: 5000,
});
const element = await page.$(selector); const element = await page.$(selector);
await element.click({ clickCount: 3 }); await element.click({ clickCount: 3 });
await page.keyboard.press("Backspace"); await page.keyboard.press("Backspace");

Loading…
Cancel
Save