1 describe("/admin/platforms", function () {
2 var reportsForDifferentPlatforms = [
5 "buildTime": "2013-02-28T09:01:47",
6 "builderName": "someBuilder",
7 "builderPassword": "somePassword",
8 "platform": "Mavericks",
9 "tests": {"test": { "metrics": {"FrameRate": { "current": [[1, 1, 1], [1, 1, 1]] } } } },
12 "buildNumber": "3001",
13 "buildTime": "2013-02-28T10:12:03",
14 "builderName": "someBuilder",
15 "builderPassword": "somePassword",
16 "platform": "Mountain Lion",
17 "tests": {"test": { "metrics": {"FrameRate": { "current": [[2, 2, 2], [2, 2, 2]] }, "Combined": { "current": [[3, 3, 3], [3, 3, 3]] }} } },
20 "buildNumber": "3003",
21 "buildTime": "2013-02-28T12:56:26",
22 "builderName": "someBuilder",
23 "builderPassword": "somePassword",
24 "platform": "Trunk Mountain Lion",
25 "tests": {"test": { "metrics": {"FrameRate": { "current": [[4, 4, 4], [4, 4, 4]] } } } }
28 function submitReport(report, callback) {
29 queryAndFetchAll('INSERT INTO builders (builder_name, builder_password_hash) values ($1, $2)',
30 [report[0].builderName, sha256(report[0].builderPassword)], function () {
31 postJSON('/api/report/', reportsForDifferentPlatforms, function (response) {
37 it("should delete the platform that got merged into another one", function () {
38 submitReport(reportsForDifferentPlatforms, function () {
39 queryAndFetchAll('SELECT * FROM platforms ORDER by platform_name', [], function (oldPlatforms) {
40 assert.equal(oldPlatforms.length, 3);
41 assert.equal(oldPlatforms[0]['platform_name'], 'Mavericks');
42 assert.equal(oldPlatforms[1]['platform_name'], 'Mountain Lion');
43 assert.equal(oldPlatforms[2]['platform_name'], 'Trunk Mountain Lion');
44 httpPost('/admin/platforms.php', {'action': 'merge', 'id': oldPlatforms[1]['platform_id'], 'destination': oldPlatforms[2]['platform_id']}, function (response) {
45 assert.equal(response.statusCode, 200);
46 queryAndFetchAll('SELECT * FROM platforms ORDER by platform_name', [], function (newPlatforms) {
47 assert.deepEqual(newPlatforms, [oldPlatforms[0], oldPlatforms[2]]);
55 it("should move test runs from the merged platform to the destination platform", function () {
56 submitReport(reportsForDifferentPlatforms, function () {
57 var queryForRuns = 'SELECT * FROM test_runs, test_configurations, platforms WHERE run_config = config_id AND config_platform = platform_id ORDER by run_mean_cache';
58 queryAndFetchAll(queryForRuns, [], function (oldTestRuns) {
59 assert.equal(oldTestRuns.length, 4);
60 assert.equal(oldTestRuns[0]['platform_name'], 'Mavericks');
61 assert.equal(oldTestRuns[0]['run_sum_cache'], 6);
62 assert.equal(oldTestRuns[1]['platform_name'], 'Mountain Lion');
63 assert.equal(oldTestRuns[1]['run_sum_cache'], 12);
64 assert.equal(oldTestRuns[2]['platform_name'], 'Mountain Lion');
65 assert.equal(oldTestRuns[2]['run_sum_cache'], 18);
66 assert.equal(oldTestRuns[3]['platform_name'], 'Trunk Mountain Lion');
67 assert.equal(oldTestRuns[3]['run_sum_cache'], 24);
68 httpPost('/admin/platforms.php', {'action': 'merge', 'id': oldTestRuns[1]['platform_id'], 'destination': oldTestRuns[3]['platform_id']}, function (response) {
69 assert.equal(response.statusCode, 200);
70 queryAndFetchAll(queryForRuns, [], function (newTestRuns) {
71 assert.equal(newTestRuns.length, 4);
72 assert.equal(newTestRuns[0]['run_id'], oldTestRuns[0]['run_id']);
73 assert.equal(newTestRuns[0]['platform_name'], 'Mavericks');
74 assert.equal(newTestRuns[0]['run_sum_cache'], 6);
75 assert.equal(newTestRuns[1]['run_id'], oldTestRuns[1]['run_id']);
76 assert.equal(newTestRuns[1]['platform_name'], 'Trunk Mountain Lion');
77 assert.equal(newTestRuns[1]['run_sum_cache'], 12);
78 assert.equal(newTestRuns[2]['run_id'], oldTestRuns[2]['run_id']);
79 assert.equal(newTestRuns[2]['platform_name'], 'Trunk Mountain Lion');
80 assert.equal(newTestRuns[2]['run_sum_cache'], 18);
81 assert.equal(newTestRuns[3]['run_id'], oldTestRuns[3]['run_id']);
82 assert.equal(newTestRuns[3]['platform_name'], 'Trunk Mountain Lion');
83 assert.equal(newTestRuns[3]['run_sum_cache'], 24);
84 assert.equal(newTestRuns[1]['run_config'], newTestRuns[3]['run_config']);