-
Notifications
You must be signed in to change notification settings - Fork 675
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Async predicate for request filter rules (#5937)
* Async predicate for request filter rules * fix cors issue
- Loading branch information
1 parent
b572936
commit 203c75d
Showing
12 changed files
with
103 additions
and
39 deletions.
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
22 changes: 22 additions & 0 deletions
22
...nal/fixtures/api/es-next/request-hooks/pages/api/request-filter-rule-async-predicate.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Async predicate for request filter rules</title> | ||
</head> | ||
<body> | ||
<h2>Send request status</h2> | ||
<button onclick="sendRequest()">Send request</button> | ||
<script> | ||
function sendRequest() { | ||
fetch('http://dummy-url.com/get') | ||
.then(res => { | ||
return res.text(); | ||
}) | ||
.then(text => { | ||
document.querySelector('h2').textContent = text; | ||
}); | ||
} | ||
</script> | ||
</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
23 changes: 23 additions & 0 deletions
23
...es/api/es-next/request-hooks/testcafe-fixtures/api/request-filter-rule-async-predicate.js
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,23 @@ | ||
import { RequestMock, Selector } from 'testcafe'; | ||
|
||
const getUrlPromise = new Promise(resolve => { | ||
setTimeout(() => { | ||
resolve('http://dummy-url.com/get'); | ||
}, 2000); | ||
}); | ||
|
||
const mock = RequestMock() | ||
.onRequestTo(async req => { | ||
return req.url === await getUrlPromise; | ||
}) | ||
.respond('Done!', 200, { 'access-control-allow-origin': '*' }); | ||
|
||
fixture `Fixture` | ||
.requestHooks(mock) | ||
.page('http://localhost:3000/fixtures/api/es-next/request-hooks/pages/api/request-filter-rule-async-predicate.html'); | ||
|
||
test('test', async t => { | ||
await t | ||
.click('button') | ||
.expect(Selector('h2').textContent).eql('Done!'); | ||
}); |
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
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
2 changes: 1 addition & 1 deletion
2
test/functional/fixtures/regression/gh-5239/testcafe-fixtures/index.js
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
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