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
231 changes: 227 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"node": ">=20.18.1"
},
"dependencies": {
"@doist/cli-core": "0.12.0",
"@doist/cli-core": "0.16.1",
"chalk": "5.6.2",
"commander": "14.0.2",
"marked": "18.0.3",
Expand Down
54 changes: 54 additions & 0 deletions src/__tests__/_fixtures/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import type { MigrateAuthResult } from '@doist/cli-core/auth'
import type { OutlineAccount } from '../../lib/outline-account.js'

/** Canonical persisted `OutlineAccount` used across auth tests. */
export const STORED_ACCOUNT: OutlineAccount = {
id: 'user-uuid',
label: 'Ada',
baseUrl: 'https://wiki.example.com',
oauthClientId: 'cid-xyz',
teamName: 'Analytics',
}

/** v1 plaintext config snapshot that round-trips to `STORED_ACCOUNT`. */
export const LEGACY_CONFIG = {
api_token: 'tk_legacy_plaintext',
base_url: 'https://wiki.example.com',
oauth_client_id: 'cid-xyz',
auth_user_id: 'user-uuid',
auth_user_name: 'Ada',
auth_team_name: 'Analytics',
} as const

/** `updateConfig` payload that wipes every v1 auth key. */
export const LEGACY_CLEAR_PAYLOAD = {
api_token: undefined,
base_url: undefined,
oauth_client_id: undefined,
auth_user_id: undefined,
auth_user_name: undefined,
auth_team_name: undefined,
} as const

/** Outline `auth.info` response body. Richer than `STORED_ACCOUNT` (carries email). */
export const AUTH_INFO = {
user: { id: 'user-uuid', name: 'Ada Lovelace', email: 'ada@example.com' },
team: { name: 'Analytics', subdomain: 'analytics' },
} as const

/** Stand-in for a cli-core `migrateLegacyAuth` skip result. */
export const SKIPPED_RESULT: MigrateAuthResult<OutlineAccount> = {
status: 'skipped',
reason: 'identify-failed',
detail: 'offline',
}

/** 200 `Response` with `body` as JSON, using the native static helper. */
export function okResponse(body: unknown): Response {
return Response.json(body)
}

/** Error `Response` with the given status (default 500). */
export function errResponse(status: number, statusText = 'Error', body?: unknown): Response {
return Response.json(body ?? {}, { status, statusText })
}
Loading
Loading