]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/e2e/src/utils/elements.ts
Translated using Weblate (Vietnamese)
[github/Chocobozzz/PeerTube.git] / client / e2e / src / utils / elements.ts
index 315718879978fe9b9cec76390b15dff8b5e64390..d9435e52052305eb6782542a8b08705c9f9a9462 100644 (file)
@@ -1,9 +1,19 @@
-function getCheckbox (name: string) {
-  return $(`my-peertube-checkbox[inputname=${name}] label`)
+async function getCheckbox (name: string) {
+  const input = $(`my-peertube-checkbox input[id=${name}]`)
+  await input.waitForExist()
+
+  return input.parentElement()
+}
+
+function isCheckboxSelected (name: string) {
+  return $(`input[id=${name}]`).isSelected()
 }
 
 async function selectCustomSelect (id: string, valueLabel: string) {
-  await $(`[formcontrolname=${id}] .ng-arrow-wrapper`).click()
+  const wrapper = $(`[formcontrolname=${id}] .ng-arrow-wrapper`)
+
+  await wrapper.waitForClickable()
+  await wrapper.click()
 
   const option = await $$(`[formcontrolname=${id}] .ng-option`).filter(async o => {
     const text = await o.getText()
@@ -16,7 +26,18 @@ async function selectCustomSelect (id: string, valueLabel: string) {
   return option.click()
 }
 
+async function findParentElement (
+  el: WebdriverIO.Element,
+  finder: (el: WebdriverIO.Element) => Promise<boolean>
+) {
+  if (await finder(el) === true) return el
+
+  return findParentElement(await el.parentElement(), finder)
+}
+
 export {
   getCheckbox,
-  selectCustomSelect
+  isCheckboxSelected,
+  selectCustomSelect,
+  findParentElement
 }