Files
n8n/packages/testing/playwright/services/source-control-api-helper.ts
alighasami 3d5eaf9445
Some checks failed
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
first commit
2026-03-17 16:22:57 +03:30

64 lines
1.5 KiB
TypeScript

import { TestError } from '../Types';
import type { ApiHelpers } from './api-helper';
export class SourceControlApiHelper {
constructor(private api: ApiHelpers) {}
async disconnect({ keepKeyPair = true }: { keepKeyPair?: boolean } = {}) {
const response = await this.api.request.post('/rest/source-control/disconnect', {
data: {
keepKeyPair,
},
});
if (!response.ok()) {
throw new TestError(`Failed to disconnect from source control: ${await response.text()}`);
}
const result = await response.json();
return result.data;
}
async connect(preferences: {
repositoryUrl: string;
}) {
const response = await this.api.request.post('/rest/source-control/preferences', {
data: {
connectionType: 'ssh',
...preferences,
},
});
if (!response.ok()) {
throw new TestError(`Failed to connect to source control: ${await response.text()}`);
}
const result = await response.json();
return result.data;
}
/**
* This will push all the changes
* OPTIMIZE: add a fileNames to select what specific changes to push
* @returns
*/
async pushWorkFolder({
commitMessage,
force = false,
}: {
commitMessage: string;
force?: boolean;
}) {
const response = await this.api.request.post('/rest/source-control/push-workfolder', {
data: {
commitMessage,
force,
fileNames: [],
},
});
if (!response.ok()) {
throw new TestError(`Failed to push work folder: ${await response.text()}`);
}
const result = await response.json();
return result.data;
}
}