Skip to content

Commit 6ef60ec

Browse files
committed
add test case for login then accept permissions
1 parent 58cf911 commit 6ef60ec

9 files changed

Lines changed: 469 additions & 295 deletions

File tree

__test__/unit/notifications/subscriptionmanager.test.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/core/executors/LoginUserOperationExecutor.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,22 @@ describe('LoginUserOperationExecutor', () => {
174174
await setPushToken(DUMMY_PUSH_TOKEN);
175175

176176
const subscriptionModel = new SubscriptionModel();
177-
subscriptionModel.setProperty('id', DUMMY_SUBSCRIPTION_ID);
177+
subscriptionModel.setProperty(
178+
'id',
179+
DUMMY_SUBSCRIPTION_ID,
180+
ModelChangeTags.HYDRATE,
181+
);
178182
subscriptionModelStore.add(subscriptionModel, ModelChangeTags.HYDRATE);
179183

180184
// perform operations with old onesignal id
181185
const executor = getExecutor();
182186

183187
const loginOp = new LoginUserOperation(APP_ID, DUMMY_ONESIGNAL_ID);
184-
loginOp.setProperty('externalId', DUMMY_EXTERNAL_ID);
188+
loginOp.setProperty(
189+
'externalId',
190+
DUMMY_EXTERNAL_ID,
191+
ModelChangeTags.HYDRATE,
192+
);
185193

186194
const createSubOp = new CreateSubscriptionOperation(
187195
mockSubscriptionOpInfo,

src/core/executors/SubscriptionOperationExecutor.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,20 @@ describe('SubscriptionOperationExecutor', () => {
5252
});
5353

5454
beforeEach(async () => {
55+
setCreateSubscriptionResponse();
5556
subscriptionModelStore = OneSignal.coreDirector.subscriptionModelStore;
5657
newRecordsState = OneSignal.coreDirector.newRecordsState;
58+
newRecordsState.records.clear();
5759

5860
identityModelStore = OneSignal.coreDirector.identityModelStore;
5961
propertiesModelStore = OneSignal.coreDirector.propertiesModelStore;
6062
subscriptionsModelStore = OneSignal.coreDirector.subscriptionModelStore;
6163

62-
identityModelStore.model.onesignalId = DUMMY_ONESIGNAL_ID;
64+
identityModelStore.model.setProperty(
65+
'onesignal_id',
66+
DUMMY_ONESIGNAL_ID,
67+
ModelChangeTags.HYDRATE,
68+
);
6369
buildUserService = new RebuildUserService(
6470
identityModelStore,
6571
propertiesModelStore,

src/core/executors/UpdateUserOperationExecutor.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { PropertiesModelStore } from '../modelStores/PropertiesModelStore';
1313
import { SubscriptionModelStore } from '../modelStores/SubscriptionModelStore';
1414
import { NewRecordsState } from '../operationRepo/NewRecordsState';
1515
import { SetPropertyOperation } from '../operations/SetPropertyOperation';
16+
import { ModelChangeTags } from '../types/models';
1617
import { ExecutionResult } from '../types/operation';
1718
import { UpdateUserOperationExecutor } from './UpdateUserOperationExecutor';
1819

@@ -49,6 +50,7 @@ describe('UpdateUserOperationExecutor', () => {
4950
identityModelStore.model.setProperty(
5051
IdentityConstants.ONESIGNAL_ID,
5152
DUMMY_ONESIGNAL_ID,
53+
ModelChangeTags.HYDRATE,
5254
);
5355
});
5456

0 commit comments

Comments
 (0)