Skip to content

Commit

Permalink
Increase Playwright timeouts, robustify YAML editor interaction (cond…
Browse files Browse the repository at this point in the history
…a-incubator#422)

* Increase timeout to build existing env for Playwright test

* Also increase default timeout

* make Playwright yaml interaction more robust
  • Loading branch information
gabalafou authored Sep 12, 2024
1 parent e93a6c1 commit d0ad03e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/features/yamlEditor/components/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const CodeEditor = ({ code, onChangeEditor }: ICodeEditor) => {
const convertToJSON = (e: string) => {
try {
setIsError(false);
onChangeEditor(parse(e));
onChangeEditor(parse(e) || {});
} catch (e) {
setIsError(true);
}
Expand All @@ -52,6 +52,7 @@ export const CodeEditor = ({ code, onChangeEditor }: ICodeEditor) => {
theme={isGrayscaleStyleType ? undefined : greenAccentTheme}
extensions={[StreamLanguage.define(yamlLanguage)]}
onChange={e => convertToJSON(e)}
data-testid="yaml-editor"
/>

<Box
Expand Down
19 changes: 12 additions & 7 deletions test/playwright/test_ux.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import random


DEFAULT_TIMEOUT = 30_000 # time in ms
DEFAULT_TIMEOUT = 60_000 # time in ms

expect.set_options(timeout=DEFAULT_TIMEOUT)

Expand Down Expand Up @@ -120,7 +120,7 @@ def _create_new_environment(page, screenshot=False):


def _existing_environment_interactions(
page, env_name, time_to_build_env=3 * 60 * 1000, screenshot=False
page, env_name, time_to_build_env=5 * 60 * 1000, screenshot=False
):
"""test interactions with existing environments.
During this test, the test will be rebuilt twice.
Expand All @@ -145,18 +145,23 @@ def _existing_environment_interactions(
env_link = page.get_by_role("link", name=env_name)
edit_button = page.get_by_role("button", name="Edit")

# edit existing environment throught the YAML editor
# edit existing environment through the YAML editor
env_link.click()
edit_button.click()
page.get_by_label("YAML").check()
if screenshot:
page.screenshot(path="test-results/conda-store-yaml-editor.png")
page.get_by_text("- rich").click()
page.get_by_text(
"channels: - conda-forgedependencies: - rich - pip: - nothing - ipykernel"
).fill(

# set the YAML editor to a particular environment specification
yaml_editor = page.get_by_test_id("yaml-editor").get_by_role("textbox")
# note: I'm not sure this is necessary but I deliberately chose to match
# text near the end of the editor to prevent the possibility of Playwright
# acting on the editor before it has finished rendering its initial value
yaml_editor.filter(has_text=r"variables: {}").clear()
yaml_editor.fill(
"channels:\n - conda-forge\ndependencies:\n - rich\n - python\n - pip:\n - nothing\n - ipykernel\n\n"
)

page.get_by_role("button", name="Save").click()
edit_button.wait_for(state="attached")

Expand Down

0 comments on commit d0ad03e

Please sign in to comment.