kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
291 lines
7.3 KiB
291 lines
7.3 KiB
9 years ago
|
// -- copyright
|
||
11 years ago
|
// OpenProject is a project management system.
|
||
10 years ago
|
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||
11 years ago
|
//
|
||
|
// This program is free software; you can redistribute it and/or
|
||
|
// modify it under the terms of the GNU General Public License version 3.
|
||
|
//
|
||
|
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||
|
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||
|
// Copyright (C) 2010-2013 the ChiliProject Team
|
||
|
//
|
||
|
// This program is free software; you can redistribute it and/or
|
||
|
// modify it under the terms of the GNU General Public License
|
||
|
// as published by the Free Software Foundation; either version 2
|
||
|
// of the License, or (at your option) any later version.
|
||
|
//
|
||
|
// This program is distributed in the hope that it will be useful,
|
||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
// GNU General Public License for more details.
|
||
|
//
|
||
|
// You should have received a copy of the GNU General Public License
|
||
|
// along with this program; if not, write to the Free Software
|
||
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
//
|
||
|
// See doc/COPYRIGHT.rdoc for more details.
|
||
9 years ago
|
// ++
|
||
11 years ago
|
|
||
9 years ago
|
|
||
|
describe('WorkPackagesListController', () => {
|
||
|
var scope;
|
||
|
var ctrl;
|
||
|
var win;
|
||
|
var wpListServiceMock;
|
||
|
var testProjectService;
|
||
|
var testWorkPackageService;
|
||
|
var testQueryService;
|
||
|
var testPaginationService;
|
||
|
var testApiWorkPackages;
|
||
|
var testAuthorisationService;
|
||
10 years ago
|
var testQueries;
|
||
11 years ago
|
var buildController;
|
||
10 years ago
|
var stateParams = {};
|
||
11 years ago
|
|
||
9 years ago
|
beforeEach(angular.mock.module('openproject.api', 'openproject.workPackages.controllers',
|
||
|
'openproject.workPackages.services', 'ng-context-menu', 'btford.modal', 'openproject.layout',
|
||
9 years ago
|
'openproject.services', 'openproject.wpButtons'));
|
||
9 years ago
|
beforeEach(angular.mock.module('openproject.templates', ($provide) => {
|
||
|
var configurationService = {
|
||
|
isTimezoneSet: sinon.stub().returns(false)
|
||
|
};
|
||
10 years ago
|
|
||
10 years ago
|
$provide.constant('$stateParams', stateParams);
|
||
10 years ago
|
$provide.constant('ConfigurationService', configurationService);
|
||
|
}));
|
||
9 years ago
|
beforeEach(angular.mock.inject(($rootScope, $controller, $timeout, $q, $cacheFactory) => {
|
||
11 years ago
|
scope = $rootScope.$new();
|
||
9 years ago
|
win = {
|
||
|
location: {pathname: ''}
|
||
11 years ago
|
};
|
||
|
|
||
10 years ago
|
var defaultWorkPackagesData = {
|
||
11 years ago
|
meta: {
|
||
10 years ago
|
query: {
|
||
|
_links: []
|
||
|
},
|
||
|
sums: [null]
|
||
|
},
|
||
|
work_packages: []
|
||
11 years ago
|
};
|
||
10 years ago
|
var workPackagesDataByQueryId = {
|
||
|
meta: {
|
||
|
query: {
|
||
9 years ago
|
props: {id: 1},
|
||
10 years ago
|
_links: []
|
||
|
},
|
||
|
sums: [null]
|
||
|
},
|
||
|
work_packages: []
|
||
|
};
|
||
9 years ago
|
var columnData = {};
|
||
|
var availableQueryiesData = {};
|
||
11 years ago
|
|
||
9 years ago
|
var projectData = {embedded: {types: []}};
|
||
|
var projectsData = [projectData];
|
||
10 years ago
|
testQueries = {
|
||
|
'1': {
|
||
|
id: 1,
|
||
10 years ago
|
columns: ['type'],
|
||
9 years ago
|
getSortation: () => null,
|
||
|
isNew: () => false
|
||
10 years ago
|
},
|
||
|
'2': {
|
||
|
id: 2,
|
||
10 years ago
|
columns: ['type'],
|
||
9 years ago
|
getSortation: () => null,
|
||
|
isNew: () => false
|
||
9 years ago
|
}
|
||
10 years ago
|
};
|
||
11 years ago
|
|
||
|
testProjectService = {
|
||
9 years ago
|
getProject: () => {
|
||
|
return $timeout(() => projectData, 10);
|
||
11 years ago
|
},
|
||
9 years ago
|
getProjects: () => {
|
||
|
return $timeout(() => projectsData, 10);
|
||
11 years ago
|
}
|
||
11 years ago
|
};
|
||
11 years ago
|
|
||
9 years ago
|
var wpCache = $cacheFactory('workPackageCache');
|
||
11 years ago
|
testWorkPackageService = {
|
||
9 years ago
|
getWorkPackages: () => {
|
||
|
return $timeout(() => defaultWorkPackagesData, 10);
|
||
11 years ago
|
},
|
||
9 years ago
|
getWorkPackagesByQueryId: () => {
|
||
|
return $timeout(() => workPackagesDataByQueryId, 10);
|
||
|
},
|
||
|
cache() {
|
||
|
return wpCache;
|
||
11 years ago
|
}
|
||
|
};
|
||
9 years ago
|
|
||
|
testApiWorkPackages = {
|
||
9 years ago
|
list: () => {
|
||
9 years ago
|
var deferred = $q.defer();
|
||
|
deferred.resolve({
|
||
|
"_type": "Collection",
|
||
|
"elements": [],
|
||
|
});
|
||
|
return deferred.promise;
|
||
|
}
|
||
|
};
|
||
|
|
||
11 years ago
|
testQueryService = {
|
||
9 years ago
|
getQuery: () => {
|
||
11 years ago
|
return {
|
||
9 years ago
|
getQueryString: () => {
|
||
11 years ago
|
}
|
||
11 years ago
|
};
|
||
11 years ago
|
},
|
||
9 years ago
|
initQuery: (id) => {
|
||
10 years ago
|
var queryId = id || 1;
|
||
|
return testQueries[queryId];
|
||
11 years ago
|
},
|
||
9 years ago
|
clearQuery: () => {
|
||
11 years ago
|
},
|
||
9 years ago
|
loadAvailableColumns: () => {
|
||
|
return $timeout(() => columnData, 10);
|
||
11 years ago
|
},
|
||
9 years ago
|
loadAvailableGroupedQueries: () => {
|
||
|
return $timeout(() => availableQueryiesData, 10);
|
||
11 years ago
|
},
|
||
|
|
||
9 years ago
|
loadAvailableUnusedColumns: () => {
|
||
|
return $timeout(() => columnData, 10);
|
||
11 years ago
|
},
|
||
|
|
||
9 years ago
|
getTotalEntries: () => {
|
||
11 years ago
|
},
|
||
9 years ago
|
|
||
|
setTotalEntries: () => 10,
|
||
11 years ago
|
};
|
||
|
testPaginationService = {
|
||
9 years ago
|
setPerPageOptions: () => {
|
||
11 years ago
|
},
|
||
9 years ago
|
setPerPage: () => {
|
||
11 years ago
|
},
|
||
9 years ago
|
setPage: () => {
|
||
11 years ago
|
}
|
||
|
};
|
||
10 years ago
|
testAuthorisationService = {
|
||
9 years ago
|
initModelAuth: () => {
|
||
10 years ago
|
}
|
||
10 years ago
|
};
|
||
11 years ago
|
|
||
9 years ago
|
wpListServiceMock = {
|
||
|
fromQueryParams() {
|
||
|
return $q.when({
|
||
|
meta: {
|
||
|
query: {},
|
||
|
columns: {},
|
||
|
export_formats: {}
|
||
|
},
|
||
|
resource: {
|
||
|
total: 10
|
||
|
},
|
||
|
work_packages: [
|
||
|
{}
|
||
|
]
|
||
|
});
|
||
|
}
|
||
|
};
|
||
11 years ago
|
|
||
9 years ago
|
buildController = (params, state, location) => {
|
||
|
scope.projectIdentifier = 'test';
|
||
11 years ago
|
ctrl = $controller("WorkPackagesListController", {
|
||
9 years ago
|
$scope: scope,
|
||
11 years ago
|
$window: win,
|
||
9 years ago
|
QueryService: testQueryService,
|
||
|
PaginationService: testPaginationService,
|
||
|
ProjectService: testProjectService,
|
||
11 years ago
|
WorkPackageService: testWorkPackageService,
|
||
9 years ago
|
apiWorkPackages: testApiWorkPackages,
|
||
|
$stateParams: params,
|
||
|
$state: state,
|
||
|
$location: location,
|
||
|
wpListService: wpListServiceMock
|
||
11 years ago
|
});
|
||
10 years ago
|
|
||
|
$timeout.flush();
|
||
11 years ago
|
};
|
||
11 years ago
|
|
||
|
}));
|
||
|
|
||
9 years ago
|
describe('initialisation of default query', () => {
|
||
|
var testParams;
|
||
|
var testState;
|
||
|
var testLocation;
|
||
10 years ago
|
|
||
9 years ago
|
beforeEach(() => {
|
||
|
testParams = {projectPath: '/projects/my-project'};
|
||
10 years ago
|
testState = {
|
||
9 years ago
|
params: testParams,
|
||
9 years ago
|
href: () => ''
|
||
10 years ago
|
};
|
||
10 years ago
|
testLocation = {
|
||
9 years ago
|
search: () => ({}),
|
||
10 years ago
|
url: angular.identity
|
||
10 years ago
|
};
|
||
10 years ago
|
|
||
|
buildController(testParams, testState, testLocation);
|
||
|
});
|
||
|
|
||
9 years ago
|
it('should initialise', () => {
|
||
|
expect(scope.operatorsAndLabelsByFilterType).to.exist;
|
||
|
expect(scope.disableFilters).to.be.false;
|
||
|
expect(scope.disableNewWorkPackage).to.be.true;
|
||
10 years ago
|
expect(scope.query.id).to.eq(testQueries['1'].id);
|
||
10 years ago
|
});
|
||
10 years ago
|
});
|
||
|
|
||
9 years ago
|
describe('initialisation of query by id', () => {
|
||
|
var testParams;
|
||
|
var testState;
|
||
|
var testLocation;
|
||
10 years ago
|
|
||
9 years ago
|
beforeEach(() => {
|
||
|
testParams = {projectPath: '/projects/my-project'};
|
||
10 years ago
|
testState = {
|
||
|
params: {
|
||
|
query_id: testQueries['2'].id
|
||
|
},
|
||
9 years ago
|
href: () => ''
|
||
10 years ago
|
};
|
||
10 years ago
|
testLocation = {
|
||
9 years ago
|
search: () => ({}),
|
||
10 years ago
|
url: angular.identity
|
||
10 years ago
|
};
|
||
10 years ago
|
|
||
|
buildController(testParams, testState, testLocation);
|
||
|
});
|
||
|
|
||
9 years ago
|
it('should initialise', () => {
|
||
10 years ago
|
expect(scope.query.id).to.eq(testQueries['2'].id);
|
||
11 years ago
|
});
|
||
11 years ago
|
});
|
||
10 years ago
|
|
||
9 years ago
|
describe('setting projectIdentifier', () => {
|
||
|
var testParams;
|
||
|
var testState;
|
||
|
var testLocation;
|
||
9 years ago
|
|
||
9 years ago
|
beforeEach(() => {
|
||
|
testParams = {projectPath: 'my-project'};
|
||
9 years ago
|
testState = {
|
||
9 years ago
|
href: () => '',
|
||
9 years ago
|
params: testParams
|
||
9 years ago
|
};
|
||
|
testLocation = {
|
||
9 years ago
|
search: () => ({}),
|
||
9 years ago
|
url: angular.identity
|
||
|
};
|
||
|
buildController(testParams, testState, testLocation);
|
||
|
});
|
||
|
|
||
9 years ago
|
it('should set the projectIdentifier', () => {
|
||
9 years ago
|
expect(scope.projectIdentifier).to.eq('my-project');
|
||
|
});
|
||
|
});
|
||
11 years ago
|
});
|