-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: return promise from field mount fn (#1162)
* feat: return promise from field mount fn * docs: update specs * refactor: simplify logic
- Loading branch information
Showing
10 changed files
with
501 additions
and
58 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<script src="/apis/stardust/dist/stardust.dev.js"></script> | ||
<script src="/apis/enigma-mocker/dist/enigma-mocker.dev.js"></script> | ||
<script src="scenarios.js"></script> | ||
|
||
<style> | ||
html, | ||
body { | ||
margin: 20px; | ||
padding: 0; | ||
background-color: #fafafa; | ||
} | ||
|
||
.wrapper { | ||
display: flex; | ||
} | ||
|
||
.listbox1 { | ||
flex: 0 0 600px; | ||
position: relative; | ||
width: 600px; | ||
height: 400px; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05); | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="wrapper"> | ||
<div class="listbox1"></div> | ||
</div> | ||
<div id="flow-tracker"></div> | ||
</body> | ||
</html> |
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,35 @@ | ||
describe('listbox', () => { | ||
const awaitText = async (selector, text, options = { timeout: 10000 }) => { | ||
await page.waitForSelector(selector, { visible: true }); | ||
await page.waitForFunction( | ||
(s, t) => document.querySelector(s) && document.querySelector(s).innerText.includes(t), | ||
options, | ||
`${selector}`, | ||
text | ||
); | ||
}; | ||
const listboxSelector = `.listbox-container`; | ||
|
||
function getScenarioUrl(scenario) { | ||
return `${process.env.BASE_URL}/listbox/listbox.html?scenario=${scenario}`; | ||
} | ||
|
||
it('should resolve mount promise after data is fetched', async () => { | ||
const url = getScenarioUrl('scenario1'); | ||
await page.goto(url); | ||
|
||
await page.waitForSelector(listboxSelector, { visible: true }); | ||
await page.waitForSelector('#flow-tracker', { visible: true }); | ||
await awaitText('#flow-tracker', 'mount promise resolved'); | ||
|
||
// eslint-disable-next-line no-promise-executor-return | ||
await new Promise((r) => setTimeout(r, 2000)); | ||
const innerText = await page.$eval('#flow-tracker', (el) => el.innerText); | ||
expect(innerText.includes('getLayout')).equal(true); | ||
expect(innerText.includes('getListObjectData')).equal(true); | ||
|
||
const actions = innerText.slice(0, -1).split(','); | ||
const lastAction = actions.pop(); | ||
expect(lastAction).equal('mount promise resolved'); | ||
}); | ||
}); |
Oops, something went wrong.