Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add retry for slot test
Browse files Browse the repository at this point in the history
wwwillchen committed Jul 13, 2024
1 parent 4fc2b15 commit 20ed97b
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions mesop/tests/e2e/web_components/slot_test.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
import {test, expect, Page} from '@playwright/test';

test('web components - slot', async ({page}) => {
await page.goto('http://localhost:32123/web_component/slot/slot_app');
// Make sure the page has loaded:
expect(page.getByRole('button', {name: 'Decrement'})).toBeVisible();
test.describe(() => {
// All tests in this describe group will get 2 retry attempts.
test.describe.configure({retries: 2});
test('web components - slot', async ({page}) => {
await page.goto('http://localhost:32123/web_component/slot/slot_app');
// Make sure the page has loaded:
expect(page.getByRole('button', {name: 'Decrement'})).toBeVisible();

assertValue(10);
await page.getByRole('button', {name: 'increment'}).click();
assertValue(11);
await page.getByRole('button', {name: 'increment'}).click();
assertValue(12);
await page.getByRole('button', {name: 'Decrement'}).click();
assertValue(11);
await page.getByRole('button', {name: 'Decrement'}).click();
assertValue(10);
assertValue(10);
await page.getByRole('button', {name: 'increment'}).click();
assertValue(11);
await page.getByRole('button', {name: 'increment'}).click();
assertValue(12);
await page.getByRole('button', {name: 'Decrement'}).click();
assertValue(11);
await page.getByRole('button', {name: 'Decrement'}).click();
assertValue(10);

async function assertValue(value: number) {
// Check that the outer component is displaying the right value.
expect(
await page
.locator('div')
.filter({hasText: `Value: ${value} increment Start of`})
.textContent(),
).toContain(value.toString());
async function assertValue(value: number) {
// Check that the outer component is displaying the right value.
expect(
await page
.locator('div')
.filter({hasText: `Value: ${value} increment Start of`})
.textContent(),
).toContain(value.toString());

// Check that the inner component is displaying the right value.
expect(
await page
.locator('slot-counter-component')
.getByText('Value:')
.textContent(),
).toContain(value.toString());
}
// Check that the inner component is displaying the right value.
expect(
await page
.locator('slot-counter-component')
.getByText('Value:')
.textContent(),
).toContain(value.toString());
}
});
});

0 comments on commit 20ed97b

Please sign in to comment.