Skip to content

✅ app: fix onesignal on e2e with random id#698

Merged
cruzdanilo merged 2 commits intomainfrom
android
Jan 30, 2026
Merged

✅ app: fix onesignal on e2e with random id#698
cruzdanilo merged 2 commits intomainfrom
android

Conversation

@cruzdanilo
Copy link
Member

@cruzdanilo cruzdanilo commented Jan 30, 2026


Open with Devin

Summary by CodeRabbit

  • Chores

    • Added a small release metadata file.
    • Updated e2e workflow job dependencies to streamline local runs.
  • Tests

    • Improved OneSignal initialization and login behavior to better support e2e testing and simulated device flows.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Jan 30, 2026

🦋 Changeset detected

Latest commit: 4380280

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Jan 30, 2026

Walkthrough

Updates e2e workflow job dependencies and adds e2e-mode conditional behavior to OneSignal initialization: introduces a readiness promise that waits for a OneSignal user event and gates enablePrompt/login behavior in EXPO_PUBLIC_ENV="e2e".

Changes

Cohort / File(s) Summary
Changeset
.changeset/silent-eyes-beg.md
Adds a new changeset file containing two YAML document separators.
Workflow Configuration
.eas/workflows/local.yaml
Alters e2e job dependencies: android_e2e now depends on android_get, and ios_e2e now depends on ios_get instead of fingerprint.
OneSignal Utilities
src/utils/onesignal.ts
Adds e2e-specific initialization flow: creates a ready promise that waits for a OneSignal user-change event, simulates/login with a random userId in e2e mode, and gates enablePrompt to wait for both hydration and the new ready promise; skips OneSignal.login in e2e mode.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant App
participant OneSignalSDK
participant Hydration
participant E2EEnv
App->>OneSignalSDK: init (mobile, appId present, EXPO_PUBLIC_ENV="e2e")
Note right of OneSignalSDK: create readyPromise\nlisten for user change event
OneSignalSDK->>E2EEnv: wait for onesignalId event
E2EEnv-->>OneSignalSDK: user-change event with onesignalId
OneSignalSDK->>OneSignalSDK: resolve readyPromise, simulate login (random userId) [no external login call]
App->>Hydration: wait for hydration
App->>OneSignalSDK: enablePrompt()
OneSignalSDK->>App: proceed after hydration + readyPromise resolved

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • dieguezguille
  • franm91
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title specifically references fixing OneSignal on e2e with random id, which directly aligns with the main code change in src/utils/onesignal.ts that implements e2e-specific OneSignal initialization logic with random user IDs.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch android

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @cruzdanilo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the reliability and isolation of end-to-end (E2E) tests by specifically adjusting the OneSignal integration. It introduces logic to ensure that OneSignal operates with temporary, random user identifiers during E2E runs, preventing data contamination. Concurrently, it refines the CI/CD pipeline's E2E job dependencies, optimizing the build and test process for these environments.

Highlights

  • OneSignal E2E Login Fix: Implemented a conditional login mechanism for OneSignal in end-to-end (E2E) testing environments, ensuring that OneSignal initializes and logs in with a randomly generated user ID when EXPO_PUBLIC_ENV is set to 'e2e'. This prevents E2E tests from interfering with actual user data.
  • OneSignal Prompt Workaround for E2E: Added a specific workaround (a 'HACK' as noted in the code) within the enablePrompt function for E2E environments, which explicitly calls OneSignal.User.getOnesignalId() before adding an in-app message trigger. This addresses potential issues with prompt display in E2E tests.
  • CI/CD Workflow Dependency Update: Updated the local EAS workflow configuration (.eas/workflows/local.yaml) to change the dependencies for android_e2e and ios_e2e jobs. They now depend on android_get and ios_get respectively, instead of fingerprint, streamlining the E2E testing pipeline.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request fixes an issue with OneSignal in end-to-end tests by logging in with a random user ID for each test run. The changes also include updates to the EAS workflow configuration to correct job dependencies. The approach to fix the e2e tests seems correct. The suggestion to improve how the random ID is generated for better clarity and to avoid potential issues with the ID format is valid and has been kept.

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View issue and 3 additional flags in Devin Review.

