зеркало из https://github.com/mozilla/treeherder.git
React work cleanup (#3892)
* Remove vestigial pinboard service file * Test cleanup: hanging commas, arrow functions, quotes, etc. * Fix async job tests. Using .then meant they sometimes didn't return before the test run completedand would throw a warning AND not execute the test ``expect``. * Fix resultset tests fetching Some models changed to use ``fetch`` so we needed to use ``fetchMock`` instead of ``$httpBackend`` for setting expected results. * Fix warnings in bugfiler tests: We needed to pass some dummy objects for PropTypes that are required. * Fix warnings in JobGroup tests: We needed to pass some dummy objects for PropTypes that are required here, too.
This commit is contained in:
Родитель
44032ff518
Коммит
e7f026d499
|
@ -1,30 +1,30 @@
|
|||
describe('getRevisionUrl filter', function() {
|
||||
var $filter;
|
||||
describe('getRevisionUrl filter', () => {
|
||||
let $filter;
|
||||
beforeEach(angular.mock.module('treeherder'));
|
||||
beforeEach(inject(function(_$filter_) {
|
||||
beforeEach(inject((_$filter_) => {
|
||||
$filter = _$filter_;
|
||||
}));
|
||||
|
||||
it('escapes some html symbols', function() {
|
||||
var getRevisionUrl = $filter('getRevisionUrl');
|
||||
it('escapes some html symbols', () => {
|
||||
const getRevisionUrl = $filter('getRevisionUrl');
|
||||
expect(getRevisionUrl('1234567890ab', 'mozilla-inbound'))
|
||||
.toEqual('/#/jobs?repo=mozilla-inbound&revision=1234567890ab');
|
||||
});
|
||||
});
|
||||
|
||||
describe('displayNumber filter', function() {
|
||||
var $filter;
|
||||
describe('displayNumber filter', () => {
|
||||
let $filter;
|
||||
beforeEach(angular.mock.module('treeherder'));
|
||||
beforeEach(inject(function(_$filter_) {
|
||||
beforeEach(inject((_$filter_) => {
|
||||
$filter = _$filter_;
|
||||
}));
|
||||
|
||||
it('returns expected values', function() {
|
||||
var displayPrecision = $filter('displayNumber');
|
||||
it('returns expected values', () => {
|
||||
const displayPrecision = $filter('displayNumber');
|
||||
const infinitySymbol = '\u221e';
|
||||
expect(displayPrecision('123.53222')).toEqual('123.53');
|
||||
expect(displayPrecision('123123123.53222')).toEqual('123,123,123.53');
|
||||
expect(displayPrecision(1/0)).toEqual(infinitySymbol);
|
||||
expect(displayPrecision(1 / 0)).toEqual(infinitySymbol);
|
||||
expect(displayPrecision(Number.NaN)).toEqual('N/A');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as fetchMock from 'fetch-mock';
|
||||
|
||||
import JobModel from '../../../../ui/models/job';
|
||||
import { getProjectUrl } from "../../../../ui/helpers/url";
|
||||
import { getProjectUrl } from '../../../../ui/helpers/url';
|
||||
|
||||
describe('JobModel', () => {
|
||||
const repoName = 'mozilla-inbound';
|
||||
|
@ -14,41 +14,34 @@ describe('JobModel', () => {
|
|||
fetchMock.restore();
|
||||
});
|
||||
|
||||
describe("getList", () => {
|
||||
describe('getList', () => {
|
||||
beforeEach(() => {
|
||||
fetchMock.get(getProjectUrl('/jobs/'), getJSONFixture('job_list/job_1.json'));
|
||||
});
|
||||
|
||||
it("should return a promise", () => {
|
||||
it('should return a promise', () => {
|
||||
const result = JobModel.getList('mozilla-inbound');
|
||||
expect(result.then).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("pagination", () => {
|
||||
describe('pagination', () => {
|
||||
beforeEach(() => {
|
||||
fetchMock.get(getProjectUrl('/jobs/?count=2'), getJSONFixture('job_list/pagination/page_1.json'));
|
||||
fetchMock.get(getProjectUrl('/jobs/?count=2&offset=2'), getJSONFixture('job_list/pagination/page_2.json'));
|
||||
});
|
||||
|
||||
it("should return a page of results by default", () => {
|
||||
JobModel.getList(
|
||||
repoName,
|
||||
{ count: 2 }
|
||||
).then((jobList) => {
|
||||
expect(jobList.length).toBe(2);
|
||||
});
|
||||
it('should return a page of results by default', async () => {
|
||||
const jobList = await JobModel.getList(repoName, { count: 2 });
|
||||
|
||||
expect(jobList.length).toBe(2);
|
||||
});
|
||||
|
||||
it("should return all the pages when fetch_all==true", () => {
|
||||
JobModel.getList(
|
||||
repoName,
|
||||
{ count: 2 },
|
||||
{ fetch_all: true }
|
||||
).then((jobList) => {
|
||||
expect(jobList.length).toBe(3);
|
||||
expect(jobList[2].id).toBe(3);
|
||||
});
|
||||
it('should return all the pages when fetch_all==true', async () => {
|
||||
const jobList = await JobModel.getList(repoName, { count: 2 }, { fetch_all: true });
|
||||
|
||||
expect(jobList.length).toBe(3);
|
||||
expect(jobList[2].id).toBe(3);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
import { getProjectUrl } from "../../../../ui/helpers/url";
|
||||
import * as fetchMock from 'fetch-mock';
|
||||
|
||||
describe('ThResultSetStore', function(){
|
||||
import { getProjectUrl } from '../../../../ui/helpers/url';
|
||||
|
||||
var $httpBackend,
|
||||
rootScope,
|
||||
model,
|
||||
repoModel,
|
||||
foregroundRepo = "mozilla-inbound";
|
||||
describe('ThResultSetStore', function () {
|
||||
|
||||
let $httpBackend;
|
||||
let rootScope;
|
||||
let model;
|
||||
let repoModel;
|
||||
const foregroundRepo = 'mozilla-inbound';
|
||||
|
||||
beforeEach(angular.mock.module('treeherder'));
|
||||
|
||||
|
@ -14,50 +16,36 @@ describe('ThResultSetStore', function(){
|
|||
ThResultSetStore, ThRepositoryModel) {
|
||||
|
||||
$httpBackend = $injector.get('$httpBackend');
|
||||
jasmine.getJSONFixtures().fixturesPath='base/tests/ui/mock';
|
||||
jasmine.getJSONFixtures().fixturesPath = 'base/tests/ui/mock';
|
||||
|
||||
$httpBackend.whenGET('https://treestatus.mozilla-releng.net/trees/mozilla-inbound').respond(
|
||||
{
|
||||
"result": {
|
||||
"status": "approval required",
|
||||
"message_of_the_day": "I before E",
|
||||
"tree": "mozilla-inbound",
|
||||
"reason": ""
|
||||
}
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
$httpBackend.whenGET(getProjectUrl('/jobs/0/unclassified_failure_count/', foregroundRepo)).respond(
|
||||
{
|
||||
"unclassified_failure_count": 1152,
|
||||
"repository": "mozilla-inbound"
|
||||
}
|
||||
fetchMock.get(
|
||||
'https://treestatus.mozilla-releng.net/trees/mozilla-inbound',
|
||||
{
|
||||
result: {
|
||||
status: 'approval required',
|
||||
message_of_the_day: 'I before E',
|
||||
tree: 'mozilla-inbound',
|
||||
reason: '',
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
$httpBackend.whenGET(getProjectUrl('/resultset/?count=10&full=true', foregroundRepo)).respond(
|
||||
getJSONFixture('push_list.json')
|
||||
getJSONFixture('push_list.json'),
|
||||
);
|
||||
|
||||
|
||||
$httpBackend.whenGET(getProjectUrl('/jobs/?count=2000&result_set_id=1&return_type=list', foregroundRepo)).respond(
|
||||
getJSONFixture('job_list/job_1.json')
|
||||
fetchMock.get(
|
||||
getProjectUrl('/jobs/?return_type=list&result_set_id=1&count=2000', foregroundRepo),
|
||||
getJSONFixture('job_list/job_1.json'),
|
||||
);
|
||||
|
||||
$httpBackend.whenGET(getProjectUrl('/jobs/?count=2000&result_set_id=2&return_type=list', foregroundRepo)).respond(
|
||||
getJSONFixture('job_list/job_2.json')
|
||||
fetchMock.get(
|
||||
getProjectUrl('/jobs/?return_type=list&result_set_id=2&count=2000', foregroundRepo),
|
||||
getJSONFixture('job_list/job_2.json'),
|
||||
);
|
||||
|
||||
$httpBackend.whenGET('/api/repository/').respond(
|
||||
getJSONFixture('repositories.json')
|
||||
);
|
||||
|
||||
$httpBackend.whenGET('/api/jobtype/').respond(
|
||||
getJSONFixture('job_type_list.json')
|
||||
);
|
||||
|
||||
$httpBackend.whenGET('/api/jobgroup/').respond(
|
||||
getJSONFixture('job_group_list.json')
|
||||
getJSONFixture('repositories.json'),
|
||||
);
|
||||
|
||||
rootScope = $rootScope.$new();
|
||||
|
@ -73,14 +61,18 @@ describe('ThResultSetStore', function(){
|
|||
$httpBackend.flush();
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
fetchMock.restore();
|
||||
});
|
||||
|
||||
/*
|
||||
Tests ThResultSetStore
|
||||
*/
|
||||
it('should have 2 resultset', function() {
|
||||
it('should have 2 resultset', () => {
|
||||
expect(model.getPushArray().length).toBe(2);
|
||||
});
|
||||
|
||||
it('should have id of 1 in foreground (current) repo', function() {
|
||||
it('should have id of 1 in foreground (current) repo', () => {
|
||||
expect(model.getPushArray()[0].id).toBe(1);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@ import { hgBaseUrl, bzBaseUrl } from '../../../../ui/helpers/url';
|
|||
import { isReftest } from '../../../../ui/helpers/job';
|
||||
import BugFiler from '../../../../ui/job-view/details/BugFiler';
|
||||
|
||||
describe('BugFiler', function () {
|
||||
describe('BugFiler', () => {
|
||||
const fullLog = 'https://queue.taskcluster.net/v1/task/AGs4CgN_RnCTb943uQn8NQ/runs/0/artifacts/public/logs/live_backing.log';
|
||||
const parsedLog = 'http://localhost:5000/logviewer.html#?job_id=89017089&repo=mozilla-inbound';
|
||||
const reftest = '';
|
||||
|
@ -26,8 +26,6 @@ describe('BugFiler', function () {
|
|||
const isOpen = true;
|
||||
|
||||
beforeEach(() => {
|
||||
jasmine.getJSONFixtures().fixturesPath = 'base/tests/ui/mock';
|
||||
|
||||
fetchMock.get(
|
||||
`${hgBaseUrl}mozilla-central/json-mozbuildinfo?p=browser/components/search/test/browser_searchbar_smallpanel_keyboard_navigation.js`,
|
||||
{
|
||||
|
@ -82,6 +80,7 @@ describe('BugFiler', function () {
|
|||
reftestUrl={isReftest(selectedJob) ? reftest : ''}
|
||||
successCallback={successCallback}
|
||||
jobGroupName={selectedJob.job_group_name}
|
||||
notify={{}}
|
||||
/>,
|
||||
);
|
||||
};
|
||||
|
@ -222,6 +221,7 @@ describe('BugFiler', function () {
|
|||
reftestUrl={isReftest(selectedJob) ? reftest : ''}
|
||||
successCallback={successCallback}
|
||||
jobGroupName={selectedJob.job_group_name}
|
||||
notify={{}}
|
||||
/>,
|
||||
);
|
||||
|
||||
|
|
|
@ -2,10 +2,13 @@ import React from 'react';
|
|||
import { mount } from 'enzyme';
|
||||
|
||||
import JobGroup from '../../../../ui/job-view/JobGroup';
|
||||
import { thEvents } from "../../../../ui/js/constants";
|
||||
import { thEvents } from '../../../../ui/js/constants';
|
||||
|
||||
describe('JobGroup component', () => {
|
||||
let $injector, $rootScope, countGroup, dupGroup;
|
||||
let $injector;
|
||||
let $rootScope;
|
||||
let countGroup;
|
||||
let dupGroup;
|
||||
const repoName = 'mozilla-inbound';
|
||||
|
||||
beforeEach(angular.mock.module('treeherder'));
|
||||
|
@ -26,7 +29,9 @@ describe('JobGroup component', () => {
|
|||
$injector={$injector}
|
||||
repoName={repoName}
|
||||
group={countGroup}
|
||||
/>
|
||||
filterPlatformCb={() => {}}
|
||||
platform={<span>windows</span>}
|
||||
/>,
|
||||
);
|
||||
expect(jobGroup.html()).toEqual(
|
||||
'<span class="platform-group"><span class="disabled job-group" title="Web platform tests with e10s">' +
|
||||
|
@ -34,7 +39,7 @@ describe('JobGroup component', () => {
|
|||
'<span class="group-content">' +
|
||||
'<span class="group-job-list"><button data-job-id="166315800" title="success | test-linux64/debug-web-platform-tests-reftests-e10s-1 - (18 mins)" class="btn btn-green filter-shown job-btn btn-xs">Wr1</button></span>' +
|
||||
'<span class="group-count-list"><button class="btn-dkgray-count btn group-btn btn-xs job-group-count filter-shown" title="2 running jobs in group">2</button>' +
|
||||
'</span></span></span></span>'
|
||||
'</span></span></span></span>',
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -44,7 +49,9 @@ describe('JobGroup component', () => {
|
|||
$injector={$injector}
|
||||
repoName={repoName}
|
||||
group={countGroup}
|
||||
/>
|
||||
filterPlatformCb={() => {}}
|
||||
platform={<span>windows</span>}
|
||||
/>,
|
||||
);
|
||||
jobGroup.setState({ expanded: true });
|
||||
jobGroup.setState({ expanded: false });
|
||||
|
@ -54,7 +61,7 @@ describe('JobGroup component', () => {
|
|||
'<span class="group-content">' +
|
||||
'<span class="group-job-list"><button data-job-id="166315800" title="success | test-linux64/debug-web-platform-tests-reftests-e10s-1 - (18 mins)" class="btn btn-green filter-shown job-btn btn-xs">Wr1</button></span>' +
|
||||
'<span class="group-count-list"><button class="btn-dkgray-count btn group-btn btn-xs job-group-count filter-shown" title="2 running jobs in group">2</button>' +
|
||||
'</span></span></span></span>'
|
||||
'</span></span></span></span>',
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -64,7 +71,9 @@ describe('JobGroup component', () => {
|
|||
$injector={$injector}
|
||||
repoName={repoName}
|
||||
group={countGroup}
|
||||
/>
|
||||
filterPlatformCb={() => {}}
|
||||
platform={<span>windows</span>}
|
||||
/>,
|
||||
);
|
||||
jobGroup.setState({ expanded: true });
|
||||
expect(jobGroup.html()).toEqual(
|
||||
|
@ -76,7 +85,7 @@ describe('JobGroup component', () => {
|
|||
'<button data-job-id="166315800" title="success | test-linux64/debug-web-platform-tests-reftests-e10s-1 - (18 mins)" class="btn btn-green filter-shown job-btn btn-xs">Wr1</button>' +
|
||||
'<button data-job-id="166315797" title="running | test-linux64/debug-web-platform-tests-e10s-1 - " class="btn btn-dkgray filter-shown job-btn btn-xs">wpt1</button>' +
|
||||
'</span>' +
|
||||
'<span class="group-count-list"></span></span></span></span>'
|
||||
'<span class="group-count-list"></span></span></span></span>',
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -86,7 +95,9 @@ describe('JobGroup component', () => {
|
|||
$injector={$injector}
|
||||
repoName={repoName}
|
||||
group={countGroup}
|
||||
/>
|
||||
filterPlatformCb={() => {}}
|
||||
platform={<span>windows</span>}
|
||||
/>,
|
||||
);
|
||||
|
||||
$rootScope.$emit(thEvents.groupStateChanged, 'expanded');
|
||||
|
@ -99,7 +110,7 @@ describe('JobGroup component', () => {
|
|||
'<button data-job-id="166315800" title="success | test-linux64/debug-web-platform-tests-reftests-e10s-1 - (18 mins)" class="btn btn-green filter-shown job-btn btn-xs">Wr1</button>' +
|
||||
'<button data-job-id="166315797" title="running | test-linux64/debug-web-platform-tests-e10s-1 - " class="btn btn-dkgray filter-shown job-btn btn-xs">wpt1</button>' +
|
||||
'</span>' +
|
||||
'<span class="group-count-list"></span></span></span></span>'
|
||||
'<span class="group-count-list"></span></span></span></span>',
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -109,7 +120,9 @@ describe('JobGroup component', () => {
|
|||
$injector={$injector}
|
||||
repoName={repoName}
|
||||
group={dupGroup}
|
||||
/>
|
||||
filterPlatformCb={() => {}}
|
||||
platform={<span>windows</span>}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(jobGroup.html()).toEqual(
|
||||
|
@ -120,7 +133,7 @@ describe('JobGroup component', () => {
|
|||
'</span>' +
|
||||
'<span class="group-count-list">' +
|
||||
'<button class="btn-green-count btn group-btn btn-xs job-group-count filter-shown" title="6 success jobs in group">6</button>' +
|
||||
'</span></span></span></span>'
|
||||
'</span></span></span></span>',
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -130,7 +143,9 @@ describe('JobGroup component', () => {
|
|||
$injector={$injector}
|
||||
repoName={repoName}
|
||||
group={dupGroup}
|
||||
/>
|
||||
filterPlatformCb={() => {}}
|
||||
platform={<span>windows</span>}
|
||||
/>,
|
||||
);
|
||||
|
||||
jobGroup.setState({ showDuplicateJobs: true });
|
||||
|
@ -143,7 +158,7 @@ describe('JobGroup component', () => {
|
|||
'</span>' +
|
||||
'<span class="group-count-list">' +
|
||||
'<button class="btn-green-count btn group-btn btn-xs job-group-count filter-shown" title="5 success jobs in group">5</button>' +
|
||||
'</span></span></span></span>'
|
||||
'</span></span></span></span>',
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -153,7 +168,9 @@ describe('JobGroup component', () => {
|
|||
$injector={$injector}
|
||||
repoName={repoName}
|
||||
group={dupGroup}
|
||||
/>
|
||||
filterPlatformCb={() => {}}
|
||||
platform={<span>windows</span>}
|
||||
/>,
|
||||
);
|
||||
|
||||
$rootScope.$emit(thEvents.duplicateJobsVisibilityChanged);
|
||||
|
@ -166,8 +183,7 @@ describe('JobGroup component', () => {
|
|||
'</span>' +
|
||||
'<span class="group-count-list">' +
|
||||
'<button class="btn-green-count btn group-btn btn-xs job-group-count filter-shown" title="5 success jobs in group">5</button>' +
|
||||
'</span></span></span></span>'
|
||||
'</span></span></span></span>',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ import './js/services/buildapi';
|
|||
import './js/services/taskcluster';
|
||||
import './js/services/classifications';
|
||||
import './js/services/jobfilters';
|
||||
import './js/services/pinboard';
|
||||
import './js/services/tcactions';
|
||||
import './js/models/resultset';
|
||||
import './js/models/resultsets_store';
|
||||
|
|
Загрузка…
Ссылка в новой задаче