diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index c51b7f3540..4b8676e761 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -629,22 +629,22 @@ Cypress.Commands.add("DeleteAPI", apiname => { ); }); -Cypress.Commands.add("CreateModal", () => { - cy.get(modalWidgetPage.selectModal).click(); - cy.get(modalWidgetPage.createModalButton).click({ force: true }); - cy.get(modalWidgetPage.controlModalType) - .find(".bp3-button") - .click({ force: true }) - .get("ul.bp3-menu") - .children() - .contains("Alert Modal") - .click(); - cy.get(modalWidgetPage.controlModalType) - .find(".bp3-button > .bp3-button-text") - .should("have.text", "Alert Modal"); - cy.get(commonlocators.editPropCrossButton).click(); - cy.reload(); -}); +// Cypress.Commands.add("CreateModal", () => { +// cy.get(modalWidgetPage.selectModal).click(); +// cy.get(modalWidgetPage.createModalButton).click({ force: true }); +// cy.get(modalWidgetPage.controlModalType) +// .find(".bp3-button") +// .click({ force: true }) +// .get("ul.bp3-menu") +// .children() +// .contains("Alert Modal") +// .click(); +// cy.get(modalWidgetPage.controlModalType) +// .find(".bp3-button > .bp3-button-text") +// .should("have.text", "Alert Modal"); +// cy.get(commonlocators.editPropCrossButton).click(); +// cy.reload(); +// }); Cypress.Commands.add("createModal", (modalType, ModalName) => { cy.get(widgetsPage.buttonOnClick) @@ -686,6 +686,7 @@ Cypress.Commands.add("createModal", (modalType, ModalName) => { .contains("Center") .click(); cy.assertPageSave(); + cy.get(".bp3-overlay-backdrop").click({ force: true }); }); Cypress.Commands.add("CheckWidgetProperties", checkboxCss => { diff --git a/app/client/src/components/designSystems/blueprint/ModalComponent.tsx b/app/client/src/components/designSystems/blueprint/ModalComponent.tsx index 03206a6636..ae9ca09cff 100644 --- a/app/client/src/components/designSystems/blueprint/ModalComponent.tsx +++ b/app/client/src/components/designSystems/blueprint/ModalComponent.tsx @@ -15,7 +15,7 @@ const Container = styled.div<{ z-index: ${props => props.zIndex || 2 - 1}; } position: fixed; - top: ${props => props.theme.headerHeight}; + top: 0; right: 0; bottom: 0; height: 100vh; diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PluginServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PluginServiceTest.java index 5973799c2e..3f2d2918b4 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PluginServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PluginServiceTest.java @@ -11,9 +11,9 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.boot.test.mock.mockito.SpyBean; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringRunner; import reactor.core.publisher.Mono; @@ -28,13 +28,18 @@ import static org.mockito.ArgumentMatchers.eq; @RunWith(SpringRunner.class) @SpringBootTest @Slf4j -@DirtiesContext +/* + * The ClassMode BEFORE_EACH_TEST_METHOD is required to get the spy pluginService to reset before each test. Else + * the spies for each test interfere with each other. This increases the test time but unfortunately, that seems to be + * the only solution for now. + */ +@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD) public class PluginServiceTest { @MockBean PluginExecutor pluginExecutor; - @Autowired + @SpyBean PluginService pluginService; @Before @@ -54,23 +59,18 @@ public class PluginServiceTest { }) .verifyComplete(); } - - /* - * The Mockito.spy used in the tests below is not implemented correctly. The spies seem to be sharing data across the - * tests. Refer to: https://dzone.com/articles/how-to-mock-spring-bean-version-2 on implementing this correctly - */ // The datasource form config is mandatory for plugins. Hence we expect an error when that file is not present @Test public void getPluginFormWithNullFormConfig() { - PluginService pluginSpy = Mockito.spy(pluginService); - Mockito.when(pluginSpy.loadPluginResource(Mockito.anyString(), eq("form.json"))) + Mockito.when(pluginService.loadPluginResource(Mockito.anyString(), eq("form.json"))) .thenReturn(Mono.error(new AppsmithException(AppsmithError.PLUGIN_LOAD_FORM_JSON_FAIL))); - Mockito.when(pluginSpy.loadPluginResource(Mockito.anyString(), eq("editor.json"))) + Mockito.when(pluginService.loadPluginResource(Mockito.anyString(), eq("editor.json"))) .thenReturn(Mono.error(new AppsmithException(AppsmithError.PLUGIN_LOAD_FORM_JSON_FAIL))); - Mono formConfig = pluginSpy.getFormConfig("random-plugin-id"); + Mono formConfig = pluginService.getFormConfig("random-plugin-id"); + StepVerifier.create(formConfig) .expectError(AppsmithException.class) .verify(); @@ -79,17 +79,15 @@ public class PluginServiceTest { // The editor form config is not mandatory for plugins. The function should return successfully even if it's not present @Test public void getPluginFormWithNullEditorConfig() { - PluginService pluginSpy = Mockito.spy(pluginService); - Map formMap = new HashMap(); formMap.put("form", new Object()); - Mockito.when(pluginSpy.loadPluginResource(Mockito.anyString(), eq("form.json"))) + Mockito.when(pluginService.loadPluginResource(Mockito.anyString(), eq("form.json"))) .thenReturn(Mono.just(formMap)); - Mockito.when(pluginSpy.loadPluginResource(Mockito.anyString(), eq("editor.json"))) + Mockito.when(pluginService.loadPluginResource(Mockito.anyString(), eq("editor.json"))) .thenReturn(Mono.error(new AppsmithException(AppsmithError.PLUGIN_LOAD_FORM_JSON_FAIL))); - Mono formConfig = pluginSpy.getFormConfig("random-plugin-id"); + Mono formConfig = pluginService.getFormConfig("random-plugin-id"); StepVerifier.create(formConfig) .assertNext(form -> { assertThat(form).isNotNull(); @@ -98,4 +96,27 @@ public class PluginServiceTest { }) .verifyComplete(); } + + @Test + public void getPluginFormValid() { + Map formMap = new HashMap(); + formMap.put("form", new Object()); + + Map editorMap = new HashMap(); + editorMap.put("editor", new Object()); + + Mockito.when(pluginService.loadPluginResource(Mockito.anyString(), eq("form.json"))) + .thenReturn(Mono.just(formMap)); + Mockito.when(pluginService.loadPluginResource(Mockito.anyString(), eq("editor.json"))) + .thenReturn(Mono.just(editorMap)); + + Mono formConfig = pluginService.getFormConfig("random-plugin-id"); + StepVerifier.create(formConfig) + .assertNext(form -> { + assertThat(form).isNotNull(); + assertThat(form.get("form")).isNotNull(); + assertThat(form.get("editor")).isNotNull(); + }) + .verifyComplete(); + } }