-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
778e18b
commit 9659e48
Showing
11 changed files
with
234 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {test, expect} from '@playwright/test'; | ||
const sandbox = 'iframe'; | ||
const example = 'react'; | ||
|
||
test.use({baseURL: 'http://localhost:8081'}); | ||
|
||
test(`basic modal interaction remote-ui legacy rendered example`, async ({ | ||
page, | ||
}) => { | ||
await page.goto(`/`); | ||
|
||
await page.getByRole('button', {name: 'Open modal'}).click(); | ||
await page.getByRole('button', {name: 'Click me!'}).click(); | ||
await page.getByRole('button', {name: 'Click me!'}).click(); | ||
|
||
await expect(page.getByText('Click Count: 2')).toBeVisible(); | ||
|
||
page.once('dialog', (dialog) => { | ||
expect(dialog.message()).toBe('You clicked 2 times!'); | ||
dialog.accept().catch(() => {}); | ||
}); | ||
|
||
const dialogPromise = page.waitForEvent('dialog'); | ||
|
||
await page.getByRole('button', {name: 'Close'}).click(); | ||
await dialogPromise; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,60 @@ | ||
/** @jsxRuntime automatic */ | ||
/** @jsxImportSource react */ | ||
|
||
import {useEffect, useState} from 'react'; | ||
import {useState} from 'react'; | ||
import {Button, Modal, Stack, Text} from './components'; | ||
|
||
export function App() { | ||
const [counter, setCounter] = useState(0); | ||
export function App({api}: {api: any}) { | ||
const [showModal, setShowModal] = useState(false); | ||
const [count, setCount] = useState(0); | ||
|
||
useEffect(() => { | ||
const timer = setTimeout(() => { | ||
setCounter(counter + 1); | ||
}, 1000); | ||
|
||
return () => clearTimeout(timer); | ||
}, [counter]); | ||
function removeModal() { | ||
setShowModal(false); | ||
} | ||
|
||
return ( | ||
<Stack> | ||
<Button | ||
onPress={() => setCounter(counter + 1)} | ||
modal={counter === 0 ? <Modal>Hello</Modal> : undefined} | ||
> | ||
Update counter | ||
</Button> | ||
<Text>Counter: {counter}</Text> | ||
<Stack spacing> | ||
<> | ||
<Text> | ||
Rendering example: <Text emphasis>remote-ui legacy</Text> | ||
</Text> | ||
<Button | ||
onPress={() => setShowModal(true)} | ||
modal={ | ||
showModal ? ( | ||
<Modal | ||
primaryAction={ | ||
<Button | ||
onPress={() => { | ||
removeModal(); | ||
if (count > 0) { | ||
alert(`You clicked ${count} times!`); | ||
} | ||
}} | ||
> | ||
Close | ||
</Button> | ||
} | ||
> | ||
<Stack spacing> | ||
<Text> | ||
Click count: <Text emphasis>{count}</Text> | ||
</Text> | ||
<Button | ||
onPress={() => { | ||
setCount((count) => count + 1); | ||
}} | ||
> | ||
Click me! | ||
</Button> | ||
</Stack> | ||
</Modal> | ||
) : undefined | ||
} | ||
> | ||
Open modal | ||
</Button> | ||
</> | ||
</Stack> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.