-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/device push identifier (#148)
* feat: update backbone return type * feat: handle device push identifier in the app-runtime * fix: add devicePushIdentifier to LocalAccountDTO * chore: add lgos * chore: simplify the event bus and make it actually work * fix: assert on the dpi * feat: add a test for push notifications * fix: remove TODO comment * chore: bumpy * chore: bump transport --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
c67ed06
commit f7dd1f2
Showing
18 changed files
with
152 additions
and
63 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
packages/app-runtime/test/modules/PushNotification.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { RemoteNotificationEvent, RemoteNotificationRegistrationEvent } from "@js-soft/native-abstractions"; | ||
import { sleep } from "@js-soft/ts-utils"; | ||
import { AppRuntime, DatawalletSynchronizedEvent, ExternalEventReceivedEvent, LocalAccountSession } from "../../src"; | ||
import { TestUtil } from "../lib"; | ||
|
||
describe("PushNotificationModuleTest", function () { | ||
let runtime: AppRuntime; | ||
let session: LocalAccountSession; | ||
let devicePushIdentifier = "dummy value"; | ||
|
||
beforeAll(async function () { | ||
runtime = await TestUtil.createRuntime(); | ||
await runtime.start(); | ||
|
||
const accounts = await TestUtil.provideAccounts(runtime, 1); | ||
session = await runtime.selectAccount(accounts[0].id); | ||
}); | ||
|
||
afterAll(async function () { | ||
await runtime.stop(); | ||
}); | ||
|
||
test("should persist push identifier", async function () { | ||
runtime.nativeEnvironment.eventBus.publish(new RemoteNotificationRegistrationEvent("handleLongerThan10Characters")); | ||
|
||
// wait for the registration to finish | ||
// there is no event to wait for, so we just wait for a second | ||
await sleep(1000); | ||
|
||
const account = await runtime.accountServices.getAccount(session.account.id); | ||
expect(account.devicePushIdentifier).toBeDefined(); | ||
|
||
devicePushIdentifier = account.devicePushIdentifier!; | ||
}); | ||
|
||
test("should do a datawallet sync when DatawalletModificationsCreated is received", async function () { | ||
runtime.nativeEnvironment.eventBus.publish( | ||
new RemoteNotificationEvent({ | ||
content: { | ||
devicePushIdentifier: devicePushIdentifier, | ||
eventName: "DatawalletModificationsCreated", | ||
sentAt: new Date().toISOString(), | ||
payload: {} | ||
} | ||
}) | ||
); | ||
|
||
const event = await TestUtil.awaitEvent(runtime, DatawalletSynchronizedEvent); | ||
expect(event).toBeDefined(); | ||
}); | ||
|
||
test("should do a sync everything when ExternalEventCreated is received", async function () { | ||
runtime.nativeEnvironment.eventBus.publish( | ||
new RemoteNotificationEvent({ | ||
content: { | ||
devicePushIdentifier: devicePushIdentifier, | ||
eventName: "ExternalEventCreated", | ||
sentAt: new Date().toISOString(), | ||
payload: {} | ||
} | ||
}) | ||
); | ||
|
||
const event = await TestUtil.awaitEvent(runtime, ExternalEventReceivedEvent); | ||
expect(event).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.