-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e8a01d
commit cd27e50
Showing
4 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Turbo</title> | ||
<script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script> | ||
<script src="/src/tests/fixtures/test.js"></script> | ||
<script type="module"> | ||
addEventListener('turbo:before-fetch-request', function(event) { | ||
event.preventDefault() | ||
if (confirm('Continue request?')) { | ||
event.detail.resume() | ||
} else { | ||
alert('Request aborted') | ||
} | ||
}) | ||
</script> | ||
</head> | ||
<body> | ||
<section> | ||
<h1>Pausable Requests</h1> | ||
<p><a id="link" href="/src/tests/fixtures/one.html">Link</a></p> | ||
</section> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { TurboDriveTestCase } from "../helpers/turbo_drive_test_case" | ||
|
||
export class PausableRequestsTests extends TurboDriveTestCase { | ||
async setup() { | ||
await this.goToLocation("/src/tests/fixtures/pausable_requests.html") | ||
} | ||
|
||
async "test pauses and resumes request"() { | ||
await this.clickSelector("#link") | ||
|
||
await this.nextBeat | ||
this.assert.strictEqual(await this.getAlertText(), 'Continue request?') | ||
await this.acceptAlert() | ||
|
||
const h1 = await this.querySelector("h1") | ||
this.assert.equal(await h1.getVisibleText(), "One") | ||
} | ||
|
||
async "test aborts request"() { | ||
await this.clickSelector("#link") | ||
|
||
await this.nextBeat | ||
this.assert.strictEqual(await this.getAlertText(), 'Continue request?') | ||
await this.dismissAlert() | ||
|
||
await this.nextBeat | ||
this.assert.strictEqual(await this.getAlertText(), 'Request aborted') | ||
await this.acceptAlert() | ||
|
||
const h1 = await this.querySelector("h1") | ||
this.assert.equal(await h1.getVisibleText(), "Pausable Requests") | ||
} | ||
} | ||
|
||
PausableRequestsTests.registerSuite() |