Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Side by Side Diff: dashboard/dashboard/elements/pinpoint-perf-job-dialog-test.html

Issue 3018723002: .
Patch Set: Created 3 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <!--
3 Copyright 2017 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
6 -->
7
8 <link rel="import" href="/dashboard/elements/pinpoint-perf-job-dialog.html">
9 <link rel="import" href="/dashboard/static/simple_xhr.html">
10 <link rel="import" href="/dashboard/static/testing_common.html">
11
12 <link rel="import" href="/tracing/base/unit.html">
13 <link rel="import" href="/tracing/core/test_utils.html">
14
15 <script>
16 'use strict';
17
18 tr.b.unittest.testSuite(function() {
19 const testOptions = {
20 tearDown() {
21 testing_common.clearXhrMock();
22 }
23 };
24
25 test('instantiation', function() {
26 const page = document.createElement('pinpoint-perf-job-dialog');
27 page.show();
28 this.addHTMLOutput(page);
29 page.close();
30 }, testOptions);
31
32 test('onSendToTrybot success fires toast', async function() {
33 const mockResponse = {
34 'jobId': 12345,
35 'jobUrl': 'http://abc'
36 };
37 testing_common.addXhrMock('*', JSON.stringify(mockResponse));
38 const page = document.createElement('pinpoint-perf-job-dialog');
39 this.addHTMLOutput(page);
40
41 page.show();
42
43 let fired = false;
44 page.fire = function(eventName) {
45 if (eventName === 'display-toast') {
46 fired = true;
47 }
48 };
49 await page.onSendToTrybot();
50 page.close();
51
52 assert.strictEqual(page.error, '');
53 assert.isTrue(fired);
54 }, testOptions);
55
56 test('onSendToTrybot failure shows error', async function() {
57 const mockResponse = {
58 'error': 'foo'
59 };
60 testing_common.addXhrMock('*', JSON.stringify(mockResponse));
61 const page = document.createElement('pinpoint-perf-job-dialog');
62 this.addHTMLOutput(page);
63
64 page.show();
65
66 let fired = false;
67 page.fire = function(eventName) {
68 if (eventName === 'display-toast') {
69 fired = true;
70 }
71 };
72 await page.onSendToTrybot();
73 page.close();
74
75 assert.strictEqual(page.error, 'foo');
76 assert.isFalse(fired);
77 }, testOptions);
78
79 const originalAsPromise = simple_xhr.asPromise;
80 const testOptionsOverwriteSimpleXhr = {
81 tearDown() {
82 simple_xhr.asPromise = originalAsPromise;
83 }
84 };
85
86 test('onSendToTrybot trace_categories included', async function() {
87 const mockResponse = {
88 'jobId': 12345
89 };
90 const page = document.createElement('pinpoint-perf-job-dialog');
91 this.addHTMLOutput(page);
92
93 page.testPath = 'master/bot/suite/foo';
94 page.startCommit = '1234567890';
95 page.endCommit = '0987654321';
96 page.startRepository = 'chromium';
97 page.endRepository = 'chromium';
98 page.show();
99 page.traceCategories = 'a,b,c';
100 page.useTrace = true;
101 page.atraceCategories = '1,2,3';
102 page.useAtrace = false;
103
104 let params;
105 simple_xhr.asPromise = function(_, p) {
106 params = p;
107 return new Promise(function(resolve, reject) {
108 resolve({jobId: 12345});
109 });
110 };
111
112 await page.onSendToTrybot();
113 page.close();
114
115 assert.strictEqual(params.test_path, 'master/bot/suite/foo');
116 assert.strictEqual(params.start_commit, '1234567890');
117 assert.strictEqual(params.end_commit, '0987654321');
118 assert.strictEqual(params.start_repository, 'chromium');
119 assert.strictEqual(params.end_repository, 'chromium');
120 assert.deepEqual(params.extra_telemetry_args, [
121 ['--extra-chrome-categories', 'a,b,c']
122 ]);
123 }, testOptionsOverwriteSimpleXhr);
124
125 test('onSendToTrybot atrace_categories included', async function() {
126 const mockResponse = {
127 'jobId': 12345
128 };
129 const page = document.createElement('pinpoint-perf-job-dialog');
130 this.addHTMLOutput(page);
131
132 page.testPath = 'master/bot/suite/foo';
133 page.startCommit = '1234567890';
134 page.endCommit = '0987654321';
135 page.startRepository = 'chromium';
136 page.endRepository = 'chromium';
137 page.show();
138 page.traceCategories = 'a,b,c';
139 page.useTrace = false;
140 page.atraceCategories = '1,2,3';
141 page.useAtrace = true;
142
143 let params;
144 simple_xhr.asPromise = function(_, p) {
145 params = p;
146 return new Promise(function(resolve, reject) {
147 resolve({jobId: 12345});
148 });
149 };
150
151 await page.onSendToTrybot();
152 page.close();
153
154 assert.strictEqual(params.test_path, 'master/bot/suite/foo');
155 assert.strictEqual(params.start_commit, '1234567890');
156 assert.strictEqual(params.end_commit, '0987654321');
157 assert.strictEqual(params.start_repository, 'chromium');
158 assert.strictEqual(params.end_repository, 'chromium');
159 assert.deepEqual(params.extra_telemetry_args, [
160 ['--extra-atrace-categories', '1,2,3']
161 ]);
162 }, testOptionsOverwriteSimpleXhr);
163 });
164 </script>
OLDNEW
« no previous file with comments | « dashboard/dashboard/elements/pinpoint-perf-job-dialog.html ('k') | dashboard/dashboard/elements/trace-button.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698