import test from 'tape-async'
import helper from 'tipsi-appium-helper'

const { driver, select, idFromXPath } = helper

test('<StarRating />', async (t) => {
  const starsAndTextId = select({
    ios: idFromXPath(`//
      XCUIElementTypeScrollView/*/*/XCUIElementTypeOther[2]/
      XCUIElementTypeOther/XCUIElementTypeStaticText
    `),
    android: idFromXPath(`//
      android.widget.ScrollView[1]/android.view.ViewGroup[1]/*/
      android.widget.TextView
    `),
  })

  try {
    await helper.openExampleFor('<StarRating />')
    const elements = await driver
      .waitForVisible(starsAndTextId, 20000)
      .elements(starsAndTextId)

    t.equal(
      elements.value.length,
      27,
      'Should render five <StarRating /> components'
    )
  } catch (error) {
    await helper.screenshot()
    await helper.source()

    throw error
  }
})

@@ -163,24 +163,21 @@
 nst star
-sAndText
+Group
 Id = sel
@@ -267,23 +267,16 @@
 ther%5B2%5D/
-%0A      
 XCUIElem
@@ -291,34 +291,8 @@
 ther
-/XCUIElementTypeStaticText
 %0A   
@@ -322,25 +322,25 @@
 mXPath(%60
-//
 %0A      
+//
 android.
@@ -393,18 +393,162 @@
 /*/%0A    
-  
+%60),%0A  %7D)%0A  const starItemId = select(%7B%0A    ios: idFromXPath(%60$%7BstarGroupId%7D/XCUIElementTypeStaticText%60),%0A    android: idFromXPath(%60$%7BstarGroupId%7D/
 android.
@@ -562,21 +562,16 @@
 TextView
-%0A    
 %60),%0A  %7D)
@@ -634,28 +634,113 @@
 %3E')%0A
+%0A
     
+for (
 const 
-elements =
+starId of %5B1, 2, 3, 4, 5%5D) %7B%0A      const currentStarId = %60$%7BstarItemId%7D%5B$%7BstarId%7D%5D%60%0A     
  awa
@@ -748,23 +748,16 @@
 t driver
-%0A      
 .waitFor
@@ -768,28 +768,27 @@
 ble(
-starsAndText
+currentStar
 Id, 2000
 0)%0A 
@@ -787,153 +787,70 @@
 2000
-0
 )%0A    
- 
- .elements(starsAndTextId)%0A%0A    t.equal(%0A      elements.value.length,%0A      27,%0A      'Should render five %3CStarRating /%3E components'%0A    
+%7D%0A%0A    t.pass('%3CStarRating /%3E example should be visible'
 )%0A  

Simplify test