-
-
Notifications
You must be signed in to change notification settings - Fork 113
Expand file tree
/
Copy pathofflineMode.test.ts
More file actions
67 lines (58 loc) · 2.55 KB
/
Copy pathofflineMode.test.ts
File metadata and controls
67 lines (58 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* @file offlineMode.test.ts
* @description Test file for validating the behavior of the new offline mode feature.
*
* This test verifies that:
* 1. The offlineMode parameter is correctly passed to the configuration
* 2. The OfflineRepository is used when offlineMode is enabled
* 3. Local tag and diff retrieval works correctly
*
* To run this test:
* npm run test-offline
*
* Note: This test requires a local git repository with tags to work properly.
*/
import {mergeConfiguration, resolveConfiguration} from '../../src/utils.js'
import {ReleaseNotesBuilder} from '../../src/releaseNotesBuilder.js'
import {OfflineRepository} from '../../src/repositories/OfflineRepository.js'
import {jest} from '@jest/globals'
jest.setTimeout(180000)
// This test validates the behavior of the new offline mode
test('Test offline mode functionality', async () => {
// Define the configuration file to use
const configuration = mergeConfiguration(undefined, resolveConfiguration('', 'configs/configuration_commit.json'))
// Set offlineMode to true in the configuration
configuration.offlineMode = true
// Create an instance of OfflineRepository
const offlineRepository = new OfflineRepository( '.')
const releaseNotesBuilder = new ReleaseNotesBuilder(
null, // The base url used for the API requests (not needed for offline mode)
offlineRepository, // Use the OfflineRepository implementation
'.', // Root path to the checked out sources
'mikepenz', // The owner of the repo to test
'release-changelog-builder-action', // The repository name - using this repo itself for the test
null, // fromTag - will be resolved automatically
null, // toTag - will be resolved automatically
false, // includeOpen - not supported in offline mode
false, // failOnError
false, // ignorePrePrerelease
false, // fetchViaCommits - not needed in offline mode
false, // fetchReviewers - not supported in offline mode
false, // fetchReleaseInformation
false, // fetchReviews - not supported in offline mode
'COMMIT', // mode - must be COMMIT for offline mode
false, // exportCache
false, // exportOnly
null, // cache
configuration // The configuration to use
)
// Build the changelog
const changeLog = await releaseNotesBuilder.build()
// Verify that a changelog was generated
expect(changeLog).toBeDefined()
expect(changeLog).not.toBe("- no changes")
expect(changeLog?.length).toBeGreaterThan(0)
// Log the changelog for inspection
console.log('Generated changelog in offline mode:')
console.log(changeLog)
})