forked from streamlit/streamlit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate static file serving e2e test to playwright (streamlit#8811)
## Describe your changes This PR migrates the static file serving e2e test to playwright. --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
- Loading branch information
1 parent
eca9170
commit 1e1e5c7
Showing
10 changed files
with
80 additions
and
95 deletions.
There are no files selected for viewing
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from playwright.sync_api import Page, expect | ||
|
||
from e2e_playwright.shared.app_utils import get_markdown | ||
|
||
|
||
def test_should_serve_existing_asset(app: Page, app_port: int): | ||
"""Test that the static serving feature serves an existing asset.""" | ||
response = app.request.get( | ||
f"http://localhost:{app_port}/app/static/streamlit-logo.png" | ||
) | ||
expect(response).to_be_ok() | ||
# Assert is safe here since we don't need to wait for something here: | ||
assert response.status == 200 | ||
|
||
|
||
def test_should_return_error_on_non_existing_asset(app: Page, app_port: int): | ||
"""Test that the static serving feature returns error code for non-existing asset.""" | ||
response = app.request.get( | ||
f"http://localhost:{app_port}/app/static/notexisting.jpeg" | ||
) | ||
expect(response).not_to_be_ok() | ||
# Assert is safe here since we don't need to wait for something here: | ||
assert response.status == 404 | ||
|
||
|
||
def test_static_served_image_embedded_in_markdown(app: Page): | ||
"""Test that an image served via the static serving can be embedded into markdown.""" | ||
markdown_element = get_markdown(app, "Images served via static serving:") | ||
image_element = markdown_element.locator("img") | ||
|
||
expect(image_element).to_be_visible() | ||
# Check that the image gets loaded correctly | ||
app.expect_response("**/streamlit-logo.png") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-15.3 KB
.../snapshots/linux/2x/staticfiles_app.spec.js/static_streamlit_logo-dark.snap.png
Binary file not shown.
Binary file removed
BIN
-13.9 KB
...press/snapshots/linux/2x/staticfiles_app.spec.js/static_streamlit_logo.snap.png
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters