Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix waitForSelector calls in create-daml-app-tests #6253

Merged
merged 1 commit into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
);
Comment on lines +310 to +312
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this make the length check below redundant?

   expect(followingList11).toHaveLength(2);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of but it seemed reasonable to keep the assertion separate from the check for how long we wait. Otherwise this is easy to get lost during refactoring.

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
);
Comment on lines +271 to +273
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waitForSelector returns immediately if the selector is already present (which is documented). ...

page2 is a separate result of newUiPage than page1. Do I understand correctly that the presence of .test-select-following on page1 influences the query on page2? How is that happening?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not following, we waited on page2 before, we wait on page2 now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, nevermind, I misread the description of the issue.

const followingList2 = await page2.$$eval('.test-select-following', following => following.map(e => e.innerHTML));
expect(followingList2).toHaveLength(2);
expect(followingList2).toContain(party1);
Expand Down