-
Notifications
You must be signed in to change notification settings - Fork 102
fix(auth): open a browser on Windows instead of a console window, and document the Windows install route #344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+75
−11
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
946da2d
fix(auth): open a browser on Windows instead of a console window
efenocchi b46d6de
test(auth): assert the delegation call, not the bare name
efenocchi 19122fd
docs(readme): document the curl and PowerShell install routes
efenocchi b1c288f
docs(readme): say when to pick the npm route, not who you are
efenocchi d4a640c
docs(readme): drop the PowerShell script-block form from Quick start
efenocchi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,41 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { readFileSync } from "node:fs"; | ||
| import { join } from "node:path"; | ||
| import { openCommandFor } from "../../src/dashboard/open.js"; | ||
|
|
||
| const AUTH_SRC = readFileSync( | ||
| join(import.meta.dirname, "../../src/commands/auth.ts"), | ||
| "utf-8", | ||
| ); | ||
|
|
||
| // The device-flow login opened a new console window instead of a browser on | ||
| // Windows, for a reason this repo had already found and written down in | ||
| // dashboard/open.ts: under cmd.exe, `start "<url>"` treats its first quoted | ||
| // argument as the WINDOW TITLE. auth.ts had its own copy of the open logic and | ||
| // never got the fix, so Windows users installed fine and then could not log in | ||
| // — a drop-off indistinguishable from someone walking away. | ||
| describe("device-flow login opens a browser on Windows", () => { | ||
| it("passes the empty title argument that makes the URL an argument", () => { | ||
| const { command, args } = openCommandFor("win32", "https://example.com/device?code=ABCD"); | ||
|
|
||
| expect(command).toBe("cmd"); | ||
| // The "" is the whole bug. Without it the URL becomes the window title. | ||
| expect(args).toEqual(["/c", "start", "", "https://example.com/device?code=ABCD"]); | ||
| expect(args[2]).toBe(""); | ||
| }); | ||
|
|
||
| // A unit test of openCommandFor cannot catch auth.ts keeping a second, | ||
| // divergent implementation — which is exactly how this shipped. Assert the | ||
| // caller actually routes through the shared helper. | ||
| it("auth.ts delegates to the shared helper instead of building its own command", () => { | ||
| // Match the import and the call, not the bare name: the explanation of this | ||
| // bug lives in a comment in auth.ts, so a substring check for | ||
| // "openInBrowser" would pass on a file that only talks about it. | ||
| expect(AUTH_SRC).toMatch( | ||
| /import\s*\{\s*openInBrowser\s*\}\s*from\s*["']\.\.\/dashboard\/open\.js["']/, | ||
| ); | ||
| expect(AUTH_SRC).toMatch(/return\s+openInBrowser\(\s*url\s*\)\s*\.attempted/); | ||
| expect(AUTH_SRC).not.toMatch(/start\s+"\$\{url\}"/); | ||
| expect(AUTH_SRC).not.toMatch(/execSync\(\s*cmd/); | ||
| }); | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.