Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame^] | 1 | #! /usr/bin/env python3 |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 2 | # |
| 3 | # BitBake Toaster Implementation |
| 4 | # |
| 5 | # Copyright (C) 2013-2016 Intel Corporation |
| 6 | # |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7 | # SPDX-License-Identifier: GPL-2.0-only |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 8 | # |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 9 | |
| 10 | """ |
| 11 | Run the js unit tests |
| 12 | """ |
| 13 | |
| 14 | from django.core.urlresolvers import reverse |
| 15 | from tests.browser.selenium_helpers import SeleniumTestCase |
| 16 | import logging |
| 17 | |
| 18 | logger = logging.getLogger("toaster") |
| 19 | |
| 20 | |
| 21 | class TestJsUnitTests(SeleniumTestCase): |
| 22 | """ Test landing page shows the Toaster brand """ |
| 23 | |
| 24 | fixtures = ['toastergui-unittest-data'] |
| 25 | |
| 26 | def test_that_js_unit_tests_pass(self): |
| 27 | url = reverse('js-unit-tests') |
| 28 | self.get(url) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 29 | self.wait_until_present('#qunit-testresult .failed') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 30 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 31 | failed = self.find("#qunit-testresult .failed").text |
| 32 | passed = self.find("#qunit-testresult .passed").text |
| 33 | total = self.find("#qunit-testresult .total").text |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 34 | |
| 35 | logger.info("Js unit tests completed %s out of %s passed, %s failed", |
| 36 | passed, |
| 37 | total, |
| 38 | failed) |
| 39 | |
| 40 | failed_tests = self.find_all("li .fail .test-message") |
| 41 | for fail in failed_tests: |
| 42 | logger.error("JS unit test failed: %s" % fail.text) |
| 43 | |
| 44 | self.assertEqual(failed, '0', |
| 45 | "%s JS unit tests failed" % failed) |