mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
Fix flakiness in create-daml-app tests (#9165)
* Fix flakiness in create-daml-app tests waitForSelector doesn’t do the trick here since one selector is enough to make this return. We need to wait until we actually have the expected number. This is what waitForFollowers already did. changelog_begin changelog_end * maybe I should test my code but also I don’t want to changelog_begin changelog_end * fine I tested it changelog_begin changelog_end
This commit is contained in:
parent
17f8bcd37d
commit
493e2154fd
@ -216,6 +216,15 @@ const newUiPage = async (): Promise<Page> => {
|
||||
return page;
|
||||
};
|
||||
|
||||
const waitForNSelector = async (page: Page, selector: string, n: number) => {
|
||||
await page.waitForFunction(
|
||||
(n, selector) => document.querySelectorAll(selector).length == n,
|
||||
{},
|
||||
n,
|
||||
selector
|
||||
);
|
||||
}
|
||||
|
||||
// Note that Follow is a consuming choice on a contract
|
||||
// with a contract key so it is crucial to wait between follows.
|
||||
// Otherwise, you get errors due to contention.
|
||||
@ -223,11 +232,7 @@ const newUiPage = async (): Promise<Page> => {
|
||||
// but that is not the underlying error (the JSON API will
|
||||
// output the contention errors as well so look through the log).
|
||||
const waitForFollowers = async (page: Page, n: number) => {
|
||||
await page.waitForFunction(
|
||||
(n) => document.querySelectorAll(".test-select-following").length == n,
|
||||
{},
|
||||
n
|
||||
);
|
||||
await waitForNSelector(page, ".test-select-following", n);
|
||||
}
|
||||
|
||||
// LOGIN_FUNCTION_BEGIN
|
||||
@ -391,7 +396,8 @@ test("log in as three different users and start following each other", async ()
|
||||
expect(noFollowing3).toEqual([]);
|
||||
|
||||
// However, Party 3 should see both Party 1 and Party 2 in the network.
|
||||
await page3.waitForSelector(".test-select-user-in-network");
|
||||
await waitForNSelector(page3, ".test-select-user-in-network", 2);
|
||||
|
||||
const network3 = await page3.$$eval(
|
||||
".test-select-user-in-network",
|
||||
(following) => following.map((e) => e.innerHTML)
|
||||
|
Loading…
Reference in New Issue
Block a user