|
| 1 | +import { TestSuite } from '../../src/app/shared/models/testSuite'; |
| 2 | +import { Test } from '../../src/app/shared/models/test'; |
| 3 | +import { TestRun } from '../../src/app/shared/models/testRun'; |
| 4 | +import { sendPost, sendGet } from '../utils/aqualityTrackingAPI.util'; |
| 5 | +import { TestResult } from '../../src/app/shared/models/test-result'; |
| 6 | +import { Project } from '../../src/app/shared/models/project'; |
| 7 | +import { BaseAPI } from './base.api'; |
| 8 | + |
| 9 | +enum Endpoints { |
| 10 | + suite_create_or_update = '/public/suite/create-or-update', |
| 11 | + testrun_start = '/public/testrun/start', |
| 12 | + testrun_finish = '/public/testrun/finish', |
| 13 | + test_result_start = '/public/test/result/start', |
| 14 | + test_result_finish = '/public/test/result/finish', |
| 15 | + test_create_or_update = '/public/test/create-or-update' |
| 16 | +} |
| 17 | + |
| 18 | +export class PublicAPI extends BaseAPI { |
| 19 | + |
| 20 | + public createOrUpdateSuite(suite: TestSuite): Promise<TestSuite> { |
| 21 | + return sendPost(Endpoints.suite_create_or_update, undefined, suite, this.token, this.project.id); |
| 22 | + } |
| 23 | + |
| 24 | + public createOrUpdateTest(test: Test): Promise<Test> { |
| 25 | + return sendPost(Endpoints.test_create_or_update, undefined, test, this.token, this.project.id); |
| 26 | + } |
| 27 | + |
| 28 | + public startTestrun(testrun: TestRun): Promise<TestRun> { |
| 29 | + return sendPost(Endpoints.testrun_start, undefined, testrun, this.token, this.project.id); |
| 30 | + } |
| 31 | + |
| 32 | + public finishTestRun(project_id: number, id: number) { |
| 33 | + return sendGet(Endpoints.testrun_finish, { project_id, id }, this.token, this.project.id); |
| 34 | + } |
| 35 | + |
| 36 | + public testResultStart(test_id: number, test_run_id: number, project_id: number) { |
| 37 | + return sendGet(Endpoints.test_result_start, { test_id, test_run_id, project_id }, this.token, this.project.id); |
| 38 | + } |
| 39 | + |
| 40 | + public testResultFinish(testResult: TestResult): Promise<TestResult> { |
| 41 | + return sendPost(Endpoints.test_result_finish, undefined, testResult, this.token, this.project.id); |
| 42 | + } |
| 43 | +} |
0 commit comments