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

Dashboard Cards: Display 3 latest pages card #18337

Merged
merged 32 commits into from
May 1, 2023
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
79d8891
Adds: style for pages item title in pages card
AjeshRPai Apr 11, 2023
bf0bfae
+ Adds:the logic to get the status text for pages item
AjeshRPai Apr 28, 2023
2150760
+ Adds:the logic to get the status icon for pages item
AjeshRPai Apr 28, 2023
a5ee320
Fixes: the string value of PagesCardContentType
AjeshRPai Apr 28, 2023
f067c12
* Updates: the status mapping card builder
AjeshRPai Apr 28, 2023
da3a02a
Adds: test for published status check
AjeshRPai Apr 28, 2023
6138662
+ Adds: test for page status - draft and scheduled
AjeshRPai Apr 28, 2023
d25f87d
* Updates: the logic of building the create Page card
AjeshRPai Apr 28, 2023
225bed9
Updates: the logic of mapping the pages items
AjeshRPai Apr 28, 2023
7a53f65
[WIP] Adds: logic for setting the status icon and text
AjeshRPai Apr 28, 2023
a176707
Updates: function statement for readability
AjeshRPai Apr 28, 2023
fae312a
Updates: text style for status and updates color of published icon
AjeshRPai Apr 29, 2023
1a6621c
Adds: text view for last edited time or scheduled time
AjeshRPai Apr 29, 2023
9d469bf
Adds: long title in preview to check how long title behave
AjeshRPai Apr 29, 2023
e7bc21e
[WIP] + Adds: the logic for showing the last edited or scheduled time
AjeshRPai Apr 29, 2023
8702d9f
+ Adds: Missing dependency for builder in test class
AjeshRPai Apr 29, 2023
b4a3d6c
* Updates: getLastEditedOrScheduledTime fun to make it readable
AjeshRPai Apr 29, 2023
574b12e
+ Adds: UI string import statically for readability
AjeshRPai May 1, 2023
b3aaeea
+ Adds: the logic to show scheduled date in relative time span
AjeshRPai May 1, 2023
6c04275
- Removes: Unneeded UiString from the statement and import
AjeshRPai May 1, 2023
daf67c8
+ Adds: UI string import statically for readability
AjeshRPai May 1, 2023
45449c1
+ Adds: test for relative time shown on card
AjeshRPai May 1, 2023
6e648d5
* Updates: statements and models used in test class
AjeshRPai May 1, 2023
ff7e61f
+ Adds: PagesCardBuilderParams import statically for readability
AjeshRPai May 1, 2023
8009e5a
+ Adds: Helper for PagesCardBuilderParams function to test class
AjeshRPai May 1, 2023
b4269b0
*[WIP] Updates: the xml for Pages item in pages card
AjeshRPai May 1, 2023
61b94fd
* Updates: the naming of icon resources used to show status of page
AjeshRPai May 1, 2023
da70b14
* Implements: the background for page status text view in light/dark
AjeshRPai May 1, 2023
51dd6dd
* Implements: the colors for pages card components in light/dark
AjeshRPai May 1, 2023
1113efc
^ Replaces: hardcoded dimensions in pages_item with values from dimens
AjeshRPai May 1, 2023
2d7358c
* Fixes: Relative time not shown in minutes
AjeshRPai May 1, 2023
ffbe3fe
Refactor: reduce the length of the data path
zwarm May 1, 2023
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
Prev Previous commit
Next Next commit
+ Adds: Missing dependency for builder in test class
* Makes test statement shorter to fix lint errors
+ Adds mock for date time utils wrapper dependancy
  • Loading branch information
AjeshRPai committed Apr 29, 2023
commit 8702d9fea76eb96c16f291506d0d5542caac92b6
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import org.junit.Before
import org.junit.Test
import org.mockito.Mock
import org.mockito.kotlin.any
import org.mockito.kotlin.whenever
import org.wordpress.android.BaseUnitTest
import org.wordpress.android.R
Expand All @@ -13,10 +14,10 @@ import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.DashboardCards.Das
import org.wordpress.android.ui.mysite.MySiteCardAndItemBuilderParams
import org.wordpress.android.ui.mysite.MySiteCardAndItemBuilderParams.PagesCardBuilderParams.PagesItemClickParams
import org.wordpress.android.ui.utils.UiString
import org.wordpress.android.util.DateTimeUtilsWrapper
import org.wordpress.android.util.config.DashboardCardPagesConfig
import kotlin.test.assertEquals


