Compare commits

...

2 Commits

Author SHA1 Message Date
a04fba579b Add test for identifier generation 2018-01-02 16:05:13 -05:00
77fa775f7b [SummaryWidget] Use objectutil to get legacy id
Use objectUtils to get a proper legacy id so that namespaces are
properly handled.  Fixes https://github.com/nasa/openmct/issues/1858
2018-01-02 15:58:30 -05:00
2 changed files with 10 additions and 3 deletions

View File

@ -5,6 +5,7 @@ define([
'./TestDataManager', './TestDataManager',
'./WidgetDnD', './WidgetDnD',
'./eventHelpers', './eventHelpers',
'../../../api/objects/object-utils',
'lodash', 'lodash',
'zepto' 'zepto'
], function ( ], function (
@ -14,6 +15,7 @@ define([
TestDataManager, TestDataManager,
WidgetDnD, WidgetDnD,
eventHelpers, eventHelpers,
objectUtils,
_, _,
$ $
) { ) {
@ -77,7 +79,7 @@ define([
this.addHyperlink(domainObject.url, domainObject.openNewTab); this.addHyperlink(domainObject.url, domainObject.openNewTab);
this.watchForChanges(openmct, domainObject); this.watchForChanges(openmct, domainObject);
var id = this.domainObject.identifier.key, var id = objectUtils.makeKeyString(this.domainObject.identifier),
self = this, self = this,
oldDomainObject, oldDomainObject,
statusCapability; statusCapability;

View File

@ -14,7 +14,8 @@ define(['../src/SummaryWidget', 'zepto'], function (SummaryWidget, $) {
beforeEach(function () { beforeEach(function () {
mockDomainObject = { mockDomainObject = {
identifier: { identifier: {
key: 'testKey' key: 'testKey',
namespace: 'testNamespace'
}, },
name: 'testName', name: 'testName',
composition: [], composition: [],
@ -49,7 +50,7 @@ define(['../src/SummaryWidget', 'zepto'], function (SummaryWidget, $) {
mockObjectService.getObjects = jasmine.createSpy('objectService'); mockObjectService.getObjects = jasmine.createSpy('objectService');
mockObjectService.getObjects.andReturn(new Promise(function (resolve, reject) { mockObjectService.getObjects.andReturn(new Promise(function (resolve, reject) {
resolve({ resolve({
testKey: mockOldDomainObject 'testNamespace:testKey': mockOldDomainObject
}); });
})); }));
mockOpenMCT = jasmine.createSpyObj('openmct', [ mockOpenMCT = jasmine.createSpyObj('openmct', [
@ -73,6 +74,10 @@ define(['../src/SummaryWidget', 'zepto'], function (SummaryWidget, $) {
summaryWidget.show(mockContainer); summaryWidget.show(mockContainer);
}); });
it('queries with legacyId', function () {
expect(mockObjectService.getObjects).toHaveBeenCalledWith(['testNamespace:testKey']);
});
it('adds its DOM element to the view', function () { it('adds its DOM element to the view', function () {
expect(mockContainer.getElementsByClassName('w-summary-widget').length).toBeGreaterThan(0); expect(mockContainer.getElementsByClassName('w-summary-widget').length).toBeGreaterThan(0);
}); });