Skip to content

Commit

Permalink
fix: broken deep links on the homecards (#3357)
Browse files Browse the repository at this point in the history
### Description

Context:
https://valora-app.slack.com/archives/C02N3AR2P2S/p1673628550702569?thread_ts=1673565367.051299&cid=C02N3AR2P2S

URLSearchParams from the `url` lib doesn't work as expected, in other
places we're using this from the global scope.

### Test plan

Tested manually, added a e2e test

### Related issues

N/A

### Backwards compatibility

Y
  • Loading branch information
kathaypacific authored and jeanregisser committed Jan 16, 2023
1 parent 67f6b8e commit b2650ef
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
4 changes: 3 additions & 1 deletion e2e/src/Notifications.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import HandleNotification from './usecases/HandleNotification'
import { quickOnboarding } from './utils/utils'

describe.skip('Handle app open from push notifications', () => {
describe('Handle app open from push notifications', () => {
beforeAll(async () => {
await quickOnboarding()
})

describe('HandleNotification', HandleNotification)
})
22 changes: 21 additions & 1 deletion e2e/src/usecases/HandleNotification.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { DetoxConstants } from 'detox'
import { launchApp } from '../utils/retries'

export default HandleNotification = () => {
it('Launch app from push notification', async () => {
// firebase is currently not enabled for e2e tests so the below test is skipped.
it.skip('Launch app from push notification', async () => {
const userNotification = {
trigger: {
type: 'push',
Expand All @@ -20,4 +22,22 @@ export default HandleNotification = () => {

await launchApp({ newInstance: true, userNotification })
})

it(':ios: Launch app and deeplink to another screen', async () => {
await launchApp({
newInstance: true,
userNotification: {
trigger: {
type: DetoxConstants.userNotificationTriggers.push,
},
payload: {
wzrk_dl: 'celo://wallet/openScreen?screen=Send',
},
},
})

await waitFor(element(by.id('RecipientPicker')))
.toBeVisible()
.withTimeout(10 * 1000)
})
}
6 changes: 3 additions & 3 deletions src/app/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ import {
mtwAddressSelector,
walletAddressSelector,
} from 'src/web3/selectors'
import { URLSearchParams, parse } from 'url'
import { parse } from 'url'

const TAG = 'app/saga'

Expand Down Expand Up @@ -250,9 +250,9 @@ function parseValue(value: string) {
function convertQueryToScreenParams(query: string) {
const decodedParams = new URLSearchParams(decodeURIComponent(query))
const params: { [key: string]: any } = {}
for (const [key, value] of decodedParams.entries()) {
decodedParams.forEach((value, key) => {
params[key] = parseValue(value)
}
})
return params
}

Expand Down

0 comments on commit b2650ef

Please sign in to comment.