Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate disconnect and disabled from cypress to playwright #8732

Merged
merged 12 commits into from
Jun 4, 2024
65 changes: 0 additions & 65 deletions e2e/specs/st_disabled.spec.js

This file was deleted.

43 changes: 0 additions & 43 deletions e2e/specs/st_disconnect.spec.js

This file was deleted.

File renamed without changes.
59 changes: 59 additions & 0 deletions e2e_playwright/disabled_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 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.

import pytest
from playwright.sync_api import Page, expect


def test_disconnecting_disables_widgets_correctly(app: Page):
expect(app.get_by_test_id("stButton").locator("button")).not_to_have_attribute(
"disabled", ""
)
expect(app.get_by_test_id("stMarkdown").first).to_contain_text("Value 1: 25")

expect(app.get_by_test_id("stConnectionStatus")).not_to_be_visible()
app.evaluate("window.streamlitDebug.shutdownRuntime()")

expect(app.get_by_test_id("stConnectionStatus")).to_contain_text("Connecting")

expect(app.get_by_test_id("stButton").locator("button")).to_have_attribute(
"disabled", ""
)
expect(app.get_by_test_id("stCheckbox").locator("input")).to_have_attribute(
"disabled", ""
)
expect(app.get_by_test_id("stDateInput").locator("input")).to_have_attribute(
"disabled", ""
)
expect(app.get_by_test_id("stRadio").locator("input").first).to_have_attribute(
"disabled", ""
)
expect(app.get_by_test_id("stSelectbox").locator("input")).to_have_attribute(
"disabled", ""
)
expect(app.get_by_test_id("stTextArea").locator("textarea")).to_have_attribute(
"disabled", ""
)
expect(app.get_by_test_id("stTextInput").locator("input")).to_have_attribute(
"disabled", ""
)
expect(app.get_by_test_id("stTimeInput").locator("input")).to_have_attribute(
"disabled", ""
)

app.get_by_test_id("stSlider").nth(0).hover()
# click in middle
app.mouse.down()

expect(app.get_by_test_id("stMarkdown").first).to_contain_text("Value 1: 25")
File renamed without changes.
23 changes: 23 additions & 0 deletions e2e_playwright/disconnect_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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.

import pytest
from playwright.sync_api import Page, expect


def test_disconnect_shows_connecting_in_status_widget_correctly(app: Page):
expect(app.get_by_test_id("stConnectionStatus")).not_to_be_visible()
app.evaluate("window.streamlitDebug.shutdownRuntime()")

expect(app.get_by_test_id("stConnectionStatus")).to_contain_text("Connecting")
Loading