testit-js-commons 5.0.5-TMS-5.8 → 5.0.6-TMS-5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -73,15 +73,13 @@ class TestRunsService extends common_1.BaseService {
73
73
  }
74
74
  getTestRun(testRunId) {
75
75
  return __awaiter(this, void 0, void 0, function* () {
76
- return yield this._client
77
- .adaptersTestRunsIdGet(testRunId)
78
- // @ts-ignore
79
- .then((response) => {
80
- const data = (response === null || response === void 0 ? void 0 : response.body) || response;
81
- return data;
82
- })
83
- // @ts-ignore
84
- .then((run) => this._converter.toLocalTestRun(run));
76
+ return yield (0, utils_1.withHttpRetry)(() => __awaiter(this, void 0, void 0, function* () {
77
+ // Temporary: adapters GET omits/empties links, attachments, description, launchSource (TMS 5.8).
78
+ // Read via public API v2; PUT stays on adapters.
79
+ const apiClient = AdaptersApi.ApiClient.instance;
80
+ const { data } = yield apiClient.callApi("/api/v2/testRuns/{id}", "GET", { id: testRunId }, {}, {}, {}, null, ["PrivateToken"], [], ["application/json"], Object, null);
81
+ return this._converter.toLocalTestRun(data);
82
+ }), { label: `getTestRun:${testRunId}` });
85
83
  });
86
84
  }
87
85
  updateTestRun(testRun) {
@@ -17,11 +17,18 @@ jest.mock("../../adapters-api/dist/index", () => ({
17
17
  authentications: {
18
18
  PrivateToken: { apiKeyPrefix: "", apiKey: "" },
19
19
  },
20
+ callApi: jest.fn(),
20
21
  },
21
22
  },
22
23
  TestRunsApi: jest.fn().mockImplementation(() => ({
23
24
  adaptersTestRunsIdTestResultsPost: jest.fn().mockResolvedValue(["result-id-1"]),
24
25
  })),
26
+ TestRunState: {
27
+ NotStarted: "NotStarted",
28
+ InProgress: "InProgress",
29
+ Stopped: "Stopped",
30
+ Completed: "Completed",
31
+ },
25
32
  }));
26
33
  jest.mock("../testresults/testresults.service", () => ({
27
34
  TestResultsService: jest.fn().mockImplementation(() => ({
@@ -29,6 +36,9 @@ jest.mock("../testresults/testresults.service", () => ({
29
36
  updateTestResult: jest.fn().mockResolvedValue(undefined),
30
37
  })),
31
38
  }));
39
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
40
+ const AdaptersApi = require("../../adapters-api/dist/index");
41
+ const callApi = AdaptersApi.ApiClient.instance.callApi;
32
42
  function makeConfig() {
33
43
  return {
34
44
  url: "http://localhost:8080",
@@ -41,6 +51,39 @@ function makeConfig() {
41
51
  function makeResult(overrides = {}) {
42
52
  return Object.assign({ autoTestExternalId: "ext-1", outcome: "Passed", stepResults: [{ title: "step-1" }] }, overrides);
43
53
  }
54
+ describe("TestRunsService.getTestRun", () => {
55
+ beforeEach(() => {
56
+ callApi.mockReset();
57
+ });
58
+ it("reads metadata via public API v2 (links/attachments/description/launchSource)", () => __awaiter(void 0, void 0, void 0, function* () {
59
+ callApi.mockResolvedValue({
60
+ data: {
61
+ id: "run-1",
62
+ name: "run",
63
+ description: "213123123",
64
+ launchSource: "Test IT",
65
+ stateName: "Completed",
66
+ status: { code: "PASSED", type: "Succeeded" },
67
+ testResults: [{ id: "ignored" }],
68
+ attachments: [{ id: "att-1" }],
69
+ links: [{ url: "https://example.com/1", title: "one", hasInfo: true }],
70
+ tags: ["a"],
71
+ },
72
+ });
73
+ const service = new testruns_service_1.TestRunsService(makeConfig());
74
+ const run = yield service.getTestRun("run-1");
75
+ expect(callApi).toHaveBeenCalledWith("/api/v2/testRuns/{id}", "GET", { id: "run-1" }, expect.any(Object), expect.any(Object), expect.any(Object), null, ["PrivateToken"], expect.any(Array), expect.any(Array), Object, null);
76
+ expect(run.description).toBe("213123123");
77
+ expect(run.launchSource).toBe("Test IT");
78
+ expect(run.stateName).toBe("Completed");
79
+ expect(run.links).toEqual([
80
+ expect.objectContaining({ url: "https://example.com/1", title: "one" }),
81
+ ]);
82
+ expect(run.attachments).toEqual([{ id: "att-1" }]);
83
+ expect(run.tags).toEqual(["a"]);
84
+ expect(run).not.toHaveProperty("testResults");
85
+ }));
86
+ });
44
87
  describe("TestRunsService.loadAutotests", () => {
45
88
  it("always POST final result even when in-progress id exists in cache", () => __awaiter(void 0, void 0, void 0, function* () {
46
89
  const service = new testruns_service_1.TestRunsService(makeConfig());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testit-js-commons",
3
- "version": "5.0.5-TMS-5.8",
3
+ "version": "5.0.6-TMS-5.8",
4
4
  "description": "JavaScript commons for Test IT",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",