blob: 4d479bbe8b7e17b8e1692792546c75d16ebc0b82 [file] [log] [blame]
brohlfsdd9ebb62019-03-28 10:23:08 +01001<!DOCTYPE html>
2<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
Dhruv Srivastavaa0e66322019-07-04 15:59:36 +02003<script src="../../../bower_components/webcomponentsjs/webcomponents.js"></script>
4<script src="/bower_components/web-component-tester/browser.js"></script>
5<script src="../../../bower_components/moment/min/moment.min.js"></script>
6<link rel="import" href="/bower_components/polymer/polymer.html">
brohlfsdd9ebb62019-03-28 10:23:08 +01007
8<title>gr-checks-item</title>
Dhruv Srivastavaa0e66322019-07-04 15:59:36 +02009<link rel="import" href="gr-checks-item.html">
brohlfsdd9ebb62019-03-28 10:23:08 +010010
11<test-fixture id="basic">
12 <template is="dom-template">
13 <gr-checks-item
14 check="{{check}}"
brohlfsdd9ebb62019-03-28 10:23:08 +010015 retry-check="[[retryCheck]]">
16 </gr-checks-item>
17 </template>
18</test-fixture>
19
20<script>
21 suite('gr-checks-item tests', () => {
22 let element;
23 let sandbox;
brohlfsdd9ebb62019-03-28 10:23:08 +010024 let retryCheckSpy;
25
Dhruv Srivastava5a86ef72019-12-09 20:10:26 +010026 setup(done => {
brohlfsdd9ebb62019-03-28 10:23:08 +010027 sandbox = sinon.sandbox.create();
brohlfsdd9ebb62019-03-28 10:23:08 +010028 retryCheckSpy = sinon.stub();
29 retryCheckSpy.returns(Promise.resolve());
30
31 element = fixture('basic', {
brohlfsdd9ebb62019-03-28 10:23:08 +010032 retryCheck: retryCheckSpy,
33 check: {
34 checkId: 'test-check-id',
Dhruv Srivastavaa0e66322019-07-04 15:59:36 +020035 url: 'http://example.com/test-log-url',
Dhruv Srivastava5a86ef72019-12-09 20:10:26 +010036 started: '2019-02-06T22:25:19.269Z',
37 finished: '2019-02-06T22:25:44.574Z',
brohlfsdd9ebb62019-03-28 10:23:08 +010038 },
39 });
40 flush(done);
41 });
42
43 teardown(() => { sandbox.restore(); });
44
brohlfsdd9ebb62019-03-28 10:23:08 +010045 test('renders the status', () => {
Dhruv Srivastava5f242972019-08-30 16:40:51 +020046 const status = element.$$('td:nth-child(4) > gr-checks-status');
brohlfsdd9ebb62019-03-28 10:23:08 +010047 assert.exists(status);
48 });
49
Dhruv Srivastava25d549d2020-02-06 11:13:53 +010050 test('renders the start time', () => {
51 assert.equal(element._startTime, '2019-02-06T22:25:19.269Z');
brohlfsdd9ebb62019-03-28 10:23:08 +010052 });
53
54 suite('duration', () => {
55 test('renders the run duration', () => {
Dhruv Srivastava25d549d2020-02-06 11:13:53 +010056 const name = element.$$('td:nth-child(6)');
Dhruv Srivastava5a86ef72019-12-09 20:10:26 +010057 assert.equal(name .textContent.trim(), '25 sec');
brohlfsdd9ebb62019-03-28 10:23:08 +010058 });
59
60 test('renders 0 sec when the start and end time are the same', () => {
61 element.check = {
62 checkId: 'test-check-id',
Dhruv Srivastavaa0e66322019-07-04 15:59:36 +020063 url: 'http://example.com/test-log-url',
Dhruv Srivastava5a86ef72019-12-09 20:10:26 +010064 started: '2019-02-06T22:25:19.269Z',
65 finished: '2019-02-06T22:25:19.269Z',
brohlfsdd9ebb62019-03-28 10:23:08 +010066 };
Dhruv Srivastava25d549d2020-02-06 11:13:53 +010067 const name = element.$$('td:nth-child(6)');
Dhruv Srivastava5a86ef72019-12-09 20:10:26 +010068 assert.equal(name .textContent.trim(), '0 sec');
brohlfsdd9ebb62019-03-28 10:23:08 +010069 });
70 });
71
72 test('renders a link to the log', () => {
Dhruv Srivastava25d549d2020-02-06 11:13:53 +010073 const logLink = element.$$('td:nth-child(7) > a');
Dhruv Srivastava5a86ef72019-12-09 20:10:26 +010074 assert.equal(logLink.getAttribute('href'),
75 'http://example.com/test-log-url');
76 assert.equal(logLink.textContent.trim(), 'View log');
brohlfsdd9ebb62019-03-28 10:23:08 +010077 });
78
Dhruv Srivastavaa0e66322019-07-04 15:59:36 +020079 // pausing this check until retry api is available from backend
80 // suite('retryCheck', () => {
81 // let retryCheckLink;
brohlfsdd9ebb62019-03-28 10:23:08 +010082
Dhruv Srivastavaa0e66322019-07-04 15:59:36 +020083 // setup(() => {
84 // retryCheckLink = element.$$('td:nth-child(7) > gr-button');
85 // });
brohlfsdd9ebb62019-03-28 10:23:08 +010086
Dhruv Srivastavaa0e66322019-07-04 15:59:36 +020087 // test('shows a link to the retry button', () => {
88 // assert.equal(retryCheckLink.textContent.trim(), "Re-run");
89 // });
brohlfsdd9ebb62019-03-28 10:23:08 +010090
Dhruv Srivastavaa0e66322019-07-04 15:59:36 +020091 // test('clicking on the link calls the retryCheck property', () => {
92 // assert.isFalse(retryCheckSpy.called);
93 // retryCheckLink.click();
94 // assert.isTrue(retryCheckSpy.called);
95 // });
96 // });
brohlfsdd9ebb62019-03-28 10:23:08 +010097 });
98</script>