UNPKG

testrail-modern-client

Version:
90 lines (89 loc) 4.24 kB
/// <reference types="node" /> /// <reference types="node" /> import { AddAttachmentResponse, Attachment } from '../models/attachments'; import { BaseService } from './base'; /** * Service class for managing TestRail attachments. * @since TestRail 6.3 */ export declare class AttachmentService extends BaseService { /** * Creates form data with file for attachment upload */ private createFormData; /** * Adds an attachment to a test case. * @param caseId - The ID of the test case * @param filePath - The path to the file to attach * @returns The created attachment ID * @throws {Error} 400 - Invalid or unknown test case * @throws {Error} 403 - No permissions to add attachments or no access to the project * @throws {Error} 413 - File too large (TestRail Cloud only) * @throws {Error} 429 - Too many requests (TestRail Cloud only) */ addToCase(caseId: number, filePath: string): Promise<AddAttachmentResponse>; /** * Adds an attachment to a test plan. * @param planId - The ID of the test plan * @param filePath - The path to the file to attach * @returns The created attachment ID * @throws {Error} 400 - Invalid or unknown test plan * @throws {Error} 403 - No permissions to add attachments or no access to the project * @throws {Error} 413 - File too large (TestRail Cloud only) * @throws {Error} 429 - Too many requests (TestRail Cloud only) */ addToPlan(planId: number, filePath: string): Promise<AddAttachmentResponse>; /** * Adds an attachment to a test plan entry. * @param planId - The ID of the test plan * @param entryId - The ID of the test plan entry * @param filePath - The path to the file to attach * @returns The created attachment ID * @throws {Error} 400 - Invalid or unknown test plan/entry * @throws {Error} 403 - No permissions to add attachments or no access to the project * @throws {Error} 413 - File too large (TestRail Cloud only) * @throws {Error} 429 - Too many requests (TestRail Cloud only) */ addToPlanEntry(planId: number, entryId: number, filePath: string): Promise<AddAttachmentResponse>; /** * Adds an attachment to a test run. * @param runId - The ID of the test run * @param filePath - The path to the file to attach * @returns The created attachment ID * @throws {Error} 400 - Invalid or unknown test run * @throws {Error} 403 - No permissions to add attachments or no access to the project * @throws {Error} 413 - File too large (TestRail Cloud only) * @throws {Error} 429 - Too many requests (TestRail Cloud only) */ addToRun(runId: number, filePath: string): Promise<AddAttachmentResponse>; /** * Adds an attachment to a test result. * @param resultId - The ID of the test result * @param filePath - The path to the file to attach * @returns The created attachment ID * @throws {Error} 400 - Invalid or unknown test result * @throws {Error} 403 - No permissions to add attachments or no access to the project * @throws {Error} 413 - File too large (TestRail Cloud only) * @throws {Error} 429 - Too many requests (TestRail Cloud only) */ addToResult(resultId: number, filePath: string): Promise<AddAttachmentResponse>; /** * Gets an attachment by ID. * @param attachmentId - The ID of the attachment * @returns The attachment file content */ get(attachmentId: number | string): Promise<Buffer>; /** * Deletes an attachment. * @param attachmentId - The ID of the attachment to delete * @throws {Error} 400 - Invalid or unknown attachment * @throws {Error} 403 - No permissions to delete attachments or no access to the project * @throws {Error} 429 - Too many requests (TestRail Cloud only) */ delete(attachmentId: number): Promise<void>; getForCase(caseId: number): Promise<Attachment[]>; getForPlan(planId: number): Promise<Attachment[]>; getForPlanEntry(planId: number, entryId: string): Promise<Attachment[]>; getForRun(runId: number): Promise<Attachment[]>; getForTest(testId: number): Promise<Attachment[]>; }