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

Scheduled post Actions #8603

Open
wants to merge 11 commits into
base: list-scheduled-post
Choose a base branch
from

Conversation

Rajat-Dabade
Copy link
Contributor

Summary

Ticket Link

Checklist

  • Added or updated unit tests (required for all new features)
  • Has UI changes
  • Includes text changes and localization file updates
  • Have tested against the 5 core themes to ensure consistency between them.
  • Have run E2E tests by adding label E2E iOS tests for PR.

Device Information

This PR was tested on:

Screenshots

Release Note


@Rajat-Dabade Rajat-Dabade force-pushed the scheduled-post-options branch 2 times, most recently from ad1c32e to 10b0d66 Compare February 21, 2025 09:05
@Rajat-Dabade Rajat-Dabade force-pushed the list-scheduled-post branch 2 times, most recently from de2b148 to 3a6f367 Compare February 21, 2025 09:15
@Rajat-Dabade Rajat-Dabade force-pushed the scheduled-post-options branch 2 times, most recently from cd6e159 to 2bd8672 Compare February 21, 2025 09:39
@Rajat-Dabade Rajat-Dabade self-assigned this Feb 21, 2025
@Rajat-Dabade Rajat-Dabade added the 2: Dev Review Requires review by a core commiter label Feb 21, 2025
@Rajat-Dabade Rajat-Dabade marked this pull request as ready for review February 21, 2025 09:47
Copy link
Member

@harshilsharma63 harshilsharma63 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@larkox larkox left a comment

Choose a reason for hiding this comment

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

Some comments to address, but in general it looks good.

deleteScheduledPostConfirmation(propsWithoutSwipeable);

// Get the cancel button callback
const cancelButton = (Alert.alert as jest.Mock).mock.calls[0][2][0];
Copy link
Contributor

Choose a reason for hiding this comment

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

Use jest.mocked(Alert.alert).mock... instead of casting it to jest.Mock. That way you keep type safety.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By doing this it was giving a linter error Object can be undefined..

Comment on lines 27 to 29
if (swipeable?.current) {
swipeable.current.close();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

0/5 Just for simplicity:

Suggested change
if (swipeable?.current) {
swipeable.current.close();
}
swipeable.current?.close();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the code.

swipeable?: React.RefObject<SwipeableMethods>;
}) {
const deleteScheduledPostOnConfirm = async () => {
await deleteScheduledPost(serverUrl, scheduledPostId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to do anything if this fails?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is handled in this PR: #8634

swipeable?: React.RefObject<SwipeableMethods>;
}) {
const deleteScheduledPostOnConfirm = async () => {
await deleteScheduledPost(serverUrl, scheduledPostId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, if this is the whole body, I don't think we need an async function. If I am not mistaken, the alert button will just call this function and forget. It will not wait for the promise to be resolved. So, if we keep it like this, there is no need for it to be a async function, or to be awaiting.

Comment on lines 23 to 28
const baseProps: {
intl: IntlShape;
serverUrl: string;
scheduledPostId: string;
swipeable?: React.RefObject<SwipeableMethods>;
} = {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use something like Parameters<T>[0] so you don't have to rewrite the type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not name this file index.test.tsx if it is about the index file?

Comment on lines 72 to 77
it('should match snapshot', () => {
const wrapper = renderWithEverything(
<SendHandler {...baseProps}/>, {database},
);
expect(wrapper.toJSON()).toBeTruthy();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not matching any snapshot, and not sure how useful it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, that correct, better to remove this from the test.

Comment on lines 123 to 125
await waitFor(() => {
expect(wrapper.toJSON()).toBeTruthy();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what is this for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessary, removed it.

Comment on lines 142 to 143
const sendDraftButton = wrapper.getByTestId('send_draft_button');
expect(sendDraftButton).toBeTruthy();
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure how this translate to "should pass correct props".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the test.

Comment on lines 159 to 163
expect(draftInput).toBeTruthy();

await waitFor(() => {
expect(wrapper.toJSON()).toBeTruthy();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure how this translates to should handle send message action.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the test.

@Rajat-Dabade Rajat-Dabade force-pushed the scheduled-post-options branch from 2bd8672 to 5517875 Compare February 25, 2025 12:14
@Rajat-Dabade Rajat-Dabade requested a review from larkox February 26, 2025 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a core commiter release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants