Browse Source

Test: import changes

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
test/pw-duplicate-check
Raju Udava 1 year ago
parent
commit
45d8828884
  1. 43
      tests/playwright/tests/db/projectOperations.spec.ts
  2. 50
      tests/playwright/tests/db/tableOperations.spec.ts
  3. 8
      tests/playwright/tests/utils/objectCompareUtil.ts

43
tests/playwright/tests/db/projectOperations.spec.ts

@ -107,9 +107,9 @@ test.describe('Project operations', () => {
const testProjectId = await projectList.list.find((p: any) => p.title === testProjectName); const testProjectId = await projectList.list.find((p: any) => p.title === testProjectName);
const dupeProjectId = await projectList.list.find((p: any) => p.title === dupeProjectName); const dupeProjectId = await projectList.list.find((p: any) => p.title === dupeProjectName);
const projectInfoOp: ProjectInfoApiUtil = new ProjectInfoApiUtil(context.token); const projectInfoOp: ProjectInfoApiUtil = new ProjectInfoApiUtil(context.token);
const original: Promise<ProjectInfo> = projectInfoOp.extractProjectInfo(testProjectId.id); const orginal: Promise<ProjectInfo> = projectInfoOp.extractProjectInfo(testProjectId.id);
const duplicate: Promise<ProjectInfo> = projectInfoOp.extractProjectInfo(dupeProjectId.id); const duplicate: Promise<ProjectInfo> = projectInfoOp.extractProjectInfo(dupeProjectId.id);
await Promise.all([original, duplicate]).then(arr => { await Promise.all([orginal, duplicate]).then(arr => {
const ignoredFields: Set<string> = new Set([ const ignoredFields: Set<string> = new Set([
'id', 'id',
'prefix', 'prefix',
@ -126,30 +126,31 @@ test.describe('Project operations', () => {
'updated_at', 'updated_at',
]); ]);
const ignoredKeys: Set<string> = new Set([ const ignoredKeys: Set<string> = new Set([
'.project.is_meta.id', '.project.id',
'.project.is_meta.title', '.project.title',
'.project.tables.0.table.id', '.project.tables.0.id',
'.project.tables.0.table.id.base_id', '.project.tables.0.base_id',
// below are potential bugs // below are potential bugs
'.project.is_meta.title.status', '.project.status',
'.project.tables.0.table.shares.views.0.view._ptn.ptype.tn', '.tables.0.views.0.view.tn',
'.project.tables.0.table.shares.views.0.view._ptn.ptype.tn._tn', '.tables.0.views.0.view.tn._tn',
'.project.tables.0.table.shares.views.0.view._ptn.ptype.tn._tn.table_meta.title', '.tables.0.views.0.view.title',
'.project.tables.0.1.table.shares.views.0.view._ptn.ptype.tn', '.tables.0.views.0.view._tn',
'.project.tables.0.1.table.shares.views.0.view._ptn.ptype.tn._tn', '.tables.1.views.0.view.title',
'.project.tables.0.1.table.shares.views.0.view._ptn.ptype.tn._tn.table_meta.title', '.tables.1.views.0.view.tn',
'.project.tables.0.1.2.table.shares.views.0.view._ptn.ptype.tn', '.tables.1.views.0.view._tn',
'.project.tables.0.1.2.table.shares.views.0.view._ptn.ptype.tn._tn', '.tables.1.views.0.view.tn._tn',
'.project.tables.0.1.2.table.shares.views.0.view._ptn.ptype.tn._tn.table_meta.title', '.tables.2.views.0.view.tn',
'.project.tables.bases.0.alias.config', '.tables.2.views.0.view._tn',
'.project.tables.bases.users.0.1.email.invite_token.main_roles.roles', '.tables.2.views.0.view.title',
'.project.tables.bases.users.0.1.2.email.invite_token.main_roles.roles', '.bases.0.config',
'.project.tables.bases.users.0.1.2.3.email.invite_token.main_roles.roles', '.users.1.roles',
'.users.2.roles',
]); ]);
const orginalProjectInfo: ProjectInfo = arr[0]; const orginalProjectInfo: ProjectInfo = arr[0];
const duplicateProjectInfo: ProjectInfo = arr[1]; const duplicateProjectInfo: ProjectInfo = arr[1];
expect(deepCompare(orginalProjectInfo, duplicateProjectInfo, ignoredFields, ignoredKeys)).toBeTruthy(); expect(deepCompare(orginalProjectInfo, duplicateProjectInfo, ignoredFields, ignoredKeys, '', false)).toBeTruthy();
}); });
// cleanup test-data // cleanup test-data

50
tests/playwright/tests/db/tableOperations.spec.ts

@ -79,14 +79,7 @@ test.describe('Table Operations', () => {
orginalTable, orginalTable,
duplicateTable, duplicateTable,
undefined, undefined,
new Set([ new Set(['.id', '.table_name', '.title', '.order', '.created_at', '.updated_at'])
'.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',
])
) )
).toBeTruthy(); ).toBeTruthy();
// check individual field values where values does not match as per design // 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(['created_at']),
new Set([ new Set([
'.table.id', '.table.id',
'.table.id.base_id.project_id.table_name', '.table.table_name',
'.table.id.base_id.project_id.table_name.title', '.table.title',
'.table.id.base_id.project_id.table_name.title.type.meta.schema.enabled.mm.tags.pinned.deleted.order', '.table.order',
'.table.id.base_id.project_id.table_name.title.type.meta.schema.enabled.mm.tags.pinned.deleted.order.created_at', '.table.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.updated_at',
'.table.shares.views.0.view.filters.sorts.firstPageData', '.views.0.view.ptn',
'.table.shares.views.webhooks.firstPageData.list.pageInfo.totalRows', '.views.0.view._ptn',
'.table.shares.views.0.view.ptn', '.views.0.view.ptn._ptn',
'.table.id.base_id.project_id.table_name.title.type.meta.schema.enabled.mm.tags.pinned.deleted.order.updated_at', '.views.0.view.ptn._ptn.ptype.tn',
'.table.shares.views.0.view.ptn._ptn', '.views.0.view.tn',
'.table.shares.views.0.view.ptn._ptn.ptype.tn', '.views.0.view._tn',
'.table.shares.views.0.view.ptn._ptn.ptype.tn._tn', '.views.0.view.id',
'.table.shares.views.0.view.ptn._ptn.ptype.tn._tn.table_meta.id', '.views.0.view.view.fk_view_id',
'.table.shares.views.0.view.ptn._ptn.ptype.tn._tn.table_meta.id.base_id.project_id.fk_model_id', '.views.0.view.view.updated_at',
'.table.shares.views.0.view.ptn._ptn.ptype.tn._tn.table_meta.id.base_id.project_id.fk_model_id.title', '.views.0.view.fk_model_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', '.views.0.view.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.meta.description.view.fk_view_id', '.views.0.view.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.base_id.project_id.uuid.updated_at', '.views.0.view.fk_view_id',
'.table.shares.views.webhooks.firstPageData.list.pageInfo.totalRows.page.pageSize.isFirstPage.isLastPage',
// Mismatch length key: // Mismatch length key:
'.table.shares.views.webhooks.firstPageData.list', '.firstPageData.list',
'.firstPageData.pageInfo',
'.views.0.firstPageData',
]) ])
) )
).toBeTruthy(); ).toBeTruthy();

