Implement Compose-based Error Panel, Error UI Model, and Tests for Comments#12404
Conversation
|
@Stypox Apologies for the fairly large diff—thought it would make sense to add a new Compose-based ErrorPanel and have it wired up end-to-end as a first step towards migration. I’m happy to split it up or tweak anything to fit the overall architecture—just let me know! |
Stypox
left a comment
There was a problem hiding this comment.
Thank you! I think this PR is the right size, and also you wrote many tests which increase the "PR line count" but do not add reviewing complexity, so there is no need to split it. And thanks for also writing test! I left a few comments to try to make the code more general so it can be used more seamlessly in other places in the app in the future (to replace other error panels in various places).
|
@Stypox I have incorporated your requests - removed the other files and just added one test file. Also I didn't want to add an additional dependency for compose testing but please let me know if you'd like me to! |
@SttApollo Tbh I have no qualms with you adding compose testing, because we are going to be adding UI tests very soon anyway. Currently we have no UI tests whatsoever, and I don't really see a downside to having tests for new functionality. @Stypox, thoughts? |
|
Yeah it would be cool if you added some tests! Would you be ok with opening a new PR after this one is merged, to setup the UI tests infrastructure and add tests for what you added in this PR? Otherwise you can also add UI tests in this PR, let us know what you prefer :-) |
|
Sure, I can open a new PR after this one is merged. For the UI test infra, I was thinking we could start with Compose instrumented testing—does that align with what you had in mind? Or should we also add Robolectric-based Compose tests and/or snapshot testing early on? |
98b3a7f to
c9fab2b
Compare
c9fab2b to
e27c7ed
Compare
…ented test compatibility
…rPanel.kt Co-authored-by: Isira Seneviratne <31027858+Isira-Seneviratne@users.noreply.github.com>
…nt/CommentSection.kt Co-authored-by: Isira Seneviratne <31027858+Isira-Seneviratne@users.noreply.github.com>
…nt/CommentSection.kt Co-authored-by: Isira Seneviratne <31027858+Isira-Seneviratne@users.noreply.github.com>
- Moved from androidTest to test directory - Removed Android test runner dependencies - Renamed to CommentSectionErrorTest - Addresses PR feedback until Compose testing is in place
Stypox
left a comment
There was a problem hiding this comment.
Looks good to me, thank you! I pushed two commits for correctly handling Locale-based ContextCompat.getString() in @Previews (otherwise some previews wouldn't be shown for me), and reordered the buttons to Recaptcha/Report, Retry, OpenInBrowser.
|
@absurdlylongusername feel free to merge if you are also ok with the changes, and then add the PR title + number to the |
|
Not to the 0.28.1 draft, but the refactor one, please :) |
|
Hi @SttApollo, sorry for late response. Thanks for your work thus far.
I'd prefer them to be in this PR, but ultimately up to you which you want: I just want them to be done ASAP. Ideally I don't want them being in a different PR to delay them being done, so I'm hoping you would have already started working on them, but if not then I guess it doesn't matter lol. Just to confirm I understand the purpose of this PR: the purpose is to add an error panel specifically for the comments section as stated in #11716, right? The ErrorPanel.kt that was added is not intended to replace the existing error_panel.xml at a later date, is it? Because if so, it doesn't have the same structure (i.e. error_panel.xml has three text fields as you can see in the image, but ErrorPanel.kt only has one)
This is fine. Would you be testing just Was also going to suggest improving the ErrorPanel previews so that they show all the buttons, or have multiple previews for each expected code path; but @Stypox has just done that. I'd also suggest having a preview for light and dark mode like we have in many other places. I.e. adding this to ErrorPanel preview @Preview(
name = "Light mode",
showBackground = true,
uiMode = Configuration.UI_MODE_NIGHT_NO
)
@Preview(
name = "Dark mode",
showBackground = true,
uiMode = Configuration.UI_MODE_NIGHT_YES
) |
|
@absurdlylongusername this is meant to completely replace error_panel.xml. It only has one text field, yes, but that's to reflect the fact that now the error message is chosen by the ErrorInfo instead of by the UI. Sure, we could add "getMainMessage()", "getSubmessage()", etc. to ErrorInfo, but I don't think it's worth it (the second and third lines of text were only used for a couple of errors even before). |
Yes np, I'll add them to this PR in the next day or two.
It is intendend to replace the xml in the future as Stypox mentioned.
This is my plan so far
Yes, will add this too. |
|
@SttApollo @Stypox Okay cool, fantastic |
Is there an issue currently to track replacing errorpanel.xml in the rest of the code? |
No, because we want to replace every But maybe this is a special case, where it would make sense to have an issue lying around that can be worked on. But what I think makes more sense is to just use the Compose error panel whenever converting a screen to Compose (I included this in #12674 for lists). |
Touché, lol.
Yeah I'm more talking about noting this down somewhere so that it is documented. Idk where though. |
|
@absurdlylongusername I ended up adding an inline |
245ef89 to
9d3ac1b
Compare
3c748e8 to
a31c26e
Compare
|
@SttApollo You seem to have reverted @Stypox's changes in aed4278. Please restore them. |
e56fc4b to
25e96d5
Compare
|
LTGM! |

What is it?
Description of the changes in your PR
ErrorPanelcomponent.MaterialTheme.colorSchemeand that all text is centered for visual parity with the legacy design.ErrorUiModelinterface to represent different failure states along withUnableToLoadCommentsUiModelspecific to Comments section.ErrorUiModeland Integration tests for the two main error states in the comment section:Resource.Error(initial load failure) andLoadState.Error(paging failure). Would add Compose testing with approval to add a new dependency.CommentsViewModel(Resource.Error) andCommentsSource(LoadState.Error) to ensure proper UI rendering and error model mapping.Before/After Screenshots/Screen Record
Fixes the following issue(s)
APK testing
The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.