Skip to content

Commit

Permalink
Add test for text_to_text
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwillchen committed Jun 25, 2024
1 parent e8b1bf3 commit 67ba405
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mesop/examples/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
from mesop.examples.testing import (
minimal_chat as minimal_chat,
)
from mesop.examples.testing import (
text_to_text as text_to_text,
)
17 changes: 17 additions & 0 deletions mesop/examples/testing/text_to_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import mesop as me
import mesop.labs as mel


@me.page(
path="/testing/text_to_text",
title="Text to Text Example",
)
def app():
mel.text_to_text(
echo,
title="Text to Text Example",
)


def echo(s: str):
return "Echo: " + s
19 changes: 19 additions & 0 deletions mesop/tests/e2e/text_to_text_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {test, expect} from '@playwright/test';

test('text to text', async ({page}) => {
await page.goto('/testing/text_to_text');
const inputLocator = page.locator('#mat-input-0');
await inputLocator.click();
await inputLocator.fill('fly');
// Need to wait for the input state to be saved before clicking.
await page.waitForTimeout(2000);
await page.getByRole('button', {name: 'Generate'}).click();
await expect(page.getByText('Echo: fly')).toBeVisible();

await inputLocator.click();
await inputLocator.fill('abc');
// Need to wait for the input state to be saved before clicking.
await page.waitForTimeout(2000);
await page.getByRole('button', {name: 'Generate'}).click();
await expect(page.getByText('Echo: abc')).toBeVisible();
});

0 comments on commit 67ba405

Please sign in to comment.