From ce5f835829e541ec821e5e7f774a3f20134310fa Mon Sep 17 00:00:00 2001 From: lyf-coder <58352715+lyf-coder@users.noreply.github.com> Date: Sat, 5 Nov 2022 01:38:39 +0800 Subject: [PATCH] test(collection-manager): 20221104151410-update-collections-hidden test correct (#1042) fix new version test fail --- ...04151410-update-collections-hidden.test.ts | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/packages/plugins/collection-manager/src/__tests__/migrations/20221104151410-update-collections-hidden.test.ts b/packages/plugins/collection-manager/src/__tests__/migrations/20221104151410-update-collections-hidden.test.ts index 273b6ac326..f3b29d3332 100644 --- a/packages/plugins/collection-manager/src/__tests__/migrations/20221104151410-update-collections-hidden.test.ts +++ b/packages/plugins/collection-manager/src/__tests__/migrations/20221104151410-update-collections-hidden.test.ts @@ -45,12 +45,43 @@ describe('migration 20221104151410-update-collections-hidden test', () => { expect(result.length).toBe(1); expect(result[0].get('hidden')).toBeFalsy(); + // > 0.8.0-alpha.9 version up test + await db.getRepository('applicationVersion').update({ + filterByTk:1, + values: { + value: '0.8.0-alpha.10', + }, + }); const migration = new UpdateCollectionsHiddenMigration({ db } as MigrationContext); migration.context.app = app; await migration.up(); + let upResult = await db.getRepository('collections').find({ + filter: { + name: 'test', + }, + }); - const upResult = await db.getRepository('collections').find({ + expect(upResult[0].get('hidden')).toBeFalsy(); + + let hiddenResult = await db.getRepository('collections').find({ + filter: { + hidden: true, + }, + }); + expect(hiddenResult.length).toBe(0); + + + // <= 0.8.0-alpha.9 version up test + await db.getRepository('applicationVersion').update({ + filterByTk:1, + values: { + value: '0.8.0-alpha.9', + }, + }); + await migration.up(); + + upResult = await db.getRepository('collections').find({ filter: { name: 'test', }, @@ -58,7 +89,7 @@ describe('migration 20221104151410-update-collections-hidden test', () => { expect(upResult[0].get('hidden')).toBeTruthy(); - const hiddenResult = await db.getRepository('collections').find({ + hiddenResult = await db.getRepository('collections').find({ filter: { hidden: true, },