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

Mark as resolved/unresolved prep 2 #1306

Merged
merged 19 commits into from
Jan 28, 2025

Conversation

chrisbobbe
Copy link
Collaborator

Here are the commits from #1301 that are just about refactoring the action-sheet tests. I've revised them for Zixuan's review #1301 (review) ; in particular by just removing an assert(() {}()) wrapper (which isn't needed because it's only running in tests).

@chrisbobbe chrisbobbe added the integration review Added by maintainers when PR may be ready for integration label Jan 24, 2025
@chrisbobbe chrisbobbe requested a review from gnprice January 24, 2025 23:35
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks! A few small comments below — otherwise these test changes all look good.

Then I think you meant to leave the last 3 commit out of this PR, right? They'll be for #1301.

Comment on lines 150 to 153
final channelIdsWithUnreads = store.unreads.streams.keys;
final topicWithUnreads = channelIdsWithUnreads.firstWhereOrNull((streamId) =>
store.unreads.countInTopicNarrow(streamId, TopicName(topic)) > 0);
if (topicWithUnreads == null) {
Copy link
Member

Choose a reason for hiding this comment

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

The name topicWithUnreads doesn't seem to match what this does — it ends up taking the value of a channel ID.

Perhaps use any instead of firstWhereOrNull?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah indeed, and hasTopicWithUnreads for the variable name.

StreamMessage? message,
}) async {
final effectiveMessage = message ?? someMessage;
assert(effectiveMessage.topic.apiName == topic);
Copy link
Member

Choose a reason for hiding this comment

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

Can this function skip taking topic as a parameter, and just get it from the message?

Future<void> showFromAppBar(WidgetTester tester, {
ZulipStream? channel,
String topic = someTopic,
Iterable<StreamMessage>? messages,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Iterable<StreamMessage>? messages,
List<StreamMessage>? messages,

Then we can skip the toList below. The callers are all passing lists anyway.

…pare`

To test showing the topic action sheet from the message list (app
bar or recipient header), we don't need `store.addMessage`; in those
cases, the message data comes via MessageListView's message fetch.

To test showing the action sheet from the Inbox, we do need a
message ID to be in the Unreads data. So, arrange that, but only in
the tests (one test) that use the Inbox.

While we're at it, also make this setup represent the common case
where we don't have the full Message object because a message list
containing the message hasn't been opened yet. When we write tests
for the upcoming resolve/unresolve button in the topic action sheet,
that's a case we'll want to exercise, in addition to the case where
we do have the message details.
This `prepare` function would also be useful for some tests outside
the 'showTopicActionSheet' group. Give it these params to start
getting it ready to move to the outer scope. We'll add more params
in the next few commits.
For the sake of some new callers when we move this function
definition to an outer scope.
For the sake of some new callers when we move this function
definition to an outer scope.
For the sake of some new callers when we move this function
definition to an outer scope.
…nSheet

Just to make this logic more similar to a `prepare` function in a
different group, to prepare (heh) for moving that `prepare` function
out and reusing it here.
Any of this function's new params (isChannelSubscribed,
isChannelMuted, visibilityPolicy, and zulipFeatureLevel) might come
in useful as we continue to add to the topic action sheet.
Which is given the value `eg.stream()`, too, anyway.
…narrow

With zulip#1039 "Fuse recipient header into app bar for topic narrows",
this setup will likely become invalid. It assumes that a topic
recipient header can be found in a topic-narrow message list.

Switching to the combined-feed narrow would break tests that use a
muted topic, because the topic's message(s) are excluded in that
narrow, so there wouldn't be a recipient header to tap.

Instead, trigger the topic action sheet from the topic-narrow app
bar.
These are natural places for someone to look for such tests.
Upcoming tests for the resolve/unresolve button can use this to test
an edge case where the button isn't offered.

While we're at it, replace finder logic in some existing checks,
making some a bit more targeted (so a not-NFC change): when finding
`UserTopicUpdateButton`s by their label text, we now require the
text to be under a BottomSheet widget.
…ssage`

When we add the resolve/unresolve button, coming up, we'll use this
to test the edge case where the button isn't shown in the
message-list app bar if the message list is empty. (For that case
we'll just pass an empty Iterable for this.)
@chrisbobbe
Copy link
Collaborator Author

Then I think you meant to leave the last 3 commit out of this PR, right? They'll be for #1301.

Ah indeed!

@chrisbobbe chrisbobbe force-pushed the pr-action-sheet-test-refactors branch from e172c58 to 55fdfd3 Compare January 28, 2025 00:01
@chrisbobbe
Copy link
Collaborator Author

Thanks for the review, revision pushed!

@gnprice
Copy link
Member

gnprice commented Jan 28, 2025

Thanks! Looks good; merging.

@gnprice gnprice merged commit 55fdfd3 into zulip:main Jan 28, 2025
1 check passed
@chrisbobbe chrisbobbe deleted the pr-action-sheet-test-refactors branch January 28, 2025 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration review Added by maintainers when PR may be ready for integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants