Skip to content

Commit

Permalink
Fix waitForSelector calls in create-daml-app-tests (digital-asset#6253)
Browse files Browse the repository at this point in the history
`waitForSelector` returns immediately if the selector is already
present (which is documented). This means that the waitForSelector
after the second follow isn’t doing anything since we already waited
for after the first follow. `waitForFunction` seemed like the simplest
solution and doesn’t require patching the HTML which is a bit finnicky
in the compat tests.

changelog_begin
changelog_end
  • Loading branch information
cocreature authored Jun 8, 2020
1 parent fd52fb2 commit 5feab1b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions compatibility/bazel_tools/create-daml-app/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ test("log in as three different users and start following each other", async ()

// Add Party 3 as well and check both are in the list.
await follow(page1, party3);
await page1.waitForSelector(".test-select-following");
await page1.waitForFunction(
() => document.querySelectorAll(".test-select-following").length == 2
);
const followingList11 = await page1.$$eval(
".test-select-following",
(following) => following.map((e) => e.innerHTML)
Expand Down Expand Up @@ -344,7 +346,9 @@ test("log in as three different users and start following each other", async ()
await follow(page2, party3);

// Check the following list is updated correctly.
await page2.waitForSelector(".test-select-following");
await page2.waitForFunction(
() => document.querySelectorAll(".test-select-following").length == 2
);
const followingList2 = await page2.$$eval(
".test-select-following",
(following) => following.map((e) => e.innerHTML)
Expand Down
8 changes: 6 additions & 2 deletions templates/create-daml-app-test-resources/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ test('log in as three different users and start following each other', async ()

// Add Party 3 as well and check both are in the list.
await follow(page1, party3);
await page1.waitForSelector('.test-select-following');
await page1.waitForFunction(
() => document.querySelectorAll(".test-select-following").length == 2
);
const followingList11 = await page1.$$eval('.test-select-following', following => following.map(e => e.innerHTML));
expect(followingList11).toHaveLength(2);
expect(followingList11).toContain(party2);
Expand Down Expand Up @@ -266,7 +268,9 @@ test('log in as three different users and start following each other', async ()
await follow(page2, party3);

// Check the following list is updated correctly.
await page2.waitForSelector('.test-select-following');
await page2.waitForFunction(
() => document.querySelectorAll(".test-select-following").length == 2
);
const followingList2 = await page2.$$eval('.test-select-following', following => following.map(e => e.innerHTML));
expect(followingList2).toHaveLength(2);
expect(followingList2).toContain(party1);
Expand Down

0 comments on commit 5feab1b

Please sign in to comment.