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

Separate Integration Tests into their own namespaces #17762

Merged
merged 1 commit into from
Nov 7, 2023

Conversation

DaveWM
Copy link
Collaborator

@DaveWM DaveWM commented Oct 30, 2023

Fixes #17679

Summary

This PR separates the integration tests into separate namespaces under status-im2.integration-test. It also adds some helper macros for performing setup steps.

Review notes

I've made a few small changes from the brief in the issue.

Firstly I've put the integration tests in the status-im2/integration-test directory, rather than have a core namespace at src/status_im2/integration_test.cljs and the other tests elsewhere. I thought this was best so that all the integration tests are in a single directory, but I can easily change this if required.

Secondly, the issue says to re-use state from some tests to run others. Doing this to the letter would require setting up some form of dependency graph for the tests, which I thought would be difficult to maintain. Also, it means you often can't run a single test, as it may depend on other tests. I've therefore taken the slightly different approach of having some setup functions that first check if they've already been run, and if they have then just skip the setup entirely. I think this keeps to the spirit of what was requested in the issue, and it's also more maintainable. Happy to incorporate any feedback though :)

Testing notes

None

Platforms

N/A

Areas that maybe impacted

Only tests.

Functional

No changes

Non-functional

No changes

Steps to test

Run the tests.

Before and after screenshots comparison

N/A

status: ready

@ghost
Copy link

ghost commented Oct 30, 2023

Hey @DaveWM, and thank you so much for making your first pull request in status-mobile! ❤️ Please help us make your experience better by filling out this brief questionnaire https://goo.gl/forms/uWqNcVpVz7OIopXg2

Copy link
Contributor

@ilmotta ilmotta left a comment

Choose a reason for hiding this comment

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

Thank you for working on this PR @DaveWM. I checked out and the integration tests are running well.

(rf-test/wait-for [::logout/logout-method]))))))

(deftest mute-chat-test
(log/info "========= mute-chat-test ==================")
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the call to info is following a convention to print a headline and it's repeated at the top of all tests, a nice improvement would be to extract to a little helper, like:

(helpers/log-headline :mute-chat-test)

[:chat/one-to-one-chat-created]
(rf/dispatch-sync [:chat/navigate-to-chat chat-id])
(is (= chat-id @(rf/subscribe [:chats/current-chat-id])))
(helpers/logout!)
Copy link
Contributor

Choose a reason for hiding this comment

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

For integration tests where things are much more stateful by nature, the exclamation mark convention doesn't add much value to me. The reader already knows a call to (helpers/logout) (no exclamation mark) will cause some side-effect in the system.

(let
[compressed-key "zQ3shWj4WaBdf2zYKCkXe6PHxDxNTzZyid1i75879Ue9cX9gA"
public-key
"0x048a6773339d11ccf5fd81677b7e54daeec544a1287bd92b725047ad6faa9a9b9f8ea86ed5a226d2a994f5f46d0b43321fd8de7b7997a166e67905c8c73cd37cea"
Copy link
Contributor

Choose a reason for hiding this comment

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

This long line is causing zprint to format the bindings weirdly. You can improve this by extracting public-key to a var or breaking up the string.

(deftest add-contact-test
  (let [compressed-key "zQ3shWj4WaBdf2zYKCkXe6PHxDxNTzZyid1i75879Ue9cX9gA"
        public-key     (str "0x048a6773339d11ccf5fd81677b7e54daeec544a1287"
                            "bd92b725047ad6faa9a9b9f8ea86ed5a226d2a994f5f4"
                            "6d0b43321fd8de7b7997a166e67905c8c73cd37cea")
        primary-name   "zQ3...9cX9gA"]
    ...))

(rf-test/run-test-async
(with-app-initialized
(with-account
(helpers/assert-messenger-started)
Copy link
Contributor

Choose a reason for hiding this comment

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

For test helpers, since they're so ubiquitous in tests, we have a convention to alias as h, so it would read as (h/assert-messenger-started).

@@ -0,0 +1,56 @@
(ns status-im2.integration-test.helpers
Copy link
Contributor

Choose a reason for hiding this comment

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

I think having the test helpers in the integration_test directory is fine and makes sense too, but so far we have added test helpers in src/test_helpers/. If you follow this suggestion, the namespace would be test-helpers.integration.

(status-im2.integration-test.helpers/create-multiaccount!)
(rf-test/wait-for
[:status-im.transport.core/messenger-started]
~@body))))
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, run make lint, I think it will detect some small issues.

[day8.re-frame.test :as rf-test]
[re-frame.core :as rf]
[status-im.events]
[status-im.multiaccounts.logout.core :as logout] ; so integration tests can run independently
Copy link
Contributor

Choose a reason for hiding this comment

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

These side comments in the ns are unnecessary imo.

[status-im2.integration-test.helpers :as helpers]
[status-im2.integration-test.wallet]
[status-im2.navigation.core] ; so integration tests can run independently
[status-im2.subs.root]
Copy link
Contributor

Choose a reason for hiding this comment

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

Just status-im2.subs.root is possible (without square brackets) because it's not being aliased.

(helpers/logout!)
(rf-test/wait-for [::logout/logout-method])))))

