Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the P2P data UI and workflow #55

Merged
merged 73 commits into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
be80d2a
Add compose dependencies
Rkareko Nov 1, 2022
7078e84
Upgrade kotlin and gradle depencies
Rkareko Nov 2, 2022
88192f6
Update main P2P screen
Rkareko Nov 2, 2022
e56f871
Wire up main P2P screen
Rkareko Nov 3, 2022
a2241b2
Add device list components
Rkareko Nov 7, 2022
a3bde87
Add progress status components
Rkareko Nov 8, 2022
1fc73cc
Run spotless Apply
Rkareko Nov 8, 2022
79e7df0
Wire up searching and waiting to pair screens
Rkareko Nov 9, 2022
7bd74c1
Logic for handling startScanning event
Rkareko Nov 9, 2022
a7bbf25
Display list of devices available for pairing
Rkareko Nov 9, 2022
2797029
Handle pair with device event
Rkareko Nov 9, 2022
4f0a68b
Wire up transferring records screen
Rkareko Nov 9, 2022
b8f5e0f
Wire up transfer complete screen
Rkareko Nov 9, 2022
f01c975
wire up cancellation of data transfer
Rkareko Nov 9, 2022
9fa787b
Inititate sending of data
Rkareko Nov 9, 2022
fada529
Fix crash during initiation of data transfer
Rkareko Nov 10, 2022
51962b7
Update modal bottom sheet
Rkareko Nov 10, 2022
43f3c77
Update progress component to have a circular shape
Rkareko Nov 10, 2022
6f2574a
Handle initial data transfer state
Rkareko Nov 11, 2022
cd1a63f
Handle user initiated termination of data transfer
Rkareko Nov 11, 2022
3132dc7
Wire up display of transfer progress
Rkareko Nov 11, 2022
a275e64
Display number of records transferred
Rkareko Nov 11, 2022
883921d
Logic for prompting next transfer
Rkareko Nov 11, 2022
4a48af5
Wire up waiting to transmit data screens
Rkareko Nov 11, 2022
704291d
Show percentage transfer progress
Rkareko Nov 11, 2022
83ccbe9
Bump up version
Rkareko Nov 11, 2022
3db1337
Add back button to top bar for dismissing p2p screen
Rkareko Nov 14, 2022
1291aff
Update bottom sheet background
Rkareko Nov 14, 2022
fc84b33
Update device list UI
Rkareko Nov 14, 2022
2f1e84e
Add proress status component state
Rkareko Nov 14, 2022
1f19418
Bump up version
Rkareko Nov 14, 2022
3b88725
Update unit tests
Rkareko Nov 15, 2022
e65e949
Remove logic for displaying bottom sheet from P2PDeviceSearchActivity
Rkareko Nov 16, 2022
ad905e8
Update UI when pairing devices have been found
Rkareko Nov 16, 2022
a2625af
Add null check
Rkareko Nov 16, 2022
6e1bfbe
Clean up commented code
Rkareko Nov 16, 2022
6a6b366
Fix failling P2PDeviceSearchActivity tests
Rkareko Nov 17, 2022
d2e18ae
Merge branch 'compose-ui-integration' of github.com:opensrp/p2p into …
Rkareko Nov 17, 2022
c8e29e6
Fix failling wifidirect datasharing stratey tests
Rkareko Nov 17, 2022
956a7ff
Temporarily ignore flaky tests
Rkareko Nov 17, 2022
b905380
Add dependencies for compose UI tests
Rkareko Nov 18, 2022
f09dea7
Add compose UI component tests
Rkareko Nov 18, 2022
f7ef61f
Include instrumented tests in jacoco test recport
Rkareko Nov 18, 2022
9dc0207
Add instructions to create AVD and run instrumented tests on CI
Rkareko Nov 18, 2022
8dde1c0
Run avd on macos
Rkareko Nov 18, 2022
1403da4
Specify api level
Rkareko Nov 18, 2022
7a60f4d
Temporarily disable AVD creation steps
Rkareko Nov 18, 2022
d97dbfb
Temporarily exclude instrumented tests from jacoco report
Rkareko Nov 18, 2022
cd82ef7
Add p2pViewModel tests
Rkareko Nov 18, 2022
57890de
Refactor current connected device value to p2p view model
Rkareko Nov 20, 2022
1d32cc0
Update p2p view model tests
Rkareko Nov 20, 2022
3237a95
Move initChannel to p2PViewModel
Rkareko Nov 20, 2022
0fc312d
Add unit tests
Rkareko Nov 20, 2022
4d69b3d
Add tests for p2PviewModel cancelTransfer
Rkareko Nov 21, 2022
95b3888
Update p2p view model tests
Rkareko Nov 21, 2022
67cad6e
Enable running of instrumented tests on CI
Rkareko Nov 21, 2022
f6fc118
Fix identation
Rkareko Nov 21, 2022
54e7ca0
Only run tests after avd has been created
Rkareko Nov 21, 2022
d126d11
Update working directory
Rkareko Nov 21, 2022
fcc9c31
Temporarily disable working directory
Rkareko Nov 21, 2022
8ddc8e2
Add task for uploading test coverage
Rkareko Nov 21, 2022
db9cf93
Compile compose test coverage
Rkareko Nov 21, 2022
10cd1eb
Upload coverage to codecov
Rkareko Nov 21, 2022
93c25c3
Upload coverage to coveralls
Rkareko Nov 21, 2022
d80b3c7
Update codecove action
Rkareko Nov 21, 2022
e4d994f
Upload coverage to coveralls
Rkareko Nov 21, 2022
0c1d93b
Add excludeFromJacocoGeneratedReport annotation
Rkareko Nov 22, 2022
9cbd9bb
Add p2PScreen tests
Rkareko Nov 22, 2022
7628b8a
Switch to running tests on ubuntu
Rkareko Nov 22, 2022
0206c3e
Revert to running tests on mac os
Rkareko Nov 22, 2022
f464d1b
Add bottom sheet screen tests
Rkareko Nov 22, 2022
aa3976c
Bump up version
Rkareko Nov 24, 2022
cd0aa8e
Code cleanup
Rkareko Nov 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ on:

