Browse Source

test: revert async changes

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

8
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 orginal: Promise<ProjectInfo> = projectInfoOp.extractProjectInfo(testProjectId.id); const original: 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([orginal, duplicate]).then(async arr => { await Promise.all([original, duplicate]).then(arr => {
const ignoredFields: Set<string> = new Set([ const ignoredFields: Set<string> = new Set([
'id', 'id',
'prefix', 'prefix',
@ -149,9 +149,7 @@ test.describe('Project operations', () => {
]); ]);
const orginalProjectInfo: ProjectInfo = arr[0]; const orginalProjectInfo: ProjectInfo = arr[0];
const duplicateProjectInfo: ProjectInfo = arr[1]; const duplicateProjectInfo: ProjectInfo = arr[1];
await expect( expect(deepCompare(orginalProjectInfo, duplicateProjectInfo, ignoredFields, ignoredKeys)).toBeTruthy();
await deepCompare(orginalProjectInfo, duplicateProjectInfo, ignoredFields, ignoredKeys)
).toBeTruthy();
}); });
// cleanup test-data // cleanup test-data

6
tests/playwright/tests/utils/objectCompareUtil.ts

@ -15,14 +15,14 @@
* @param breakAtFirstMismatch : default true. returns false on first field mismatch * @param breakAtFirstMismatch : default true. returns false on first field mismatch
* @returns * @returns
*/ */
export async function deepCompare( export function deepCompare(
obj1: any, obj1: any,
obj2: any, obj2: any,
ignoredFields?: Set<string>, ignoredFields?: Set<string>,
ignoredKeys?: Set<string>, ignoredKeys?: Set<string>,
keyId = '', keyId = '',
breakAtFirstMismatch = true breakAtFirstMismatch = true
): Promise<boolean> { ): boolean {
if (ignoredKeys !== undefined && ignoredKeys.has(keyId)) { if (ignoredKeys !== undefined && ignoredKeys.has(keyId)) {
return true; return true;
} }
@ -56,7 +56,7 @@ export async function deepCompare(
// console.log(`${keyId} ignored in comparison`) // console.log(`${keyId} ignored in comparison`)
} else { } else {
keyId = keyId + '.' + key; keyId = keyId + '.' + key;
if (!(await 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