Skip to content

Commit c662ecd

Browse files
committed
add more tests
1 parent 150fb27 commit c662ecd

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

test/test_backups.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ def test_shows_backups(page: Page):
5959
},
6060
]
6161

62+
def test_switches_to_other_db(page: Page):
63+
page.goto("http://localhost:8080")
64+
page.get_by_text("db1").click()
65+
page.get_by_role("button", name="db1").click()
66+
page.get_by_role("link", name="db2").click()
67+
expect(page.get_by_role("heading", name="Last backup")).to_have_text(
68+
"Last backup —"
69+
)
70+
expect(page.get_by_role("heading", name="Backups")).to_have_text("Backups 0")
71+
6272

6373
def test_creates_backup(page: Page):
6474
cleanup_backups()

test/test_database.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
from playwright.sync_api import Page, expect
22
from utils import cleanup_backups, cleanup_db, extract_table_data, get_db1_tables
33

4+
def test_switches_to_other_db(page: Page):
5+
page.goto("http://localhost:8080")
6+
page.get_by_text("db1").click()
7+
page.get_by_role("button", name="db1").click()
8+
page.get_by_role("link", name="db2").click()
9+
expect(page.get_by_role("heading", name="Records")).to_have_text("Records 17")
10+
expect(page.get_by_role("heading", name="Tables")).to_have_text("Tables 3")
11+
table_data = extract_table_data(page.locator((":text('Tables') + table")))
12+
assert table_data == [
13+
{"Name": "animals", "Records": "6"},
14+
{"Name": "countries", "Records": "6"},
15+
{"Name": "books", "Records": "5"},
16+
]
417

518
def test_shows_total_record_count_in_db(page: Page):
619
page.goto("http://localhost:8080")

test/test_profile.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from playwright.sync_api import Page, expect
2+
3+
4+
def test_title(page: Page):
5+
page.goto("http://localhost:8080")
6+
expect(page.get_by_role("link", name="Postgres Backup Tool")).to_be_visible()
7+
8+
9+
def test_shows_user_initials_in_header(page: Page):
10+
page.goto("http://localhost:8080")
11+
expect(page.get_by_role("button", name="TU")).to_be_visible()
12+
13+
14+
def test_shows_user_name_in_popup(page: Page):
15+
page.goto("http://localhost:8080")
16+
page.get_by_role("button", name="TU").click()
17+
expect(page.get_by_text("Test User")).to_be_visible()

0 commit comments

Comments
 (0)