Fix formatting on new tests

This commit is contained in:
Max Berger
2026-03-10 23:35:40 +01:00
parent d99631e47d
commit 9c88ba07be
4 changed files with 99 additions and 62 deletions

View File

@@ -36,67 +36,84 @@ def radicale_server(tmp_path: pathlib.Path) -> Generator[str, Any, None]:
def test_upload_zero_files(page: Page, radicale_server: str) -> None:
login(page, radicale_server)
page.click('.fabcontainer a[data-name="upload"]')
# Click upload without selecting files
page.click('#uploadcollectionscene button[data-name="submit"]')
# Check for error message at the bottom of the scene
error_locator = page.locator('#uploadcollectionscene > span[data-name="error"]')
expect(error_locator).to_be_visible()
expect(error_locator).to_contain_text("Please select at least one file")
def test_upload_one_file_custom_href(page: Page, radicale_server: str, tmp_path: pathlib.Path) -> None:
def test_upload_one_file_custom_href(
page: Page, radicale_server: str, tmp_path: pathlib.Path
) -> None:
login(page, radicale_server)
# Create a fake file to upload
test_file = tmp_path / "test.ics"
test_file.write_text("BEGIN:VCALENDAR\nVERSION:2.0\nEND:VCALENDAR")
page.click('.fabcontainer a[data-name="upload"]')
# Upload 1 file and set custom href
page.set_input_files('#uploadcollectionscene input[data-name="uploadfile"]', str(test_file))
page.set_input_files(
'#uploadcollectionscene input[data-name="uploadfile"]', str(test_file)
)
page.fill('#uploadcollectionscene input[data-name="href"]', "testcollection")
page.click('#uploadcollectionscene button[data-name="submit"]')
# Wait for upload to complete in the list item
expect(page.locator('#uploadcollectionscene li:not(.hidden) [data-name="success"]')).to_be_visible()
expect(
page.locator('#uploadcollectionscene li:not(.hidden) [data-name="success"]')
).to_be_visible()
# Close scene
page.click('#uploadcollectionscene button[data-name="close"]')
# Verify 1 collection exists with "testcollection" in url
expect(page.locator('article:not(.hidden)')).to_have_count(1)
expect(page.locator('article:not(.hidden) input[data-name="url"]')).to_have_value(re.compile(r".*testcollection/.*"))
expect(page.locator("article:not(.hidden)")).to_have_count(1)
expect(page.locator('article:not(.hidden) input[data-name="url"]')).to_have_value(
re.compile(r".*testcollection/.*")
)
def test_upload_two_files(page: Page, radicale_server: str, tmp_path: pathlib.Path) -> None:
def test_upload_two_files(
page: Page, radicale_server: str, tmp_path: pathlib.Path
) -> None:
login(page, radicale_server)
# Create two fake files
file1 = tmp_path / "test1.ics"
file1.write_text("BEGIN:VCALENDAR\nVERSION:2.0\nEND:VCALENDAR")
file2 = tmp_path / "test2.ics"
file2.write_text("BEGIN:VCALENDAR\nVERSION:2.0\nEND:VCALENDAR")
page.click('.fabcontainer a[data-name="upload"]')
# Upload 2 files
page.set_input_files('#uploadcollectionscene input[data-name="uploadfile"]', [str(file1), str(file2)])
page.set_input_files(
'#uploadcollectionscene input[data-name="uploadfile"]', [str(file1), str(file2)]
)
# HREF field should be hidden
expect(page.locator('#uploadcollectionscene input[data-name="href"]')).to_be_hidden()
expect(page.locator('#uploadcollectionscene [data-name="hreflimitmsg"]')).to_be_visible()
expect(
page.locator('#uploadcollectionscene input[data-name="href"]')
).to_be_hidden()
expect(
page.locator('#uploadcollectionscene [data-name="hreflimitmsg"]')
).to_be_visible()
page.click('#uploadcollectionscene button[data-name="submit"]')
# Wait for uploads to complete
# Wait until 2 entries in the upload list show success
expect(page.locator('#uploadcollectionscene li:not(.hidden) [data-name="success"]')).to_have_count(2)
expect(
page.locator('#uploadcollectionscene li:not(.hidden) [data-name="success"]')
).to_have_count(2)
# Close scene
page.click('#uploadcollectionscene button[data-name="close"]')
# Verify 2 collections exist
expect(page.locator('article:not(.hidden)')).to_have_count(2)
expect(page.locator("article:not(.hidden)")).to_have_count(2)