-
Notifications
You must be signed in to change notification settings - Fork 659
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
should restore cookie correctly when using useRole with the preserveU…
…rl option (closes #2282) (#2285) * should restore cookie correctly when using useRole with the preserveUrl option (closes #2282) * changes after request
- Loading branch information
1 parent
87ff50b
commit f773c21
Showing
8 changed files
with
91 additions
and
17 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
describe('[Regression](GH-2282)', function () { | ||
it('Cookies should be restored correctly when User Roles with the preserveUrl option are used', function () { | ||
return runTests('testcafe-fixtures/index.js'); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
test/functional/fixtures/regression/gh-2282/pages/authorized.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,27 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
<script type="text/javascript"> | ||
window.onload = function () { | ||
if (!document.cookie || document.cookie === 'auth=false') | ||
location.href = './login.html'; | ||
else { | ||
var result = document.getElementById('result'); | ||
|
||
result.innerHTML = 'logged' | ||
} | ||
} | ||
|
||
function logout () { | ||
document.cookie = 'auth=false'; | ||
location.href = './login.html'; | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<div id="result">no access</div> | ||
<div style="border: 1px solid black; width: 200px;" onclick="logout()">Reset cookie</div> | ||
</body> | ||
</html> |
21 changes: 21 additions & 0 deletions
21
test/functional/fixtures/regression/gh-2282/pages/login.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,21 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
<script type="text/javascript"> | ||
function login () { | ||
document.cookie = 'auth=true'; | ||
location.href = './authorized.html'; | ||
} | ||
|
||
window.onload = function () { | ||
if (document.cookie === 'auth=true') | ||
location.href = './authorized.html'; | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<div id="login" style="border: 1px solid black; width: 200px;" onclick="login()">Click me to log in</div> | ||
</body> | ||
</html> |
21 changes: 21 additions & 0 deletions
21
test/functional/fixtures/regression/gh-2282/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Selector, Role } from 'testcafe'; | ||
|
||
const role = Role('http://localhost:3000/fixtures/regression/gh-2282/pages/login.html', async t => { | ||
await t.click(Selector('#login')); | ||
}, { preserveUrl: true }); | ||
|
||
|
||
fixture `GH-2282 - Cookies should be restored correctly when User Roles with the preserveUrl option are used` | ||
.beforeEach(async t => { | ||
await t.useRole(role); | ||
}); | ||
|
||
test('Login and save cookies in the role', async t => { | ||
await t.expect(Selector('#result').textContent).contains('logged'); | ||
}); | ||
|
||
test('Restore cookies from the role', async t => { | ||
await t.expect(Selector('#result').textContent).contains('logged'); | ||
}); | ||
|
||
|
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