const val PAGE_STATUS_PUBLISH = "publish"
const val PAGE_STATUS_DRAFT = "draft"
const val PAGE_STATUS_SCHEDULED = "future"
Expand Down Expand Up @@ -61,14 +62,22 @@ class PagesCardBuilderTest : BaseUnitTest() {
@Mock
private lateinit var dashboardCardPagesConfig: DashboardCardPagesConfig

@Mock
private lateinit var dateTimeUtilsWrapper: DateTimeUtilsWrapper

private lateinit var builder: PagesCardBuilder

private val onPagesCardFooterClick: () -> Unit = { }
private val onPagesItemClick: (params: PagesItemClickParams) -> Unit = {}

@Before
fun build() {
builder = PagesCardBuilder(dashboardCardPagesConfig)
builder = PagesCardBuilder(dashboardCardPagesConfig, dateTimeUtilsWrapper)
setupMocks()
}

private fun setupMocks() {
whenever(dateTimeUtilsWrapper.javaDateToTimeSpan(any())).thenReturn("")
}

@Test
Expand Down Expand Up @@ -100,7 +109,7 @@ class PagesCardBuilderTest : BaseUnitTest() {
}

@Test
fun `given there is a page with published status, when card is built, then pages item has published icon and text`() {
fun `given a page with published status, when card is built, then pages item has published icon and text`() {
whenever(dashboardCardPagesConfig.isEnabled()).thenReturn(true)
val params = MySiteCardAndItemBuilderParams.PagesCardBuilderParams(
pageCard = PAGES_MODEL,
Expand All @@ -110,8 +119,8 @@ class PagesCardBuilderTest : BaseUnitTest() {

val result = builder.build(params) as PagesCardWithData

assertEquals(UiString.UiStringRes(R.string.dashboard_card_page_item_status_published),result.pages[0].status)
assertEquals(R.drawable.ic_published_page_dashboard_card,result.pages[0].statusIcon)
assertEquals(UiString.UiStringRes(R.string.dashboard_card_page_item_status_published), result.pages[0].status)
assertEquals(R.drawable.ic_published_page_dashboard_card, result.pages[0].statusIcon)
}

@Test
Expand All @@ -125,12 +134,12 @@ class PagesCardBuilderTest : BaseUnitTest() {

val result = builder.build(params) as PagesCardWithData

assertEquals(UiString.UiStringRes(R.string.dashboard_card_page_item_status_draft),result.pages[1].status)
assertEquals(R.drawable.ic_draft_page_draft_dashboard_card,result.pages[1].statusIcon)
assertEquals(UiString.UiStringRes(R.string.dashboard_card_page_item_status_draft), result.pages[1].status)
assertEquals(R.drawable.ic_draft_page_draft_dashboard_card, result.pages[1].statusIcon)
}

@Test
fun `given there is a page with scheduled status, when card is built, then pages item has scheduled icon and text`() {
fun `given a page with scheduled status, when card is built, then pages item has scheduled icon and text`() {
whenever(dashboardCardPagesConfig.isEnabled()).thenReturn(true)
val params = MySiteCardAndItemBuilderParams.PagesCardBuilderParams(
pageCard = PAGES_MODEL_3,
Expand All @@ -140,8 +149,8 @@ class PagesCardBuilderTest : BaseUnitTest() {

val result = builder.build(params) as PagesCardWithData

assertEquals(UiString.UiStringRes(R.string.dashboard_card_page_item_status_scheduled),result.pages[2].status)
assertEquals(R.drawable.ic_scheduled_page_dashboard_card,result.pages[2].statusIcon)
assertEquals(UiString.UiStringRes(R.string.dashboard_card_page_item_status_scheduled), result.pages[2].status)
assertEquals(R.drawable.ic_scheduled_page_dashboard_card, result.pages[2].statusIcon)
}

/* CREATE NEW PAGE CARD CASES */
Expand Down