Skip to content

Commit a070a3a

Browse files
committed
merge
1 parent 5fa427e commit a070a3a

File tree

82 files changed

+5874
-580
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+5874
-580
lines changed

.github/workflows/deploy.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,20 @@ jobs:
2727
- name: Make gradlew executable
2828
run: chmod +x ./gradlew
2929

30-
- name: Execute Gradle command - assembleDebug
31-
run: ./gradlew assembleDebug
30+
- name: Debug and Test
31+
uses: ./.github/workflows/pull_request_push.yml
32+
33+
- name: build release
34+
run: ./gradlew assembleRelease --stackTrace
35+
36+
- name: list files
37+
run: ls -lrt app/build/outputs/apk/release
3238

3339
- name: Upload Artifact to Firebase App Distribution
3440
uses: wzieba/Firebase-Distribution-Github-Action@v1
3541
with:
3642
appId: ${{ secrets.FIREBASE_APP_ID }}
3743
serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
3844
groups: testers
39-
file: app/build/apk/debug/app-debug.apk
45+
file: app/build/outputs/apk/release/app-release-unsigned.apk
4046
releaseNotes: ${{ inputs.release_notes }}

.github/workflows/test_debug.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,12 @@ jobs:
2222
- name: Make gradlew executable
2323
run: chmod +x ./gradlew
2424

25-
- name: Execute Gradle command - testDebugUnitTest
26-
run: ./gradlew testDebugUnitTest
25+
- name: Execute Gradle command - unitTest
26+
run: ./gradlew testDebugUnitTest --continue
27+
28+
- name: Upload Test Reports
29+
if: ${{ always() }}
30+
uses: actions/[email protected]
31+
with:
32+
name: test-reports
33+
path: '**/build/reports/tests/'