jobs:
unit_tests:
runs-on: ubuntu-latest
runs-on: macos-latest
strategy:
matrix:
api-level: [ 30 ]
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
Expand All @@ -21,9 +24,34 @@ jobs:
run: chmod +x gradlew
- name: Spotless check p2p-lib module
run: ./gradlew p2p-lib:spotlessCheck
- name: Run unit tests with Gradle
run: ./gradlew p2p-lib:clean p2p-lib:jacocoTestReport --stacktrace
- name: Upload coverage to Coveralls with Gradle
run: ./gradlew p2p-lib:coveralls --stacktrace
- name: Load AVD cache
uses: actions/cache@v2
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
# working-directory: android
api-level: ${{ matrix.api-level }}
arch: x86_64
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Run unit and instrumentation tests and generate coverage report
uses: reactivecircus/android-emulator-runner@v2
with:
# working-directory: android
api-level: ${{ matrix.api-level }}
arch: x86_64
force-avd-creation: true
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: ./gradlew p2p-lib:clean p2p-lib:jacocoTestReport p2p-lib:coveralls --stacktrace
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ buildscript {

versions.kotlin_coveralls = '2.12.0'
versions.jacoco_tool = '0.8.7'
ext.composeVersion = "1.2.1"

deps.kotlin_coveralls_plugin = "gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:$versions.kotlin_coveralls"

Expand All @@ -15,9 +16,9 @@ buildscript {
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0"
classpath "org.jetbrains.kotlin:kotlin-serialization:1.6.10"
classpath "com.android.tools.build:gradle:7.1.3"
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10'
classpath "org.jetbrains.kotlin:kotlin-serialization:1.7.10"
classpath deps.kotlin_coveralls_plugin
classpath deps.spotless

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Nov 16 16:10:20 SAST 2021
#Wed Nov 02 07:33:43 EAT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
34 changes: 30 additions & 4 deletions p2p-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jacoco {
}

android {
compileSdk 30
compileSdk 32

defaultConfig {
minSdk 21
Expand Down Expand Up @@ -49,8 +49,12 @@ android {
jvmTarget = '1.8'
}
buildFeatures {
compose true
viewBinding true
}
composeOptions {
kotlinCompilerExtensionVersion '1.3.0'
}
testOptions {
execution 'ANDROIDX_TEST_ORCHESTRATOR'
animationsDisabled true
Expand Down Expand Up @@ -82,6 +86,20 @@ dependencies { configuration ->
implementation 'com.google.code.gson:gson:2.8.7'
implementation 'androidx.activity:activity:1.3.1'

//Configure Jetpack Compose and navigation
api("androidx.compose.ui:ui:$composeVersion")
api("androidx.compose.ui:ui-tooling:$composeVersion")
api("androidx.compose.foundation:foundation:$composeVersion")
api("androidx.compose.material:material:$composeVersion")
api("androidx.compose.material:material-icons-core:$composeVersion")
api("androidx.compose.material:material-icons-extended:$composeVersion")
api("androidx.compose.runtime:runtime-livedata:$composeVersion")
api("androidx.lifecycle:lifecycle-viewmodel-compose:2.5.1")
api("androidx.paging:paging-compose:1.0.0-alpha15")
api("androidx.activity:activity-compose:1.5.1")
api ("com.google.accompanist:accompanist-flowlayout:0.23.1")
api("androidx.work:work-runtime-ktx:2.7.1")

roomDependencies(configuration)
locationDependencies(configuration)

Expand All @@ -100,6 +118,11 @@ dependencies { configuration ->

androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

// Compose UI test dependencies
testImplementation("androidx.compose.ui:ui-test-junit4:$composeVersion")
androidTestImplementation("androidx.compose.ui:ui-test-junit4:$composeVersion")
debugImplementation("androidx.compose.ui:ui-test-manifest:$composeVersion")
}

def roomDependencies(configuration) {
Expand All @@ -118,7 +141,9 @@ def locationDependencies(configuration) {
configuration.implementation 'com.google.android.gms:play-services-location:16.0.0'
}

task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest'/*, 'createDebugCoverageReport'*/]) {
task jacocoTestReport(type: JacocoReport, dependsOn: [
'testDebugUnitTest',
'connectedDebugAndroidTest'/*, 'createDebugCoverageReport'*/]) {

reports {
xml.enabled = true
Expand Down Expand Up @@ -162,7 +187,8 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest'/*, 'cr
classDirectories.setFrom(files([javaDebugTree, kotlinDebugTree]))

executionData.setFrom(fileTree(dir: project.buildDir, includes: [
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec',
'jacoco/testDebugUnitTest.exec',
'outputs/code_coverage/debugAndroidTest/connected/**/*.ec',
'outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec'
]))
}
Expand Down Expand Up @@ -197,7 +223,7 @@ afterEvaluate {
from(components["release"])
artifactId = "p2p-lib"
groupId = "org.smartregister"
version = "0.5.0-SNAPSHOT"
version = "0.6.0-SNAPSHOT"
pom {
name.set("Peer to Peer Library")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ class ExampleInstrumentedTest {
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("org.smartregister.p2p", appContext.packageName)
assertEquals("org.smartregister.p2p.test", appContext.packageName)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/*
* Copyright 2022 Ona Systems, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.smartregister.p2p.search.ui.p2p

import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.ModalBottomSheetState
import androidx.compose.material.ModalBottomSheetValue
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import org.junit.Rule
import org.junit.Test
import org.smartregister.p2p.authentication.model.DeviceRole
import org.smartregister.p2p.model.P2PState
import org.smartregister.p2p.search.ui.p2p.components.CIRCULAR_PROGRESS_INDICATOR_TEST_TAG

class BottomSheetScreenTest {
@get:Rule val composeRule = createComposeRule()

@Test
@OptIn(ExperimentalMaterialApi::class)
fun bottomSheetScreenRendersCorrectlyForSenderDevice() {
composeRule.setContent {
BottomSheet(
deviceList = emptyList(),
onEvent = {},
modalBottomSheetState = ModalBottomSheetState(ModalBottomSheetValue.HalfExpanded),
p2PUiState = P2PUiState(),
deviceName = "John",
deviceRole = DeviceRole.SENDER,
p2PState = P2PState.RECEIVING_DATA
)
}

composeRule.onNodeWithText("Searching for nearby recipient").assertExists().assertIsDisplayed()
composeRule.onNodeWithText("Searching nearby device as").assertExists().assertIsDisplayed()
composeRule
.onNodeWithTag(BOTTOM_SHEET_CANCEL_ICON_TEST_TAG)
.assertExists()
.assertIsDisplayed()
.performClick()
composeRule.onNodeWithTag(P2P_BOTTOM_SHEET_LIST).assertExists()
}

@Test
@OptIn(ExperimentalMaterialApi::class)
fun bottomSheetScreenRendersCorrectlyForReceiverDevice() {
composeRule.setContent {
BottomSheet(
deviceList = emptyList(),
onEvent = {},
modalBottomSheetState = ModalBottomSheetState(ModalBottomSheetValue.HalfExpanded),
p2PUiState = P2PUiState(),
deviceName = "John",
deviceRole = DeviceRole.RECEIVER,
p2PState = P2PState.RECEIVING_DATA
)
}

composeRule.onNodeWithText("Waiting to pair...").assertExists().assertIsDisplayed()
composeRule
.onNodeWithText("Waiting to be paired with sender as")
.assertExists()
.assertIsDisplayed()
composeRule
.onNodeWithTag(BOTTOM_SHEET_CANCEL_ICON_TEST_TAG)
.assertExists()
.assertIsDisplayed()
.performClick()
}

@Test
@OptIn(ExperimentalMaterialApi::class)
fun bottomSheetScreenRendersCorrectlyForCompleteTransferStatus() {
composeRule.setContent {
BottomSheet(
deviceList = emptyList(),
onEvent = {},
modalBottomSheetState = ModalBottomSheetState(ModalBottomSheetValue.HalfExpanded),
p2PUiState = P2PUiState(),
deviceName = "John",
deviceRole = DeviceRole.RECEIVER,
p2PState = P2PState.TRANSFER_COMPLETE
)
}

composeRule.onNodeWithText("OKay").assertExists().assertIsDisplayed()
composeRule.onNodeWithText("Send Data").assertExists().assertIsDisplayed()
composeRule.onNodeWithText("Device data successfully sent").assertExists().assertIsDisplayed()
composeRule
.onNodeWithTag(BOTTOM_SHEET_BUTTON_TEST_TAG)
.assertExists()
.assertIsDisplayed()
.performClick()
composeRule
.onNodeWithTag(BOTTOM_SHEET_CANCEL_ICON_TEST_TAG)
.assertExists()
.assertIsDisplayed()
.performClick()
}

@Test
@OptIn(ExperimentalMaterialApi::class)
fun bottomSheetScreenRendersCorrectlyForPairDevicesFoundStatus() {
composeRule.setContent {
BottomSheet(
deviceList = emptyList(),
onEvent = {},
modalBottomSheetState = ModalBottomSheetState(ModalBottomSheetValue.HalfExpanded),
p2PUiState = P2PUiState(),
deviceName = "John",
deviceRole = DeviceRole.SENDER,
p2PState = P2PState.PAIR_DEVICES_FOUND
)
}

composeRule
.onNodeWithTag(CIRCULAR_PROGRESS_INDICATOR_TEST_TAG)
.assertExists()
.assertIsDisplayed()
}
}
Loading