Skip to content

Commit 21652bb

Browse files
committed
fix: logic fix for registerNewAppVersion
1 parent 2b27220 commit 21652bb

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/libs/e2e-test-utils/src/lib/appManager/register-new-app-version.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,19 @@ export async function registerNewAppVersion({
5959
existingAbilityMap.set(ability.abilityIpfsCid, ability.policyIpfsCids);
6060
});
6161

62-
// Check if we have the same number of abilities
63-
if (existingAbilityMap.size !== abilityIpfsCids.length) {
64-
// Different number of abilities, need to register new version; fall through to register new version
65-
} else {
62+
// Check if we have the same number of abilities and compare them
63+
if (existingAbilityMap.size === abilityIpfsCids.length) {
6664
// For each ability in the new version, check if it exists with the same policies
6765
const allMatch = abilityIpfsCids.every((abilityId, index) => {
6866
const existingPolicies = existingAbilityMap.get(abilityId);
69-
if (!existingPolicies) return false; // Ability doesn't exist in current version
67+
if (existingPolicies === undefined) return false; // Ability doesn't exist in current version
7068

7169
const newPolicies = abilityPolicies[index];
72-
if (!newPolicies) return false; // Handle undefined policies
70+
if (newPolicies === undefined) {
71+
throw new Error(
72+
`Parallel arrays are not in sync: abilityPolicies[${index}] is undefined for ability '${abilityId}'.`,
73+
);
74+
}
7375

7476
// Compare policy arrays (order-independent)
7577
if (existingPolicies.length !== newPolicies.length) return false;

0 commit comments

Comments
 (0)