Fix query menu ng2 test

pull/6263/head
Oliver Günther 7 years ago
parent 70c1c95726
commit dffe2b5c83
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 2
      frontend/app/components/wp-edit/field-types/wp-edit-multi-select-field.module.ts
  2. 16
      frontend/app/components/wp-query-menu/wp-query-menu.ng2.test.ts
  3. 8
      frontend/app/components/wp-query-menu/wp-query-menu.service.ts

@ -152,7 +152,7 @@ export class MultiSelectEditField extends EditField {
if (option) {
result = _.find(this.valueOptions, (valueOption) => valueOption.href === option.href)!;
}
return result || this.nullOption;
}

@ -37,17 +37,15 @@ import {$stateToken} from 'core-app/angular4-transition-utils';
@Component({
template: `
<li>
<div id="main-menu-work-packages-wrapper">
<a id="main-menu-work-packages">Work packages</a>
</div>
<div id="main-menu-work-packages-wrapper">
<a id="main-menu-work-packages">Work packages</a>
<ul class="menu-children"></ul>'
</li>
</div>
`
})
class WpQueryMenuTestComponent { }
describe('wp-query-menu', () => {
describe.only('wp-query-menu', () => {
let app:WpQueryMenuTestComponent;
let fixture:ComponentFixture<WpQueryMenuTestComponent>;
let element:JQuery;
@ -59,7 +57,7 @@ describe('wp-query-menu', () => {
const $transitionStub = {
onStart: (criteria:any, callback:(transition:any) => any) => {
transitionCallback = (id:any) => callback({
params: (val:string) => { return { queryId: id }; }
params: (val:string) => { return { query_id: id }; }
} as any);
}
};
@ -75,7 +73,7 @@ describe('wp-query-menu', () => {
{ provide: $stateToken, useValue: { go: (...args:any[]) => undefined } },
{ provide: WorkPackagesListChecksumService, useValue: { clear: () => undefined } },
{ provide: TransitionService, useValue: $transitionStub },
{ provide: QueryMenuService, useValue: queryMenuService },
QueryMenuService,
]
}).compileComponents()
.then(() => {
@ -84,6 +82,7 @@ describe('wp-query-menu', () => {
app = fixture.debugElement.componentInstance;
element = jQuery(fixture.elementRef.nativeElement);
menuContainer = element.find('ul.menu-children');
queryMenuService.initialize();
});
}));
@ -94,6 +93,7 @@ describe('wp-query-menu', () => {
objectId = '1';
var generateMenuItem = function() {
queryMenuService = TestBed.get(QueryMenuService);
queryMenuService.add(title, path, objectId);
fixture.detectChanges();

@ -46,7 +46,7 @@ export class QueryMenuService {
private currentQueryId:string|null = null;
private uiRouteStateName = 'work-packages.list';
private container = jQuery('#main-menu-work-packages').parent().find('ul.menu-children');
private container:JQuery;
constructor(@Inject($stateToken) protected $state:StateService,
protected $transitions:TransitionService,
@ -57,6 +57,8 @@ export class QueryMenuService {
this.onQueryIdChanged(queryId);
});
this.initialize();
this.container.on('click', `.${QUERY_MENU_ITEM_TYPE}`, (event) => {
if (LinkHandling.isClickedWithModifier(event) || LinkHandling.isOutsideAngular()) {
return true;
@ -69,6 +71,10 @@ export class QueryMenuService {
}
public initialize() {
this.container = jQuery('#main-menu-work-packages').parent().find('ul.menu-children');
}
/**
* Add a query menu item
*/

Loading…
Cancel
Save