Skip to content

Commit

Permalink
Merge branch 'dev' into feat-search
Browse files Browse the repository at this point in the history
  • Loading branch information
alexymumo authored Mar 31, 2024
2 parents 5889357 + 3d086da commit 16fe9ee
Show file tree
Hide file tree
Showing 29 changed files with 746 additions and 27 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/android_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ jobs:
- name: Build with Gradle
run: ./gradlew build

- name: Upload coverage report to CodeCov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: alexymumo/News-App

- name: Upload a build artifact
uses: actions/upload-artifact@v3.1.3
with:
Expand Down
27 changes: 27 additions & 0 deletions .idea/androidTestResultsUserPreferences.xml

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

19 changes: 19 additions & 0 deletions .idea/deploymentTargetDropDown.xml

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

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![codecov](https://codecov.io/gh/alexymumo/News-App/graph/badge.svg?token=15AJMIDLLE)](https://codecov.io/gh/alexymumo/News-App)

## News-App
- News App is a multi-module news app built using Kotlin, Jetpack Compose and [News API]("https://newsapi.org/")

Expand Down
4 changes: 4 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ android {
"proguard-rules.pro"
)
}
debug {
enableAndroidTestCoverage = true
enableUnitTestCoverage = true
}
}

compileOptions {
Expand Down
21 changes: 12 additions & 9 deletions core/database/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,17 @@ dependencies {

implementation(libs.android.core)
implementation(libs.android.appcompat)
testImplementation(libs.junit)
androidTestImplementation(libs.expresso.core)
androidTestImplementation(libs.truth)
testImplementation(libs.truth)
androidTestImplementation(libs.core.testing)
implementation(libs.junit.androidx.ktx)
implementation(libs.core.ktx)
implementation(libs.core.test)

// Paging
implementation(libs.paging.runtime)

// Robolectric
testImplementation(libs.roboelectric)

// Coroutine
implementation(libs.bundles.coroutine)

// Room
testImplementation(libs.room.testing)
implementation(libs.room.paging)
implementation(libs.room.ktx)
api(libs.room.runtime)
Expand All @@ -69,4 +61,15 @@ dependencies {
// Hilt
implementation(libs.dagger.hilt)
kapt(libs.hilt.compiler)


testImplementation(libs.junit)
testImplementation(libs.truth)
testImplementation(libs.room.testing)
testImplementation(libs.roboelectric)

androidTestImplementation(libs.core.testing)
androidTestImplementation(libs.expresso.core)
androidTestImplementation(libs.truth)
androidTestImplementation(libs.junit)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright 2024 News-App
*
* 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 com.alexmumo.database.db

import android.content.Context
import androidx.room.Room
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.alexmumo.database.dao.ArticleDao
import com.alexmumo.database.dao.BookMarkDao
import com.alexmumo.database.dao.RemoteKeyDao
import com.alexmumo.database.entity.ArticleEntity
import com.alexmumo.database.entity.SourceEntity
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith

@OptIn(ExperimentalCoroutinesApi::class)
@RunWith(AndroidJUnit4::class)
class NewsDatabaseTest {

private lateinit var articleDao: ArticleDao
private lateinit var bookMarkDao: BookMarkDao
private lateinit var remoteKeyDao: RemoteKeyDao
private lateinit var newsDatabase: NewsDatabase

@Before
fun setUpDatabase() {
val context = ApplicationProvider.getApplicationContext<Context>()
newsDatabase = Room.inMemoryDatabaseBuilder(
context,
NewsDatabase::class.java
).build()
}

@Test
fun saveArticles_returns_a_listOf_articles() = runTest {
articleDao.saveArticles(articles)
val articles = articleDao.pagingSource()
assertThat(articles).isNotNull()
}

@Test
fun deleteArticles_returns_null() = runTest {
articleDao.saveArticles(articles)
val articles = articleDao.deleteArticles()
assertThat(articles).isNull()
}

@After
fun closeDatabase() {
newsDatabase.close()
}

companion object {
private val article = ArticleEntity(author = null, content = null, description = null, publishedAt = null, title = null, SourceEntity(id = null, name = ""), url = "", urlToImage = null)
val articles = listOf(article)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright 2024 News-App
*
* 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 com.alexmumo.datastore

class NewsPreferenceTest
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.nonTransitiveRClass=true
android.enableJetifier=true
16 changes: 9 additions & 7 deletions presentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,17 @@ android {

testOptions {
unitTests {
isIncludeAndroidResources = false
isIncludeAndroidResources = true
}
}

packaging {
resources.excludes.addAll(
listOf(
"META-INF/LICENSE.md",
"META-INF/LICENSE-notice.md"
)
)
}
buildTypes {
release {
isMinifyEnabled = false
Expand Down Expand Up @@ -112,8 +119,6 @@ dependencies {
// Splash - Screen
implementation(libs.splash.screen)

// Roboelectric
implementation(libs.roboelectric)

// Hilt
implementation(libs.dagger.hilt)
Expand All @@ -124,9 +129,6 @@ dependencies {
androidTestImplementation(libs.junit.ext)
debugImplementation(libs.compose.ui.test.manifest)




}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2024 News-App
*
* 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 com.alexmumo.presentation.data

import com.alexmumo.domain.model.Article
import com.alexmumo.domain.model.Source

val article = Article(
author = null,
content = null,
description = null,
publishedAt = null,
source = Source(
id = null,
name = ""
),
title = null,
url = "",
urlToImage = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ fun BookMarkScreen(
Scaffold(
topBar = {
TopAppBar(
modifier = Modifier.testTag("top_app_bar_test_tag"),
title = {
Text(
text = "BookMarks",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Card
import androidx.compose.material3.Divider
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
Expand Down Expand Up @@ -54,6 +53,7 @@ fun BookMarkCard(
.fillMaxWidth()
.height(150.dp)
.padding(4.dp)
.testTag("book_mark_card_tag")
.clickable {
// onNavigate(bookMarkEntity)
}
Expand Down Expand Up @@ -97,12 +97,14 @@ fun BookMarkCard(
}
}
Divider(
modifier = Modifier.fillMaxWidth(),
modifier = Modifier.fillMaxWidth()
.testTag("divider_tag"),
thickness = 1.dp,
color = MaterialTheme.colorScheme.onPrimary
)
}

/*
@Composable
fun BookMarkItem(
bookMarkEntity: BookMarkEntity
Expand Down Expand Up @@ -167,6 +169,7 @@ fun BookMarkItem(
}
}
}
*/

@Preview
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.alexmumo.common.convertStringToDate
import com.alexmumo.database.entity.BookMarkEntity
import com.alexmumo.domain.model.Article
import com.alexmumo.presentation.R
Expand Down Expand Up @@ -190,7 +189,8 @@ fun DetailScreen(
maxLines = 1,
fontSize = 16.sp,
color = Color.Green,
text = convertStringToDate(article.publishedAt ?: "UnKnown")
text = article.publishedAt ?: "Uknown"
// text = convertStringToDate(article.publishedAt ?: "UnKnown")
)
}
}
Expand All @@ -209,7 +209,8 @@ fun CustomLikeButton(
imageVector = Icons.Filled.FavoriteBorder, contentDescription = null,
modifier = Modifier
.height(30.dp)
.width(30.dp),
.width(30.dp)
.testTag("custom_like_tag"),
tint = if (bookmarked) {
Color.Magenta
} else {
Expand Down
Loading

0 comments on commit 16fe9ee

Please sign in to comment.