Open in Devin Review

@sentry
Copy link

sentry bot commented Jan 30, 2026

Codecov Report

❌ Patch coverage is 54.54545% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.71%. Comparing base (c0da73c) to head (4380280).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/utils/onesignal.ts 54.54% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #698      +/-   ##
==========================================
- Coverage   63.78%   63.71%   -0.08%     
==========================================
  Files         169      169              
  Lines        5315     5324       +9     
  Branches     1497     1501       +4     
==========================================
+ Hits         3390     3392       +2     
- Misses       1738     1745       +7     
  Partials      187      187              
Flag Coverage Δ
e2e 42.23% <54.54%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In @.eas/workflows/local.yaml:
- Around line 34-35: The workflow is incorrectly reading outputs from jobs
listed under "after" via "needs" (e.g., needs.android_build.outputs.build_id);
update those references to use the "after" context and fall back to the sibling
repack job where applicable — replace usages like
needs.android_build.outputs.build_id with after.android_build.outputs.build_id
|| after.android_repack.outputs.build_id (and do the same for ios:
after.ios_build.outputs.build_id || after.ios_repack.outputs.build_id) so the
workflow consistently reads outputs from conditionally-executed jobs.

In `@src/utils/onesignal.ts`:
- Around line 69-72: The code directly reads process.env.EXPO_PUBLIC_ENV in
onesignal initialization branches (around OneSignal.initialize and
OneSignal.login and the other occurrences noted at lines ~81-85 and ~91) which
bypasses the valibot-validated config; change these to use the validated
environment value exported from your central config (e.g., import the validated
env object or an exported boolean like isE2E) and replace direct checks of
process.env.EXPO_PUBLIC_ENV with that shared isE2E boolean so
OneSignal.initialize, OneSignal.login and the other branches use the validated
config instead of raw process.env.
- Around line 81-85: Extract the multi-line async arrow callback into a named
async function (e.g., async function handleOnboardTrigger()) and call that
function in place of the inline async () => { ... } so the block around
queryClient.getQueryData, DISMISS_EXPIRY check, the
OneSignal.User.getOnesignalId call, and
OneSignal.InAppMessages.addTrigger("onboard","1") becomes a function
declaration; also replace the inline comment "// HACK" with a lowercase comment
"// hack" to satisfy the comment-casing rule and keep the same try/catch
behavior for OneSignal.User.getOnesignalId().catch(() => undefined).

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @.eas/workflows/local.yaml:
- Around line 32-34: The workflow is incorrectly referencing outputs with
needs.android_build/needs.android_repack while those jobs are declared in the
after array; update the output accessors to use after.<job>.outputs.<name>
(e.g., after.android_build.outputs.build_id or
after.android_repack.outputs.build_id) wherever build_id is referenced (the
android_e2e job and the analogous iOS e2e references), or alternatively move
android_build and android_repack into the needs array so the existing
needs.<job>.outputs.<name> syntax becomes valid; ensure consistent use of
after.<job>.outputs.build_id for jobs listed under after (and the same change
for the iOS job names referenced).

In `@src/utils/onesignal.ts`:
- Line 84: Update the HACK comment next to the OneSignal.User.getOnesignalId()
call to include a ticket/issue reference (e.g., "HACK: temporary workaround, see
TICKET-1234") and replace the silent .catch(() => undefined) with a handler that
logs the caught error for debugging in e2e runs (use existing logger or
console.warn/error) while still returning/ignoring the value; locate the call in
the OneSignal helper where OneSignal.User.getOnesignalId() is awaited and apply
these changes to preserve behavior but surface errors for investigation.

@cruzdanilo cruzdanilo merged commit 4380280 into main Jan 30, 2026
15 of 17 checks passed
@cruzdanilo cruzdanilo deleted the android branch January 30, 2026 13:26
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.

1 participant