diff --git a/plugins/services/src/js/components/modals/EditServiceModal.js b/plugins/services/src/js/components/modals/EditServiceModal.js
index 1f7afed820..11a4fd6679 100644
--- a/plugins/services/src/js/components/modals/EditServiceModal.js
+++ b/plugins/services/src/js/components/modals/EditServiceModal.js
@@ -5,6 +5,7 @@ import EditFrameworkConfiguration
import CreateServiceModal
from "#PLUGINS/services/src/js/components/modals/CreateServiceModal";
import DCOSStore from "#SRC/js/stores/DCOSStore";
+import FullScreenModal from "#SRC/js/components/modals/FullScreenModal";
class EditServiceModal extends Component {
render() {
@@ -12,6 +13,10 @@ class EditServiceModal extends Component {
const serviceID = decodeURIComponent(id);
const service = DCOSStore.serviceTree.findItemById(serviceID);
+ if (!service) {
+ return ;
+ }
+
if (
service.getLabels().DCOS_PACKAGE_DEFINITION != null ||
service.getLabels().DCOS_PACKAGE_METADATA != null
diff --git a/plugins/services/src/js/components/modals/__tests__/EditServiceModal-test.js b/plugins/services/src/js/components/modals/__tests__/EditServiceModal-test.js
new file mode 100644
index 0000000000..ea4776d383
--- /dev/null
+++ b/plugins/services/src/js/components/modals/__tests__/EditServiceModal-test.js
@@ -0,0 +1,56 @@
+import React from "react";
+import { shallow } from "enzyme";
+
+jest.mock("#SRC/js/stores/DCOSStore");
+
+const DCOSStore = require("#SRC/js/stores/DCOSStore");
+const EditServiceModal = require("../EditServiceModal").default;
+
+describe("EditServiceModal", function() {
+ it("renders an empty modal if no service is found", function() {
+ DCOSStore.serviceTree = {
+ findItemById() {
+ return null;
+ }
+ };
+
+ const wrapper = shallow(
+
+ );
+ expect(wrapper.type().name).toBe("FullScreenModal");
+ });
+
+ it("renders an edit modal if the service has been created", function() {
+ DCOSStore.serviceTree = {
+ findItemById() {
+ return {
+ getLabels() {
+ return { DCOS_PACKAGE_DEFINITION: "some-value" };
+ }
+ };
+ }
+ };
+
+ const wrapper = shallow(
+
+ );
+ expect(wrapper.type().name).toBe("EditFrameworkConfiguration");
+ });
+
+ it("renders a create modal if the service has not been created", function() {
+ DCOSStore.serviceTree = {
+ findItemById() {
+ return {
+ getLabels() {
+ return { DCOS_PACKAGE_DEFINITION: null };
+ }
+ };
+ }
+ };
+
+ const wrapper = shallow(
+
+ );
+ expect(wrapper.type().name).toBe("CreateServiceModal");
+ });
+});