8
tests/playwright/tests/utils/objectCompareUtil.ts

@ -20,9 +20,10 @@ export function deepCompare(
obj2: any, obj2: any,
ignoredFields?: Set<string>, ignoredFields?: Set<string>,
ignoredKeys?: Set<string>, ignoredKeys?: Set<string>,
keyId = '', rootKeyId = '',
breakAtFirstMismatch = true breakAtFirstMismatch = true
): boolean { ): boolean {
let keyId = rootKeyId;
if (ignoredKeys !== undefined && ignoredKeys.has(keyId)) { if (ignoredKeys !== undefined && ignoredKeys.has(keyId)) {
return true; return true;
} }
@ -51,11 +52,12 @@ export function deepCompare(
for (const key of keys1) { for (const key of keys1) {
if ( if (
(ignoredFields !== undefined && ignoredFields.has(key)) || (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`) // console.log(`${keyId} ignored in comparison`)
} else { } else {
keyId = keyId + '.' + key; keyId = rootKeyId + '.' + key;
if (!deepCompare(obj1[key], obj2[key], ignoredFields, ignoredKeys, keyId, breakAtFirstMismatch)) { if (!deepCompare(obj1[key], obj2[key], ignoredFields, ignoredKeys, keyId, breakAtFirstMismatch)) {
return !breakAtFirstMismatch; return !breakAtFirstMismatch;
// return false; // return false;

Loading…
Cancel
Save