Skip to content

Commit e7164c0

Browse files
committed
should pass sdk version for addSms/addEmail
1 parent b5deb8d commit e7164c0

File tree

6 files changed

+22
-7
lines changed

6 files changed

+22
-7
lines changed

src/core/executors/LoginUserOperationExecutor.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,9 @@ describe('LoginUserOperationExecutor', () => {
353353
refresh_device_metadata: true,
354354
subscriptions: [
355355
{
356+
device_model: '',
357+
device_os: 56,
358+
sdk: '1',
356359
token: mockSubscriptionOpInfo.token,
357360
type: mockSubscriptionOpInfo.type,
358361
},
@@ -391,6 +394,9 @@ describe('LoginUserOperationExecutor', () => {
391394
expect.objectContaining({
392395
subscriptions: [
393396
{
397+
device_model: '',
398+
device_os: 56,
399+
sdk: '1',
394400
type: mockSubscriptionOpInfo.type,
395401
...updates,
396402
},
@@ -435,7 +441,10 @@ describe('LoginUserOperationExecutor', () => {
435441
expect.objectContaining({
436442
subscriptions: [
437443
{
444+
device_model: '',
445+
device_os: 56,
438446
id: DUMMY_SUBSCRIPTION_ID,
447+
sdk: '1',
439448
type: mockSubscriptionOpInfo.type,
440449
token: mockSubscriptionOpInfo.token,
441450
},

src/core/executors/SubscriptionOperationExecutor.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,11 @@ describe('SubscriptionOperationExecutor', () => {
194194

195195
expect(createSubscriptionFn).toHaveBeenCalledWith({
196196
subscription: {
197-
type: SubscriptionType.ChromePush,
198197
enabled: false,
199-
token: 'new-token',
200198
notification_types: NotificationType.UserOptedOut,
199+
token: 'new-token',
200+
sdk: '1',
201+
type: SubscriptionType.ChromePush,
201202
},
202203
});
203204
});

src/core/executors/SubscriptionOperationExecutor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export class SubscriptionOperationExecutor implements IOperationExecutor {
8585
createOperation.notification_types;
8686

8787
const subscription = {
88+
sdk: createOperation.sdk,
8889
type: createOperation.type,
8990
enabled,
9091
token,

src/core/operationRepo/OperationRepo.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
DUMMY_ONESIGNAL_ID,
44
DUMMY_SUBSCRIPTION_ID,
55
} from '__test__/support/constants';
6+
import { mockUserAgent } from '__test__/support/environment/TestEnvironmentHelpers';
67
import { fakeWaitForOperations } from '__test__/support/helpers/executors';
78
import Log from 'src/shared/libraries/Log';
89
import Database, { OperationItem } from 'src/shared/services/Database';
@@ -38,6 +39,7 @@ vi.spyOn(OperationModelStore.prototype, 'create').mockImplementation(() => {
3839
});
3940

4041
let mockOperationModelStore: OperationModelStore;
42+
mockUserAgent();
4143

4244
describe('OperationRepo', () => {
4345
let opRepo: OperationRepo;

src/core/operations/BaseFullSubscriptionOperation.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import FuturePushSubscriptionRecord from 'src/page/userModel/FuturePushSubscriptionRecord';
12
import { ICreateUserSubscription } from '../types/api';
23
import {
34
NotificationTypeValue,
@@ -27,11 +28,11 @@ export abstract class BaseFullSubscriptionOperation extends BaseSubscriptionOper
2728
super(operationName, appId, onesignalId);
2829

2930
if (subscription) {
30-
this.device_model = subscription.device_model;
31-
this.device_os = subscription.device_os;
31+
this.sdk = FuturePushSubscriptionRecord.getSdk();
32+
this.device_model = FuturePushSubscriptionRecord.getDeviceModel();
33+
this.device_os = FuturePushSubscriptionRecord.getDeviceOS();
3234
this.enabled = subscription.enabled;
3335
this.notification_types = subscription.notification_types;
34-
this.sdk = subscription.sdk;
3536
this.subscriptionId = subscription.subscriptionId;
3637
this.token = subscription.token;
3738
this.type = subscription.type;

src/onesignal/OneSignal.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ describe('OneSignal', () => {
148148
const identityModel = window.OneSignal.coreDirector.getIdentityModel();
149149
expect(identityModel.getProperty('someLabel')).toBeUndefined();
150150

151-
await waitForOperations(3);
152-
expect(deleteAliasFn).toHaveBeenCalled();
151+
await vi.waitUntil(() => deleteAliasFn.mock.calls.length === 1);
153152
});
154153

155154
test('can delete multiple aliases from the current user', async () => {
@@ -213,6 +212,7 @@ describe('OneSignal', () => {
213212
const subscription: ICreateUserSubscription = {
214213
enabled: true,
215214
notification_types: 1,
215+
sdk: '1',
216216
token: email,
217217
type: 'Email',
218218
};
@@ -303,6 +303,7 @@ describe('OneSignal', () => {
303303
const subscription: ICreateUserSubscription = {
304304
enabled: true,
305305
notification_types: 1,
306+
sdk: '1',
306307
token: sms,
307308
type: 'SMS',
308309
};

0 commit comments

Comments
 (0)