Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
minhnhatdeii committed Dec 12, 2024
1 parent 5fa427e commit a070a3a
Show file tree
Hide file tree
Showing 82 changed files with 5,874 additions and 580 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,20 @@ jobs:
- name: Make gradlew executable
run: chmod +x ./gradlew

- name: Execute Gradle command - assembleDebug
run: ./gradlew assembleDebug
- name: Debug and Test
uses: ./.github/workflows/pull_request_push.yml

- name: build release
run: ./gradlew assembleRelease --stackTrace

- name: list files
run: ls -lrt app/build/outputs/apk/release

- name: Upload Artifact to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action@v1
with:
appId: ${{ secrets.FIREBASE_APP_ID }}
serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
groups: testers
file: app/build/apk/debug/app-debug.apk
file: app/build/outputs/apk/release/app-release-unsigned.apk
releaseNotes: ${{ inputs.release_notes }}
11 changes: 9 additions & 2 deletions .github/workflows/test_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,12 @@ jobs:
- name: Make gradlew executable
run: chmod +x ./gradlew

- name: Execute Gradle command - testDebugUnitTest
run: ./gradlew testDebugUnitTest
- name: Execute Gradle command - unitTest
run: ./gradlew testDebugUnitTest --continue

- name: Upload Test Reports
if: ${{ always() }}
uses: actions/[email protected]
with:
name: test-reports
path: '**/build/reports/tests/'
26 changes: 26 additions & 0 deletions .idea/androidTestResultsUserPreferences.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ dependencies {
implementation(libs.firebase.auth.ktx)
implementation(libs.firebase.firestore)
testImplementation(libs.junit)
androidTestImplementation("org.mockito:mockito-core:4.9.0")
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
Expand All @@ -98,4 +99,10 @@ dependencies {
// Retrofit
implementation ("com.squareup.retrofit2:retrofit:2.9.0")
implementation ("com.squareup.retrofit2:converter-gson:2.9.0")

implementation ("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")

// // Hilt Testing dependencies
// androidTestImplementation("androidx.hilt:hilt-testing:1.0.0")
// androidTestImplementation("com.google.dagger:hilt-android-testing:2.43.2")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package com.example.harmonyhub.components_test

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.test.ext.junit.runners.AndroidJUnit4
import com.example.harmonyhub.ui.components.AlbumCard
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class AlbumCardTest {

@get:Rule
val composeTestRule = createComposeRule()

@Test
fun albumCard_displaysSongNameAndArtistsCorrectly() {
val songName = "Shape of You"
val albumImg = "https://example.com/sample_image.jpg"
val id = "1"
val listArtist = listOf("Ed Sheeran")

composeTestRule.setContent {
AlbumCard(
songName = songName,
albumImg = albumImg,
id = id,
listArtist = listArtist
)
}

// Kiểm tra sự tồn tại của AlbumCard thông qua TestTag
composeTestRule
.onNodeWithTag("AlbumCard")
.assertExists()

// Kiểm tra hiển thị songName và nghệ sĩ
composeTestRule
.onNodeWithText(songName)
.assertIsDisplayed()

composeTestRule
.onNodeWithText("Ed Sheeran")
.assertIsDisplayed()
}


@Test
fun albumCard_handlesMultipleArtistsCorrectly() {
val songName = "Chìm Sâu"
val albumImg = "https://example.com/sample_image2.jpg"
val id = "2"
val listArtist = listOf("RPT MCK", "Trung Trần")

composeTestRule.setContent {
AlbumCard(
songName = songName,
albumImg = albumImg,
id = id,
listArtist = listArtist
)
}

// Kiểm tra danh sách nghệ sĩ ghép đúng
composeTestRule
.onNodeWithText("RPT MCK, Trung Trần")
.assertIsDisplayed()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.harmonyhub.components_test

import androidx.compose.ui.test.assert
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import com.example.harmonyhub.ui.components.ArtistsCard
import org.junit.Rule
import org.junit.Test


class ArtistsCardTest {

@get:Rule
val composeTestRule = createComposeRule()



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.example.harmonyhub.components_test

import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.onNodeWithContentDescription
import com.example.harmonyhub.ui.components.ChartCard
import org.junit.Rule
import org.junit.Test

class ChartCardTest {

@get:Rule
val composeTestRule = createComposeRule()

@Test
fun testChartCardDisplay() {
val chartImg = "https://example.com/chart_image.jpg"
val chartName = "Top 100 Chart"
val chartId = "1"

composeTestRule.setContent {
ChartCard(
chartImg = chartImg,
chartName = chartName,
chartId = chartId
)
}

// Kiểm tra xem ảnh có được tải và hiển thị đúng không
composeTestRule.onNodeWithContentDescription("Photo")
.assertExists() // Kiểm tra nếu ảnh hiển thị

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.example.harmonyhub.components_test

import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import com.example.harmonyhub.ui.components.GenreCard
import org.junit.Rule
import org.junit.Test

class GenreCardTest {

@get:Rule
val composeTestRule = createComposeRule()

@Test
fun testGenreCardDisplay() {
// Thiết lập nội dung cho composable GenreCard
composeTestRule.setContent {
GenreCard(genre = "Pop")
}

// Kiểm tra xem GenreCard có hiển thị đúng không (bằng cách tìm text trên card)
composeTestRule.onNodeWithText("Pop")
.assertIsDisplayed()
}

@Test
fun testGenreCardClickAction() {
// Thiết lập nội dung cho composable GenreCard
composeTestRule.setContent {
GenreCard(genre = "Pop")
}

// Kiểm tra hành động nhấp vào card
composeTestRule.onNodeWithText("Pop")
.performClick()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//package com.example.harmonyhub.components_test
//
//import androidx.compose.ui.test.assertIsDisplayed
//import androidx.compose.ui.test.junit4.createComposeRule
//import androidx.compose.ui.test.onNodeWithText
//import androidx.compose.ui.test.performClick
//import com.example.harmonyhub.ui.components.PlaylistCard
//import com.example.harmonyhub.ui.components.Playlist
//import org.junit.Rule
//import org.junit.Test
//
//class PlaylistCardTest {
//
// @get:Rule
// val composeTestRule = createComposeRule()
//
// @Test
// fun testPlaylistCardDisplay() {
// // Thiết lập nội dung cho composable PlaylistCard
// val playlist = Playlist(name = "Top Hits", img = com.example.harmonyhub.R.drawable.v)
// composeTestRule.setContent {
// PlaylistCard(playlist = playlist, onClick = {})
// }
//
// // Kiểm tra xem tên playlist có hiển thị trên card không
// composeTestRule.onNodeWithText("Top Hits")
// .assertIsDisplayed()
// }
//
// @Test
// fun testPlaylistCardClickAction() {
// // Thiết lập nội dung cho composable PlaylistCard
// val playlist = Playlist(name = "Top Hits", img = com.example.harmonyhub.R.drawable.v)
// var clicked = false
// composeTestRule.setContent {
// PlaylistCard(playlist = playlist, onClick = { clicked = true })
// }
//
// // Mô phỏng hành động nhấp vào card
// composeTestRule.onNodeWithText("Top Hits")
// .performClick()
//
// // Kiểm tra xem hành động nhấp vào có được thực thi không
// assert(clicked)
// }
//}
Loading

0 comments on commit a070a3a

Please sign in to comment.