Skip to content
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

160205 release #1213

Merged
merged 8 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions __test__/support/environment/TestContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,10 @@ export default class TestContext {
kind: configIntegrationKind,
},
serviceWorker: {
path: undefined,
workerName: undefined,
registrationScope: undefined,
customizationEnabled: true,
customizationEnabled: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like customizationEnabled is pre-existing dead code, so we could just clean this up instead of changing the value, since it has no effect anywhere.

path: '/',
workerName: 'OneSignalSDKWorker.js',
registrationScope: '/',
},
setupBehavior: {
allowLocalhostAsSecureOrigin: false,
Expand Down
46 changes: 46 additions & 0 deletions __test__/unit/helpers/configHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { getFinalAppConfig } from '../../support/helpers/configHelper';
import { ConfigHelper } from '../../../src/shared/helpers/ConfigHelper';
import TestContext from '../../support/environment/TestContext';

const SERVICE_WORKER_PATH = 'push/onesignal/';

describe('ConfigHelper Tests', () => {
beforeEach(async () => {
await TestEnvironment.initialize();
Expand Down Expand Up @@ -200,4 +202,48 @@ describe('ConfigHelper Tests', () => {
);
expect(finalConfig.autoResubscribe).toBe(true);
});

test('service worker config override (true) for typical site works', () => {
const fakeUserConfig: AppUserConfig = {
appId: getRandomUuid(),
serviceWorkerParam: { scope: '/' + SERVICE_WORKER_PATH },
serviceWorkerPath: SERVICE_WORKER_PATH + 'OneSignalSDKWorker.js',
serviceWorkerOverrideForTypical: true,
}

const fakeServerConfig = TestContext.getFakeServerAppConfig(
ConfigIntegrationKind.TypicalSite,
);

const finalConfig = ConfigHelper.getUserConfigForConfigIntegrationKind(
ConfigIntegrationKind.TypicalSite,
fakeUserConfig,
fakeServerConfig,
);

expect(finalConfig.serviceWorkerPath).toBe('push/onesignal/OneSignalSDKWorker.js');
expect(finalConfig.serviceWorkerParam).toEqual({ scope: '/push/onesignal/' });
})

test('service worker config override (false) for typical site works', () => {
const fakeUserConfig: AppUserConfig = {
appId: getRandomUuid(),
serviceWorkerParam: { scope: '/' + SERVICE_WORKER_PATH },
serviceWorkerPath: SERVICE_WORKER_PATH + 'OneSignalSDKWorker.js',
serviceWorkerOverrideForTypical: false,
}

const fakeServerConfig = TestContext.getFakeServerAppConfig(
ConfigIntegrationKind.TypicalSite,
);

const finalConfig = ConfigHelper.getUserConfigForConfigIntegrationKind(
ConfigIntegrationKind.TypicalSite,
fakeUserConfig,
fakeServerConfig,
);

expect(finalConfig.serviceWorkerPath).toBe('OneSignalSDKWorker.js');
expect(finalConfig.serviceWorkerParam).toEqual({ scope: '/' });
})
});