Skip to content

Commit a795a41

Browse files
authored
Add e2e tests (#163)
1 parent 4282b99 commit a795a41

File tree

7 files changed

+44
-8
lines changed

7 files changed

+44
-8
lines changed
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import {test} from '@playwright/test';
1+
import {test, expect} from '@playwright/test';
22

3-
test('test', async ({page}) => {
3+
test('test input interactivity works', async ({page}) => {
44
await page.goto('/components/input/e2e/input_app');
5-
// TODO: write test.
6-
// expect(await page.getByText('Hello, world!').textContent()).toContain(
7-
// 'Hello, world!',
8-
// );
5+
await page.getByLabel('Basic input').fill('hi');
6+
expect(await page.getByText('hi').textContent()).toEqual('hi');
97
});

mesop/examples/generator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ def generate_str():
77
yield "foo"
88
sleep(1)
99
yield "bar"
10+
sleep(10)
11+
yield "waited10seconds"
1012

1113

1214
@me.stateclass

mesop/examples/playground.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def header():
3636
)
3737
):
3838
me.text(
39-
"Playground",
39+
"Playground Page",
4040
type="headline-5",
4141
style=me.Style(margin=me.Margin(top=0, right=0, bottom=0, left=0)),
4242
)

mesop/tests/e2e/buttons_test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {test, expect} from '@playwright/test';
2+
3+
test('buttons', async ({page}) => {
4+
await page.goto('/buttons');
5+
expect(await page.getByText('0 clicks').textContent()).toEqual('0 clicks');
6+
await page.getByRole('button', {name: 'primary color button'}).click();
7+
expect(await page.getByText('1 clicks').textContent()).toEqual('1 clicks');
8+
});

mesop/tests/e2e/conditional_event_handler_test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {test, expect} from '@playwright/test';
22

33
test('test conditional event handler', async ({page}) => {
44
await page.goto('/testing/conditional_event_handler');
5-
await page.goto('http://localhost:32123/testing/conditional_event_handler');
65
await page.getByLabel('first checkbox').check();
76
await page.getByLabel('second checkbox').check();
87
expect(

mesop/tests/e2e/generator_test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {test, expect} from '@playwright/test';
2+
3+
test('generator', async ({page}) => {
4+
await page.goto('/generator');
5+
await page.getByRole('button', {name: 'click'}).click();
6+
// Asserting that some of the text has been yielded.
7+
// We don't assert the first chunk "foo" to avoid a race condition.
8+
// The last chunk is delayed by 10 seconds so the chance of a race
9+
// condition should be low.
10+
expect(await page.getByText('foobar').textContent()).toEqual('foobar');
11+
});

mesop/tests/e2e/navigation_test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {test, expect} from '@playwright/test';
2+
3+
test('navigation', async ({page}) => {
4+
await page.goto('/');
5+
6+
// Check the text that we're on the home page.
7+
expect(
8+
await page.getByRole('heading', {name: 'Welcome'}).textContent(),
9+
).toEqual('Welcome');
10+
11+
// Trigger a navigation by clicking on the nav menu button.
12+
await page.getByRole('button', {name: 'Playground', exact: true}).click();
13+
14+
// Check the text has changed which means navigation succeeded.
15+
expect(await page.getByText('Playground Page').textContent()).toEqual(
16+
'Playground Page',
17+
);
18+
});

0 commit comments

Comments
 (0)