Skip to content

Commit

Permalink
Fix functional tests (#106)
Browse files Browse the repository at this point in the history
* chore: update chromedriver to v118

* fix: refactor tests to await the promise to fix failing tests

* docs: changelog entry
  • Loading branch information
oscarleonnogales authored Oct 31, 2023
1 parent cd3a466 commit c21ce7b
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 29 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Dev Dependency Updates
- Update to TypeScript 5
- Update Chromedriver to 118

# 5.2.1

Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@wdio/sync": "^7.25.2",
"async": "^3.2.4",
"browserify": "^17.0.0",
"chromedriver": "^114.0.2",
"chromedriver": "^118.0.1",
"del": "^6.0.0",
"ejs": "^3.1.8",
"eslint": "^8.35.0",
Expand Down
40 changes: 24 additions & 16 deletions spec/functional/popup-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ describe("Popup Events", () => {
timeout: 1000,
}
);
const actual = $("p").getText();

expect($$("p").length).toBe(1);
expect(actual).toBe(expected);
$("p")
.getText()
.then((actual) => {
expect($$("p").length).toBe(1);
expect(actual).toBe(expected);
});
});

it("should be able to send events to opener frames", () => {
Expand Down Expand Up @@ -71,10 +73,12 @@ describe("Popup Events", () => {
timeout: 1000,
}
);
const actual = $("p").getText();

expect($$("p").length).toBe(1);
expect(actual).toContain(expected);
$("p")
.getText()
.then((actual) => {
expect($$("p").length).toBe(1);
expect(actual).toContain(expected);
});
});

it("should not double-receive events in popups", () => {
Expand Down Expand Up @@ -107,10 +111,12 @@ describe("Popup Events", () => {
timeout: 1000,
}
);
const actual = $("p").getText();

expect($$("p").length).toBe(1);
expect(actual).not.toContain("FAILURE");
$("p")
.getText()
.then((actual) => {
expect($$("p").length).toBe(1);
expect(actual).not.toContain("FAILURE");
});
});

it("should be able to receive messages from opener window", () => {
Expand Down Expand Up @@ -141,9 +147,11 @@ describe("Popup Events", () => {
timeout: 1000,
}
);
const actual = $("p").getText();

expect($$("p").length).toBe(1);
expect(actual).not.toContain("FAILURE");
$("p")
.getText()
.then((actual) => {
expect($$("p").length).toBe(1);
expect(actual).not.toContain("FAILURE");
});
});
});
15 changes: 11 additions & 4 deletions spec/functional/reply-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,16 @@ describe("Reply Events", () => {
browser.switchToFrame(2);
const frame3ReceivedQuestion = $("p").getText();

expect(indexReceived).toBe(0);
expect(frame1Received).toBe(0);
expect(frame2Received).toBe(0);
expect(frame3ReceivedQuestion).toBe("are you there?");
Promise.all([
indexReceived,
frame1Received,
frame2Received,
frame3ReceivedQuestion,
]).then(() => {
expect(indexReceived).toBe(0);
expect(frame1Received).toBe(0);
expect(frame2Received).toBe(0);
expect(frame3ReceivedQuestion).toBe("are you there?");
});
});
});
18 changes: 13 additions & 5 deletions spec/functional/target-frames.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,18 @@ describe("targetFrames Events", () => {
browser.switchToFrame(2);
const frame3ReceivedQuestion = $$("p").length;

expect(indexReceived).toBe(1);
expect(innerframe1Received).toBe(0);
expect(frame1Received).toBe(0);
expect(frame2Received).toBe(0);
expect(frame3ReceivedQuestion).toBe(0);
Promise.all([
indexReceived,
innerframe1Received,
frame1Received,
frame2Received,
frame3ReceivedQuestion,
]).then(() => {
expect(indexReceived).toBe(1);
expect(innerframe1Received).toBe(0);
expect(frame1Received).toBe(0);
expect(frame2Received).toBe(0);
expect(frame3ReceivedQuestion).toBe(0);
});
});
});

0 comments on commit c21ce7b

Please sign in to comment.