mirror of
https://github.com/usememos/memos.git
synced 2024-12-20 09:41:58 +03:00
81d4f01b7f
* add i18n * add base e2e test * add multiple test for e2e * extract the funciton of write memo * change test sturct * deteled unused dir * use fixture * add fixture * restruced the project * feat: add workflow * feat: change playwright test position * feat: change playwright test position * using yarn intead of npm * change install method * only enable sign in test * adjust the order of test * change report pos * fix style of e2e workflow * add review test * unify locale * randome write content * change report pos * reduce unused wait time * reduce unused folder * stash * merge upstream locale * change test name * add test item * change action name * add lanuage setting * add shotscreen * change name of test * fix the error of import dep * fix the error of import dep * fix the error of filename * fix the format of workflow * fix the name error of test case * feat: change the describe of test case * feat: remove unused test * feat: change the fixtures name * feat: remove unused config * feat: change docker action * feat: change the generate method * feat: extrace screenshot * feat: change extra path * feat: change extra path * feat: screenshot and upload * feat: change upload filename * feat: change login method * feat: change e2e method * feat: change e2e test * feat: add wait for login --------- Co-authored-by: CorrectRoadH <a778917369@gmail.comå>
53 lines
2.2 KiB
TypeScript
53 lines
2.2 KiB
TypeScript
import { expect, Page } from "@playwright/test";
|
|
import locale from "../src/locales/en.json";
|
|
import { baseHost } from "./fixtures";
|
|
|
|
async function screenshot(page: Page, name: string) {
|
|
await page.screenshot({ path: `playwright-screenshot/${name}.png`, fullPage: true });
|
|
}
|
|
|
|
async function writeMemo(page: Page, content: string) {
|
|
await expect(page.getByRole("button", { name: locale.editor.save })).toBeDisabled();
|
|
await page.getByPlaceholder("Any thoughts...").fill(content);
|
|
await expect(page.getByRole("button", { name: locale.editor.save })).toBeEnabled();
|
|
await page.getByRole("button", { name: locale.editor.save }).click();
|
|
}
|
|
|
|
async function login(page: Page, username: string, password: string) {
|
|
page.goto(`${baseHost}/`);
|
|
await screenshot(page, "explore-page");
|
|
await page.waitForURL("**/explore");
|
|
await screenshot(page, "explore-page-after-wait");
|
|
await page.getByRole("link", { name: locale.common["sign-in"] }).click();
|
|
await screenshot(page, "auth-page");
|
|
await page.waitForURL("**/auth");
|
|
await page.locator('input[type="text"]').click();
|
|
await page.locator('input[type="text"]').fill(username);
|
|
await page.locator('input[type="password"]').click();
|
|
await page.locator('input[type="password"]').fill(password);
|
|
await page.getByRole("button", { name: locale.common["sign-in"] }).click();
|
|
await page.waitForTimeout(1000);
|
|
await screenshot(page, "home-page-login-success");
|
|
}
|
|
|
|
async function signUp(page: Page, username: string, password: string) {
|
|
await page.goto(`${baseHost}/`);
|
|
await page.waitForURL("**/auth");
|
|
await screenshot(page, "sign-up-page");
|
|
await page.locator('input[type="text"]').click();
|
|
await page.locator('input[type="text"]').fill(username);
|
|
await page.locator('input[type="password"]').click();
|
|
await page.locator('input[type="password"]').fill(password);
|
|
await page.getByRole("button", { name: locale.auth["signup-as-host"] }).click();
|
|
await page.waitForTimeout(1000);
|
|
await screenshot(page, "home-page-sign-up-success");
|
|
}
|
|
|
|
async function review(page: Page) {
|
|
await page.goto(`${baseHost}/`);
|
|
await page.getByRole("link", { name: locale["daily-review"]["title"] }).click();
|
|
await screenshot(page, "review");
|
|
}
|
|
|
|
export { writeMemo, login, signUp, review };
|