Skip to content

Commit

Permalink
Merge branch 'main' into empty-shared-folders
Browse files Browse the repository at this point in the history
  • Loading branch information
jvigliotta authored Feb 28, 2024
2 parents 976e684 + e22d35b commit 9294fb1
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 107 deletions.
6 changes: 5 additions & 1 deletion src/historical/HistoricalProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ define([
// TODO: better handling when domain not available.
}

const sessions = sessionServiceDefault.default();
const sessions = this.getSessionService();
const session = sessions.getHistoricalSession();

if (session) {
Expand Down Expand Up @@ -644,5 +644,9 @@ define([
return false;
}

HistoricalProvider.prototype.getSessionService = function () {
return sessionServiceDefault.default();
}

return HistoricalProvider;
});
201 changes: 95 additions & 106 deletions src/historical/HistoricalProviderSpec.js
Original file line number Diff line number Diff line change
@@ -1,124 +1,113 @@
/*global define,describe,beforeEach,it,jasmine,expect*/
import HistoricalProvider from './HistoricalProvider';

define([
'./HistoricalProvider'
], function (
HistoricalProvider
) {
'use strict';
describe('Historical Provider', function () {
let historicalProvider;
let mockOpenMct;
let mockMetadata;
let options;
let mockDomainObject;
let mockSessionService;
let mockNotification;
let resolveCallback;
let rejectCallback;

xdescribe('Historical Provider', function () {
let historicalProvider;
let mockOpenMct;
let mockMetadata;
let options;
let mockDomainObject;
let mockSessionService;
let mockNotification;
let resolveCallback;
let rejectCallback;
beforeEach(function () {
options = {
domain: 'scet'
};
mockOpenMct = {};

beforeEach(function () {
options = {
domain: 'scet'
};
mockOpenMct = {};

mockOpenMct.telemetry = jasmine.createSpyObj('telemetryApi', [
'getMetadata'
]);
mockMetadata = jasmine.createSpyObj('metadata', [
'value',
'values'
]);
mockMetadata.values.and.returnValue([]);
mockOpenMct.telemetry.getMetadata.and.returnValue(mockMetadata);
mockMetadata.value.and.returnValue({
'key': 'scet'
});
mockOpenMct.telemetry = jasmine.createSpyObj('telemetryApi', [
'getMetadata'
]);
mockMetadata = jasmine.createSpyObj('metadata', [
'value',
'values'
]);
mockMetadata.values.and.returnValue([]);
mockOpenMct.telemetry.getMetadata.and.returnValue(mockMetadata);
mockMetadata.value.and.returnValue({
'key': 'scet'
});

mockSessionService = jasmine.createSpyObj('sessionService', [
'getHistoricalSession'
]);
mockOpenMct.$injector = jasmine.createSpyObj('injector', [
'get'
]);
mockOpenMct.$injector.get.and.returnValue(mockSessionService);
mockOpenMct.notifications = jasmine.createSpyObj('notificationAPI', [
'alert'
]);
mockNotification = jasmine.createSpyObj('notification', [
'on',
'off'
]);
mockOpenMct.notifications.alert.and.returnValue(mockNotification);
mockSessionService = jasmine.createSpyObj('SessionService', [
'getHistoricalSession'
]);
spyOn(HistoricalProvider.prototype, 'getSessionService').and.returnValue(mockSessionService);

mockOpenMct.notifications = jasmine.createSpyObj('notificationAPI', [
'alert'
]);
mockNotification = jasmine.createSpyObj('notification', [
'on',
'off'
]);
mockOpenMct.notifications.alert.and.returnValue(mockNotification);

historicalProvider = new HistoricalProvider(mockOpenMct);
historicalProvider = new HistoricalProvider(mockOpenMct);

resolveCallback = rejectCallback = (response) => {};
});
resolveCallback = rejectCallback = (response) => {};
});

describe ('min-max requests', function() {
beforeEach(function () {
mockDomainObject = {
identifier: {
namespace: 'test-namesapce',
key: 'test-key'
},
type: 'vista.channel',
telemetry: {
channelMinMaxUrl: 'some-url'
}
describe ('min-max requests', function() {
beforeEach(function () {
mockDomainObject = {
identifier: {
namespace: 'test-namesapce',
key: 'test-key'
},
type: 'vista.channel',
telemetry: {
channelMinMaxUrl: 'some-url'
}
options.size = 2;
options.strategy = 'minmax';
});
it('show a warning when filters are defined', function () {
options.filters = {
filterName: {
equals: ['someValue']
}
};
historicalProvider.request(mockDomainObject, options).then(resolveCallback, rejectCallback);
expect(mockOpenMct.notifications.alert).toHaveBeenCalled();
});

describe('do not show a warning', function () {
it('when filters are undefined', function () {
options.filters = undefined;
historicalProvider.request(mockDomainObject, options).then(resolveCallback, rejectCallback);;
expect(mockOpenMct.notifications.alert).not.toHaveBeenCalled();
});
it('when filters are empty', function () {
options.filters = {
somekey: {}
};
historicalProvider.request(mockDomainObject, options).then(resolveCallback, rejectCallback);;
expect(mockOpenMct.notifications.alert).not.toHaveBeenCalled();
});
})
}
options.size = 2;
options.strategy = 'minmax';
});
describe('non min-max requests', function() {
beforeEach(function () {
mockDomainObject = {
identifier: {
namespace: 'test-namesapce',
key: 'test-key'
},
type: 'vista.channel',
telemetry: {
channelMinMaxUrl: 'some-url'
}
it('show a warning when filters are defined', function () {
options.filters = {
filterName: {
equals: ['someValue']
}
};
historicalProvider.request(mockDomainObject, options).then(resolveCallback, rejectCallback);
expect(mockOpenMct.notifications.alert).toHaveBeenCalled();
});

describe('do not show a warning', function () {
it('when filters are undefined', function () {
options.filters = undefined;
historicalProvider.request(mockDomainObject, options).then(resolveCallback, rejectCallback);;
expect(mockOpenMct.notifications.alert).not.toHaveBeenCalled();
});
it('Do not show a warning when filters are defined', function () {
it('when filters are empty', function () {
options.filters = {
filterName: 'filterValue'
somekey: {}
};
historicalProvider.request(mockDomainObject, options);
historicalProvider.request(mockDomainObject, options).then(resolveCallback, rejectCallback);;
expect(mockOpenMct.notifications.alert).not.toHaveBeenCalled();
});
});
})
});
describe('non min-max requests', function() {
beforeEach(function () {
mockDomainObject = {
identifier: {
namespace: 'test-namesapce',
key: 'test-key'
},
type: 'vista.channel',
telemetry: {
channelMinMaxUrl: 'some-url'
}
}
});
it('Do not show a warning when filters are defined', function () {
options.filters = {
filterName: 'filterValue'
};
historicalProvider.request(mockDomainObject, options);
expect(mockOpenMct.notifications.alert).not.toHaveBeenCalled();
});
});
});

0 comments on commit 9294fb1

Please sign in to comment.