.idea/androidTestResultsUserPreferences.xml

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/deploymentTargetSelector.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ dependencies {
7272
implementation(libs.firebase.auth.ktx)
7373
implementation(libs.firebase.firestore)
7474
testImplementation(libs.junit)
75+
androidTestImplementation("org.mockito:mockito-core:4.9.0")
7576
androidTestImplementation(libs.androidx.junit)
7677
androidTestImplementation(libs.androidx.espresso.core)
7778
androidTestImplementation(platform(libs.androidx.compose.bom))
@@ -98,4 +99,10 @@ dependencies {
9899
// Retrofit
99100
implementation ("com.squareup.retrofit2:retrofit:2.9.0")
100101
implementation ("com.squareup.retrofit2:converter-gson:2.9.0")
102+
103+
implementation ("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
104+
105+
// // Hilt Testing dependencies
106+
// androidTestImplementation("androidx.hilt:hilt-testing:1.0.0")
107+
// androidTestImplementation("com.google.dagger:hilt-android-testing:2.43.2")
101108
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package com.example.harmonyhub.components_test
2+
3+
import androidx.compose.ui.test.assertIsDisplayed
4+
import androidx.compose.ui.test.junit4.createComposeRule
5+
import androidx.compose.ui.test.onNodeWithTag
6+
import androidx.compose.ui.test.onNodeWithText
7+
import androidx.test.ext.junit.runners.AndroidJUnit4
8+
import com.example.harmonyhub.ui.components.AlbumCard
9+
import org.junit.Rule
10+
import org.junit.Test
11+
import org.junit.runner.RunWith
12+
13+
@RunWith(AndroidJUnit4::class)
14+
class AlbumCardTest {
15+
16+
@get:Rule
17+
val composeTestRule = createComposeRule()
18+
19+
@Test
20+
fun albumCard_displaysSongNameAndArtistsCorrectly() {
21+
val songName = "Shape of You"
22+
val albumImg = "https://example.com/sample_image.jpg"
23+
val id = "1"
24+
val listArtist = listOf("Ed Sheeran")
25+
26+
composeTestRule.setContent {
27+
AlbumCard(
28+
songName = songName,
29+
albumImg = albumImg,
30+
id = id,
31+
listArtist = listArtist
32+
)
33+
}
34+
35+
// Kiểm tra sự tồn tại của AlbumCard thông qua TestTag
36+
composeTestRule
37+
.onNodeWithTag("AlbumCard")
38+
.assertExists()
39+
40+
// Kiểm tra hiển thị songName và nghệ sĩ
41+
composeTestRule
42+
.onNodeWithText(songName)
43+
.assertIsDisplayed()
44+
45+
composeTestRule
46+
.onNodeWithText("Ed Sheeran")
47+
.assertIsDisplayed()
48+
}
49+
50+
51+
@Test
52+
fun albumCard_handlesMultipleArtistsCorrectly() {
53+
val songName = "Chìm Sâu"
54+
val albumImg = "https://example.com/sample_image2.jpg"
55+
val id = "2"
56+
val listArtist = listOf("RPT MCK", "Trung Trần")
57+
58+
composeTestRule.setContent {
59+
AlbumCard(
60+
songName = songName,
61+
albumImg = albumImg,
62+
id = id,
63+
listArtist = listArtist
64+
)
65+
}
66+
67+
// Kiểm tra danh sách nghệ sĩ ghép đúng
68+
composeTestRule
69+
.onNodeWithText("RPT MCK, Trung Trần")
70+
.assertIsDisplayed()
71+
}
72+
73+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.example.harmonyhub.components_test
2+
3+
import androidx.compose.ui.test.assert
4+
import androidx.compose.ui.test.assertIsDisplayed
5+
import androidx.compose.ui.test.hasText
6+
import androidx.compose.ui.test.junit4.createComposeRule
7+
import androidx.compose.ui.test.onNodeWithContentDescription
8+
import androidx.compose.ui.test.onNodeWithText
9+
import androidx.compose.ui.test.performClick
10+
import com.example.harmonyhub.ui.components.ArtistsCard
11+
import org.junit.Rule
12+
import org.junit.Test
13+
14+
15+
class ArtistsCardTest {
16+
17+
@get:Rule
18+
val composeTestRule = createComposeRule()
19+
20+
21+
22+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.example.harmonyhub.components_test
2+
3+
import androidx.compose.ui.test.assertIsDisplayed
4+
import androidx.compose.ui.test.junit4.createComposeRule
5+
import androidx.compose.ui.test.onNodeWithText
6+
import androidx.compose.ui.test.performClick
7+
import androidx.compose.ui.test.onNodeWithContentDescription
8+
import com.example.harmonyhub.ui.components.ChartCard
9+
import org.junit.Rule
10+
import org.junit.Test
11+
12+
class ChartCardTest {
13+
14+
@get:Rule
15+
val composeTestRule = createComposeRule()
16+
17+
@Test
18+
fun testChartCardDisplay() {
19+
val chartImg = "https://example.com/chart_image.jpg"
20+
val chartName = "Top 100 Chart"
21+
val chartId = "1"
22+
23+
composeTestRule.setContent {
24+
ChartCard(
25+
chartImg = chartImg,
26+
chartName = chartName,
27+
chartId = chartId
28+
)
29+
}
30+
31+
// Kiểm tra xem ảnh có được tải và hiển thị đúng không
32+
composeTestRule.onNodeWithContentDescription("Photo")
33+
.assertExists() // Kiểm tra nếu ảnh hiển thị
34+
35+
}
36+
37+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.example.harmonyhub.components_test
2+
3+
import androidx.compose.ui.test.assertIsDisplayed
4+
import androidx.compose.ui.test.junit4.createComposeRule
5+
import androidx.compose.ui.test.onNodeWithText
6+
import androidx.compose.ui.test.performClick
7+
import com.example.harmonyhub.ui.components.GenreCard
8+
import org.junit.Rule
9+
import org.junit.Test
10+
11+
class GenreCardTest {
12+
13+
@get:Rule
14+
val composeTestRule = createComposeRule()
15+
16+
@Test
17+
fun testGenreCardDisplay() {
18+
// Thiết lập nội dung cho composable GenreCard
19+
composeTestRule.setContent {
20+
GenreCard(genre = "Pop")
21+
}
22+
23+
// Kiểm tra xem GenreCard có hiển thị đúng không (bằng cách tìm text trên card)
24+
composeTestRule.onNodeWithText("Pop")
25+
.assertIsDisplayed()
26+
}
27+
28+
@Test
29+
fun testGenreCardClickAction() {
30+
// Thiết lập nội dung cho composable GenreCard
31+
composeTestRule.setContent {
32+
GenreCard(genre = "Pop")
33+
}
34+
35+
// Kiểm tra hành động nhấp vào card
36+
composeTestRule.onNodeWithText("Pop")
37+
.performClick()
38+
}
39+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//package com.example.harmonyhub.components_test
2+
//
3+
//import androidx.compose.ui.test.assertIsDisplayed
4+
//import androidx.compose.ui.test.junit4.createComposeRule
5+
//import androidx.compose.ui.test.onNodeWithText
6+
//import androidx.compose.ui.test.performClick
7+
//import com.example.harmonyhub.ui.components.PlaylistCard
8+
//import com.example.harmonyhub.ui.components.Playlist
9+
//import org.junit.Rule
10+
//import org.junit.Test
11+
//
12+
//class PlaylistCardTest {
13+
//
14+
// @get:Rule
15+
// val composeTestRule = createComposeRule()
16+
//
17+
// @Test
18+
// fun testPlaylistCardDisplay() {
19+
// // Thiết lập nội dung cho composable PlaylistCard
20+
// val playlist = Playlist(name = "Top Hits", img = com.example.harmonyhub.R.drawable.v)
21+
// composeTestRule.setContent {
22+
// PlaylistCard(playlist = playlist, onClick = {})
23+
// }
24+
//
25+
// // Kiểm tra xem tên playlist có hiển thị trên card không
26+
// composeTestRule.onNodeWithText("Top Hits")
27+
// .assertIsDisplayed()
28+
// }
29+
//
30+
// @Test
31+
// fun testPlaylistCardClickAction() {
32+
// // Thiết lập nội dung cho composable PlaylistCard
33+
// val playlist = Playlist(name = "Top Hits", img = com.example.harmonyhub.R.drawable.v)
34+
// var clicked = false
35+
// composeTestRule.setContent {
36+
// PlaylistCard(playlist = playlist, onClick = { clicked = true })
37+
// }
38+
//
39+
// // Mô phỏng hành động nhấp vào card
40+
// composeTestRule.onNodeWithText("Top Hits")
41+
// .performClick()
42+
//
43+
// // Kiểm tra xem hành động nhấp vào có được thực thi không
44+
// assert(clicked)
45+
// }
46+
//}

0 commit comments

Comments
 (0)