AIRAVATA-3645 web components: Handle case where GRP id is set to null
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/store.js b/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/store.js
index 1e1053d..1322499 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/store.js
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/store.js
@@ -264,7 +264,7 @@
} else {
commit("updateGroupResourceProfileId", { groupResourceProfileId });
}
- if (oldValue !== groupResourceProfileId) {
+ if (groupResourceProfileId && oldValue !== groupResourceProfileId) {
await dispatch("loadApplicationDeployments");
await dispatch("applyGroupResourceProfile");
}
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/tests/unit/web-components/store.spec.js b/django_airavata/apps/workspace/static/django_airavata_workspace/tests/unit/web-components/store.spec.js
index 1b8346f..b9e4a01 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/tests/unit/web-components/store.spec.js
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/tests/unit/web-components/store.spec.js
@@ -38,7 +38,14 @@
}
mutationCount++;
- if (mutationCount >= expectedMutations.length) {
+ checkIfDone();
+ };
+
+ const checkIfDone = () => {
+ if (
+ mutationCount >= expectedMutations.length &&
+ actionCount >= expectedActions.length
+ ) {
done();
}
};
@@ -55,9 +62,7 @@
}
actionCount++;
- if (actionCount >= expectedActions.length) {
- done();
- }
+ checkIfDone();
return action.result;
};
@@ -881,3 +886,50 @@
done,
});
});
+
+test("updateGroupResourceProfileId: test normal case where updated to a GRP id", (done) => {
+ const mockGetters = {
+ groupResourceProfileId: "old_grp_id",
+ };
+ const groupResourceProfileId = "new_grp_id";
+ const expectedMutations = [
+ {
+ type: "updateGroupResourceProfileId",
+ payload: { groupResourceProfileId },
+ },
+ ];
+ const expectedActions = [
+ { type: "loadApplicationDeployments" },
+ { type: "applyGroupResourceProfile" },
+ ];
+ testAction(actions.updateGroupResourceProfileId, {
+ payload: {
+ groupResourceProfileId,
+ },
+ getters: mockGetters,
+ expectedMutations,
+ done,
+ expectedActions,
+ });
+});
+
+test("updateGroupResourceProfileId: test case where GRP id is updated to null", (done) => {
+ const mockGetters = {
+ groupResourceProfileId: "old_grp_id",
+ };
+ const groupResourceProfileId = null;
+ const expectedMutations = [
+ {
+ type: "updateGroupResourceProfileId",
+ payload: { groupResourceProfileId },
+ },
+ ];
+ testAction(actions.updateGroupResourceProfileId, {
+ payload: {
+ groupResourceProfileId,
+ },
+ getters: mockGetters,
+ expectedMutations,
+ done,
+ });
+});