diff --git a/tests/playwright/tests/db/projectOperations.spec.ts b/tests/playwright/tests/db/projectOperations.spec.ts index 942ce6e61b..03054b5f49 100644 --- a/tests/playwright/tests/db/projectOperations.spec.ts +++ b/tests/playwright/tests/db/projectOperations.spec.ts @@ -126,30 +126,31 @@ test.describe('Project operations', () => { 'updated_at', ]); const ignoredKeys: Set = new Set([ - '.project.is_meta.id', - '.project.is_meta.title', - '.project.tables.0.table.id', - '.project.tables.0.table.id.base_id', + '.project.id', + '.project.title', + '.project.tables.0.id', + '.project.tables.0.base_id', // below are potential bugs - '.project.is_meta.title.status', - '.project.tables.0.table.shares.views.0.view._ptn.ptype.tn', - '.project.tables.0.table.shares.views.0.view._ptn.ptype.tn._tn', - '.project.tables.0.table.shares.views.0.view._ptn.ptype.tn._tn.table_meta.title', - '.project.tables.0.1.table.shares.views.0.view._ptn.ptype.tn', - '.project.tables.0.1.table.shares.views.0.view._ptn.ptype.tn._tn', - '.project.tables.0.1.table.shares.views.0.view._ptn.ptype.tn._tn.table_meta.title', - '.project.tables.0.1.2.table.shares.views.0.view._ptn.ptype.tn', - '.project.tables.0.1.2.table.shares.views.0.view._ptn.ptype.tn._tn', - '.project.tables.0.1.2.table.shares.views.0.view._ptn.ptype.tn._tn.table_meta.title', - '.project.tables.bases.0.alias.config', - '.project.tables.bases.users.0.1.email.invite_token.main_roles.roles', - '.project.tables.bases.users.0.1.2.email.invite_token.main_roles.roles', - '.project.tables.bases.users.0.1.2.3.email.invite_token.main_roles.roles', + '.project.status', + '.tables.0.views.0.view.tn', + '.tables.0.views.0.view.tn._tn', + '.tables.0.views.0.view.title', + '.tables.0.views.0.view._tn', + '.tables.1.views.0.view.title', + '.tables.1.views.0.view.tn', + '.tables.1.views.0.view._tn', + '.tables.1.views.0.view.tn._tn', + '.tables.2.views.0.view.tn', + '.tables.2.views.0.view._tn', + '.tables.2.views.0.view.title', + '.bases.0.config', + '.users.1.roles', + '.users.2.roles', ]); const orginalProjectInfo: ProjectInfo = arr[0]; const duplicateProjectInfo: ProjectInfo = arr[1]; - expect(deepCompare(orginalProjectInfo, duplicateProjectInfo, ignoredFields, ignoredKeys)).toBeTruthy(); + expect(deepCompare(orginalProjectInfo, duplicateProjectInfo, ignoredFields, ignoredKeys, '', false)).toBeTruthy(); }); // cleanup test-data diff --git a/tests/playwright/tests/db/tableOperations.spec.ts b/tests/playwright/tests/db/tableOperations.spec.ts index 8151b00279..21b72c62ff 100644 --- a/tests/playwright/tests/db/tableOperations.spec.ts +++ b/tests/playwright/tests/db/tableOperations.spec.ts @@ -79,14 +79,7 @@ test.describe('Table Operations', () => { orginalTable, duplicateTable, undefined, - new Set([ - '.id', - '.id.base_id.project_id.table_name', - '.id.base_id.project_id.table_name.title', - '.id.base_id.project_id.table_name.title.type.meta.schema.enabled.mm.tags.pinned.deleted.order', - '.id.base_id.project_id.table_name.title.type.meta.schema.enabled.mm.tags.pinned.deleted.order.created_at', - '.id.base_id.project_id.table_name.title.type.meta.schema.enabled.mm.tags.pinned.deleted.order.created_at.updated_at', - ]) + new Set(['.id', '.table_name', '.title', '.order', '.created_at', '.updated_at']) ) ).toBeTruthy(); // check individual field values where values does not match as per design @@ -120,28 +113,29 @@ test.describe('Table Operations', () => { new Set(['created_at']), new Set([ '.table.id', - '.table.id.base_id.project_id.table_name', - '.table.id.base_id.project_id.table_name.title', - '.table.id.base_id.project_id.table_name.title.type.meta.schema.enabled.mm.tags.pinned.deleted.order', - '.table.id.base_id.project_id.table_name.title.type.meta.schema.enabled.mm.tags.pinned.deleted.order.created_at', - '.table.id.base_id.project_id.table_name.title.type.meta.schema.enabled.mm.tags.pinned.deleted.order.created_at.updated_at', - '.table.shares.views.0.view.filters.sorts.firstPageData', - '.table.shares.views.webhooks.firstPageData.list.pageInfo.totalRows', - '.table.shares.views.0.view.ptn', - '.table.id.base_id.project_id.table_name.title.type.meta.schema.enabled.mm.tags.pinned.deleted.order.updated_at', - '.table.shares.views.0.view.ptn._ptn', - '.table.shares.views.0.view.ptn._ptn.ptype.tn', - '.table.shares.views.0.view.ptn._ptn.ptype.tn._tn', - '.table.shares.views.0.view.ptn._ptn.ptype.tn._tn.table_meta.id', - '.table.shares.views.0.view.ptn._ptn.ptype.tn._tn.table_meta.id.base_id.project_id.fk_model_id', - '.table.shares.views.0.view.ptn._ptn.ptype.tn._tn.table_meta.id.base_id.project_id.fk_model_id.title', - '.table.shares.views.0.view.ptn._ptn.ptype.tn._tn.table_meta.id.base_id.project_id.fk_model_id.title.type.is_default.show_system_fields.lock_type.uuid.password.show.order.updated_at', - '.table.shares.views.0.view.ptn._ptn.ptype.tn._tn.table_meta.id.base_id.project_id.fk_model_id.title.type.is_default.show_system_fields.lock_type.uuid.password.show.order.updated_at.meta.description.view.fk_view_id', - '.table.shares.views.0.view.ptn._ptn.ptype.tn._tn.table_meta.id.base_id.project_id.fk_model_id.title.type.is_default.show_system_fields.lock_type.uuid.password.show.order.updated_at.meta.description.view.fk_view_id.base_id.project_id.uuid.updated_at', - '.table.shares.views.webhooks.firstPageData.list.pageInfo.totalRows.page.pageSize.isFirstPage.isLastPage', + '.table.table_name', + '.table.title', + '.table.order', + '.table.created_at', + '.table.updated_at', + '.views.0.view.ptn', + '.views.0.view._ptn', + '.views.0.view.ptn._ptn', + '.views.0.view.ptn._ptn.ptype.tn', + '.views.0.view.tn', + '.views.0.view._tn', + '.views.0.view.id', + '.views.0.view.view.fk_view_id', + '.views.0.view.view.updated_at', + '.views.0.view.fk_model_id', + '.views.0.view.title', + '.views.0.view.updated_at', + '.views.0.view.fk_view_id', // Mismatch length key: - '.table.shares.views.webhooks.firstPageData.list', + '.firstPageData.list', + '.firstPageData.pageInfo', + '.views.0.firstPageData', ]) ) ).toBeTruthy(); diff --git a/tests/playwright/tests/utils/objectCompareUtil.ts b/tests/playwright/tests/utils/objectCompareUtil.ts index e6eb072499..44a01969c8 100644 --- a/tests/playwright/tests/utils/objectCompareUtil.ts +++ b/tests/playwright/tests/utils/objectCompareUtil.ts @@ -20,9 +20,10 @@ export function deepCompare( obj2: any, ignoredFields?: Set, ignoredKeys?: Set, - keyId = '', + rootKeyId = '', breakAtFirstMismatch = true ): boolean { + let keyId = rootKeyId; if (ignoredKeys !== undefined && ignoredKeys.has(keyId)) { return true; } @@ -51,11 +52,12 @@ export function deepCompare( for (const key of keys1) { if ( (ignoredFields !== undefined && ignoredFields.has(key)) || - key.endsWith(' List') /* temp hack to avoid fields like */ + key.endsWith(' List') /* temp hack to avoid fields like */ || + key.includes('___') ) { // console.log(`${keyId} ignored in comparison`) } else { - keyId = keyId + '.' + key; + keyId = rootKeyId + '.' + key; if (!deepCompare(obj1[key], obj2[key], ignoredFields, ignoredKeys, keyId, breakAtFirstMismatch)) { return !breakAtFirstMismatch; // return false;