Skip to content

Commit a973000

Browse files
committed
refactor: add a test checking that resolvers are not called with empty version when building dashboard with added/removed packages
1 parent 553e290 commit a973000

File tree

5 files changed

+124
-2
lines changed

5 files changed

+124
-2
lines changed

test/dashboards.test.ts

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,78 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
import { describe, test, expect, jest } from '@jest/globals'
17+
import { LocalRegistry } from './helpers/registry'
18+
import { BUILD_TYPE, VERSION_STATUS } from '../src/consts'
19+
import { Editor } from './helpers/editor'
1620

1721
describe('Dashboard build', () => {
1822
test('dashboard should have changes', async () => {
1923
// todo
2024
}, 100000)
21-
test('changelog of dashboards should have changes', async () => {
22-
// todo
25+
test('Resolvers should not be called for empty versions when building changelog for dashboard that has added removed packages', async () => {
26+
const pckg1Id = 'dashboards/pckg1'
27+
const pckg2Id = 'dashboards/pckg2'
28+
29+
await LocalRegistry.openPackage(pckg1Id).publish(pckg1Id, {
30+
version: 'v1',
31+
packageId: pckg1Id,
32+
files: [{ fileId: 'v1.yaml' }],
33+
})
34+
35+
await LocalRegistry.openPackage(pckg2Id).publish(pckg2Id, {
36+
version: 'v2',
37+
packageId: pckg2Id,
38+
files: [{ fileId: 'v2.yaml' }],
39+
})
40+
41+
const dashboard = LocalRegistry.openPackage('dashboards/dashboard')
42+
await dashboard.publish(dashboard.packageId, {
43+
packageId: 'dashboards/dashboard',
44+
version: 'v1',
45+
apiType: 'rest',
46+
refs: [
47+
{ refId: pckg1Id, version: 'v1' },
48+
],
49+
})
50+
51+
await dashboard.publish(dashboard.packageId, {
52+
packageId: 'dashboards/dashboard',
53+
version: 'v2',
54+
apiType: 'rest',
55+
refs: [
56+
{ refId: pckg2Id, version: 'v2' },
57+
],
58+
})
59+
60+
const editor = new Editor(dashboard.packageId, {
61+
version: 'v2',
62+
packageId: dashboard.packageId,
63+
previousVersionPackageId: dashboard.packageId,
64+
previousVersion: 'v1',
65+
buildType: BUILD_TYPE.CHANGELOG,
66+
status: VERSION_STATUS.RELEASE,
67+
})
68+
const versionResolverSpy = jest.spyOn(editor.registry as LocalRegistry, 'versionResolver')
69+
const versionDocumentsResolverSpy = jest.spyOn(editor.registry as LocalRegistry, 'versionDocumentsResolver')
70+
const rawDocumentResolverSpy = jest.spyOn(editor.registry as LocalRegistry, 'rawDocumentResolver')
71+
72+
await editor.run()
73+
74+
// versionResolver(version, packageId)
75+
versionResolverSpy.mock.calls.forEach(args => {
76+
// args: [packageId = '', version]
77+
expect(args[1]).toBeTruthy()
78+
})
79+
80+
// versionDocumentsResolver(version, packageId)
81+
versionDocumentsResolverSpy.mock.calls.forEach(args => {
82+
expect(args[0]).toBeTruthy()
83+
})
84+
85+
// rawDocumentResolver(version, packageId, slug)
86+
rawDocumentResolverSpy.mock.calls.forEach(args => {
87+
expect(args[0]).toBeTruthy()
88+
})
2389
}, 100000)
2490
})
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
openapi: "3.0.0"
2+
info:
3+
title: some test
4+
version: 0.1.0
5+
paths:
6+
/some/path1:
7+
summary: some path item summary
8+
description: some path item description
9+
get:
10+
summary: some operation summary
11+
description: some operation description
12+
responses:
13+
'200':
14+
description: some response description
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
openapi: "3.0.0"
2+
info:
3+
title: some test
4+
version: 0.1.0
5+
paths:
6+
/some/path1:
7+
summary: some path item summary
8+
description: some path item description
9+
get:
10+
summary: some operation summary
11+
description: changed some operation description
12+
responses:
13+
'200':
14+
description: some response description
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
openapi: "3.0.0"
2+
info:
3+
title: some test
4+
version: 0.1.0
5+
paths:
6+
/some/path2:
7+
summary: some path item summary
8+
description: some path item description
9+
get:
10+
summary: some operation summary
11+
description: some operation description
12+
responses:
13+
'200':
14+
description: some response description
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
openapi: "3.0.0"
2+
info:
3+
title: some test
4+
version: 0.1.0
5+
paths:
6+
/some/path2:
7+
summary: some path item summary
8+
description: some path item description
9+
get:
10+
summary: some operation summary
11+
description: changed some operation description
12+
responses:
13+
'200':
14+
description: some response description

0 commit comments

Comments
 (0)