Skip to content

Commit 68868e6

Browse files
committed
Fix more tests
1 parent fe147bf commit 68868e6

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

end-to-end/attempt-silent-login.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ describe('attempt silent login', async () => {
9797
});
9898
}
9999

100-
const loggedOutCookies = await context.cookies(baseUrl);
100+
const loggedOutCookies = await context.cookies();
101101
assert.isNotOk(loggedOutCookies.find(({ name }) => name === 'appSession'));
102102

103103
await goto(baseUrl, page);

end-to-end/backchannel-logout.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ describe('back-channel logout', async () => {
3737
.concat(['--no-sandbox', '--disable-setuid-sandbox']),
3838
});
3939
const page = await browser.newPage();
40+
const context = page.browserContext();
4041
await goto(baseUrl, page);
4142
assert.match(page.url(), /http:\/\/localhost:300/);
4243
await Promise.all([page.click('a'), page.waitForNavigation()]);
@@ -67,8 +68,9 @@ describe('back-channel logout', async () => {
6768
assert.equal(res.statusCode, 204);
6869

6970
await goto(baseUrl, page);
70-
const loggedOutCookies = await page.cookies('http://localhost:3000');
71-
assert.notOk(loggedOutCookies.find(({ name }) => name === 'appSession'));
71+
72+
const loggedOutCookies = await context.cookies();
73+
assert.isNotOk(loggedOutCookies.find(({ name }) => name === 'appSession'));
7274
};
7375

7476
it('should logout via back-channel logout', () =>

end-to-end/basic.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ describe('basic login and logout', async () => {
3535
.concat(['--no-sandbox', '--disable-setuid-sandbox']),
3636
});
3737
const page = await browser.newPage();
38+
const context = page.browserContext();
39+
3840
await goto(baseUrl, page);
3941
assert.match(
4042
page.url(),
@@ -64,7 +66,7 @@ describe('basic login and logout', async () => {
6466
* verify their content since they're encrypted, so at least let's check it's
6567
* small enough that a token can't possibly fit inside.
6668
*/
67-
const loggedOutCookies = await page.cookies('http://localhost:3000');
69+
const loggedOutCookies = await context.cookies();
6870
assert.isTrue(loggedOutCookies.find(({ name }) => name === 'appSession').size < 200);
6971
});
7072
});

test/tokenSetUtils.tests.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,26 @@ function newReq(props = {}) {
1717

1818
describe('TokenSetUtils', () => {
1919
describe('areScopesCompatible()', () => {
20-
it('returns true when scopes are enough plus some extra', () => {
21-
assert.isTrue(
22-
TokenSetUtils.areScopesCompatible({ scope: 'a b' }, { scope: 'b c a' }),
23-
);
24-
});
25-
26-
it('returns false when scopes are not enough', () => {
27-
assert.isFalse(
28-
TokenSetUtils.areScopesCompatible({ scope: 'a b' }, { scope: 'b' }),
29-
);
30-
});
20+
/** @type {[string | undefined, string | undefined, boolean][]} */
21+
const testCases = [
22+
['a b', 'b c a', true],
23+
['a b', 'b', false],
24+
['foo', undefined, true],
25+
[undefined, undefined, true],
26+
];
3127

32-
it('falls back to default SDK scope when no scope is requested', () => {
33-
assert.isTrue(
34-
TokenSetUtils.areScopesCompatible(
35-
{},
36-
{ scope: 'openid profile email' },
37-
),
38-
);
39-
});
28+
testCases.forEach((testCase) => {
29+
const [requested, available, expected] = testCase;
4030

41-
it('returns false when no scope is available', () => {
42-
assert.isFalse(TokenSetUtils.areScopesCompatible({ scope: 'a b' }, {}));
31+
it(`returns ${expected} for (${requested}, ${available})`, () => {
32+
assert.strictEqual(
33+
expected,
34+
TokenSetUtils.areScopesCompatible(
35+
{ scope: requested },
36+
{ scope: available },
37+
),
38+
);
39+
});
4340
});
4441
});
4542

0 commit comments

Comments
 (0)