Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/settings-onboarding-page.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions test/settings-hosted-denied-feedback.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {runInNewContext} from 'node:vm';
import {SERVICE_SCRIPT} from '../src/settings-onboarding-page.js';
test('GitHub device-flow denial explains that the user can start again',async()=>{
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)};
const say=(id,text)=>get(id).textContent=text;
const start=SERVICE_SCRIPT.indexOf('async function pollHosted(');const end=SERVICE_SCRIPT.lastIndexOf('load();');
const context={$:get,say,hostedFlow:true,hostedGeneration:1,api:async()=>({status:'denied'}),load(){throw Error('should not load after denial')}};
runInNewContext(SERVICE_SCRIPT.slice(start,end),context);await context.pollHosted(1);
assert.equal(get('hosted-service-result').textContent,'GitHub sign-in failed: Sign-in was not approved. Click Sign in with GitHub to try again.');
assert.equal(context.hostedFlow,false);
});
Loading