mirror of
https://github.com/zadam/trilium.git
synced 2025-10-19 06:38:59 +02:00
refactor(e2e): wrapper class for dropdown locator
This commit is contained in:
parent
0958204779
commit
253ef633dc
@ -42,20 +42,18 @@ test("User can change language from settings", async ({ page, context }) => {
|
||||
|
||||
// Check that the default value (English) is set.
|
||||
await expect(app.currentNoteSplit).toContainText("First day of the week");
|
||||
const languageCombobox = app.currentNoteSplit.locator(".options-section .dropdown").first();
|
||||
const languageCombobox = app.dropdown(app.currentNoteSplit.locator(".options-section .dropdown").first());
|
||||
await expect(languageCombobox).toContainText("English");
|
||||
|
||||
// Select Chinese and ensure the translation is set.
|
||||
await languageCombobox.locator(".dropdown-toggle").click();
|
||||
await languageCombobox.locator(".dropdown-item", { hasText: "简体中文" }).click();
|
||||
await languageCombobox.selectOptionByText("简体中文");
|
||||
await app.currentNoteSplit.locator("button[name=restart-app-button]").click();
|
||||
|
||||
await expect(app.currentNoteSplit).toContainText("一周的第一天", { timeout: 15000 });
|
||||
await expect(languageCombobox).toContainText("简体中文");
|
||||
|
||||
// Select English again.
|
||||
await languageCombobox.locator(".dropdown-toggle").click();
|
||||
await languageCombobox.locator(".dropdown-item", { hasText: "English" }).click();
|
||||
await languageCombobox.selectOptionByText("English");
|
||||
await app.currentNoteSplit.locator("button[name=restart-app-button]").click();
|
||||
await expect(app.currentNoteSplit).toContainText("Language", { timeout: 15000 });
|
||||
await expect(languageCombobox).toContainText("English");
|
||||
|
@ -9,6 +9,10 @@ interface GotoOpts {
|
||||
|
||||
const BASE_URL = "http://127.0.0.1:8082";
|
||||
|
||||
interface DropdownLocator extends Locator {
|
||||
selectOptionByText: (text: string) => Promise<void>;
|
||||
}
|
||||
|
||||
export default class App {
|
||||
readonly page: Page;
|
||||
readonly context: BrowserContext;
|
||||
@ -157,4 +161,14 @@ export default class App {
|
||||
})
|
||||
).toBeOK();
|
||||
}
|
||||
|
||||
dropdown(_locator: Locator): DropdownLocator {
|
||||
let locator = _locator as DropdownLocator;
|
||||
locator.selectOptionByText = async (text: string) => {
|
||||
await locator.locator(".dropdown-toggle").click();
|
||||
await locator.locator(".dropdown-item", { hasText: text }).click();
|
||||
};
|
||||
return locator;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user