| 
13 | 13 |  * See the License for the specific language governing permissions and  | 
14 | 14 |  * limitations under the License.  | 
15 | 15 |  */  | 
 | 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'  | 
16 | 20 | 
 
  | 
17 | 21 | describe('Dashboard build', () => {  | 
18 | 22 |   test('dashboard should have changes', async () => {  | 
19 | 23 |     // todo  | 
20 | 24 |   }, 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 | +    })  | 
23 | 89 |   }, 100000)  | 
24 | 90 | })  | 
0 commit comments