Skip to content

Should pass sdk version for addSms/addEmail #1312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/core/executors/LoginUserOperationExecutor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ describe('LoginUserOperationExecutor', () => {
refresh_device_metadata: true,
subscriptions: [
{
device_model: '',
device_os: 56,
sdk: '1',
token: mockSubscriptionOpInfo.token,
type: mockSubscriptionOpInfo.type,
},
Expand Down Expand Up @@ -391,6 +394,9 @@ describe('LoginUserOperationExecutor', () => {
expect.objectContaining({
subscriptions: [
{
device_model: '',
device_os: 56,
sdk: '1',
type: mockSubscriptionOpInfo.type,
...updates,
},
Expand Down Expand Up @@ -435,7 +441,10 @@ describe('LoginUserOperationExecutor', () => {
expect.objectContaining({
subscriptions: [
{
device_model: '',
device_os: 56,
id: DUMMY_SUBSCRIPTION_ID,
sdk: '1',
type: mockSubscriptionOpInfo.type,
token: mockSubscriptionOpInfo.token,
},
Expand Down
5 changes: 3 additions & 2 deletions src/core/executors/SubscriptionOperationExecutor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,11 @@ describe('SubscriptionOperationExecutor', () => {

expect(createSubscriptionFn).toHaveBeenCalledWith({
subscription: {
type: SubscriptionType.ChromePush,
enabled: false,
token: 'new-token',
notification_types: NotificationType.UserOptedOut,
token: 'new-token',
sdk: '1',
type: SubscriptionType.ChromePush,
},
});
});
Expand Down
1 change: 1 addition & 0 deletions src/core/executors/SubscriptionOperationExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class SubscriptionOperationExecutor implements IOperationExecutor {
createOperation.notification_types;

const subscription = {
sdk: createOperation.sdk,
type: createOperation.type,
enabled,
token,
Expand Down
2 changes: 2 additions & 0 deletions src/core/operationRepo/OperationRepo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
DUMMY_ONESIGNAL_ID,
DUMMY_SUBSCRIPTION_ID,
} from '__test__/support/constants';
import { mockUserAgent } from '__test__/support/environment/TestEnvironmentHelpers';
import { fakeWaitForOperations } from '__test__/support/helpers/executors';
import Log from 'src/shared/libraries/Log';
import Database, { OperationItem } from 'src/shared/services/Database';
Expand Down Expand Up @@ -38,6 +39,7 @@ vi.spyOn(OperationModelStore.prototype, 'create').mockImplementation(() => {
});

let mockOperationModelStore: OperationModelStore;
mockUserAgent();

describe('OperationRepo', () => {
let opRepo: OperationRepo;
Expand Down
7 changes: 4 additions & 3 deletions src/core/operations/BaseFullSubscriptionOperation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import FuturePushSubscriptionRecord from 'src/page/userModel/FuturePushSubscriptionRecord';
import { ICreateUserSubscription } from '../types/api';
import {
NotificationTypeValue,
Expand Down Expand Up @@ -27,11 +28,11 @@ export abstract class BaseFullSubscriptionOperation extends BaseSubscriptionOper
super(operationName, appId, onesignalId);

if (subscription) {
this.device_model = subscription.device_model;
this.device_os = subscription.device_os;
this.sdk = FuturePushSubscriptionRecord.getSdk();
this.device_model = FuturePushSubscriptionRecord.getDeviceModel();
this.device_os = FuturePushSubscriptionRecord.getDeviceOS();
this.enabled = subscription.enabled;
this.notification_types = subscription.notification_types;
this.sdk = subscription.sdk;
this.subscriptionId = subscription.subscriptionId;
this.token = subscription.token;
this.type = subscription.type;
Expand Down
5 changes: 3 additions & 2 deletions src/onesignal/OneSignal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ describe('OneSignal', () => {
const identityModel = window.OneSignal.coreDirector.getIdentityModel();
expect(identityModel.getProperty('someLabel')).toBeUndefined();

await waitForOperations(3);
expect(deleteAliasFn).toHaveBeenCalled();
await vi.waitUntil(() => deleteAliasFn.mock.calls.length === 1);
});

test('can delete multiple aliases from the current user', async () => {
Expand Down Expand Up @@ -213,6 +212,7 @@ describe('OneSignal', () => {
const subscription: ICreateUserSubscription = {
enabled: true,
notification_types: 1,
sdk: '1',
token: email,
type: 'Email',
};
Expand Down Expand Up @@ -303,6 +303,7 @@ describe('OneSignal', () => {
const subscription: ICreateUserSubscription = {
enabled: true,
notification_types: 1,
sdk: '1',
token: sms,
type: 'SMS',
};
Expand Down
Loading