Skip to content

[Tests] Add more complex user switching tests#1430

Merged
nan-li merged 9 commits intomainfrom
tests/add_user_switching_tests
May 10, 2024
Merged

[Tests] Add more complex user switching tests#1430
nan-li merged 9 commits intomainfrom
tests/add_user_switching_tests

Conversation

@nan-li
Copy link
Copy Markdown
Contributor

@nan-li nan-li commented May 9, 2024

Description

One Line Summary

Add more complex user switching tests involving multiple calls to login / logout / user updates in a short span.

Details

Motivation

  • Adding more testing, and prevent regressions in behavior.
  • We have seen bugs come up when changes have been made that changed expected behavior.

Scope

Unit tests

Testing

Unit testing

Added new test class SwitchUserTests

  1. testIdentifyUserSuccessfully_thenLogin_sendsCorrectTags - existing test migrated from other file
  2. testAnonUser_thenIdentifyUserWithConflict_sendsCorrectUpdatesAndFetchesUser - Starts up with creating the anon user, then a login with conflict happens.
  3. testAnonUser_thenIdentifyUserWithConflict_thenLogout_sendsCorrectUpdatesWithNoFetch - Starts up with creating the anon user, then a login with conflict happens, then a logout happens.
  4. testAnonUser_thenIdentifyUserWithConflict_thenLogin_sendsCorrectUpdatesAndFetchesUser - Starts up with creating the anon user, then a login with conflict happens, then a login to another user happens.

Manual testing

None, app runs.

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item

This change is Reviewable

nan-li added 3 commits May 8, 2024 23:58
* Some requests executed too quickly and need small delay to mimic real server calls
* This was motivated by flaky behavior where Identify User will return very quickly and the user in the SDK should have changed by then, but did not.
@nan-li nan-li force-pushed the tests/add_user_switching_tests branch 2 times, most recently from d53e36c to 4d0e3e7 Compare May 9, 2024 17:03
Comment thread iOS_SDK/OneSignalSDK/OneSignalCoreMocks/Extensions/NSDictionary+UnitTests.swift Outdated
Comment thread iOS_SDK/OneSignalSDK/OneSignalUserTests/SwitchUserTests.swift Outdated
nan-li added 6 commits May 9, 2024 13:34
* These changes were motivate by need to check if [subscription: [token: email] is within a fuller subscription payload
* Move user switching tests to new test class
* Remove test `testIdentifyUserWithConflict_whenNotCurrentUser_sendsCorrectTags` as its behavior is already being tested in the new tests
* Test was failing, increase the time we give to run all threads, and increase the delay in the Client to simulate request making
* SwitchUserTests to SwitchUserIntegrationTests
@nan-li nan-li force-pushed the tests/add_user_switching_tests branch from 46efbac to 7d60db6 Compare May 9, 2024 20:34
Base automatically changed from fix/identify_user_bug_when_in_the_middle to main May 10, 2024 20:44
@nan-li nan-li merged commit e8a15b9 into main May 10, 2024
@nan-li nan-li deleted the tests/add_user_switching_tests branch May 10, 2024 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants