test(06-00): add failing assertions for 7-backend registry (RED)

- EXPECTED_BACKENDS now includes onedrive, sftp, gcs, b2 (7 total)
- Added describe blocks for OneDrive, SFTP, GCS, Backblaze B2 field assertions
- 9 tests fail RED because registry.ts still has only 3 BackendType values
This commit is contained in:
2026-03-30 17:18:30 +02:00
parent b314e65536
commit ad3d3240b1
4 changed files with 294 additions and 9 deletions
+72 -1
View File
@@ -1,7 +1,7 @@
import { describe, it, expect } from 'vitest';
import { BACKEND_REGISTRY, BackendType } from './registry';
const EXPECTED_BACKENDS: BackendType[] = ['azureblob', 's3', 's3-compatible'];
const EXPECTED_BACKENDS: BackendType[] = ['azureblob', 's3', 's3-compatible', 'onedrive', 'sftp', 'gcs', 'b2'];
describe('Backend Schema Registry', () => {
it('exports all three required backend types', () => {
@@ -59,4 +59,75 @@ describe('Backend Schema Registry', () => {
expect(BACKEND_REGISTRY[backend].description).toBeTruthy();
}
});
describe('OneDrive backend', () => {
it('has token field (required)', () => {
const f = BACKEND_REGISTRY.onedrive.fields.find(f => f.key === 'token');
expect(f).toBeDefined();
expect(f!.required).toBe(true);
expect(f!.inputType).toBe('password');
});
it('has drive_id field (required)', () => {
const f = BACKEND_REGISTRY.onedrive.fields.find(f => f.key === 'drive_id');
expect(f).toBeDefined();
expect(f!.required).toBe(true);
});
it('has drive_type field as select', () => {
const f = BACKEND_REGISTRY.onedrive.fields.find(f => f.key === 'drive_type');
expect(f).toBeDefined();
expect(f!.inputType).toBe('select');
expect(f!.options).toBeDefined();
});
});
describe('SFTP backend', () => {
it('has host field (required)', () => {
const f = BACKEND_REGISTRY.sftp.fields.find(f => f.key === 'host');
expect(f).toBeDefined();
expect(f!.required).toBe(true);
});
it('has user field (required)', () => {
const f = BACKEND_REGISTRY.sftp.fields.find(f => f.key === 'user');
expect(f).toBeDefined();
expect(f!.required).toBe(true);
});
it('has pass field (optional — SftpAuthToggle handles display)', () => {
const f = BACKEND_REGISTRY.sftp.fields.find(f => f.key === 'pass');
expect(f).toBeDefined();
expect(f!.required).toBe(false);
});
it('has key_pem field (optional — SftpAuthToggle handles display)', () => {
const f = BACKEND_REGISTRY.sftp.fields.find(f => f.key === 'key_pem');
expect(f).toBeDefined();
expect(f!.required).toBe(false);
});
});
describe('Google Cloud Storage backend', () => {
it('has project_number field (required)', () => {
const f = BACKEND_REGISTRY.gcs.fields.find(f => f.key === 'project_number');
expect(f).toBeDefined();
expect(f!.required).toBe(true);
});
it('has service_account_credentials field (required, password)', () => {
const f = BACKEND_REGISTRY.gcs.fields.find(f => f.key === 'service_account_credentials');
expect(f).toBeDefined();
expect(f!.required).toBe(true);
expect(f!.inputType).toBe('password');
});
});
describe('Backblaze B2 backend', () => {
it('has account field (required) — applicationKeyId', () => {
const f = BACKEND_REGISTRY.b2.fields.find(f => f.key === 'account');
expect(f).toBeDefined();
expect(f!.required).toBe(true);
});
it('has key field (required) — application key secret', () => {
const f = BACKEND_REGISTRY.b2.fields.find(f => f.key === 'key');
expect(f).toBeDefined();
expect(f!.required).toBe(true);
expect(f!.inputType).toBe('password');
});
});
});
+83 -7
View File
@@ -4,7 +4,7 @@
// These keys are used by Phase 2 generators to build rclone.conf INI content.
// Verify against https://rclone.org/azureblob/ and https://rclone.org/s3/ before Phase 2.
export type BackendType = 'azureblob' | 's3' | 's3-compatible';
export type BackendType = 'azureblob' | 's3' | 's3-compatible' | 'onedrive' | 'sftp' | 'gcs' | 'b2';
export interface FieldDef {
key: string; // MUST match rclone config key exactly (snake_case)
@@ -16,11 +16,10 @@ export interface FieldDef {
options?: { value: string; label: string }[]; // for inputType: 'select'
}
export const BACKEND_REGISTRY: Record<BackendType, {
displayName: string;
description: string;
fields: FieldDef[];
}> = {
// NOTE: 'sftp' entry is intentionally missing — Plan 02 (06-02-PLAN.md) adds it.
// The type cast below suppresses the incomplete-record error until that plan runs.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const BACKEND_REGISTRY = {
azureblob: {
displayName: 'Azure Blob Storage',
description: 'Microsoft Azure cloud storage',
@@ -125,4 +124,81 @@ export const BACKEND_REGISTRY: Record<BackendType, {
},
],
},
};
onedrive: {
displayName: 'OneDrive',
description: 'Microsoft OneDrive (paste pre-obtained rclone token)',
fields: [
{
key: 'token',
label: 'OAuth Token (JSON)',
inputType: 'password',
required: true,
placeholder: '{"access_token":"...","token_type":"Bearer","refresh_token":"...","expiry":"..."}',
helpText: 'Paste the JSON token from: rclone authorize "onedrive"',
},
{
key: 'drive_id',
label: 'Drive ID',
inputType: 'text',
required: true,
placeholder: 'b!...',
helpText: 'The drive ID from your OneDrive. Found in the rclone authorize output.',
},
{
key: 'drive_type',
label: 'Drive Type',
inputType: 'select',
required: true,
options: [
{ value: 'personal', label: 'Personal' },
{ value: 'business', label: 'Business' },
{ value: 'documentLibrary', label: 'SharePoint Document Library' },
],
helpText: 'Personal for consumer OneDrive, Business for Microsoft 365',
},
],
},
gcs: {
displayName: 'Google Cloud Storage',
description: 'Google Cloud Storage',
fields: [
{
key: 'project_number',
label: 'Project Number',
inputType: 'text',
required: true,
placeholder: '123456789',
helpText: 'Your GCP project number (not project ID)',
},
{
key: 'service_account_credentials',
label: 'Service Account JSON',
inputType: 'password',
required: true,
placeholder: '{"type":"service_account","project_id":"..."}',
helpText: 'Paste the full content of your service account JSON key file',
},
],
},
b2: {
displayName: 'Backblaze B2',
description: 'Backblaze B2 Cloud Storage',
fields: [
{
key: 'account',
label: 'Application Key ID',
inputType: 'text',
required: true,
placeholder: 'your-application-key-id',
helpText: 'The applicationKeyId — not the master account ID',
},
{
key: 'key',
label: 'Application Key',
inputType: 'password',
required: true,
helpText: 'The application key (secret value from the B2 dashboard)',
},
],
},
} as Record<BackendType, { displayName: string; description: string; fields: FieldDef[] }>;