Skip to content

Commit ca7bac8

Browse files
committed
Explain a denied GitHub device sign-in
Closes #1037
1 parent 20d09a9 commit ca7bac8

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎src/settings-onboarding-page.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import test from 'node:test';
2+
import assert from 'node:assert/strict';
3+
import {runInNewContext} from 'node:vm';
4+
import {SERVICE_SCRIPT} from '../src/settings-onboarding-page.js';
5+
test('GitHub device-flow denial explains that the user can start again',async()=>{
6+
const nodes=new Map();const get=id=>{if(!nodes.has(id))nodes.set(id,{value:'https://cards.example',hidden:true,addEventListener(k,fn){this[k]=fn},replaceChildren(){}});return nodes.get(id)};
7+
const say=(id,text)=>get(id).textContent=text;
8+
const start=SERVICE_SCRIPT.indexOf('async function pollHosted(');const end=SERVICE_SCRIPT.lastIndexOf('load();');
9+
const context={$:get,say,hostedFlow:true,hostedGeneration:1,api:async()=>({status:'denied'}),load(){throw Error('should not load after denial')}};
10+
runInNewContext(SERVICE_SCRIPT.slice(start,end),context);await context.pollHosted(1);
11+
assert.equal(get('hosted-service-result').textContent,'GitHub sign-in failed: Sign-in was not approved. Click Sign in with GitHub to try again.');
12+
assert.equal(context.hostedFlow,false);
13+
});

0 commit comments

Comments
 (0)