Skip to content

Commit

Permalink
Fix: Folder deletion not working (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandregpereira committed Jun 23, 2024
1 parent c8babc5 commit 416bcbf
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 9 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/android.yml → .github/workflows/Main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
name: Android CI
name: Android Main CI

on:
push:
branches:
- main
- dev
paths-ignore:
- '**.md'
- 'media/**'
pull_request:
paths-ignore:
- '**.md'
- 'media/**'
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/PR.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Android PR CI

on:
pull_request:
paths-ignore:
- '**.md'
- 'media/**'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- name: set up JDK 17
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'adopt'

- name: Setup Gradle
uses: gradle/[email protected]

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew assembleDebug testDebugUnitTest jvmTest

- name: Verify database migration
run: chmod +x ./scripts/sqldelight/verifyDatabaseMigration && ./scripts/sqldelight/verifyDatabaseMigration

- name: Upload the test report
if: failure()
uses: actions/[email protected]
with:
name: TestReport
path: |
feature-monster-compendium/build/reports/tests
data/build/reports/tests
domain/build/reports/tests
- name: Upload an APK
uses: actions/[email protected]
with:
name: app-debug.apk
path: app/build/outputs/apk/debug/app-debug.apk

- name: Upload an APK metadata JSON
uses: actions/[email protected]
with:
name: output-metadata.json
path: app/build/outputs/apk/debug/output-metadata.json
3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,7 @@ dependencies {
implementation(libs.koin.compose)
testImplementation(libs.bundles.unittest)
testImplementation(libs.koin.test)
androidTestImplementation(libs.bundles.instrumentedtest)
androidTestImplementation(libs.compose.ui.test)
debugImplementation(libs.compose.ui.test.manifest)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package br.alexandregpereira.hunter.app.folder

import androidx.compose.ui.test.assertIsNotDisplayed
import androidx.compose.ui.test.isDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.longClick
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.onRoot
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performTextInput
import androidx.compose.ui.test.performTouchInput
import androidx.compose.ui.test.printToLog
import androidx.test.espresso.Espresso
import br.alexandregpereira.hunter.app.MainScreen
import org.junit.Rule
import org.junit.Test

class FolderListTest {

@get:Rule
val composeTestRule = createComposeRule()

@Test
fun folderDeletion() {
composeTestRule.setContent {
MainScreen()
}

composeTestRule.waitUntil(timeoutMillis = 5000) {
composeTestRule.onNodeWithText("Aboleth").isDisplayed()
}
composeTestRule.onNodeWithText("Aboleth").performClick()
composeTestRule.waitUntil(timeoutMillis = 5000) {
composeTestRule.onNodeWithContentDescription("MonsterOptions").isDisplayed()
}
composeTestRule.onNodeWithContentDescription("MonsterOptions").performClick()
composeTestRule.onNodeWithText("Add to Folder").performClick()
composeTestRule.onNodeWithText("Folder name").performTextInput("Folder Test")
composeTestRule.onNodeWithText("Save").performClick()
Espresso.pressBack()
composeTestRule.onNodeWithText("Folders").performClick()
composeTestRule.onNodeWithText("Folder Test").performTouchInput { longClick() }
composeTestRule.onNodeWithText("Delete").performClick()
composeTestRule.onNodeWithText("Folder Test").assertIsNotDisplayed()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@ class FolderListStateHolder internal constructor(

fun onItemSelectionDeleteClick() {
analytics.trackItemSelectionDeleteClick()
onItemSelectionClose()
flowOf(state.value.itemSelection)
.map { it.toList() }
.map { folderNames ->
removeMonsterFolders(folderNames).collect()
}
.flowOn(dispatcher)
.onEach { loadMonsterFolders() }
.onEach {
onItemSelectionClose()
loadMonsterFolders()
}
.launchIn(scope)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -77,7 +79,7 @@ fun MonsterTitleCompose(
end = contentPadding.calculateEndPadding(LayoutDirection.Rtl),
top = contentPadding.calculateTopPadding(),
bottom = contentPadding.calculateBottomPadding()
),
).semantics { contentDescription = "MonsterOptions" },
onOptionsClicked
)
}
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil_compose
compose-activity = { module = "androidx.activity:activity-compose", version.ref = "compose_activity" }
compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" }
compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
compose-ui-test = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" }
compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" }
compose-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
compose-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" }
compose-util = { module = "androidx.compose.ui:ui-util", version.ref = "compose" }
Expand Down

0 comments on commit 416bcbf

Please sign in to comment.