mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-09 20:50:58 +00:00
9b57183a99
* fix(cloud): show owner model balance and enforce single owner * fix(migrations): create owner index idempotently --------- Co-authored-by: dadachann <185672915+dadachann@users.noreply.github.com>
60 lines
2.3 KiB
JavaScript
60 lines
2.3 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import test from 'node:test';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const root = path.resolve(
|
|
path.dirname(fileURLToPath(import.meta.url)),
|
|
'../..',
|
|
);
|
|
const read = (file) => fs.readFileSync(path.join(root, file), 'utf8');
|
|
|
|
test('invited local registration returns to login instead of authenticating', () => {
|
|
const source = read('src/app/invitations/accept/page.tsx');
|
|
assert.doesNotMatch(
|
|
source,
|
|
/beginAuthenticatedSession\([\s\S]{0,120}response\.token/,
|
|
);
|
|
assert.match(source, /navigate\('\/login\?invitation=1'/);
|
|
});
|
|
|
|
test('authenticated invitation page offers logout while retaining invitation', () => {
|
|
const source = read('src/app/invitations/accept/page.tsx');
|
|
assert.match(source, /workspace\.logoutAndReturn/);
|
|
assert.match(source, /setPendingInvitationToken\(token\)/);
|
|
});
|
|
|
|
test('Space OAuth callback distinguishes unknown and unbound accounts by stable codes', () => {
|
|
const source = read('src/app/auth/space/callback/page.tsx');
|
|
assert.match(source, /space_account_not_registered/);
|
|
assert.match(source, /space_account_binding_required/);
|
|
});
|
|
|
|
test('models panel derives LangBot Models billing state from workspace owner', () => {
|
|
const source = read('src/app/home/components/models-dialog/ModelsPanel.tsx');
|
|
assert.match(source, /getWorkspaceSpaceBilling/);
|
|
assert.doesNotMatch(source, /getSpaceCredits\(\)/);
|
|
assert.match(source, /membership\.role === 'owner'/);
|
|
});
|
|
|
|
test('provider card represents owner and member owner-bound states explicitly', () => {
|
|
const source = read(
|
|
'src/app/home/components/models-dialog/components/ProviderCard.tsx',
|
|
);
|
|
assert.match(source, /isWorkspaceOwner/);
|
|
assert.match(source, /ownerSpaceBound/);
|
|
assert.match(source, /models\.ownerMustBindSpace/);
|
|
assert.match(source, /models\.usesOwnerSpaceBilling/);
|
|
assert.match(source, /isWorkspaceOwner && \(\s*<Button/);
|
|
});
|
|
|
|
test('workspace member controls never offer ownership transfer', () => {
|
|
const source = read(
|
|
'src/app/home/components/workspace-settings/WorkspaceSettingsPanel.tsx',
|
|
);
|
|
assert.doesNotMatch(source, /canTransferOwner/);
|
|
assert.doesNotMatch(source, /workspace\.transferOwnership/);
|
|
assert.doesNotMatch(source, /<SelectItem value="owner">/);
|
|
});
|