Bug 1754025 [wpt PR 32729] - WebKit export of https://bugs.webkit.org/show_bug.cgi...
[gecko.git] / tools / tryselect / test / test_chooser.py
blob217351c2061b5fbc37f577ca32ae06f440b521ce
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 from __future__ import absolute_import, print_function, unicode_literals
7 import mozunit
8 import pytest
10 from tryselect.selectors.chooser.app import create_application
13 TASKS = [
15 "kind": "build",
16 "label": "build-windows",
17 "attributes": {
18 "build_platform": "windows",
22 "kind": "test",
23 "label": "test-windows-mochitest-e10s",
24 "attributes": {
25 "unittest_suite": "mochitest-browser-chrome",
26 "mochitest_try_name": "mochitest-browser-chrome",
32 @pytest.fixture
33 def app(tg):
34 app = create_application(tg)
35 app.config["TESTING"] = True
37 ctx = app.app_context()
38 ctx.push()
39 yield app
40 ctx.pop()
43 def test_try_chooser(app):
44 client = app.test_client()
46 response = client.get("/")
47 assert response.status_code == 200
49 expected_output = [
50 b"""<title>Try Chooser Enhanced</title>""",
51 b"""<input class="filter" type="checkbox" id=windows name="build" value='{"build_platform": ["windows"]}' onchange="console.log('checkbox onchange triggered');apply();">""", # noqa
52 b"""<input class="filter" type="checkbox" id=mochitest-browser-chrome name="test" value='{"unittest_suite": ["mochitest-browser-chrome"]}' onchange="console.log('checkbox onchange triggered');apply();">""", # noqa
55 for expected in expected_output:
56 assert expected in response.data
58 response = client.post("/", data={"action": "Cancel"})
59 assert response.status_code == 200
60 assert b"You may now close this page" in response.data
61 assert app.tasks == []
63 response = client.post("/", data={"action": "Push", "selected-tasks": ""})
64 assert response.status_code == 200
65 assert b"You may now close this page" in response.data
66 assert app.tasks == []
68 response = client.post(
69 "/",
70 data={
71 "action": "Push",
72 "selected-tasks": "build-windows\ntest-windows-mochitest-e10s",
75 assert response.status_code == 200
76 assert b"You may now close this page" in response.data
77 assert set(app.tasks) == set(["build-windows", "test-windows-mochitest-e10s"])
80 if __name__ == "__main__":
81 mozunit.main()