]>
Commit | Line | Data |
---|---|---|
1db86422 C |
1 | async function getCheckbox (name: string) { |
2 | const input = $(`my-peertube-checkbox input[id=${name}]`) | |
3 | await input.waitForExist() | |
4 | ||
5 | return input.parentElement() | |
a9bfa85d C |
6 | } |
7 | ||
5bdfa604 C |
8 | function isCheckboxSelected (name: string) { |
9 | return $(`input[id=${name}]`).isSelected() | |
10 | } | |
11 | ||
a9bfa85d | 12 | async function selectCustomSelect (id: string, valueLabel: string) { |
814e9e07 C |
13 | const wrapper = $(`[formcontrolname=${id}] .ng-arrow-wrapper`) |
14 | ||
15 | await wrapper.waitForClickable() | |
16 | await wrapper.click() | |
a9bfa85d C |
17 | |
18 | const option = await $$(`[formcontrolname=${id}] .ng-option`).filter(async o => { | |
19 | const text = await o.getText() | |
20 | ||
21 | return text.trimStart().startsWith(valueLabel) | |
22 | }).then(options => options[0]) | |
23 | ||
24 | await option.waitForDisplayed() | |
25 | ||
26 | return option.click() | |
6d210220 C |
27 | } |
28 | ||
5bdfa604 C |
29 | async function findParentElement ( |
30 | el: WebdriverIO.Element, | |
31 | finder: (el: WebdriverIO.Element) => Promise<boolean> | |
32 | ) { | |
33 | if (await finder(el) === true) return el | |
34 | ||
35 | return findParentElement(await el.parentElement(), finder) | |
36 | } | |
37 | ||
6d210220 | 38 | export { |
a9bfa85d | 39 | getCheckbox, |
5bdfa604 C |
40 | isCheckboxSelected, |
41 | selectCustomSelect, | |
42 | findParentElement | |
6d210220 | 43 | } |