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

tests: boxes: Add SAVE_AS_DRAFT keypress test for write box. #950

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mkp6781
Copy link
Contributor

@mkp6781 mkp6781 commented Mar 16, 2021

No description provided.

@zulipbot zulipbot added size: M [Automatic label added by zulipbot] area: tests labels Mar 16, 2021
Comment on lines 90 to 104
if stream_message:
write_box.stream_id = 1
draft = {
'type': 'stream',
'to': 'Current Stream',
'content': 'Random message',
'subject': 'Topic'
}
else:
write_box.to_write_box = mocker.Mock()
draft = {
'type': 'private',
'to': ['[email protected]'],
'content': 'Random message'
}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe a parametrize could be replaced with this conditional check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback @Ezio-Sarthak . I have parametrized the draft_message now.

Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

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

@mkp6781 I support @Ezio-Sarthak 's feedback, but other than my point below this looks close to ready 👍

Note that the 'fixes' text will close the issue, so you'll need to rephrase it slightly or just remove it.

Comment on lines 73 to 74
@pytest.mark.parametrize('draft_message_in_current_session', [
True, None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

You're using a descriptive parameter as a setting here, which is a little confusing.

@neiljp neiljp added the PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback label Mar 28, 2021
@mkp6781 mkp6781 force-pushed the test_keypress_for_write_box branch from 4004b4b to b3a75dd Compare April 1, 2021 09:28
@mkp6781
Copy link
Contributor Author

mkp6781 commented Apr 1, 2021

@zulipbot remove "PR awaiting update"
@zulipbot add "PR needs review"

@zulipbot zulipbot added PR needs review PR requires feedback to proceed and removed PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback labels Apr 1, 2021
Copy link
Member

@zee-bit zee-bit left a comment

Choose a reason for hiding this comment

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

Thanks for noticing the missing tests. This should be almost ready to merge. 👍

You still haven't addressed Neil's concern about removing/rephrasing the fixes text, and the parametrize is not used properly as we'd expect. You can take a look at other similar tests to figure out how parametrize works, or you can consult the pytest docs. :)

Comment on lines 79 to 93
{
'type': 'private',
'to': ['[email protected]'],
'content': 'Random message'
},
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add one test fixture for PM huddle too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have only two data structures PrivateComposition and StreamComposition. Testing already covers both these cases. For PM huddle, its just a case of appending more emails to the existing list. Is there a need for a separate parameter?

Comment on lines 97 to 100
write_box.stream_write_box = mocker.Mock(edit_text="Current Stream")
write_box.title_write_box = mocker.Mock(edit_text="Topic")
write_box.msg_write_box = mocker.Mock(edit_text="Random message")
write_box.recipient_emails = ['[email protected]']
Copy link
Member

Choose a reason for hiding this comment

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

Looks like you aren't using the data from test fixture, and still providing a hard-coded value matching with the fixtures - that's why the tests aren't failing. This shouldn't happen; otherwise, there's no reason to use parametrize, right :)

Plus, the above three write_box objects are only for stream message and the last one for PM's, so probably better to have separate cases; but it's minor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like you aren't using the data from test fixture, and still providing a hard-coded value matching with the fixtures - that's why the tests aren't failing. This shouldn't happen; otherwise, there's no reason to use parametrize, right

Yeah my bad. :)

Comment on lines 102 to 132
if draft_composition['type'] == "stream":
write_box.stream_id = 1
else:
write_box.to_write_box = mocker.Mock()
Copy link
Member

Choose a reason for hiding this comment

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

The second point in the above review could be shifted here.

@mkp6781 mkp6781 force-pushed the test_keypress_for_write_box branch from b3a75dd to 884f260 Compare April 7, 2021 14:53
@zulipbot zulipbot added size: L [Automatic label added by zulipbot] and removed size: M [Automatic label added by zulipbot] labels Apr 7, 2021
@mkp6781 mkp6781 force-pushed the test_keypress_for_write_box branch from 884f260 to 960469a Compare April 7, 2021 14:58
@zulipbot zulipbot added size: M [Automatic label added by zulipbot] and removed size: L [Automatic label added by zulipbot] labels Apr 7, 2021
Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

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

.

@mkp6781 mkp6781 force-pushed the test_keypress_for_write_box branch from 960469a to bd6ee16 Compare June 3, 2021 04:04
@mkp6781 mkp6781 force-pushed the test_keypress_for_write_box branch from bd6ee16 to fa8c70a Compare June 3, 2021 06:05
@zulipbot zulipbot added size: L [Automatic label added by zulipbot] and removed size: M [Automatic label added by zulipbot] labels Jun 3, 2021
@mkp6781
Copy link
Contributor Author

mkp6781 commented Jun 3, 2021

I have rebased this branch. Used Black to reformat the code so that it passes linting tests.

@zulipbot
Copy link
Member

Heads up @mkp6781, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the upstream/main branch and resolve your pull request's merge conflicts accordingly.

@neiljp
Copy link
Collaborator

neiljp commented Feb 4, 2024

Marking this as a completion candidate, but the underlying code has changed somewhat, so in addition to a rebase and improving the tests, this will need some adjustment to fit the new code - this will require digging for eg. renames and similar.

@neiljp neiljp added PR completion candidate PR with reviews that may unblock merging and removed PR needs review PR requires feedback to proceed labels Feb 4, 2024
@criticic
Copy link
Collaborator

criticic commented Feb 7, 2024

I'd like to work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: tests has conflicts PR completion candidate PR with reviews that may unblock merging size: L [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants