Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Always connect to client notification service if user is logged in #184

Merged
merged 1 commit into from
Mar 1, 2021
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
43 changes: 22 additions & 21 deletions src/context/context-provider.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//#region imports

import {
BBAuth,
BBAuthTokenErrorCode
Expand Down Expand Up @@ -29,18 +27,16 @@ import {
BBContextDestinations
} from './context-destinations';

//#endregion

describe('Context provider', () => {
let messageIsFromOmnibarReturnValue: boolean;

let testDestinationsSingle: BBContextDestinations;
let testDestinationsMultiple: BBContextDestinations;
let testDestinationsNone: BBContextDestinations;

let postOmnibarMessageSpy: jasmine.Spy;
let messageIsFromOmnibarSpy: jasmine.Spy;
let redirectToErrorSpy: jasmine.Spy;
let postOmnibarMessageSpy: jasmine.Spy<typeof BBAuthInterop.postOmnibarMessage>;
let messageIsFromOmnibarSpy: jasmine.Spy<typeof BBAuthInterop.messageIsFromOmnibar>;
let redirectToErrorSpy: jasmine.Spy<typeof BBAuthNavigator.redirectToError>;

let getTokenFake: () => Promise<string>;

Expand Down Expand Up @@ -96,6 +92,15 @@ describe('Context provider', () => {
});
}

async function ensureContextWithCatch(args: BBContextArgs): Promise<BBContextArgs> {
try {
return await BBContextProvider.ensureContext(args);
} catch (err) {
// Handle the promise rejection that happens when canceling the welcome screen after each test run.
return undefined;
}
}

beforeEach(() => {
BBContextProvider.url = 'about:blank';

Expand Down Expand Up @@ -163,7 +168,7 @@ describe('Context provider', () => {
});

it('should automatically resolve if environment ID is not required', async (done) => {
const args = await BBContextProvider.ensureContext({
const args = await ensureContextWithCatch({
envIdRequired: false
});

Expand All @@ -172,7 +177,7 @@ describe('Context provider', () => {
});

it('should automatically resolve if environment ID is required but provided', async (done) => {
const args = await BBContextProvider.ensureContext({
const args = await ensureContextWithCatch({
envId: '123',
envIdRequired: true
});
Expand All @@ -191,7 +196,7 @@ describe('Context provider', () => {
}
);

BBContextProvider.ensureContext({
ensureContextWithCatch({
envIdRequired: true,
svcId: 'abc'
});
Expand All @@ -208,10 +213,6 @@ describe('Context provider', () => {
it(
'should not redirect if disableRedirect and environment ID is required but the user is not in an environment',
async (done) => {
const expectedArgs: BBContextArgs = {
url: 'custom-url'
};

replyWithDestinations(
'abc',
'',
Expand Down Expand Up @@ -242,7 +243,7 @@ describe('Context provider', () => {
testDestinationsNone
);

BBContextProvider.ensureContext({
ensureContextWithCatch({
envIdRequired: true
});

Expand All @@ -258,7 +259,7 @@ describe('Context provider', () => {
testDestinationsSingle
);

const args = await BBContextProvider.ensureContext({
const args = await ensureContextWithCatch({
envIdRequired: true,
svcId: 'abc'
});
Expand All @@ -274,7 +275,7 @@ describe('Context provider', () => {
testDestinationsMultiple
);

const contextPromise = BBContextProvider.ensureContext({
const contextPromise = ensureContextWithCatch({
envIdRequired: true,
svcId: 'abc',
url: 'https://example.com'
Expand Down Expand Up @@ -339,7 +340,7 @@ describe('Context provider', () => {
testDestinationsMultiple
);

BBContextProvider.ensureContext({
ensureContextWithCatch({
envIdRequired: true,
svcId: 'abc'
});
Expand Down Expand Up @@ -376,7 +377,7 @@ describe('Context provider', () => {
testDestinationsMultiple
);

BBContextProvider.ensureContext({
ensureContextWithCatch({
envIdRequired: true,
svcId: 'abc'
});
Expand Down Expand Up @@ -420,7 +421,7 @@ describe('Context provider', () => {
testDestinationsMultiple
);

BBContextProvider.ensureContext({
ensureContextWithCatch({
envIdRequired: true,
svcId: 'abc',
url: 'https://example.com'
Expand All @@ -444,7 +445,7 @@ describe('Context provider', () => {
testDestinationsMultiple
);

BBContextProvider.ensureContext({
ensureContextWithCatch({
envIdRequired: true,
svcId: 'abc',
url: 'https://example.com'
Expand Down
25 changes: 25 additions & 0 deletions src/omnibar/omnibar-push-notifications-connect-args.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {
BBOmnibarNavigationItem
} from './omnibar-navigation-item';

export interface BBOmnibarPushNotificationsConnectArgs {

customMessageCallback: any;

envId: string;

handleNavigate: (navItem: BBOmnibarNavigationItem) => void;

handleNavigateUrl: (url: string) => void;

leId: string;

notificationsCallback: (message: any) => void;

openPushNotificationsMenu: () => void;

showVerticalNav: boolean;

svcId: string;

}
Loading