This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
The following commit(s) were added to refs/heads/develop by this push:
new e0c90cce AIRAVATA-3645 web components: Handle case where GRP id is set
to null
e0c90cce is described below
commit e0c90cceda75d680ee3fd61266042a2dba4eca4b
Author: Marcus Christie <[email protected]>
AuthorDate: Mon Aug 8 12:14:01 2022 -0400
AIRAVATA-3645 web components: Handle case where GRP id is set to null
---
.../js/web-components/store.js | 2 +-
.../tests/unit/web-components/store.spec.js | 60 ++++++++++++++++++++--
2 files changed, 57 insertions(+), 5 deletions(-)
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 1e1053d5..13224994 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 @@ export const actions = {
} 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 1b8346fa..b9e4a012 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 @@ const testAction = (
}
mutationCount++;
- if (mutationCount >= expectedMutations.length) {
+ checkIfDone();
+ };
+
+ const checkIfDone = () => {
+ if (
+ mutationCount >= expectedMutations.length &&
+ actionCount >= expectedActions.length
+ ) {
done();
}
};
@@ -55,9 +62,7 @@ const testAction = (
}
actionCount++;
- if (actionCount >= expectedActions.length) {
- done();
- }
+ checkIfDone();
return action.result;
};
@@ -881,3 +886,50 @@ test("updateTotalCPUCount: update nodeCount when
cpuPerNode > 0, but apply maxim
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,
+ });
+});