|
1 | 1 | import requests |
2 | | -from playwright.sync_api import sync_playwright |
| 2 | +from playwright.sync_api import expect, sync_playwright |
3 | 3 |
|
4 | 4 | from util import get_auth_headers |
5 | 5 |
|
@@ -62,29 +62,29 @@ def test_ui(): |
62 | 62 | # Navigate to Apache Superset. |
63 | 63 | page = browser.new_page() |
64 | 64 | page.goto(uri_home) |
| 65 | + page.wait_for_url("**/login/") |
65 | 66 |
|
66 | 67 | # Run the login procedure. |
67 | | - assert page.text_content(".panel-title") == "Sign In" |
68 | | - assert page.url.endswith("/login/") |
69 | 68 | page.type("input#username", "admin") |
70 | 69 | page.type("input#password", "admin") |
71 | | - page.click("input[type=submit]") |
| 70 | + page.click("[type=submit]") |
| 71 | + page.wait_for_load_state() |
72 | 72 |
|
73 | | - # Verify login was successful, and being navigated to `Home`. |
74 | | - html_title = page.text_content("title").strip() |
75 | | - assert html_title == "Superset" |
76 | | - assert page.url.endswith("/superset/welcome/") |
77 | | - |
78 | | - # Invoke SQL Lab with an example query, and verify response. |
79 | | - sql = "SELECT * FROM sys.summits LIMIT 42;" |
| 73 | + # Navigate to SQL Lab. |
80 | 74 | page.goto(uri_sqllab) |
| 75 | + page.wait_for_load_state() |
| 76 | + |
| 77 | + # Invoke query on SQL Lab. |
| 78 | + sql = "SELECT region, mountain, height FROM sys.summits LIMIT 42;" |
81 | 79 | page.wait_for_selector("#ace-editor") |
82 | 80 | page.evaluate(f"ace.edit('ace-editor').setValue('{sql}')") |
83 | 81 | page.get_by_role("button", name="Run").click() |
84 | | - page.wait_for_timeout(500) |
85 | | - page_body = page.text_content("div.ant-tabs-content-holder") |
86 | | - assert "42 rows" in page_body |
87 | | - assert "Monte Rosa" in page_body |
| 82 | + page.wait_for_load_state() |
| 83 | + |
| 84 | + # Verify SQL Lab response. |
| 85 | + locator = page.locator("body") |
| 86 | + # expect(locator).to_contain_text("42 rows") |
| 87 | + expect(locator).to_contain_text("Monte Rosa") |
88 | 88 |
|
89 | 89 | # That's it. |
90 | 90 | browser.close() |
0 commit comments