1 describe("/admin/regenerate-manifest", function () {
3 it("should generate an empty manifest when database is empty", function () {
4 httpGet('/admin/regenerate-manifest', function (response) {
5 assert.equal(response.statusCode, 200);
6 httpGet('/data/manifest', function (response) {
7 assert.equal(response.statusCode, 200);
8 var manifest = JSON.parse(response.responseText);
9 delete manifest.defaultDashboard;
10 delete manifest.dashboards;
11 delete manifest.elapsedTime;
12 assert.deepEqual(manifest, {
25 it("should generate manifest with bug trackers without repositories", function () {
26 queryAndFetchAll("INSERT INTO bug_trackers (tracker_id, tracker_name, tracker_new_bug_url) VALUES"
27 + " (1, 'Bugzilla', 'bugs.webkit.org')", [], function () {
28 httpGet('/admin/regenerate-manifest', function (response) {
29 assert.equal(response.statusCode, 200);
30 httpGet('/data/manifest', function (response) {
31 assert.equal(response.statusCode, 200);
32 var manifest = JSON.parse(response.responseText);
33 assert.deepEqual(manifest['bugTrackers'],
34 {1: {name: 'Bugzilla', bugUrl: null, newBugUrl: 'bugs.webkit.org', repositories: null}});
41 it("should generate manifest with bug trackers and repositories", function () {
42 queryAndFetchAll("INSERT INTO repositories (repository_id, repository_name, repository_url, repository_blame_url) VALUES"
43 + " (1, 'WebKit', 'trac.webkit.org', null), (2, 'Chromium', null, 'SomeBlameURL')", [], function () {
44 queryAndFetchAll("INSERT INTO bug_trackers (tracker_id, tracker_name) VALUES (3, 'Bugzilla'), (4, 'Issue Tracker')", [], function () {
45 queryAndFetchAll("INSERT INTO tracker_repositories (tracrepo_tracker, tracrepo_repository) VALUES (3, 1), (4, 1), (4, 2)", [], function () {
46 httpGet('/admin/regenerate-manifest', function (response) {
47 assert.equal(response.statusCode, 200);
48 httpGet('/data/manifest', function (response) {
49 assert.equal(response.statusCode, 200);
50 var manifest = JSON.parse(response.responseText);
51 assert.deepEqual(manifest['repositories'], {
52 1: { name: 'WebKit', url: 'trac.webkit.org', blameUrl: null, hasReportedCommits: false },
53 2: { name: 'Chromium', url: null, blameUrl: 'SomeBlameURL', hasReportedCommits: false }
55 assert.deepEqual(manifest['bugTrackers'][3], {name: 'Bugzilla', bugUrl: null, newBugUrl: null, repositories: ['1']});
56 assert.deepEqual(manifest['bugTrackers'][4], {name: 'Issue Tracker', bugUrl: null, newBugUrl: null, repositories: ['1', '2']});
65 it("should generate manifest with builders", function () {
66 queryAndFetchAll("INSERT INTO builders (builder_id, builder_name, builder_password_hash, builder_build_url) VALUES"
67 + " (1, 'SomeBuilder', 'a', null), (2, 'SomeOtherBuilder', 'b', 'SomeURL')", [], function () {
68 httpGet('/admin/regenerate-manifest', function (response) {
69 assert.equal(response.statusCode, 200);
70 httpGet('/data/manifest', function (response) {
71 assert.equal(response.statusCode, 200);
72 var manifest = JSON.parse(response.responseText);
73 assert.deepEqual(manifest['builders'], {
74 '1': { name: 'SomeBuilder', buildUrl: null },
75 '2': { name: 'SomeOtherBuilder', buildUrl: 'SomeURL' }
83 it("should generate manifest with tests", function () {
84 queryAndFetchAll("INSERT INTO tests (test_id, test_name, test_parent) VALUES"
85 + " (1, 'SomeTest', null), (2, 'SomeOtherTest', null), (3, 'ChildTest', 1)", [], function () {
86 httpGet('/admin/regenerate-manifest', function (response) {
87 assert.equal(response.statusCode, 200);
88 httpGet('/data/manifest', function (response) {
89 assert.equal(response.statusCode, 200);
90 var manifest = JSON.parse(response.responseText);
91 assert.deepEqual(manifest['tests'], {
92 '1': { name: 'SomeTest', url: null, parentId: null },
93 '2': { name: 'SomeOtherTest', url: null, parentId: null },
94 '3': { name: 'ChildTest', url: null, parentId: '1' }
102 it("should generate manifest with metrics", function () {
103 queryAndFetchAll("INSERT INTO tests (test_id, test_name, test_parent) VALUES"
104 + " (1, 'SomeTest', null), (2, 'SomeOtherTest', null), (3, 'ChildTest', 1)", [], function () {
105 queryAndFetchAll('INSERT INTO aggregators (aggregator_id, aggregator_name, aggregator_definition) values (4, $1, $2)',
106 ['Total', 'values.reduce(function (a, b) { return a + b; })'], function () {
107 queryAndFetchAll("INSERT INTO test_metrics (metric_id, metric_test, metric_name, metric_aggregator) VALUES"
108 + " (5, 1, 'Time', null), (6, 2, 'Time', 4), (7, 2, 'Malloc', 4)", [], function () {
109 httpGet('/admin/regenerate-manifest', function (response) {
110 assert.equal(response.statusCode, 200);
111 httpGet('/data/manifest', function (response) {
112 assert.equal(response.statusCode, 200);
113 var manifest = JSON.parse(response.responseText);
114 assert.deepEqual(manifest['metrics'], {
115 '5': { name: 'Time', test: '1', aggregator: null },
116 '6': { name: 'Time', test: '2', aggregator: 'Total' },
117 '7': { name: 'Malloc', test: '2', aggregator: 'Total' }
127 // FIXME: Test the generation of all and dashboard.