Skip to content

Commit 16b024a

Browse files
frostebiteclaude
andcommitted
test: fix integration test and hex changesets in test fixtures
- Fix integration test to properly run only in CI (when CI env is set) - Use correct reference to mockedFetch instead of creating new reference - Replace all invalid hex changesets with valid 12-character hex strings Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent ddf3a70 commit 16b024a

1 file changed

Lines changed: 21 additions & 18 deletions

File tree

functions/test/scrapeVersions.test.ts

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ describe('scrapeVersions', () => {
4848
},
4949
{
5050
version: '2023.2.10f1',
51-
changeset: 'def456ghi789',
51+
changeset: '234567ab8cd9',
5252
},
5353
];
5454

5555
const mockXltsVersions = [
5656
{
5757
version: '2022.3.21f1', // XLTS versions might have same format as regular versions
58-
changeset: 'xyz789uvw123',
58+
changeset: '789abcdef012',
5959
},
6060
{
6161
version: '2021.3.25f1',
62-
changeset: 'uvw123rst456',
62+
changeset: '345cdef67890',
6363
},
6464
];
6565

@@ -95,7 +95,7 @@ describe('scrapeVersions', () => {
9595
expect(result).toContainEqual(
9696
expect.objectContaining({
9797
version: '2023.2.10f1',
98-
changeSet: 'def456ghi789',
98+
changeSet: '234567ab8cd9',
9999
major: 2023,
100100
minor: 2,
101101
patch: '10',
@@ -106,7 +106,7 @@ describe('scrapeVersions', () => {
106106
expect(result).toContainEqual(
107107
expect.objectContaining({
108108
version: '2022.3.21f1',
109-
changeSet: 'xyz789uvw123',
109+
changeSet: '789abcdef012',
110110
major: 2022,
111111
minor: 3,
112112
patch: '21',
@@ -116,7 +116,7 @@ describe('scrapeVersions', () => {
116116
expect(result).toContainEqual(
117117
expect.objectContaining({
118118
version: '2021.3.25f1',
119-
changeSet: 'uvw123rst456',
119+
changeSet: '345cdef67890',
120120
major: 2021,
121121
minor: 3,
122122
patch: '25',
@@ -192,11 +192,11 @@ describe('scrapeVersions', () => {
192192
const mockXltsVersions = [
193193
{
194194
version: '2022.3.20f1', // Duplicate version
195-
changeset: 'duplicate456',
195+
changeset: 'abc123def456',
196196
},
197197
{
198198
version: '2022.3.21f1',
199-
changeset: 'xyz789uvw123',
199+
changeset: '789abcdef012',
200200
},
201201
];
202202

@@ -225,18 +225,18 @@ describe('scrapeVersions', () => {
225225
},
226226
{
227227
version: '2022.3.20a1', // Alpha version - should be excluded
228-
changeset: 'def456ghi789',
228+
changeset: '234567ab8cd9',
229229
},
230230
];
231231

232232
const mockXltsVersions = [
233233
{
234234
version: '2021.3.25f1', // Final version - should be included
235-
changeset: 'xyz789uvw123',
235+
changeset: '789abcdef012',
236236
},
237237
{
238238
version: '2020.3.15a2', // Alpha version - should be excluded
239-
changeset: 'uvw123rst456',
239+
changeset: '345cdef67890',
240240
},
241241
];
242242

@@ -265,7 +265,7 @@ describe('scrapeVersions', () => {
265265
expect(result).toContainEqual(
266266
expect.objectContaining({
267267
version: '2021.3.25f1',
268-
changeSet: 'xyz789uvw123',
268+
changeSet: '789abcdef012',
269269
major: 2021,
270270
minor: 3,
271271
patch: '25',
@@ -284,14 +284,14 @@ describe('scrapeVersions', () => {
284284
},
285285
{
286286
version: '5.6.7f1', // Should be excluded (major < 2017)
287-
changeset: 'def456ghi789',
287+
changeset: '234567ab8cd9',
288288
},
289289
];
290290

291291
const mockXltsVersions = [
292292
{
293293
version: '2021.3.25f1', // Should be included
294-
changeset: 'xyz789uvw123',
294+
changeset: '789abcdef012',
295295
},
296296
];
297297

@@ -320,7 +320,7 @@ describe('scrapeVersions', () => {
320320
expect(result).toContainEqual(
321321
expect.objectContaining({
322322
version: '2021.3.25f1',
323-
changeSet: 'xyz789uvw123',
323+
changeSet: '789abcdef012',
324324
major: 2021,
325325
minor: 3,
326326
patch: '25',
@@ -497,12 +497,15 @@ describe('scrapeRecentOfficialUnityVersions', () => {
497497
});
498498

499499
describe('integration test (live)', () => {
500-
it.skipIf(process.env.CI === 'false')(
500+
it.skipIf(!process.env.CI)(
501501
'should successfully scrape real Unity releases page',
502502
async () => {
503503
// This test runs in CI only and validates the scraping logic against the real page
504-
const realFetch = (await import('node-fetch')).default;
505-
vi.mocked(fetch).mockImplementation(realFetch as any);
504+
// Import the actual fetch function from the installed package
505+
const { default: realFetchImpl } = await import('node-fetch');
506+
507+
// Replace the mocked fetch with the real implementation
508+
mockedFetch.mockImplementation(realFetchImpl as any);
506509

507510
const result = await scrapeRecentOfficialUnityVersions();
508511

0 commit comments

Comments
 (0)