Compare commits

..

1 Commits

Author SHA1 Message Date
Simon Genin (ges) 5efc9ad462 [FIX] remove indeterminism in animation tests
Animations have quite a few intricate calls to request next animation
frames. On quick devices, the helper method nextFrame made of 2
request of animation frames would not be enough and race condition
problems would rise.

The fix is simply to ask the nextFrame helper to do a third request
of animation frame in the animation tests, making the test deterministic
on a very fast device. Hopefully, this should be enough.
2021-10-04 11:21:55 +02:00
5 changed files with 12 additions and 54 deletions
+1 -3
View File
@@ -31,6 +31,4 @@ release-notes.md
.rpt2_cache
# useful in some cases
/temp
coverage
/temp
+1 -3
View File
@@ -76,9 +76,7 @@
"jsx",
"json",
"node"
],
"collectCoverage": true,
"coverageReporters": ["html"]
]
},
"prettier": {
"printWidth": 100,
+5 -5
View File
@@ -420,29 +420,29 @@ describe("animations", () => {
widget.state.flag = true;
await nextFrame();
await nextFrame(3);
widget.el!.querySelector("span")!.dispatchEvent(new Event("transitionend"));
expect(fixture.innerHTML).toBe('<div><span class="">blue</span></div>');
expect(QWeb.utils.transitionInsert).toBeCalledTimes(1);
widget.state.flag = false;
await nextFrame();
await nextFrame(3);
expect(fixture.innerHTML).toBe(
'<div><span class="chimay-leave-active chimay-leave-to" data-owl-key="__3__">blue</span></div>'
);
expect(QWeb.utils.transitionInsert).toBeCalledTimes(1);
widget.state.flag = true;
await nextFrame();
await nextFrame(3);
expect(fixture.innerHTML).toBe(
'<div><span class="chimay-enter-active chimay-enter-to" data-owl-key="__3__">blue</span></div>'
);
expect(QWeb.utils.transitionInsert).toBeCalledTimes(2);
widget.state.flag = false;
await nextFrame();
await nextFrame(3);
widget.state.flag = true;
await nextFrame();
await nextFrame(3);
expect(QWeb.utils.transitionInsert).toBeCalledTimes(3);
widget.el!.querySelector("span")!.dispatchEvent(new Event("transitionend"));
+4 -3
View File
@@ -41,9 +41,10 @@ export async function nextTick(): Promise<void> {
await new Promise((resolve) => scheduler.requestAnimationFrame(resolve));
}
export async function nextFrame(): Promise<void> {
await new Promise((resolve) => scheduler.requestAnimationFrame(resolve));
await new Promise((resolve) => scheduler.requestAnimationFrame(resolve));
export async function nextFrame(numberOfAnimationFrames: number = 2): Promise<void> {
for (let i = 0; i < numberOfAnimationFrames; i++) {
await new Promise((resolve) => scheduler.requestAnimationFrame(resolve));
}
}
export function makeTestFixture() {
+1 -40
View File
@@ -62,9 +62,6 @@ async function startRelease() {
}
let shouldUploadPlayground = await ask(`Should this release be uploaded on the playground [y/n] ? (y)`);
shouldUploadPlayground = shouldUploadPlayground.toLowerCase() !== 'n';
let shouldUploadPCoverageReport = await ask(`Should this release coverage report be published [y/n] ? (y)`);
shouldUploadPCoverageReport = shouldUploadPCoverageReport.toLowerCase() !== 'n';
// ---------------------------------------------------------------------------
log(`Step 2/${STEPS}: running tests...`);
@@ -125,7 +122,7 @@ async function startRelease() {
if (shouldUploadPlayground) {
log(`Bonus step: publishing new release on playground...`);
let owl_code = null;
let status = 0
status = 0
try {
owl_code = await readFile("dist/owl.iife.js");
@@ -156,42 +153,6 @@ async function startRelease() {
logError("Something went wrong for the playground update.")
}
}
if (shouldUploadPCoverageReport) {
let status = 0
log(`Bonus step: publishing new coverage report...`);
if (!fs.existsSync("./coverage")) {
logError("Couldn't update coverage report, there is no coverage folder on master.")
return;
}
status += await execCommand("git stash push -a -- coverage");
if (status !== 0) {
logError("Couldn't stash coverage")
return;
}
status += await execCommand("git checkout gh-pages");
if (status !== 0) {
logError("Couldn't switch to gh-pages branch")
return;
}
status += await execCommand("rm -rf coverage");
status += await execCommand("git stash pop");
status += await execCommand("git add coverage");
status += await execCommand(`git commit -m "[IMP] update coverage report for owl v${next}"`);
status += await execCommand(`git push origin gh-pages`);
status += await execCommand("git checkout -");
if (status !== 0) {
logError("Something went wrong for the coverage report update.")
}
}
}
// -----------------------------------------------------------------------------