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

[Bug] Fix root cause that caused StatsGranularTabsTest to fail. #20606

Merged
merged 9 commits into from
Apr 17, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import dagger.hilt.android.testing.HiltAndroidTest
import org.junit.After
import org.junit.Assume.assumeTrue
import org.junit.Before
import org.junit.Ignore
import org.junit.Test
import org.wordpress.android.BuildConfig
import org.wordpress.android.R
import org.wordpress.android.e2e.pages.MySitesPage
import org.wordpress.android.rules.Retry
import org.wordpress.android.support.BaseTest
import org.wordpress.android.support.ComposeEspressoLink
import org.wordpress.android.support.WPSupportUtils
Expand All @@ -38,7 +36,6 @@ class StatsGranularTabsTest : BaseTest() {
}
}

@Ignore("The 'Days' screen might occasionally not load. Disabled until tests rerun is implemented.")
@Test
fun e2eAllDayStatsLoad() {
val todayVisits = StatsVisitsData("97", "28", "14", "11")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ abstract class BaseStatsUseCase<DOMAIN_MODEL, UI_STATE>(
if (!state.cached) {
val updatedCachedData = loadCachedData()
if (domainModel != updatedCachedData) {
domainModel = updatedCachedData
domainModel = state.model
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean the whole if{} block is redundant here?!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first glance, the answer is that its not redundant. Not because of my change, but because of the updateState(). If the state values are the same, I imagine we don't want to fire a call to updateState. But this is where your input will matter as there may be details about fluxc I don't fully understand. Presumably, if we are using a data class, which I believe we do for those models, data from the cache can equal data from the web. Basing this solely off the docs. I could be wrong. Your thoughts 😄 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FluxC is also long before my time!

Wdyt? @irfano

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know what. I also just realized that I see why you are saying that. domainModel != updatedCachedData is confusing. It should be domainModel != state. Does that make more sense @ravishanker ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know what. I also just realized that I see why you are saying that. domainModel != updatedCachedData is confusing. It should be domainModel != state. Does that make more sense @ravishanker ?

Yes! We can remove val updatedCachedData = loadCachedData() line and check domainModel != state

updateState()
}
}
Expand Down
Loading