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

Introduce malli library #17867

Merged
merged 25 commits into from
Nov 18, 2023
Merged

Introduce malli library #17867

merged 25 commits into from
Nov 18, 2023

Conversation

ilmotta
Copy link
Contributor

@ilmotta ilmotta commented Nov 10, 2023

Summary

This PR is the foundational step to start using malli in this project. It is not a small PR, and some parts of the code are not trivial. All this is necessary to guarantee our hot-reload, testing and REPL workflows are kept intact and enjoyable. Special thanks to @J-Son89, @clauxx, and @yqrashawn for helping review, test and propose improvements to this PR's branch.

Please, take in consideration we will only be able to realize malli's full power in future iterations. Do expect exciting ideas from other collaborators! Too many to spoil now ;)

For those without context: the mobile team watched a presentation about malli and went through a light RFC to put everyone on the same page, among other discussions here and there in PRs.

To keep things relatively short:

  1. Unit, integration and component tests will short-circuit (fail) when inputs/outputs don't conform to their respective function schemas (CI should fail too).
  2. Failed schema checks will not block the app from initializing, nor throw an exception that would trigger the LogBox. Exceptions are only thrown in the scope of automated tests.
  3. There's zero performance impact in production code because we only instrument. Instrumentation is removed from the compiled code due to the usage of ^boolean js.goog/DEBUG.
  4. We shouldn't expect any meaningful slowdown during development. Perhaps in a distant and brighter future, where we have a ton more instrumentation, this could be an issue (although I've never had this problem). In any case, we shouldn't profile in debug mode, and instrumentation is disabled when debug mode is disabled.

Demo

In this demo we see a live experience without hot-reload or REPL involved, just pressing things around. As the instrumented function (step component) is called, when an invalid input argument is passed, a red warning is automatically displayed, telling the developer to look at the logs. When the same function is called again with the correct arguments, the error is removed from the screen.

Without a mechanism to warn the developer, and since we don't throw exceptions to avoid the LogBox, the developer would frequently forget to fix schemas, increasing the likelihood of merging with such problems.

The automatic error removal only works if using schema/instrument because we can then wrap the original function using a HoF. Only in future endeavors we'll be able to achieve this effect with the macro approach, because we cannot just wrap a var and use malli.core/=>. We're considering submitting a PR to malli as well.

demo-malli.webm

What are we instrumenting in this PR?

Per our team's agreement, we're only instrumenting the bare minimum in this PR, to showcase 2 examples.

  • Instrument a utility function utils.money/format-amount using the macro approach.
  • Instrument a quo component quo.components.counter.step.view/view using the functional approach.

Both approaches are useful, the functional approach is powerful and allow us to instrument anonymous functions, like the ones we pass to subscriptions or event handlers, or the higher-order function quo.theme/with-theme. The macro approach is perfect for functions already defined with defn.

I evaluated the schema or function in the REPL but nothing changes

  • If you evaluate the source function, you need to evaluate schema/=> or schema/instrument as well.
  • Remember to var quote when using schema/instrument.
  • You must call (status-im2.setup.schema/setup!) after any var is re-instrumented. It's advisable to add a keybinding in your editor to send this expression automatically to the CLJS REPL, or add the call at the end of the namespace you are working on (similar to how some devs add (run-tests) at the end of test namespaces).

Where should schemas be defined?

For the moment, we should focus on instrumenting quo components, so define each function schema in the same namespace as the component's public view var.

