-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathLanguageUiHelper.ts
77 lines (63 loc) · 2.83 KB
/
LanguageUiHelper.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import {Page, Locator, expect} from "@playwright/test"
import {UiBaseLocators} from "./UiBaseLocators";
import { ConstantHelper } from "./ConstantHelper";
export class LanguageUiHelper extends UiBaseLocators{
private readonly languagesMenu: Locator;
private readonly languageDropdown: Locator;
private readonly defaultLanguageToggle: Locator;
private readonly mandatoryLanguageToggle: Locator;
private readonly addFallbackLanguageBtn: Locator;
private readonly languageTable: Locator;
constructor(page: Page) {
super(page);
this.languagesMenu = page.locator('umb-menu').getByLabel('Languages');
this.languageDropdown = page.locator('umb-input-culture-select #expand-symbol-wrapper');
this.defaultLanguageToggle = page.locator('uui-toggle').filter({ hasText: /Default language/ }).locator('#toggle');
this.mandatoryLanguageToggle = page.locator('uui-toggle').filter({ hasText: /Mandatory language/ }).locator('#toggle');
this.addFallbackLanguageBtn = page.locator('#add-button');
this.languageTable = page.locator('umb-language-table-collection-view');
}
async clickLanguagesMenu() {
await expect(this.languagesMenu).toBeVisible();
await this.languagesMenu.click();
}
async goToLanguages() {
await this.goToSection(ConstantHelper.sections.settings);
await this.clickLanguagesMenu();
await expect(this.createLink).toBeVisible();
}
async removeFallbackLanguageByName(name: string) {
await this.page.locator('uui-ref-node[name="' + name + '"]').getByLabel('Remove').click();
await this.confirmToRemoveBtn.click();
}
async chooseLanguageByName(name: string) {
await this.languageDropdown.click();
await this.page.locator('umb-input-culture-select').getByText(name, {exact: true}).click();
}
async clickLanguageByName(name: string) {
await this.languageTable.getByText(name, {exact: true}).click();
}
async isLanguageNameVisible(name: string, isVisible = true) {
return await expect(this.languageTable.getByText(name, {exact: true})).toBeVisible({visible: isVisible});
}
async switchDefaultLanguageOption() {
await this.defaultLanguageToggle.click();
}
async switchMandatoryLanguageOption() {
await this.mandatoryLanguageToggle.click();
}
async clickAddFallbackLanguageButton() {
await this.addFallbackLanguageBtn.click();
}
async clickRemoveLanguageByName(name: string) {
await this.page.locator('uui-table-row').filter({has: this.page.getByText(name, {exact: true})}).getByLabel('#actions_delete').click({force:true});
}
async removeLanguageByName(name: string) {
await this.clickRemoveLanguageByName(name);
await this.clickConfirmToDeleteButton();
}
async selectFallbackLanguageByName(name: string) {
await this.page.locator('umb-language-picker-modal').getByLabel(name).click();
await this.clickSubmitButton();
}
}