Skip to content

Commit

Permalink
Migrate disconnect and disabled from cypress to playwright (#8732)
Browse files Browse the repository at this point in the history
## Describe your changes

## GitHub Issue Link (if applicable)

## Testing Plan

- Explanation of why no additional tests are needed
- Unit Tests (JS and/or Python)
- E2E Tests
- Any manual testing needed?

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.

---------

Co-authored-by: willhuang1997 <willhuang1997@gmail.com>
  • Loading branch information
sfc-gh-wihuang and willhuang1997 committed Jun 4, 2024
1 parent 5775cf2 commit 65c0a6b
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 56 deletions.
13 changes: 0 additions & 13 deletions e2e/scripts/st_disconnect.py

This file was deleted.

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

This file was deleted.

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

# activating this will disable all elements and simulate runtime shutdown
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")
Binary file not shown.
Binary file not shown.

0 comments on commit 65c0a6b

Please sign in to comment.