| <!DOCTYPE html> |
| <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> |
| |
| <script src="/node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"></script> |
| <script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script> |
| <script src="../bower_components/web-component-tester/browser.js"></script> |
| |
| <title>gr-checkers-list-view</title> |
| |
| <test-fixture id="basic"> |
| <template> |
| <gr-checkers-list> |
| </gr-checkers-list> |
| </template> |
| </test-fixture> |
| |
| <script type="module"> |
| import '../test/common-test-setup.js'; |
| import './gr-checkers-list.js'; |
| const CHECKERS = [ |
| { |
| uuid: 'C:D', |
| name: 'A', |
| description: 'B', |
| repository: 'Backend', |
| status: 'ENABLED', |
| blocking: [ |
| |
| ], |
| query: 'status:open', |
| created: '2019-07-25 13:08:43.000000000', |
| updated: '2019-07-25 13:08:43.000000000', |
| }, |
| { |
| uuid: 'aa:bb', |
| name: 'n1', |
| description: 'd1', |
| repository: 'All-Users', |
| status: 'ENABLED', |
| blocking: [ |
| |
| ], |
| query: 'status:open', |
| created: '2019-07-29 13:07:17.000000000', |
| updated: '2019-07-29 13:07:17.000000000', |
| }, |
| { |
| uuid: 'adsf:asdasdas', |
| name: 'ds', |
| description: 's', |
| repository: 'Scripts', |
| status: 'ENABLED', |
| blocking: [ |
| |
| ], |
| query: 'status:open', |
| created: '2019-07-29 13:28:09.000000000', |
| updated: '2019-07-29 13:28:09.000000000', |
| }, |
| { |
| uuid: 'ijkl:mnop', |
| name: 'abcd', |
| description: 'efgh', |
| repository: 'All-Projects', |
| status: 'ENABLED', |
| blocking: [ |
| |
| ], |
| query: 'status:open', |
| created: '2019-07-29 09:33:25.000000000', |
| updated: '2019-07-29 09:33:25.000000000', |
| }, |
| { |
| uuid: 'ngfnf:mhghgnhghn', |
| name: 'nbvfg', |
| description: 'fjhgj', |
| repository: 'All-Users', |
| status: 'ENABLED', |
| blocking: [ |
| |
| ], |
| query: 'status:open', |
| created: '2019-08-06 14:21:34.000000000', |
| updated: '2019-08-06 14:21:34.000000000', |
| }, |
| { |
| uuid: 'sdfsdf--:sdfsdf333', |
| name: 'sdfsdf', |
| description: 'sdfsdfsd', |
| repository: 'Scripts', |
| status: 'ENABLED', |
| blocking: [ |
| |
| ], |
| query: 'status:open', |
| created: '2019-07-30 13:00:19.000000000', |
| updated: '2019-07-30 13:00:19.000000000', |
| }, |
| { |
| uuid: 'test:checker1', |
| name: 'Unit Tests', |
| description: 'Random description that should be improved at some point', |
| repository: 'Backend', |
| status: 'ENABLED', |
| blocking: [ |
| |
| ], |
| query: 'status:open', |
| created: '2019-07-22 13:16:52.000000000', |
| updated: '2019-07-22 14:21:14.000000000', |
| }, |
| { |
| uuid: 'test:checker2', |
| name: 'Code Style', |
| repository: 'Backend', |
| status: 'ENABLED', |
| blocking: [ |
| |
| ], |
| query: 'status:open', |
| created: '2019-07-22 13:26:56.000000000', |
| updated: '2019-07-22 13:26:56.000000000', |
| }, |
| { |
| uuid: 'xddf:sdfsdfsdf', |
| name: 'sdfsdf', |
| description: 'sdfsdf', |
| repository: 'Scripts', |
| status: 'ENABLED', |
| blocking: [ |
| |
| ], |
| query: 'status:open', |
| created: '2019-07-29 14:11:59.000000000', |
| updated: '2019-07-29 14:11:59.000000000', |
| }, |
| { |
| uuid: 'zxczxc:bnvnbvnbvn', |
| name: 'zxc', |
| description: 'zxc', |
| repository: 'Scripts', |
| status: 'ENABLED', |
| blocking: [ |
| |
| ], |
| query: 'status:open', |
| created: '2019-07-29 14:00:24.000000000', |
| updated: '2019-07-29 14:00:24.000000000', |
| }, |
| { |
| uuid: 'zxczxc:sdfsdf', |
| name: 'zxc', |
| description: 'zxc', |
| repository: 'Scripts', |
| status: 'ENABLED', |
| blocking: [ |
| |
| ], |
| query: 'status:open', |
| created: '2019-07-29 13:30:47.000000000', |
| updated: '2019-07-29 13:30:47.000000000', |
| }, |
| ]; |
| |
| suite('gr-checkers-list tests', () => { |
| let element; |
| let sandbox; |
| let getSpy; let getResolve; |
| |
| setup(done => { |
| sandbox = sinon.sandbox.create(); |
| |
| getSpy = sinon.stub(); |
| const getPromise = new Promise((resolve, reject) => { |
| getResolve = resolve; |
| }); |
| getSpy.returns(getPromise); |
| |
| const pluginRestApi = { |
| get: getSpy, |
| }; |
| |
| element = fixture('basic'); |
| element.pluginRestApi = pluginRestApi; |
| |
| element.$.listOverlay.refit = () => {}; |
| element.$.listOverlay.open = () => { |
| return Promise.resolve(() => {}); |
| }; |
| flush(done); |
| }); |
| |
| teardown(() => { sandbox.restore(); }); |
| |
| test('renders checker list table headings', () => { |
| const checkersList = element.$$('table'); |
| const headings = checkersList.firstElementChild.firstElementChild. |
| children; |
| const expectedHeadings = ['Checker Name', 'Repository', 'Status', |
| 'Required', 'Checker Description', 'Edit']; |
| for (let i = 0; i < headings.length; i++) { |
| assert(headings[i].innerText.trim() === expectedHeadings[i]); |
| } |
| }); |
| |
| test('create checker button renders', () => { |
| assert(element.shadowRoot.querySelector('#createNewContainer')); |
| const button = element.shadowRoot.querySelector('#createNewContainer') |
| .querySelector('gr-button'); |
| assert(button); |
| assert(button.innerText === 'Create New'); |
| }); |
| |
| suite('with checkers', () => { |
| setup(done => { |
| getResolve(CHECKERS); |
| element._showConfigureOverlay(); |
| flush(done); |
| }); |
| |
| test('renders correct number of checkers', () => { |
| const checkers = element |
| .shadowRoot.querySelector('table > tbody:nth-child(2)') |
| .querySelectorAll('tr'); |
| assert(checkers.length === CHECKERS.length); |
| }); |
| |
| test('renders correct checkers', () => { |
| const checkers = element.$$('table > tbody:nth-child(2)') |
| .querySelectorAll('tr'); |
| for (let i = 0; i < checkers.length; i++) { |
| const checkerDetails = checkers[i].querySelectorAll('td'); |
| assert(CHECKERS[i].name === checkerDetails[0].innerText); |
| assert(CHECKERS[i].repository === checkerDetails[1].innerText); |
| const status = CHECKERS[i].status || 'NO'; |
| assert(status === checkerDetails[2].innerText); |
| const checkerRequired = (CHECKERS[i].blocking && |
| CHECKERS[i].blocking.length > 0) |
| ? 'YES': 'NO'; |
| assert(checkerRequired === checkerDetails[3].innerText); |
| const description = CHECKERS[i].description || ''; |
| assert(description === checkerDetails[4].innerText); |
| } |
| }); |
| }); |
| }); |
| </script> |