brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> |
Dhruv Srivastava | a0e6632 | 2019-07-04 15:59:36 +0200 | [diff] [blame] | 3 | <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"> |
brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 7 | |
| 8 | <title>gr-checks-item</title> |
Dhruv Srivastava | a0e6632 | 2019-07-04 15:59:36 +0200 | [diff] [blame] | 9 | <link rel="import" href="gr-checks-item.html"> |
brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 10 | |
| 11 | <test-fixture id="basic"> |
| 12 | <template is="dom-template"> |
| 13 | <gr-checks-item |
| 14 | check="{{check}}" |
brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 15 | 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; |
brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 24 | let retryCheckSpy; |
| 25 | |
Dhruv Srivastava | 5a86ef7 | 2019-12-09 20:10:26 +0100 | [diff] [blame] | 26 | setup(done => { |
brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 27 | sandbox = sinon.sandbox.create(); |
brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 28 | retryCheckSpy = sinon.stub(); |
| 29 | retryCheckSpy.returns(Promise.resolve()); |
| 30 | |
| 31 | element = fixture('basic', { |
brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 32 | retryCheck: retryCheckSpy, |
| 33 | check: { |
| 34 | checkId: 'test-check-id', |
Dhruv Srivastava | a0e6632 | 2019-07-04 15:59:36 +0200 | [diff] [blame] | 35 | url: 'http://example.com/test-log-url', |
Dhruv Srivastava | 5a86ef7 | 2019-12-09 20:10:26 +0100 | [diff] [blame] | 36 | started: '2019-02-06T22:25:19.269Z', |
| 37 | finished: '2019-02-06T22:25:44.574Z', |
brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 38 | }, |
| 39 | }); |
| 40 | flush(done); |
| 41 | }); |
| 42 | |
| 43 | teardown(() => { sandbox.restore(); }); |
| 44 | |
brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 45 | test('renders the status', () => { |
Dhruv Srivastava | 5f24297 | 2019-08-30 16:40:51 +0200 | [diff] [blame] | 46 | const status = element.$$('td:nth-child(4) > gr-checks-status'); |
brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 47 | assert.exists(status); |
| 48 | }); |
| 49 | |
Dhruv Srivastava | 25d549d | 2020-02-06 11:13:53 +0100 | [diff] [blame^] | 50 | test('renders the start time', () => { |
| 51 | assert.equal(element._startTime, '2019-02-06T22:25:19.269Z'); |
brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 52 | }); |
| 53 | |
| 54 | suite('duration', () => { |
| 55 | test('renders the run duration', () => { |
Dhruv Srivastava | 25d549d | 2020-02-06 11:13:53 +0100 | [diff] [blame^] | 56 | const name = element.$$('td:nth-child(6)'); |
Dhruv Srivastava | 5a86ef7 | 2019-12-09 20:10:26 +0100 | [diff] [blame] | 57 | assert.equal(name .textContent.trim(), '25 sec'); |
brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 58 | }); |
| 59 | |
| 60 | test('renders 0 sec when the start and end time are the same', () => { |
| 61 | element.check = { |
| 62 | checkId: 'test-check-id', |
Dhruv Srivastava | a0e6632 | 2019-07-04 15:59:36 +0200 | [diff] [blame] | 63 | url: 'http://example.com/test-log-url', |
Dhruv Srivastava | 5a86ef7 | 2019-12-09 20:10:26 +0100 | [diff] [blame] | 64 | started: '2019-02-06T22:25:19.269Z', |
| 65 | finished: '2019-02-06T22:25:19.269Z', |
brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 66 | }; |
Dhruv Srivastava | 25d549d | 2020-02-06 11:13:53 +0100 | [diff] [blame^] | 67 | const name = element.$$('td:nth-child(6)'); |
Dhruv Srivastava | 5a86ef7 | 2019-12-09 20:10:26 +0100 | [diff] [blame] | 68 | assert.equal(name .textContent.trim(), '0 sec'); |
brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 69 | }); |
| 70 | }); |
| 71 | |
| 72 | test('renders a link to the log', () => { |
Dhruv Srivastava | 25d549d | 2020-02-06 11:13:53 +0100 | [diff] [blame^] | 73 | const logLink = element.$$('td:nth-child(7) > a'); |
Dhruv Srivastava | 5a86ef7 | 2019-12-09 20:10:26 +0100 | [diff] [blame] | 74 | assert.equal(logLink.getAttribute('href'), |
| 75 | 'http://example.com/test-log-url'); |
| 76 | assert.equal(logLink.textContent.trim(), 'View log'); |
brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 77 | }); |
| 78 | |
Dhruv Srivastava | a0e6632 | 2019-07-04 15:59:36 +0200 | [diff] [blame] | 79 | // pausing this check until retry api is available from backend |
| 80 | // suite('retryCheck', () => { |
| 81 | // let retryCheckLink; |
brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 82 | |
Dhruv Srivastava | a0e6632 | 2019-07-04 15:59:36 +0200 | [diff] [blame] | 83 | // setup(() => { |
| 84 | // retryCheckLink = element.$$('td:nth-child(7) > gr-button'); |
| 85 | // }); |
brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 86 | |
Dhruv Srivastava | a0e6632 | 2019-07-04 15:59:36 +0200 | [diff] [blame] | 87 | // test('shows a link to the retry button', () => { |
| 88 | // assert.equal(retryCheckLink.textContent.trim(), "Re-run"); |
| 89 | // }); |
brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 90 | |
Dhruv Srivastava | a0e6632 | 2019-07-04 15:59:36 +0200 | [diff] [blame] | 91 | // test('clicking on the link calls the retryCheck property', () => { |
| 92 | // assert.isFalse(retryCheckSpy.called); |
| 93 | // retryCheckLink.click(); |
| 94 | // assert.isTrue(retryCheckSpy.called); |
| 95 | // }); |
| 96 | // }); |
brohlfs | dd9ebb6 | 2019-03-28 10:23:08 +0100 | [diff] [blame] | 97 | }); |
| 98 | </script> |