To be specific:

  • A schema used only to instrument a single function and not used elsewhere, like a quo component schema, wouldn't benefit from being defined in a separate namespace because that would force the developer to constantly open two files instead of one to check function signatures.
  • A common schema reused across the repo, like :schema.common/theme should be registered in the global registry schema.registry so that consumers can just refer to it by keyword, as if it was a built-in malli schema.
  • A common schema describing status-go entities like message, notification, community, etc can be stored either in the respective src/status_im2/contexts/* or registered globally, or even somewhere else. This is yet to be defined, but since I chose not to include schemas for them, we can postpone this guideline.

How do I learn malli?

Malli's README is fairly complete. The REPL can be your best friend in this journey. Ping other devs with more context, pairing can be much more effective :)

Steps to test (devs only)

We suggest you at least checkout the branch and try to modify the quo.components.counter.step.view/?schema to see how malli works on a basic level. If you are a REPL user, please report if you faced any issue 🙌

status: ready

malli.core malli
malli.dev.pretty malli.pretty
malli.dev.virhe malli.virhe
malli.error malli.error
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI: I added these aliases because there's a tendency devs would copy from tutorials alias abbreviations like mu to mean malli.util, or me to mean malli.error.

@status-im-auto
Copy link
Member

status-im-auto commented Nov 10, 2023

Jenkins Builds

Click to see older builds (14)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 1bf6205 #1 2023-11-10 04:15:00 ~6 min android-e2e 🤖apk 📲
✔️ 1bf6205 #1 2023-11-10 04:18:33 ~9 min android 🤖apk 📲
1bf6205 #1 2023-11-10 04:19:25 ~10 min tests 📄log
✔️ 1bf6205 #1 2023-11-10 04:21:19 ~12 min ios 📱ipa 📲
✔️ ffad93a #2 2023-11-13 21:29:08 ~6 min android-e2e 🤖apk 📲
✔️ ffad93a #2 2023-11-13 21:29:17 ~6 min android 🤖apk 📲
✔️ 292a6ad #3 2023-11-13 21:35:11 ~5 min ios 📱ipa 📲
✔️ 292a6ad #3 2023-11-13 21:35:30 ~6 min android-e2e 🤖apk 📲
✔️ 292a6ad #3 2023-11-13 21:39:01 ~9 min android 🤖apk 📲
✔️ 292a6ad #3 2023-11-13 21:39:42 ~10 min tests 📄log
✔️ 24f4f15 #4 2023-11-15 16:34:54 ~5 min android-e2e 🤖apk 📲
✔️ 24f4f15 #4 2023-11-15 16:36:47 ~7 min ios 📱ipa 📲
✔️ 24f4f15 #4 2023-11-15 16:39:33 ~10 min android 🤖apk 📲
✔️ 24f4f15 #4 2023-11-15 16:39:38 ~10 min tests 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ bd5b69b #5 2023-11-15 17:39:38 ~10 min android 🤖apk 📲
✔️ bd5b69b #5 2023-11-15 17:40:33 ~11 min tests 📄log
✔️ bd5b69b #5 2023-11-15 17:40:55 ~12 min android-e2e 🤖apk 📲
✔️ bd5b69b #5 2023-11-15 17:41:57 ~13 min ios 📱ipa 📲
✔️ c974afc #6 2023-11-18 11:58:09 ~5 min android-e2e 🤖apk 📲
✔️ c974afc #6 2023-11-18 11:58:26 ~6 min ios 📱ipa 📲
✔️ c974afc #6 2023-11-18 12:00:46 ~8 min android 🤖apk 📲
✔️ c974afc #6 2023-11-18 12:03:04 ~10 min tests 📄log


(def view
(quo.theme/with-theme
(schema/instrument #'view-internal ?schema)))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI: This is the functional approach with schema/instrument. Notice the need to var quote view-internal. This has been added to the schema guidelines too.


(schema/=> format-amount
[:=> [:cat [:maybe :int]]
[:maybe :string]])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI: The macro approach with schema/=> is more convenient when the function to instrument is not wrapped in higher-order functions (which is the case for quo components wrapped in quo.theme/with-theme).

@J-Son89
Copy link
Contributor

J-Son89 commented Nov 10, 2023

Thanks for the detailed pr. Great work @ilmotta! 🙌


(def view (theme/with-theme view-internal))
(def ?schema
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe it could be defined above the usage? it makes it a bit more clearer if reading it the first time, but no strong opinion

Copy link
Contributor Author

@ilmotta ilmotta Nov 13, 2023

Choose a reason for hiding this comment

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

I have no preference @cammellos, and since nobody objected to your suggestion I'll apply it.

Edit: resolved in 292a6ad

Copy link
Contributor

@cammellos cammellos left a comment

Choose a reason for hiding this comment

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

looks really good, can't wait to try it out, thanks for driving the initiative, amazing work!

@cammellos
Copy link
Contributor

2023-11-10T04:18:59.156Z]     -- Schema error at quo.components.counter.step.view/view-internal ----

[2023-11-10T04:18:59.156Z] 

[2023-11-10T04:18:59.156Z]     Invalid function arguments:

[2023-11-10T04:18:59.156Z]       [{:customization-color nil,

[2023-11-10T04:18:59.156Z]         :in-blur-view? nil,

[2023-11-10T04:18:59.156Z]         :theme nil,

[2023-11-10T04:18:59.156Z]         :type :neutral}

[2023-11-10T04:18:59.156Z]        1]

[2023-11-10T04:18:59.156Z] 

[2023-11-10T04:18:59.156Z]     Input Schema:

[2023-11-10T04:18:59.156Z]       [:catn

[2023-11-10T04:18:59.156Z]        [:props [:map {#} [#] [#] [#] [#] ...]]

[2023-11-10T04:18:59.156Z]        [:value [:maybe [#]]]]

[2023-11-10T04:18:59.156Z] 

[2023-11-10T04:18:59.156Z]     Errors:

[2023-11-10T04:18:59.156Z]       {:in [0 :theme],

[2023-11-10T04:18:59.156Z]        :message "should be either :light or :dark",

[2023-11-10T04:18:59.156Z]        :path [:props :theme 0],

[2023-11-10T04:18:59.156Z]        :schema [:enum :light :dark],

[2023-11-10T04:18:59.156Z]        :value nil}

I believe it caught something already, the component test wasn't passing all the parameters required :)

@FFFra
Copy link
Contributor

FFFra commented Nov 10, 2023

This is amazing! Can't wait to try out! Thank you a lot @ilmotta

Copy link
Member

@clauxx clauxx left a comment

Choose a reason for hiding this comment

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

Great work! Can't wait to put it to work 🎆

@status-im-auto
Copy link
Member

78% of end-end tests have passed

Total executed tests: 45
Failed tests: 6
Expected to fail tests: 4
Passed tests: 35
IDs of failed tests: 702782,702733,702813,702745,702855,703391 
IDs of expected to fail tests: 702732,703503,702731,702808 

Failed tests (6)

Click to expand
  • Rerun failed tests

  • Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_emoji_send_reply_and_open_link, id: 702782

    Device 2: Find `OpenInStatusButton` by `xpath`: `//*[@text="Open in Status"]`
    Device 2: Tap on found: OpenInStatusButton

    critical/chats/test_1_1_public_chats.py:168: in test_1_1_chat_emoji_send_reply_and_open_link
        if not web_view.element_by_text('Make the jump to web3').is_element_displayed(60):
    ../views/base_element.py:212: in is_element_displayed
        return self.wait_for_visibility_of_element(sec, ignored_exceptions=ignored_exceptions)
    ../views/base_element.py:137: in wait_for_visibility_of_element
        .until(expected_conditions.visibility_of_element_located((self.by, self.locator)))
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/support/wait.py:86: in until
        value = method(self._driver)
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/support/expected_conditions.py:152: in _predicate
        return _element_if_visible(driver.find_element(*locator))
    /home/jenkins/.local/lib/python3.10/site-packages/appium/webdriver/webdriver.py:409: in find_element
        return self.execute(RemoteCommand.FIND_ELEMENT, {'using': by, 'value': value})['value']
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py:345: in execute
        self.error_handler.check_response(response)
    /home/jenkins/.local/lib/python3.10/site-packages/appium/webdriver/errorhandler.py:122: in check_response
        raise exception_class(msg=message, stacktrace=format_stacktrace(stacktrace))
     An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: socket hang up
    E   Stacktrace:
    E   UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: socket hang up
    E       at UIA2Proxy.command (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/jsonwp-proxy/proxy.js:355:13)
    E       at processTicksAndRejections (node:internal/process/task_queues:95:5)
    E       at AndroidUiautomator2Driver.helpers.doFindElementOrEls (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/lib/commands/find.js:30:10)
    E       at doFind (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/find.js:36:17)
    E       at wrappedCondFn (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/timeout.ts:137:14)
    E       at spin (/mnt/sauce/appium/appium-v2.0.0/node_modules/asyncbox/lib/asyncbox.js:221:20)
    E       at spin (/mnt/sauce/appium/appium-v2.0.0/node_modules/asyncbox/lib/asyncbox.js:231:14)
    E       at waitForCondition (/mnt/sauce/appium/appium-v2.0.0/node_modules/asyncbox/lib/asyncbox.js:238:10)
    E       at AndroidUiautomator2Driver.implicitWaitForCondition (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/timeout.ts:139:12)
    E       at AndroidUiautomator2Driver.findElOrEls (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/find.js:60:5)
    E       at AndroidUiautomator2Driver.findElOrElsWithProcessing (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/find.ts:60:12)
    E       at AndroidUiautomator2Driver.findElement (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/find.ts:75:12)
    



    Device sessions

    2. test_1_1_chat_text_message_delete_push_disappear, id: 702733

    critical/chats/test_1_1_public_chats.py:456: in test_1_1_chat_text_message_delete_push_disappear
        if not self.chat_2.chat_message_input.is_element_displayed():
    ../views/base_element.py:212: in is_element_displayed
        return self.wait_for_visibility_of_element(sec, ignored_exceptions=ignored_exceptions)
    ../views/base_element.py:137: in wait_for_visibility_of_element
        .until(expected_conditions.visibility_of_element_located((self.by, self.locator)))
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/support/wait.py:86: in until
        value = method(self._driver)
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/support/expected_conditions.py:152: in _predicate
        return _element_if_visible(driver.find_element(*locator))
    /home/jenkins/.local/lib/python3.10/site-packages/appium/webdriver/webdriver.py:409: in find_element
        return self.execute(RemoteCommand.FIND_ELEMENT, {'using': by, 'value': value})['value']
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py:345: in execute
        self.error_handler.check_response(response)
    /home/jenkins/.local/lib/python3.10/site-packages/appium/webdriver/errorhandler.py:122: in check_response
        raise exception_class(msg=message, stacktrace=format_stacktrace(stacktrace))
     An unknown server-side error occurred while processing the command. Original error: 'POST /element' cannot be proxied to UiAutomator2 server because the instrumentation process is not running (probably crashed). Check the server log and/or the logcat output for more details
    E   Stacktrace:
    E   UnknownError: An unknown server-side error occurred while processing the command. Original error: 'POST /element' cannot be proxied to UiAutomator2 server because the instrumentation process is not running (probably crashed). Check the server log and/or the logcat output for more details
    E       at UIA2Proxy.command (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/jsonwp-proxy/proxy.js:355:13)
    E       at processTicksAndRejections (node:internal/process/task_queues:95:5)
    E       at AndroidUiautomator2Driver.helpers.doFindElementOrEls (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/lib/commands/find.js:30:10)
    E       at doFind (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/find.js:36:17)
    E       at wrappedCondFn (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/timeout.ts:137:14)
    E       at spin (/mnt/sauce/appium/appium-v2.0.0/node_modules/asyncbox/lib/asyncbox.js:221:20)
    E       at waitForCondition (/mnt/sauce/appium/appium-v2.0.0/node_modules/asyncbox/lib/asyncbox.js:238:10)
    E       at AndroidUiautomator2Driver.implicitWaitForCondition (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/timeout.ts:139:12)
    E       at AndroidUiautomator2Driver.findElOrEls (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/find.js:60:5)
    E       at AndroidUiautomator2Driver.findElOrElsWithProcessing (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/find.ts:60:12)
    E       at AndroidUiautomator2Driver.findElement (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/find.ts:75:12)
    



    Device sessions

    3. test_1_1_chat_push_emoji, id: 702813

    Device 1: Could not reach home view by pressing system back button

    critical/chats/test_1_1_public_chats.py:318: in test_1_1_chat_push_emoji
        self.home_2.navigate_back_to_home_view()
    ../views/base_view.py:396: in navigate_back_to_home_view
        while not self.chat_floating_screen.is_element_disappeared(1) \
    ../views/base_element.py:222: in is_element_disappeared
        return self.wait_for_invisibility_of_element(sec)
    ../views/base_element.py:146: in wait_for_invisibility_of_element
        .until(expected_conditions.invisibility_of_element_located((self.by, self.locator)))
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/support/wait.py:86: in until
        value = method(self._driver)
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/support/expected_conditions.py:319: in _predicate
        target = driver.find_element(*target)
    /home/jenkins/.local/lib/python3.10/site-packages/appium/webdriver/webdriver.py:409: in find_element
        return self.execute(RemoteCommand.FIND_ELEMENT, {'using': by, 'value': value})['value']
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py:345: in execute
        self.error_handler.check_response(response)
    /home/jenkins/.local/lib/python3.10/site-packages/appium/webdriver/errorhandler.py:122: in check_response
        raise exception_class(msg=message, stacktrace=format_stacktrace(stacktrace))
     An unknown server-side error occurred while processing the command. Original error: 'POST /element' cannot be proxied to UiAutomator2 server because the instrumentation process is not running (probably crashed). Check the server log and/or the logcat output for more details
    E   Stacktrace:
    E   UnknownError: An unknown server-side error occurred while processing the command. Original error: 'POST /element' cannot be proxied to UiAutomator2 server because the instrumentation process is not running (probably crashed). Check the server log and/or the logcat output for more details
    E       at UIA2Proxy.command (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/jsonwp-proxy/proxy.js:355:13)
    E       at processTicksAndRejections (node:internal/process/task_queues:95:5)
    E       at AndroidUiautomator2Driver.helpers.doFindElementOrEls (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/lib/commands/find.js:30:10)
    E       at doFind (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/find.js:36:17)
    E       at wrappedCondFn (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/timeout.ts:137:14)
    E       at spin (/mnt/sauce/appium/appium-v2.0.0/node_modules/asyncbox/lib/asyncbox.js:221:20)
    E       at waitForCondition (/mnt/sauce/appium/appium-v2.0.0/node_modules/asyncbox/lib/asyncbox.js:238:10)
    E       at AndroidUiautomator2Driver.implicitWaitForCondition (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/timeout.ts:139:12)
    E       at AndroidUiautomator2Driver.findElOrEls (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/find.js:60:5)
    E       at AndroidUiautomator2Driver.findElOrElsWithProcessing (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/find.ts:60:12)
    E       at AndroidUiautomator2Driver.findElement (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/find.ts:75:12)
    



    Device sessions

    4. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745

    Device 1: Find SendMessageButton by accessibility id: send-message-button
    Device 1: Tap on found: SendMessageButton

    critical/chats/test_1_1_public_chats.py:278: in test_1_1_chat_non_latin_messages_stack_update_profile_photo
        self.home_2.navigate_back_to_home_view()
    ../views/base_view.py:396: in navigate_back_to_home_view
        while not self.chat_floating_screen.is_element_disappeared(1) \
    ../views/base_element.py:222: in is_element_disappeared
        return self.wait_for_invisibility_of_element(sec)
    ../views/base_element.py:146: in wait_for_invisibility_of_element
        .until(expected_conditions.invisibility_of_element_located((self.by, self.locator)))
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/support/wait.py:86: in until
        value = method(self._driver)
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/support/expected_conditions.py:319: in _predicate
        target = driver.find_element(*target)
    /home/jenkins/.local/lib/python3.10/site-packages/appium/webdriver/webdriver.py:409: in find_element
        return self.execute(RemoteCommand.FIND_ELEMENT, {'using': by, 'value': value})['value']
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py:345: in execute
        self.error_handler.check_response(response)
    /home/jenkins/.local/lib/python3.10/site-packages/appium/webdriver/errorhandler.py:122: in check_response
        raise exception_class(msg=message, stacktrace=format_stacktrace(stacktrace))
     An unknown server-side error occurred while processing the command. Original error: 'POST /element' cannot be proxied to UiAutomator2 server because the instrumentation process is not running (probably crashed). Check the server log and/or the logcat output for more details
    E   Stacktrace:
    E   UnknownError: An unknown server-side error occurred while processing the command. Original error: 'POST /element' cannot be proxied to UiAutomator2 server because the instrumentation process is not running (probably crashed). Check the server log and/or the logcat output for more details
    E       at UIA2Proxy.command (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/jsonwp-proxy/proxy.js:355:13)
    E       at processTicksAndRejections (node:internal/process/task_queues:95:5)
    E       at AndroidUiautomator2Driver.helpers.doFindElementOrEls (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/lib/commands/find.js:30:10)
    E       at doFind (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/find.js:36:17)
    E       at wrappedCondFn (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/timeout.ts:137:14)
    E       at spin (/mnt/sauce/appium/appium-v2.0.0/node_modules/asyncbox/lib/asyncbox.js:221:20)
    E       at waitForCondition (/mnt/sauce/appium/appium-v2.0.0/node_modules/asyncbox/lib/asyncbox.js:238:10)
    E       at AndroidUiautomator2Driver.implicitWaitForCondition (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/timeout.ts:139:12)
    E       at AndroidUiautomator2Driver.findElOrEls (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/find.js:60:5)
    E       at AndroidUiautomator2Driver.findElOrElsWithProcessing (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/find.ts:60:12)
    E       at AndroidUiautomator2Driver.findElement (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/find.ts:75:12)
    



    Device sessions

    5. test_1_1_chat_edit_message, id: 702855

    Device 1: Could not reach home view by pressing system back button

    critical/chats/test_1_1_public_chats.py:369: in test_1_1_chat_edit_message
        self.home_2.navigate_back_to_home_view()
    ../views/base_view.py:396: in navigate_back_to_home_view
        while not self.chat_floating_screen.is_element_disappeared(1) \
    ../views/base_element.py:222: in is_element_disappeared
        return self.wait_for_invisibility_of_element(sec)
    ../views/base_element.py:146: in wait_for_invisibility_of_element
        .until(expected_conditions.invisibility_of_element_located((self.by, self.locator)))
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/support/wait.py:86: in until
        value = method(self._driver)
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/support/expected_conditions.py:319: in _predicate
        target = driver.find_element(*target)
    /home/jenkins/.local/lib/python3.10/site-packages/appium/webdriver/webdriver.py:409: in find_element
        return self.execute(RemoteCommand.FIND_ELEMENT, {'using': by, 'value': value})['value']
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py:345: in execute
        self.error_handler.check_response(response)
    /home/jenkins/.local/lib/python3.10/site-packages/appium/webdriver/errorhandler.py:122: in check_response
        raise exception_class(msg=message, stacktrace=format_stacktrace(stacktrace))
     An unknown server-side error occurred while processing the command. Original error: 'POST /element' cannot be proxied to UiAutomator2 server because the instrumentation process is not running (probably crashed). Check the server log and/or the logcat output for more details
    E   Stacktrace:
    E   UnknownError: An unknown server-side error occurred while processing the command. Original error: 'POST /element' cannot be proxied to UiAutomator2 server because the instrumentation process is not running (probably crashed). Check the server log and/or the logcat output for more details
    E       at UIA2Proxy.command (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/jsonwp-proxy/proxy.js:355:13)
    E       at processTicksAndRejections (node:internal/process/task_queues:95:5)
    E       at AndroidUiautomator2Driver.helpers.doFindElementOrEls (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/lib/commands/find.js:30:10)
    E       at doFind (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/find.js:36:17)
    E       at wrappedCondFn (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/timeout.ts:137:14)
    E       at spin (/mnt/sauce/appium/appium-v2.0.0/node_modules/asyncbox/lib/asyncbox.js:221:20)
    E       at waitForCondition (/mnt/sauce/appium/appium-v2.0.0/node_modules/asyncbox/lib/asyncbox.js:238:10)
    E       at AndroidUiautomator2Driver.implicitWaitForCondition (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/timeout.ts:139:12)
    E       at AndroidUiautomator2Driver.findElOrEls (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/find.js:60:5)
    E       at AndroidUiautomator2Driver.findElOrElsWithProcessing (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/find.ts:60:12)
    E       at AndroidUiautomator2Driver.findElement (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/find.ts:75:12)
    



    Device sessions

    6. test_1_1_chat_send_image_save_and_share, id: 703391

    critical/chats/test_1_1_public_chats.py:395: in test_1_1_chat_send_image_save_and_share
        if not self.chat_2.chat_message_input.is_element_displayed():
    ../views/base_element.py:212: in is_element_displayed
        return self.wait_for_visibility_of_element(sec, ignored_exceptions=ignored_exceptions)
    ../views/base_element.py:137: in wait_for_visibility_of_element
        .until(expected_conditions.visibility_of_element_located((self.by, self.locator)))
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/support/wait.py:86: in until
        value = method(self._driver)
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/support/expected_conditions.py:152: in _predicate
        return _element_if_visible(driver.find_element(*locator))
    /home/jenkins/.local/lib/python3.10/site-packages/appium/webdriver/webdriver.py:409: in find_element
        return self.execute(RemoteCommand.FIND_ELEMENT, {'using': by, 'value': value})['value']
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py:345: in execute
        self.error_handler.check_response(response)
    /home/jenkins/.local/lib/python3.10/site-packages/appium/webdriver/errorhandler.py:122: in check_response
        raise exception_class(msg=message, stacktrace=format_stacktrace(stacktrace))
     An unknown server-side error occurred while processing the command. Original error: 'POST /element' cannot be proxied to UiAutomator2 server because the instrumentation process is not running (probably crashed). Check the server log and/or the logcat output for more details
    E   Stacktrace:
    E   UnknownError: An unknown server-side error occurred while processing the command. Original error: 'POST /element' cannot be proxied to UiAutomator2 server because the instrumentation process is not running (probably crashed). Check the server log and/or the logcat output for more details
    E       at UIA2Proxy.command (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/jsonwp-proxy/proxy.js:355:13)
    E       at processTicksAndRejections (node:internal/process/task_queues:95:5)
    E       at AndroidUiautomator2Driver.helpers.doFindElementOrEls (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/lib/commands/find.js:30:10)
    E       at doFind (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/find.js:36:17)
    E       at wrappedCondFn (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/timeout.ts:137:14)
    E       at spin (/mnt/sauce/appium/appium-v2.0.0/node_modules/asyncbox/lib/asyncbox.js:221:20)
    E       at waitForCondition (/mnt/sauce/appium/appium-v2.0.0/node_modules/asyncbox/lib/asyncbox.js:238:10)
    E       at AndroidUiautomator2Driver.implicitWaitForCondition (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/timeout.ts:139:12)
    E       at AndroidUiautomator2Driver.findElOrEls (/mnt/sauce/appium/appium-v2.0.0/appium_home/linux/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/find.js:60:5)
    E       at AndroidUiautomator2Driver.findElOrElsWithProcessing (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/find.ts:60:12)
    E       at AndroidUiautomator2Driver.findElement (/mnt/sauce/appium/appium-v2.0.0/packages/base-driver/lib/basedriver/commands/find.ts:75:12)
    



    Device sessions

    Expected to fail tests (4)

    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

    Class TestCommunityOneDeviceMerged:

    1. test_community_discovery, id: 703503

    Test is not run, e2e blocker  
    

    [[reason: [NOTRUN] Curated communities not loading, https://github.com//issues/17852]]

    Passed tests (35)

    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 TestActivityMultipleDevicePRTwo:

    1. test_activity_center_mentions, id: 702957
    Device sessions

    2. test_activity_center_admin_notification_accept_swipe, id: 702958
    Device sessions

    Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_message_reaction, id: 702730
    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 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 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 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_undo_delete_message, id: 702869
    Device sessions

    4. test_community_navigate_to_channel_when_relaunch, id: 702846
    Device sessions

    5. test_community_mute_community_and_channel, id: 703382
    Device sessions

    Class TestActivityCenterContactRequestMultipleDevicePR:

    1. test_add_contact_field_validation, id: 702777
    Device sessions

    2. test_activity_center_contact_request_accept_swipe_mark_all_as_read, id: 702851
    Device sessions

    3. test_activity_center_contact_request_decline, id: 702850
    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

    @ilmotta
    Copy link
    Contributor Author

    ilmotta commented Nov 18, 2023

    FYI: @status-im/mobile-qa, in this PR we expect no impact for users, no regressions. The best we can suggest is to run sanity checks in the most common flows.

    @ilmotta no issues from my side. ISSUE 1 is fixed. Failed e2e are not PR related. If this PR is not dependent on #17919 then we are good to merge.

    Hi @pavloburykh. When you tested this PR build with Issue 1 fixed, you did that using the same commit I cherry picked to the PR you mentioned #17919. I just merged that one, and then rebased this malli PR against develop, and successfully ran the e2e tests.

    Therefore, I think we're safe to merge without further manual tests. Time to merge 🚀

    @ilmotta ilmotta merged commit c1dcd7a into develop Nov 18, 2023
    6 checks passed
    @ilmotta ilmotta deleted the malli-core-foundations branch November 18, 2023 14:04
    yevh-berdnyk pushed a commit that referenced this pull request Dec 8, 2023
    …17919)
    
    In PR #17867 we have a namespace
    named schema.core, but this namespace is taken by library prismatic/schema
    already (see https://github.com/plumatic/schema/tree/master/src/cljc/schema), a
    library used by our direct dependency on bidi 2.1.6. This leads to a broken
    build where the ClojureScript compiler reports undeclared vars
    (https://clojurescript.org/reference/compiler-options#warnings).
    
    We change the order Java resolves dependencies via the classpath mechanism. We
    now first resolve our own Clojure sources, and then project dependencies.
    yevh-berdnyk pushed a commit that referenced this pull request Dec 8, 2023
    This commit is the foundational step to start using malli
    (https://github.com/metosin/malli) in this project.
    
    Take in consideration we will only be able to realize malli's full power in
    future iterations.
    
    For those without context: the mobile team watched a presentation about malli
    and went through a light RFC to put everyone on the same page, among other
    discussions here and there in PRs.
    
    To keep things relatively short:
    
    1. Unit, integration and component tests will short-circuit (fail) when
       inputs/outputs don't conform to their respective function schemas (CI should
       fail too).
    2. Failed schema checks will not block the app from initializing, nor throw an
       exception that would trigger the LogBox. Exceptions are only thrown in the
       scope of automated tests.
    3. There's zero performance impact in production code because we only
       instrument. Instrumentation is removed from the compiled code due to the
       usage of "^boolean js.goog/DEBUG".
    4. We shouldn't expect any meaningful slowdown during development.
    
    **What are we instrumenting in this PR?**
    
    Per our team's agreement, we're only instrumenting the bare minimum to showcase 2 examples.
    
    - Instrument a utility function utils.money/format-amount using the macro
      approach.
    - Instrument a quo component quo.components.counter.step.view/view using the
      functional approach.
    
    Both approaches are useful, the functional approach is powerful and allow us to
    instrument anonymous functions, like the ones we pass to subscriptions or event
    handlers, or the higher-order function quo.theme/with-theme. The macro approach
    is perfect for functions already defined with defn.
    
    **I evaluated the schema or function in the REPL but nothing changes**
    
    - If you evaluate the source function, you need to evaluate schema/=> or
      schema/instrument as well.
    - Remember to *var quote* when using schema/instrument.
    - You must call "(status-im2.setup.schema/setup!)" after any var is
      re-instrumented. It's advisable to add a keybinding in your editor to send
      this expression automatically to the CLJS REPL, or add the call at the end of
      the namespace you are working on (similar to how some devs add "(run-tests)"
      at the end of test namespaces).
    
    **Where should schemas be defined?**
    
    For the moment, we should focus on instrumenting quo components, so define each
    function schema in the same namespace as the component's public "view" var.
    
    To be specific:
    
    - A schema used only to instrument a single function and not used elsewhere,
      like a quo component schema, wouldn't benefit from being defined in a separate
      namespace because that would force the developer to constantly open two files
      instead of one to check function signatures.
    - A common schema reused across the repo, like ":schema.common/theme" should be
      registered in the global registry "schema.registry" so that consumers can just
      refer to it by keyword, as if it was a built-in malli schema.
    - A common schema describing status-go entities like message, notification,
      community, etc can be stored either in the respective
      "src/status_im2/contexts/*" or registered globally, or even somewhere else.
      This is yet to be defined, but since I chose not to include schemas for them,
      we can postpone this guideline.
    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.