Skip to content

Commit

Permalink
Attempt to fix flaky Scroll Restoration test
Browse files Browse the repository at this point in the history
There is a common test failure in CI:

```
× firefox on linux 5.11.0-1020-azure - ScrollRestorationTests - landing on an anchor (0.02s)
444
    TypeError: Cannot read property 'slice' of null
445
      at RemoteChannel.read @ src/tests/helpers/remote_channel.ts:14:44
```

This commit addresses it in two ways. First, ensures that the
`scroll_restoration.html` page loads the
`src/tests/fixtures/test.js` script to wire-up the remote channels (like
`window.eventLogs` and `window.mutationLogs`).

Next, it modifies the test itself to await the `this.nextBody` hook, to
ensure that the page load completes before checking the scroll.
  • Loading branch information
seanpdoyle committed Nov 20, 2021
1 parent 5529aab commit 10d7d67
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/tests/fixtures/scroll_restoration.html
Expand Up @@ -4,6 +4,7 @@
<meta charset="utf-8">
<title>Scroll Restoration</title>
<script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script>
<script src="/src/tests/fixtures/test.js"></script>
<style>
li {
min-height: 50vh;
Expand Down
3 changes: 1 addition & 2 deletions src/tests/functional/scroll_restoration_tests.ts
Expand Up @@ -3,9 +3,8 @@ import { TurboDriveTestCase } from "../helpers/turbo_drive_test_case"
export class ScrollRestorationTests extends TurboDriveTestCase {
async "test landing on an anchor"() {
await this.goToLocation("/src/tests/fixtures/scroll_restoration.html#three")
await this.nextBeat
await this.nextBody
const { y: yAfterLoading } = await this.scrollPosition
await this.nextBeat
this.assert.notEqual(yAfterLoading, 0)
}

Expand Down

0 comments on commit 10d7d67

Please sign in to comment.