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

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

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

Loading…
Cancel
Save