Skip to content

Commit

Permalink
Merge pull request #1820 from dedis/work-karate-4xiom5-events-tests
Browse files Browse the repository at this point in the history
Add karate UI tests rollcall create and join
  • Loading branch information
4xiom5 authored Apr 23, 2024
2 parents a489ed7 + b44922f commit 3cd4457
Show file tree
Hide file tree
Showing 15 changed files with 264 additions and 31 deletions.
1 change: 1 addition & 0 deletions fe1-web/src/features/rollCall/components/AttendeeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const AttendeeList = ({ popTokens, personalToken }: IPropTypes) => {
<ListItem.Title
style={[Typography.base, Typography.code]}
numberOfLines={1}
testID={`attendee_${idx}`}
selectable>
{token.valueOf()}
</ListItem.Title>
Expand Down
3 changes: 2 additions & 1 deletion fe1-web/src/features/rollCall/components/RollCallOpen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ const RollCallOpen = ({
Typography.centered,
Typography.code,
textStyle.topSpace,
]}>
]}
testID="roll_call_pop_token">
{popToken}
</Text>
<PoPTextButton onPress={() => Clipboard.setStringAsync(popToken)}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ exports[`EventRollCall render correctly no duplicate attendees opened roll calls
},
]
}
testID="roll_call_pop_token"
/>
<View
accessible={true}
Expand Down Expand Up @@ -871,7 +872,7 @@ exports[`EventRollCall render correctly no duplicate attendees opened roll calls
"textAlign": "left",
}
}
testID="listItemTitle"
testID="attendee_0"
>
attendee1
</Text>
Expand Down Expand Up @@ -1018,7 +1019,7 @@ exports[`EventRollCall render correctly no duplicate attendees opened roll calls
"textAlign": "left",
}
}
testID="listItemTitle"
testID="attendee_1"
>
attendee2
</Text>
Expand Down Expand Up @@ -1555,6 +1556,7 @@ exports[`EventRollCall render correctly no duplicate attendees re-opened roll ca
},
]
}
testID="roll_call_pop_token"
/>
<View
accessible={true}
Expand Down Expand Up @@ -1914,7 +1916,7 @@ exports[`EventRollCall render correctly no duplicate attendees re-opened roll ca
"textAlign": "left",
}
}
testID="listItemTitle"
testID="attendee_0"
>
attendee1
</Text>
Expand Down Expand Up @@ -2061,7 +2063,7 @@ exports[`EventRollCall render correctly no duplicate attendees re-opened roll ca
"textAlign": "left",
}
}
testID="listItemTitle"
testID="attendee_1"
>
attendee2
</Text>
Expand Down Expand Up @@ -2801,7 +2803,7 @@ exports[`EventRollCall render correctly non organizers closed roll calls 1`] = `
"textAlign": "left",
}
}
testID="listItemTitle"
testID="attendee_0"
>
attendee1
</Text>
Expand Down Expand Up @@ -2948,7 +2950,7 @@ exports[`EventRollCall render correctly non organizers closed roll calls 1`] = `
"textAlign": "left",
}
}
testID="listItemTitle"
testID="attendee_1"
>
attendee2
</Text>
Expand Down Expand Up @@ -3911,6 +3913,7 @@ exports[`EventRollCall render correctly non organizers opened roll calls 1`] = `
},
]
}
testID="roll_call_pop_token"
/>
<View
accessible={true}
Expand Down Expand Up @@ -4270,7 +4273,7 @@ exports[`EventRollCall render correctly non organizers opened roll calls 1`] = `
"textAlign": "left",
}
}
testID="listItemTitle"
testID="attendee_0"
>
attendee1
</Text>
Expand Down Expand Up @@ -4417,7 +4420,7 @@ exports[`EventRollCall render correctly non organizers opened roll calls 1`] = `
"textAlign": "left",
}
}
testID="listItemTitle"
testID="attendee_1"
>
attendee2
</Text>
Expand Down Expand Up @@ -4954,6 +4957,7 @@ exports[`EventRollCall render correctly non organizers re-opened roll calls 1`]
},
]
}
testID="roll_call_pop_token"
/>
<View
accessible={true}
Expand Down Expand Up @@ -5313,7 +5317,7 @@ exports[`EventRollCall render correctly non organizers re-opened roll calls 1`]
"textAlign": "left",
}
}
testID="listItemTitle"
testID="attendee_0"
>
attendee1
</Text>
Expand Down Expand Up @@ -5460,7 +5464,7 @@ exports[`EventRollCall render correctly non organizers re-opened roll calls 1`]
"textAlign": "left",
}
}
testID="listItemTitle"
testID="attendee_1"
>
attendee2
</Text>
Expand Down Expand Up @@ -6200,7 +6204,7 @@ exports[`EventRollCall render correctly organizers closed roll calls 1`] = `
"textAlign": "left",
}
}
testID="listItemTitle"
testID="attendee_0"
>
attendee1
</Text>
Expand Down Expand Up @@ -6347,7 +6351,7 @@ exports[`EventRollCall render correctly organizers closed roll calls 1`] = `
"textAlign": "left",
}
}
testID="listItemTitle"
testID="attendee_1"
>
attendee2
</Text>
Expand Down Expand Up @@ -7645,7 +7649,7 @@ exports[`EventRollCall render correctly organizers opened roll calls 1`] = `
"textAlign": "left",
}
}
testID="listItemTitle"
testID="attendee_0"
>
attendee1
</Text>
Expand Down Expand Up @@ -7792,7 +7796,7 @@ exports[`EventRollCall render correctly organizers opened roll calls 1`] = `
"textAlign": "left",
}
}
testID="listItemTitle"
testID="attendee_1"
>
attendee2
</Text>
Expand Down Expand Up @@ -8656,7 +8660,7 @@ exports[`EventRollCall render correctly organizers re-opened roll calls 1`] = `
"textAlign": "left",
}
}
testID="listItemTitle"
testID="attendee_0"
>
attendee1
</Text>
Expand Down Expand Up @@ -8803,7 +8807,7 @@ exports[`EventRollCall render correctly organizers re-opened roll calls 1`] = `
"textAlign": "left",
}
}
testID="listItemTitle"
testID="attendee_1"
>
attendee2
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,14 @@ class RollCallFragment : AbstractEventFragment {
Timber.tag(TAG).d("key displayed is %s", pk)

// Set the QR visible only if the rollcall is opened and the user isn't the organizer
binding.rollCallPkQrCode.visibility = if (rollCall.isOpen) View.VISIBLE else View.INVISIBLE
if (rollCall.isOpen) {
binding.rollCallPopTokenText.text = pk
binding.rollCallPkQrCode.visibility = View.VISIBLE
binding.rollCallPopTokenText.visibility = View.VISIBLE
} else {
binding.rollCallPkQrCode.visibility = View.INVISIBLE
binding.rollCallPopTokenText.visibility = View.INVISIBLE
}

// Don't lose time generating the QR code if it's not visible
if (laoViewModel.isOrganizer || rollCall.isClosed) {
Expand Down
12 changes: 11 additions & 1 deletion fe2-android/app/src/main/res/layout/roll_call_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/roll_call_end_time" />

<TextView
android:id="@+id/roll_call_pop_token_text"
android:layout_width="wrap_content"
android:layout_height="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/roll_call_pk_qr_code" />

<TextView
android:id="@+id/roll_call_fragment_title"
style="@style/title_style"
Expand Down Expand Up @@ -268,7 +276,9 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/roll_call_attendees_text"
app:layout_constraintVertical_bias="@dimen/roll_call_attendees_list_vertical_bias" />
app:layout_constraintVertical_bias="@dimen/roll_call_attendees_list_vertical_bias" >

</ListView>

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public static ViewInteraction rollCallQRCode() {
return onView(withId(R.id.roll_call_pk_qr_code));
}

public static ViewInteraction rollCallPopTokenText() {
return onView(withId(R.id.roll_call_pop_token_text));
}

public static ViewInteraction rollCallLocationCard() {
return onView(withId(R.id.roll_call_location_card));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@ class RollCallFragmentTest {
messageSenderHelper.assertSubscriptions()
}

@Test
fun managementButtonVisibilityTest() {
rollCallRepo.updateRollCall(LAO_ID, openRollCall(ROLL_CALL))

RollCallFragmentPageObject.managementButton()
.check(
ViewAssertions.matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))
)
}

@Test
fun scanButtonOpenScanningTest() {
rollCallRepo.updateRollCall(LAO_ID, openRollCall(ROLL_CALL))
Expand Down Expand Up @@ -351,6 +361,35 @@ class RollCallFragmentTest {
)
}

@Test
@Throws(UnknownLaoException::class)
fun popTokenVisibilityTest() {
// Invisible when created
RollCallFragmentPageObject.rollCallPopTokenText()
.check(
ViewAssertions.matches(
ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.INVISIBLE)
)
)
// Visible when opened
rollCallRepo.updateRollCall(LAO_ID, openRollCall(ROLL_CALL))
RollCallFragmentPageObject.rollCallPopTokenText()
.check(
ViewAssertions.matches(
ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)
)
)

// Invisible after
rollCallRepo.updateRollCall(LAO_ID, closeRollCall(ROLL_CALL))
RollCallFragmentPageObject.rollCallPopTokenText()
.check(
ViewAssertions.matches(
ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.INVISIBLE)
)
)
}

@Test
fun reopenButtonVisibilityTest() {
// Close the roll call 1
Expand Down
6 changes: 4 additions & 2 deletions tests/karate/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ The following options are available (option names must be prefixed by `-D`).
| url | URL of the web app | 'file:../../fe1-web/web-build/index.html' |
| screenWidth | Width of the browser | 1920 |
| screenHeight | Height of the browser | 1080 |
| serverURL | Client URL of the backend server | 'ws://localhost:9000/client' for the web and 'ws://10.0.2.2:9000/client' for android |
| serverURL | Client URL of the backend server from the test host perspective | 'ws://localhost:9000/client' |
| platformServerURL | Client URL of the backend server from the tested platform perspective | 'ws://localhost:9000/client' |

### Android Front-end
Build the application by running `./gradlew assembleDebug` in the corresponding directory.
Expand All @@ -247,4 +248,5 @@ The following options are available (option names must be prefixed by `-D`).
| Name | Description | Default |
|--------------|------------------------------------------------|-------------------------------------------|
| avd | Name of the android emulator | Choosen automatically by appium |
| serverURL | Client URL of the backend server | 'ws://localhost:9000/client' for the web and 'ws://10.0.2.2:9000/client' for android |
| serverURL | Client URL of the backend server from the test host perspective | 'ws://localhost:9000/client' |
| platformServerURL | Client URL of the backend server from the tested platform perspective | 'ws://10.0.2.2:9000/client' |
Loading

0 comments on commit 3cd4457

Please sign in to comment.