Merge branch 'release' of github.com:appsmithorg/appsmith into release
This commit is contained in:
commit
a17d7a4a8f
2
.github/workflows/client.yml
vendored
2
.github/workflows/client.yml
vendored
|
|
@ -138,7 +138,7 @@ jobs:
|
||||||
--env APPSMITH_REDIS_URL=redis://localhost:6379 \
|
--env APPSMITH_REDIS_URL=redis://localhost:6379 \
|
||||||
--env APPSMITH_ENCRYPTION_PASSWORD=password \
|
--env APPSMITH_ENCRYPTION_PASSWORD=password \
|
||||||
--env APPSMITH_ENCRYPTION_SALT=salt \
|
--env APPSMITH_ENCRYPTION_SALT=salt \
|
||||||
appsmith/appsmith-server:latest
|
appsmith/appsmith-server:release
|
||||||
|
|
||||||
- name: Installing Yarn serve
|
- name: Installing Yarn serve
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
|
|
@ -80,4 +80,6 @@ This section has moved here: https://facebook.github.io/create-react-app/docs/de
|
||||||
|
|
||||||
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
|
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
|
||||||
|
|
||||||
|
### Cypress tests via Github Actions
|
||||||
|
|
||||||
|
The cypress tests run via Github actions pull the `release` Docker image of the server to run as a service locally. This is to ensure that we don't face any network flakiness during tests.
|
||||||
|
|
@ -308,7 +308,7 @@ public class PluginServiceImpl extends BaseService<PluginRepository, Plugin, Str
|
||||||
// Remove this pluginId from the cache so it is tried again next time.
|
// Remove this pluginId from the cache so it is tried again next time.
|
||||||
formCache.remove(pluginId)
|
formCache.remove(pluginId)
|
||||||
)
|
)
|
||||||
.onErrorMap(Exceptions::unwrap)
|
.onErrorReturn(new HashMap())
|
||||||
.cache();
|
.cache();
|
||||||
|
|
||||||
Mono<Map> resourceMono = Mono.zip(formMono, editorMono)
|
Mono<Map> resourceMono = Mono.zip(formMono, editorMono)
|
||||||
|
|
@ -391,7 +391,7 @@ public class PluginServiceImpl extends BaseService<PluginRepository, Plugin, Str
|
||||||
.getResourceAsStream(resourcePath);
|
.getResourceAsStream(resourcePath);
|
||||||
|
|
||||||
if (resourceAsStream == null) {
|
if (resourceAsStream == null) {
|
||||||
return Mono.error(new AppsmithException(AppsmithError.PLUGIN_LOAD_FORM_JSON_FAIL, "Form Resource not found"));
|
return Mono.error(new AppsmithException(AppsmithError.PLUGIN_LOAD_FORM_JSON_FAIL, "form resource " + resourcePath + " not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,14 @@ import com.appsmith.external.models.ActionConfiguration;
|
||||||
import com.appsmith.external.models.ActionExecutionResult;
|
import com.appsmith.external.models.ActionExecutionResult;
|
||||||
import com.appsmith.external.models.DatasourceConfiguration;
|
import com.appsmith.external.models.DatasourceConfiguration;
|
||||||
import com.appsmith.external.plugins.PluginExecutor;
|
import com.appsmith.external.plugins.PluginExecutor;
|
||||||
|
import com.appsmith.server.exceptions.AppsmithError;
|
||||||
|
import com.appsmith.server.exceptions.AppsmithException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
|
|
@ -16,7 +19,11 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
import reactor.test.StepVerifier;
|
import reactor.test.StepVerifier;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
|
|
@ -27,6 +34,9 @@ public class PluginServiceTest {
|
||||||
@MockBean
|
@MockBean
|
||||||
PluginExecutor pluginExecutor;
|
PluginExecutor pluginExecutor;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
PluginService pluginService;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
Mockito.when(this.pluginExecutor.execute(Mockito.any(), Mockito.any(), Mockito.any()))
|
Mockito.when(this.pluginExecutor.execute(Mockito.any(), Mockito.any(), Mockito.any()))
|
||||||
|
|
@ -44,4 +54,48 @@ public class PluginServiceTest {
|
||||||
})
|
})
|
||||||
.verifyComplete();
|
.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")))
|
||||||
|
.thenReturn(Mono.error(new AppsmithException(AppsmithError.PLUGIN_LOAD_FORM_JSON_FAIL)));
|
||||||
|
Mockito.when(pluginSpy.loadPluginResource(Mockito.anyString(), eq("editor.json")))
|
||||||
|
.thenReturn(Mono.error(new AppsmithException(AppsmithError.PLUGIN_LOAD_FORM_JSON_FAIL)));
|
||||||
|
|
||||||
|
Mono<Map> formConfig = pluginSpy.getFormConfig("random-plugin-id");
|
||||||
|
StepVerifier.create(formConfig)
|
||||||
|
.expectError(AppsmithException.class)
|
||||||
|
.verify();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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")))
|
||||||
|
.thenReturn(Mono.just(formMap));
|
||||||
|
Mockito.when(pluginSpy.loadPluginResource(Mockito.anyString(), eq("editor.json")))
|
||||||
|
.thenReturn(Mono.error(new AppsmithException(AppsmithError.PLUGIN_LOAD_FORM_JSON_FAIL)));
|
||||||
|
|
||||||
|
Mono<Map> formConfig = pluginSpy.getFormConfig("random-plugin-id");
|
||||||
|
StepVerifier.create(formConfig)
|
||||||
|
.assertNext(form -> {
|
||||||
|
assertThat(form).isNotNull();
|
||||||
|
assertThat(form.get("form")).isNotNull();
|
||||||
|
assertThat(form.get("editor")).isNull();
|
||||||
|
})
|
||||||
|
.verifyComplete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user