Skip to content

Commit 69fd366

Browse files
committed
chore: Add tests for publishers releases
1 parent 51aaa8c commit 69fd366

8 files changed

Lines changed: 525 additions & 1 deletion

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import {
2+
getRevisionsMap,
3+
initReleasesData,
4+
getTrackingChannel,
5+
} from "../releasesState";
6+
7+
import {
8+
mockRevisions,
9+
mockRevisionsMap,
10+
mockReleases,
11+
mockReleasesData,
12+
mockReleasedChannels,
13+
} from "../../../test-utils";
14+
15+
describe("getRevisionsMap", () => {
16+
test("returns a revisions map", () => {
17+
expect(getRevisionsMap(mockRevisions)).toEqual(mockRevisionsMap);
18+
});
19+
});
20+
21+
describe("initReleasesData", () => {
22+
test("returns releases data", () => {
23+
expect(initReleasesData(mockRevisionsMap, mockReleases)).toEqual(
24+
mockReleasesData,
25+
);
26+
});
27+
});
28+
29+
describe("getTrackingChannel", () => {
30+
test("returns tracking channel", () => {
31+
expect(
32+
getTrackingChannel(
33+
mockReleasedChannels,
34+
"latest",
35+
"candidate",
36+
"ppc64el",
37+
),
38+
).toEqual("latest/stable");
39+
});
40+
});

static/js/publisher/pages/Releases/components/TrackInfo.test.tsx renamed to static/js/publisher/pages/Releases/components/__tests__/TrackInfo.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { fireEvent, render, screen } from "@testing-library/react";
2-
import TrackInfo from "./TrackInfo";
2+
import TrackInfo from "../TrackInfo";
33
import { Tooltip } from "@canonical/react-components";
44
import "@testing-library/jest-dom";
55