(deftest create-community-test
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe better is to extract this community test outside the core namespace, and into integration_test/community.cljs, just like you did for wallet.cljs and chat.cljs.

(rf-test/run-test-async
(with-app-initialized
(with-account
(helpers/assert-messenger-started)
Copy link
Contributor

Choose a reason for hiding this comment

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

Every time with-account is used in the tests, assert-messenger-started is called as well. I think it would be better to move this check to the macro itself because it's always desirable.

@DaveWM DaveWM force-pushed the develop branch 3 times, most recently from b973fda to 9f9384b Compare November 1, 2023 12:12
@DaveWM
Copy link
Collaborator Author

DaveWM commented Nov 1, 2023

Thanks for the review @ilmotta. All your suggestions sound good to me, I've updated the PR to implement them all

Copy link
Contributor

@ilmotta ilmotta 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 the review @ilmotta. All your suggestions sound good to me, I've updated the PR to implement them all

Great work @DaveWM, PR looks good to me.

Copy link
Contributor

@siddarthkay siddarthkay left a comment

Choose a reason for hiding this comment

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

Looks good!
Lets get you access to run this PR in CI

@status-im-auto
Copy link
Member

status-im-auto commented Nov 3, 2023

Jenkins Builds

Click to see older builds (16)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 9f9384b #1 2023-11-03 10:49:20 ~6 min android 🤖apk 📲
✔️ 9f9384b #1 2023-11-03 11:10:45 ~9 min tests 📄log
✔️ 9f9384b #1 2023-11-04 08:51:11 ~5 min android-e2e 🤖apk 📲
✔️ 9f9384b #1 2023-11-04 10:08:04 ~5 min ios 📱ipa 📲
✔️ 5b71e25 #2 2023-11-04 13:14:34 ~5 min android-e2e 🤖apk 📲
✔️ 5b71e25 #2 2023-11-04 13:14:54 ~6 min ios 📱ipa 📲
✔️ 5b71e25 #2 2023-11-04 13:17:56 ~8 min tests 📄log
✔️ 5b71e25 #2 2023-11-04 13:17:59 ~9 min android 🤖apk 📲
✔️ 90f2a99 #3 2023-11-04 13:34:04 ~5 min android-e2e 🤖apk 📲
✔️ 90f2a99 #3 2023-11-04 13:34:30 ~5 min android 🤖apk 📲
✔️ 90f2a99 #3 2023-11-04 13:37:07 ~8 min tests 📄log
✔️ 90f2a99 #3 2023-11-04 13:39:16 ~10 min ios 📱ipa 📲
✔️ d0baaad #5 2023-11-07 10:33:13 ~5 min ios 📱ipa 📲
✔️ d0baaad #5 2023-11-07 10:33:55 ~6 min android-e2e 🤖apk 📲
✔️ d0baaad #5 2023-11-07 10:35:30 ~7 min android 🤖apk 📲
✔️ d0baaad #5 2023-11-07 10:36:13 ~8 min tests 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ fa74db1 #6 2023-11-07 10:46:45 ~5 min ios 📱ipa 📲
✔️ fa74db1 #6 2023-11-07 10:46:54 ~5 min android 🤖apk 📲
✔️ fa74db1 #6 2023-11-07 10:47:05 ~5 min android-e2e 🤖apk 📲
✔️ fa74db1 #6 2023-11-07 10:49:46 ~8 min tests 📄log
✔️ f12e7ed #7 2023-11-07 11:08:29 ~6 min android-e2e 🤖apk 📲
✔️ f12e7ed #7 2023-11-07 11:11:36 ~9 min android 🤖apk 📲
✔️ f12e7ed #7 2023-11-07 11:13:32 ~11 min tests 📄log
✔️ f12e7ed #7 2023-11-07 11:16:23 ~14 min ios 📱ipa 📲

@DaveWM DaveWM force-pushed the develop branch 2 times, most recently from 5b71e25 to 90f2a99 Compare November 4, 2023 13:28
@status-im-auto
Copy link
Member

89% of end-end tests have passed

Total executed tests: 45
Failed tests: 2
Expected to fail tests: 3
Passed tests: 40
IDs of failed tests: 702777,702846 
IDs of expected to fail tests: 702732,702731,702808 

Failed tests (2)

Click to expand
  • Rerun failed tests

  • Class TestActivityCenterContactRequestMultipleDevicePR:

    1. test_add_contact_field_validation, id: 702777

    ## Creating new multiaccount (password:'qwerty1234', keycard:'False', enable_notification: 'False')
    Device 2: Wait for element `Button` for max 20s and click when it is available

    activity_center/test_activity_center.py:147: in test_add_contact_field_validation
        self.device_2.create_user(username=new_username_2, user_number=self.device_2_users_number)
    ../views/sign_in_view.py:230: in create_user
        self.show_profiles_button.wait_and_click(20)
    ../views/base_element.py:96: in wait_and_click
        self.wait_for_visibility_of_element(sec)
    ../views/base_element.py:139: in wait_for_visibility_of_element
        raise TimeoutException(
     Device 2: Button by accessibility id:`show-profiles` is not found on the screen after wait_for_visibility_of_element
    



    Device sessions

    Class TestCommunityOneDeviceMerged:

    1. test_community_navigate_to_channel_when_relaunch, id: 702846

    ## Signed in successfully!
    Device 1: Looking for a message by text: some_text

    critical/chats/test_public_chat_browsing.py:81: in test_community_navigate_to_channel_when_relaunch
        self.drivers[0].fail("Not navigated to channel view after reopening app")
    base_test_case.py:179: in fail
        pytest.fail('Device %s: %s' % (self.number, text))
     Device 1: Not navigated to channel view after reopening app
    



    Device sessions

    Expected to fail tests (3)

    Click to expand

    Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_pin_messages, id: 702731

    Test is not run, e2e blocker  
    

    [[reason: [NOTRUN] Pin feature is in development]]

    Class TestGroupChatMultipleDeviceMergedNewUI:

    1. test_group_chat_pin_messages, id: 702732

    Test is not run, e2e blocker  
    

    [[reason: [NOTRUN] Pin feature is in development]]

    2. test_group_chat_offline_pn, id: 702808

    Device 3: Looking for a message by text: message from old member
    Device 3: Looking for a message by text: message from new member

    critical/chats/test_group_chat.py:323: in test_group_chat_offline_pn
        self.errors.verify_no_errors()
    base_test_case.py:191: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Messages PN was not fetched from offline 
    

    [[Data delivery issue]]

    Device sessions

    Passed tests (40)

    Click to expand

    Class TestGroupChatMultipleDeviceMergedNewUI:

    1. test_group_chat_mute_chat, id: 703495
    Device sessions

    2. test_group_chat_send_image_save_and_share, id: 703297
    Device sessions

    3. test_group_chat_reactions, id: 703202
    Device sessions

    4. test_group_chat_join_send_text_messages_push, id: 702807
    Device sessions

    Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_emoji_send_reply_and_open_link, id: 702782
    Device sessions

    2. test_1_1_chat_text_message_delete_push_disappear, id: 702733
    Device sessions

    3. test_1_1_chat_push_emoji, id: 702813
    Device sessions

    4. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745
    Device sessions

    5. test_1_1_chat_edit_message, id: 702855
    Device sessions

    6. test_1_1_chat_send_image_save_and_share, id: 703391
    Device sessions

    7. test_1_1_chat_message_reaction, id: 702730
    Device sessions

    Class TestActivityCenterContactRequestMultipleDevicePR:

    1. test_activity_center_contact_request_accept_swipe_mark_all_as_read, id: 702851
    Device sessions

    2. test_activity_center_contact_request_decline, id: 702850
    Device sessions

    Class TestCommunityMultipleDeviceMergedTwo:

    1. test_community_markdown_support, id: 702809
    Device sessions

    2. test_community_hashtag_links_to_community_channels, id: 702948
    Device sessions

    3. test_community_mentions_push_notification, id: 702786
    Device sessions

    4. test_community_leave, id: 702845
    Device sessions

    5. test_community_join_when_node_owner_offline, id: 703629
    Device sessions

    Class TestActivityMultipleDevicePR:

    1. test_navigation_jump_to, id: 702936
    Device sessions

    2. test_activity_center_reply_read_unread_delete_filter_swipe, id: 702947
    Device sessions

    Class TestCommunityOneDeviceMerged:

    1. test_restore_multiaccount_with_waku_backup_remove_switch, id: 703133
    Device sessions

    2. test_community_copy_and_paste_message_in_chat_input, id: 702742
    Device sessions

    3. test_community_discovery, id: 703503
    Device sessions

    4. test_community_undo_delete_message, id: 702869
    Device sessions

    5. test_community_mute_community_and_channel, id: 703382
    Device sessions

    Class TestOneToOneChatMultipleSharedDevicesNewUiTwo:

    1. test_1_1_chat_delete_via_long_press_relogin, id: 702784
    Device sessions

    2. test_1_1_chat_is_shown_message_sent_delivered_from_offline, id: 702783
    Device sessions

    3. test_1_1_chat_mute_chat, id: 703496
    Device sessions

    Class TestCommunityMultipleDeviceMerged:

    1. test_community_several_images_send_reply, id: 703194
    Device sessions

    2. test_community_one_image_send_reply, id: 702859
    Device sessions

    3. test_community_emoji_send_copy_paste_reply, id: 702840
    Device sessions

    4. test_community_mark_all_messages_as_read, id: 703086
    Device sessions

    5. test_community_contact_block_unblock_offline, id: 702894
    Device sessions

    6. test_community_message_delete, id: 702839
    Device sessions

    7. test_community_message_send_check_timestamps_sender_username, id: 702838
    Device sessions

    8. test_community_links_with_previews_github_youtube_twitter_gif_send_enable, id: 702844
    Device sessions

    9. test_community_message_edit, id: 702843
    Device sessions

    10. test_community_unread_messages_badge, id: 702841
    Device sessions

    Class TestActivityMultipleDevicePRTwo:

    1. test_activity_center_mentions, id: 702957
    Device sessions

    2. test_activity_center_admin_notification_accept_swipe, id: 702958
    Device sessions

    @siddarthkay siddarthkay merged commit cb005af into status-im:develop Nov 7, 2023
    5 checks passed
    ilmotta added a commit that referenced this pull request Nov 15, 2023
    Integration tests weren't running since #17762 was merged a week ago.
    
    This commit also allows individual integration test namespaces to run if you change the :ns-regexp option in shadow-cljs. This is quite handy, since they are relatively slow.
    
    Fixes #17895
    yevh-berdnyk pushed a commit that referenced this pull request Dec 8, 2023
    yevh-berdnyk pushed a commit that referenced this pull request Dec 8, 2023
    Integration tests weren't running since #17762 was merged a week ago.
    
    This commit also allows individual integration test namespaces to run if you change the :ns-regexp option in shadow-cljs. This is quite handy, since they are relatively slow.
    
    Fixes #17895
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    Archived in project
    Archived in project
    Development

    Successfully merging this pull request may close these issues.

    Separate Integration Tests into their own namespaces
    6 participants