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

v1.1 with new mocky identifier #19

Merged
merged 8 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ android {
applicationId = "com.shahin.bookmine"
minSdk = libs.versions.minSdkVersion.get().toInt()
targetSdk = libs.versions.targetSdkVersion.get().toInt()
versionCode = 1
versionName = "1.0"
versionCode = 2
versionName = "1.1"

buildConfigField ("String", "MOCKY_IDENTIFIER", "\"c7738499-6a6d-49f4-a747-e293c7ee0fea\"")
buildConfigField ("String", "MOCKY_IDENTIFIER", "\"c23ee969-4e7c-40c3-9721-9c59b56346e0\"")

testInstrumentationRunner = "com.shahin.bookmine.HiltTestRunner"
vectorDrawables {
Expand Down
Binary file added app/release/baselineProfiles/0/app-release.dm
Binary file not shown.
Binary file added app/release/baselineProfiles/1/app-release.dm
Binary file not shown.
37 changes: 37 additions & 0 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.shahin.bookmine",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
],
"elementType": "File",
"baselineProfiles": [
{
"minApi": 28,
"maxApi": 30,
"baselineProfiles": [
"baselineProfiles/1/app-release.dm"
]
},
{
"minApi": 31,
"maxApi": 2147483647,
"baselineProfiles": [
"baselineProfiles/0/app-release.dm"
]
}
],
"minSdkVersionForDexing": 23
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ class AppNavHostTest {

@Test
fun navigateToBookDetailsScreen() = runTest {
Thread.sleep(5000) // wait for some items to load
Thread.sleep(6000) // wait for some items to load

composeTestRule.onAllNodesWithTag("books-screen")[0] // first item - whatever it is
.performClick() // click on the first item

Thread.sleep(1000) // wait a second for the details screen to show up

composeTestRule.onNodeWithTag("book-details-screen")
.assertIsDisplayed()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,21 @@ class BooksDaoTest {
placeholdersEnabled = false
)
)

// sizes should be the same since we have 3 items with "Book" in their title
assertEquals(
listOf(dummyBooks[0], dummyBooks[1], dummyBooks[2]),
(result as PagingSource.LoadResult.Page).data
dummyBooks.size,
(result as PagingSource.LoadResult.Page).data.size
)

// and the first item should the BookEntity with id = 3
assertEquals(
3, // expected id the 3
(result as PagingSource.LoadResult.Page).data[0].id
)
assertEquals(
dummyBooks[2].id,
(result as PagingSource.LoadResult.Page).data[0].id
)
}

Expand Down Expand Up @@ -132,9 +144,18 @@ class BooksDaoTest {
placeholdersEnabled = false
)
)

// since a new reordering is added to the dao we'll have a slightly different expected list
// Reordering is from oldest to newest, so the first item should be [id = 3]
assertEquals(
dummyBooks[2].id,
(allBooksResult as PagingSource.LoadResult.Page).data[0].id
)

// now for checking if we're getting all the results we should just check the size
assertEquals(
dummyBooks,
(allBooksResult as PagingSource.LoadResult.Page).data
dummyBooks.size,
(allBooksResult as PagingSource.LoadResult.Page).data.size
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,20 @@ interface BooksDao {
* [getBooksByTitle] returns all [BookEntity]s when [title] is empty and not blank
*/
@Transaction
@Query(" SELECT * FROM books WHERE title LIKE '%' || :title || '%' ")
@Query("""
SELECT * FROM books
WHERE title LIKE '%' || :title || '%'
ORDER BY
CASE
WHEN release_date LIKE '% BC' THEN -CAST(SUBSTR(release_date, 1, LENGTH(release_date) - 3) AS INT)
ELSE CAST(SUBSTR(release_date, -4) AS INT)
END DESC,
CASE
WHEN release_date LIKE '%/%/%' THEN STRFTIME('%Y-%m-%d', release_date)
ELSE STRFTIME('%Y-01-01', release_date || '-01-01')
END DESC,
id ASC
""")
fun getBooksByTitle(title: String): PagingSource<Int, BookEntity>

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
Expand Down Expand Up @@ -322,7 +323,7 @@ private fun DetailsScreenContent(
modifier = Modifier.testTag("details-author"),
text = buildAnnotatedString {
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
append("Author:")
append(stringResource(R.string.author))
}
append(" ")
append(bookDetails?.author.orEmpty())
Expand Down
4 changes: 4 additions & 0 deletions feature/book_details/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="author">Author:</string>
</resources>
Loading