diff --git a/mesop/components/checkbox/e2e/BUILD b/mesop/components/checkbox/e2e/BUILD new file mode 100644 index 000000000..6d31bd3e2 --- /dev/null +++ b/mesop/components/checkbox/e2e/BUILD @@ -0,0 +1,13 @@ +load("//build_defs:defaults.bzl", "py_library") + +package( + default_visibility = ["//build_defs:mesop_internal"], +) + +py_library( + name = "e2e", + srcs = glob(["*.py"]), + deps = [ + "//mesop", + ], +) diff --git a/mesop/components/checkbox/e2e/__init__.py b/mesop/components/checkbox/e2e/__init__.py new file mode 100644 index 000000000..c1b643a66 --- /dev/null +++ b/mesop/components/checkbox/e2e/__init__.py @@ -0,0 +1 @@ +from . import checkbox_app as checkbox_app diff --git a/mesop/components/checkbox/e2e/checkbox_app.py b/mesop/components/checkbox/e2e/checkbox_app.py new file mode 100644 index 000000000..e51262c5f --- /dev/null +++ b/mesop/components/checkbox/e2e/checkbox_app.py @@ -0,0 +1,22 @@ +import mesop as me + + +@me.stateclass +class State: + checked: bool = False + + +@me.on(me.CheckboxEvent) +def on_update(event: me.CheckboxEvent): + state = me.state(State) + state.checked = event.checked + + +@me.page(path="/components/checkbox/e2e/checkbox_app") +def app(): + me.checkbox(label="checkbox", on_update=on_update) + state = me.state(State) + if state.checked: + me.text(text="is checked") + else: + me.text(text="is not checked") diff --git a/mesop/components/checkbox/e2e/checkbox_test.ts b/mesop/components/checkbox/e2e/checkbox_test.ts new file mode 100644 index 000000000..04582ffc2 --- /dev/null +++ b/mesop/components/checkbox/e2e/checkbox_test.ts @@ -0,0 +1,13 @@ +import {test, expect} from '@playwright/test'; + +test('test', async ({page}) => { + await page.goto('/components/checkbox/e2e/checkbox_app'); + expect(await page.getByText('is not checked').textContent()).toContain( + 'is not checked', + ); + + await page.getByRole('checkbox').check(); + expect(await page.getByText('is checked').textContent()).toContain( + 'is checked', + ); +}); diff --git a/mesop/testing/BUILD b/mesop/testing/BUILD index fb6986839..456d2200a 100644 --- a/mesop/testing/BUILD +++ b/mesop/testing/BUILD @@ -12,6 +12,7 @@ py_library( "//mesop/components/markdown/e2e", "//mesop/components/text_input/e2e", "//mesop/components/box/e2e", + "//mesop/components/checkbox/e2e", "//mesop/components/text/e2e", "//mesop/examples", ], diff --git a/mesop/testing/index.py b/mesop/testing/index.py index e24464b78..6c829259e 100644 --- a/mesop/testing/index.py +++ b/mesop/testing/index.py @@ -1,6 +1,7 @@ from mesop.examples import index as index import mesop.components.text.e2e as text_e2e import mesop.components.box.e2e as box_e2e +import mesop.components.checkbox.e2e as checkbox_e2e import mesop.components.text_input.e2e as text_input_e2e import mesop.components.markdown.e2e as markdown_e2e # REF(//scripts/gen_component.py):insert_component_e2e_import_export