Skip to content
Open
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
544 changes: 544 additions & 0 deletions SECURITY_CHANGES_SUMMARY.md

Large diffs are not rendered by default.

45 changes: 44 additions & 1 deletion jestSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import { setIconOptions } from '@fluentui/react';
import * as Enzyme from 'enzyme';
import * as Adapter from 'enzyme-adapter-react-16';
import { appConfig } from './src/appConfig/appConfig'

// Define globals that were previously in Jest config
(global as any).__DEV__ = true;
(global as any).frameSignature = 'portalEnvironmentFrameSignature';

// tslint:disable-next-line: no-string-literal
global.Headers = jest.fn();
Expand All @@ -31,5 +34,45 @@ jest.mock('react-i18next', () => ({
jest.mock('./src/appConfig/appConfig', () => ({
...jest.requireActual('./src/appConfig/appConfig'),
appConfig: {
hostMode: 'electron', // Use electron mode since we only support Electron now
controllerPort: 8081,
telemetryConnString: 'InstrumentationKey=4e4b375e-0c49-42e3-8a51-20b22ce36181;IngestionEndpoint=https://westus2-2.in.applicationinsights.azure.com/;LiveEndpoint=https://westus2.livediagnostics.monitor.azure.com/'
}}));

// Mock the device API interface for IPC communication
const mockDataPlaneResponse = {
body: { body: {} },
statusCode: 200
};

(window as any).api_device = {
dataPlaneRequest: jest.fn(() => Promise.resolve(mockDataPlaneResponse)),
readLocalFile: jest.fn(() => Promise.resolve(null)),
readLocalFileNaive: jest.fn(() => Promise.resolve('{}')),
getDirectories: jest.fn(() => Promise.resolve([])),
startEventHubMonitoring: jest.fn(() => Promise.resolve()),
stopEventHubMonitoring: jest.fn(() => Promise.resolve()),
onEventHubMessage: jest.fn(() => () => {}),
sendMessageToDevice: jest.fn(() => Promise.resolve())
};

// Mock the settings interface
(window as any).api_settings = {
useHighContrast: jest.fn(() => Promise.resolve(false))
};

// Mock the authentication interface
(window as any).api_authentication = {
login: jest.fn(() => Promise.resolve()),
logout: jest.fn(() => Promise.resolve()),
getProfileToken: jest.fn(() => Promise.resolve(null))
};

// Mock the credentials interface
(window as any).api_credentials = {
storeCredential: jest.fn(() => Promise.resolve(null)),
getCredential: jest.fn(() => Promise.resolve(null)),
deleteCredential: jest.fn(() => Promise.resolve(null)),
listCredentials: jest.fn(() => Promise.resolve([])),
isEncryptionAvailable: jest.fn(() => Promise.resolve(false))
};
Loading