static/js/publisher/test-utils/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { mockListingData } from "./mockListingData";
22
import { mockActiveDeviceMetrics } from "./mockActiveDeviceMetrics";
33
import { mockTerritoryMetrics } from "./mockTerritoryMetrics";
4+
import { mockReleases } from "./mockReleases";
5+
import { mockRevisions } from "./mockRevisions";
6+
import { mockReleasedChannels } from "./mockReleasedChannels";
7+
import { mockReleasesData } from "./mockReleasesData";
8+
import { mockRevisionsMap } from "./mockRevisionsMap";
49
import RecoilObserver from "./RecoilObserver";
510
import brandStoreRequests from "./brand-store-requests";
611
import {
@@ -20,4 +25,9 @@ export {
2025
storesResponse,
2126
mockActiveDeviceMetrics,
2227
mockTerritoryMetrics,
28+
mockReleases,
29+
mockRevisions,
30+
mockReleasedChannels,
31+
mockReleasesData,
32+
mockRevisionsMap,
2333
};
Lines changed: 302 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,302 @@
1+
export const mockReleasedChannels = {
2+
"latest/candidate": {
3+
amd64: {
4+
architectures: ["amd64"],
5+
attributes: {},
6+
base: "core18",
7+
build_url: null,
8+
confinement: "strict",
9+
created_at: "2022-06-01T08:59:35Z",
10+
epoch: {
11+
read: [0],
12+
write: [0],
13+
},
14+
grade: "stable",
15+
revision: 23,
16+
"sha3-384":
17+
"20c4e17fca36fddccb933b730454256e81714914f2f050996a63efe250e1aa44e5e4dc92959e9cd72cf7ef9ca918c5b6",
18+
size: 4096,
19+
status: "Published",
20+
version: "1.0.1",
21+
expiration: null,
22+
progressive: {
23+
"current-percentage": 100,
24+
paused: null,
25+
percentage: null,
26+
},
27+
channels: ["latest/candidate", "latest/beta", "latest/stable"],
28+
prog_channels: [],
29+
},
30+
arm64: {
31+
architectures: ["arm64"],
32+
attributes: {},
33+
base: "core18",
34+
build_url: null,
35+
confinement: "strict",
36+
created_at: "2022-06-20T08:37:52Z",
37+
epoch: {
38+
read: [0],
39+
write: [0],
40+
},
41+
grade: "stable",
42+
revision: 24,
43+
"sha3-384":
44+
"ce8fc73571f5afe9ca13ed19ec0605990d78c26abb5dc273528e56e3e46a5215672adb75602a17a53a6de79288e60f5b",
45+
size: 4096,
46+
status: "Published",
47+
version: "2.0.0",
48+
expiration: null,
49+
progressive: {
50+
"current-percentage": 0,
51+
paused: null,
52+
percentage: null,
53+
},
54+
channels: ["latest/beta", "latest/stable", "latest/candidate"],
55+
prog_channels: [],
56+
},
57+
armhf: {
58+
architectures: ["armhf"],
59+
attributes: {
60+
"build-request-id": "lp-79412770",
61+
"build-request-timestamp": "2023-05-12T11:27:58Z",
62+
},
63+
base: "bare",
64+
build_url:
65+
"https://launchpad.net/~build.staging.snapcraft.io/+snap/1a34fa8a4dd2a8ec399c23b7bee98faf/+build/2105843",
66+
confinement: "strict",
67+
created_at: "2023-05-12T11:35:12Z",
68+
epoch: {
69+
read: [0],
70+
write: [0],
71+
},
72+
grade: "stable",
73+
revision: 33,
74+
"sha3-384":
75+
"39157150b8dd7ffe736fd27fe143296416d6e4193412cf5a671716f13d1000804e3524d859ae0694ae01dc0e49ae8bb9",
76+
size: 4096,
77+
status: "Published",
78+
version: "3.0.0",
79+
expiration: null,
80+
progressive: {
81+
"current-percentage": 0,
82+
paused: null,
83+
percentage: null,
84+
},
85+
channels: ["latest/edge", "latest/candidate", "latest/stable"],
86+
prog_channels: [],
87+
},
88+
},
89+
"latest/edge": {
90+
amd64: {
91+
architectures: ["amd64"],
92+
attributes: {},
93+
base: "core18",
94+
build_url: null,
95+
confinement: "strict",
96+
created_at: "2022-06-01T08:56:34Z",
97+
epoch: {
98+
read: [0],
99+
write: [0],
100+
},
101+
grade: "stable",
102+
revision: 22,
103+
"sha3-384":
104+
"0b266783778244bb4ae59be30f8723fd976b8e8bf4b7921e53ebd9921dc250b5d39aea8cc0c72cd5a75a0e2365fd4575",
105+
size: 4096,
106+
status: "Published",
107+
version: "0.8",
108+
expiration: null,
109+
progressive: {
110+
"current-percentage": null,
111+
paused: null,
112+
percentage: null,
113+
},
114+
channels: ["latest/edge"],
115+
prog_channels: [],
116+
},
117+
arm64: {
118+
architectures: ["arm64"],
119+
attributes: {
120+
"build-request-id": "lp-95738871",
121+
"build-request-timestamp": "2025-02-04T13:52:18Z",
122+
},
123+
base: "bare",
124+
build_url:
125+
"https://launchpad.net/~build.staging.snapcraft.io/+snap/1a34fa8a4dd2a8ec399c23b7bee98faf/+build/2719363",
126+
confinement: "strict",
127+
created_at: "2025-02-04T14:08:08Z",
128+
epoch: {
129+
read: [0],
130+
write: [0],
131+
},
132+
grade: "stable",
133+
revision: 61,
134+
"sha3-384":
135+
"40f7b56e7c1ce28af4b071930723455deae6943e2c8545e5e668a0443cff6094557711a58334fea1d43a3b0017ec6364",
136+
size: 16384,
137+
status: "Published",
138+
version: "4.0.1",
139+
expiration: null,
140+
progressive: {
141+
"current-percentage": 0,
142+
paused: false,
143+
percentage: 50,
144+
},
145+
channels: ["latest/edge", "latest/stable"],
146+
prog_channels: ["latest/stable"],
147+
},
148+
},
149+
"latest/stable": {
150+
amd64: {
151+
architectures: ["amd64"],
152+
attributes: {},
153+
base: "core18",
154+
build_url: null,
155+
confinement: "strict",
156+
created_at: "2022-06-01T08:59:35Z",
157+
epoch: {
158+
read: [0],
159+
write: [0],
160+
},
161+
grade: "stable",
162+
revision: 23,
163+
"sha3-384":
164+
"20c4e17fca36fddccb933b730454256e81714914f2f050996a63efe250e1aa44e5e4dc92959e9cd72cf7ef9ca918c5b6",
165+
size: 4096,
166+
status: "Published",
167+
version: "1.0.1",
168+
expiration: null,
169+
progressive: {
170+
"current-percentage": 100,
171+
paused: null,
172+
percentage: null,
173+
},
174+
channels: ["latest/candidate", "latest/beta", "latest/stable"],
175+
prog_channels: [],
176+
},
177+
arm64: {
178+
architectures: ["arm64"],
179+
attributes: {
180+
"build-request-id": "lp-95738871",
181+
"build-request-timestamp": "2025-02-04T13:52:18Z",
182+
},
183+
base: "bare",
184+
build_url:
185+
"https://launchpad.net/~build.staging.snapcraft.io/+snap/1a34fa8a4dd2a8ec399c23b7bee98faf/+build/2719363",
186+
confinement: "strict",
187+
created_at: "2025-02-04T14:08:08Z",
188+
epoch: {
189+
read: [0],
190+
write: [0],
191+
},
192+
grade: "stable",
193+
revision: 61,
194+
"sha3-384":
195+
"40f7b56e7c1ce28af4b071930723455deae6943e2c8545e5e668a0443cff6094557711a58334fea1d43a3b0017ec6364",
196+
size: 16384,
197+
status: "Published",
198+
version: "4.0.1",
199+
expiration: null,
200+
progressive: {
201+
"current-percentage": 0,
202+
paused: false,
203+
percentage: 50,
204+
},
205+
channels: ["latest/edge", "latest/stable"],
206+
prog_channels: ["latest/stable"],
207+
},
208+
armhf: {
209+
architectures: ["armhf"],
210+
attributes: {
211+
"build-request-id": "lp-79412770",
212+
"build-request-timestamp": "2023-05-12T11:27:58Z",
213+
},
214+
base: "bare",
215+
build_url:
216+
"https://launchpad.net/~build.staging.snapcraft.io/+snap/1a34fa8a4dd2a8ec399c23b7bee98faf/+build/2105843",
217+
confinement: "strict",
218+
created_at: "2023-05-12T11:35:12Z",
219+
epoch: {
220+
read: [0],
221+
write: [0],
222+
},
223+
grade: "stable",
224+
revision: 33,
225+
"sha3-384":
226+
"39157150b8dd7ffe736fd27fe143296416d6e4193412cf5a671716f13d1000804e3524d859ae0694ae01dc0e49ae8bb9",
227+
size: 4096,
228+
status: "Published",
229+
version: "3.0.0",
230+
expiration: null,
231+
progressive: {
232+
"current-percentage": 0,
233+
paused: null,
234+
percentage: null,
235+
},
236+
channels: ["latest/edge", "latest/candidate", "latest/stable"],
237+
prog_channels: [],
238+
},
239+
ppc64el: {
240+
architectures: ["ppc64el"],
241+
attributes: {
242+
"build-request-id": "lp-79412770",
243+
"build-request-timestamp": "2023-05-12T11:27:58Z",
244+
},
245+
base: "bare",
246+
build_url:
247+
"https://launchpad.net/~build.staging.snapcraft.io/+snap/1a34fa8a4dd2a8ec399c23b7bee98faf/+build/2105845",
248+
confinement: "strict",
249+
created_at: "2023-05-12T11:32:16Z",
250+
epoch: {
251+
read: [0],
252+
write: [0],
253+
},
254+
grade: "stable",
255+
revision: 31,
256+
"sha3-384":
257+
"2c9f21647b78bb8d61afef0678996e451c68e8e6a4ab9c3184d3309b5a3abc9895d9021540c2e3df73ac7563bfea0d5d",
258+
size: 4096,
259+
status: "Published",
260+
version: "3.0.0",
261+
expiration: null,
262+
progressive: {
263+
"current-percentage": 0,
264+
paused: null,
265+
percentage: null,
266+
},
267+
channels: ["latest/edge", "latest/stable"],
268+
prog_channels: [],
269+
},
270+
s390x: {
271+
architectures: ["s390x"],
272+
attributes: {
273+
"build-request-id": "lp-79412770",
274+
"build-request-timestamp": "2023-05-12T11:27:58Z",
275+
},
276+
base: "bare",
277+
build_url:
278+
"https://launchpad.net/~build.staging.snapcraft.io/+snap/1a34fa8a4dd2a8ec399c23b7bee98faf/+build/2105846",
279+
confinement: "strict",
280+
created_at: "2023-05-12T11:32:18Z",
281+
epoch: {
282+
read: [0],
283+
write: [0],
284+
},
285+
grade: "stable",
286+
revision: 32,
287+
"sha3-384":
288+
"061cc4297271240f8ba572b8e183a51c9924e412066d4f3fd71300d213bd133a841b5d3a9ee1a374823b92914d177f97",
289+
size: 4096,
290+
status: "Published",
291+
version: "3.0.0",
292+
expiration: null,
293+
progressive: {
294+
"current-percentage": 0,
295+
paused: null,
296+
percentage: null,
297+
},
298+
channels: ["latest/edge", "latest/stable"],
299+
prog_channels: [],
300+
},
301+
},
302+
};

0 commit comments

Comments
 (0)