blob: e8b4295b862c166a53b356e7e4ca483283c01d8a [file] [log] [blame]
Brad Bishop96ff1982019-08-19 13:50:42 -04001#! /usr/bin/env python3
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05002#
3# BitBake Toaster Implementation
4#
5# Copyright (C) 2013-2016 Intel Corporation
6#
Brad Bishopc342db32019-05-15 21:57:59 -04007# SPDX-License-Identifier: GPL-2.0-only
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05008#
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05009
10"""
11Run the js unit tests
12"""
13
14from django.core.urlresolvers import reverse
15from tests.browser.selenium_helpers import SeleniumTestCase
16import logging
17
18logger = logging.getLogger("toaster")
19
20
21class 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 Williamsc0f7c042017-02-23 20:41:17 -060029 self.wait_until_present('#qunit-testresult .failed')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050030
Patrick Williamsc0f7c042017-02-23 20:41:17 -060031 failed = self.find("#qunit-testresult .failed").text
32 passed = self.find("#qunit-testresult .passed").text
33 total = self.find("#qunit-testresult .total").text
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050034
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)