ea17693e by Ean Schuessler

Fix McpTestScreen rendering by implementing missing webappName property in WebFacadeStub

1 parent e4ef25c5
......@@ -14,14 +14,9 @@
<set field="userId" from="ec.user?.userId ?: 'ANONYMOUS'"/>
<set field="sessionId" from="ec.web?.sessionId ?: 'NO_SESSION'"/>
<!-- Test different data access patterns -->
<entity-find entity-name="moqui.basic.Enumeration" list="enumerations" limit="5"/>
<entity-find entity-name="McpSession" list="mcpSessions" limit="5">
<econdition field-name="userId" from="userId"/>
</entity-find>
<!-- Test service calls -->
<service-call name="org.moqui.impl.SystemServices.ping" out-map="pingResult"/>
<service-call name="McpServices.mcp#Ping" out-map="pingContext"/>
<set field="pingResult" from="pingContext?.result"/>
<!-- Test permissions -->
<set field="hasAdminAccess" from="ec.user?.hasPermission('MCP_ADMIN')"/>
......@@ -30,7 +25,7 @@
<!-- Test context data -->
<set field="renderMode" from="sri.renderMode ?: 'unknown'"/>
<set field="screenPath" from="sri.screenPath ?: 'unknown'"/>
<set field="screenPath" from="sri.getActiveScreenPath()?.join('/') ?: 'unknown'"/>
<set field="webappName" from="ec.web?.webappName ?: 'unknown'"/>
<set field="locale" from="ec.user?.locale ?: 'en_US'"/>
</actions>
......@@ -81,9 +76,7 @@
<container style="test-section">
<label text="Data Access Tests" type="h2"/>
<container style="data-section">
<label text="System Ping Result: ${pingResult?.message ?: 'No response'}" type="p"/>
<label text="Enumerations Found: ${enumerations?.size() ?: 0}" type="p"/>
<label text="MCP Sessions Found: ${mcpSessions?.size() ?: 0}" type="p"/>
<label text="System Ping Result: ${pingResult?.status ?: 'No response'}" type="p"/>
</container>
</container>
......
......@@ -1457,6 +1457,7 @@ def startTime = System.currentTimeMillis()
def screenTest = new org.moqui.mcp.CustomScreenTestImpl(ec.ecfi)
.rootScreen(rootScreen)
.renderMode(renderMode ? renderMode : "html")
.auth(ec.user.username) // Propagate current user to the test renderer
ec.logger.info("MCP Screen Execution: ScreenTest object created: ${screenTest?.getClass()?.getSimpleName()}")
......
......@@ -55,6 +55,7 @@ class CustomScreenTestImpl implements McpScreenTest {
protected String servletContextPath = null
protected String webappName = null
protected boolean skipJsonSerialize = false
protected String authUsername = null
protected static final String hostname = "localhost"
long renderCount = 0, errorCount = 0, totalChars = 0, startTime = System.currentTimeMillis()
......@@ -116,6 +117,8 @@ class CustomScreenTestImpl implements McpScreenTest {
@Override McpScreenTest baseLinkUrl(String baseLinkUrl) { this.baseLinkUrl = baseLinkUrl; return this }
@Override McpScreenTest servletContextPath(String scp) { this.servletContextPath = scp; return this }
@Override McpScreenTest skipJsonSerialize(boolean skip) { this.skipJsonSerialize = skip; return this }
McpScreenTest auth(String username) { this.authUsername = username; return this }
@Override
McpScreenTest webappName(String wan) {
......@@ -213,6 +216,8 @@ class CustomScreenTestImpl implements McpScreenTest {
ExecutionContextFactoryImpl ecfi = sti.ecfi
ExecutionContextImpl localEci = ecfi.getEci()
String username = localEci.userFacade.getUsername()
if (!username && sti.authUsername) username = sti.authUsername
org.apache.shiro.subject.Subject loginSubject = localEci.userFacade.getCurrentSubject()
boolean authzDisabled = localEci.artifactExecutionFacade.getAuthzDisabled()
CustomScreenTestRenderImpl stri = this
......
......@@ -125,6 +125,12 @@ class WebFacadeStub implements WebFacade {
return withPort ? "localhost:8080" : "localhost"
}
String getWebappName() {
// Return a default webappName since this is a stub implementation
// In real Moqui, this would come from the webapp configuration
return "mcp"
}
@Override
String getPathInfo() {
if (logger.isDebugEnabled()) {
......@@ -176,6 +182,8 @@ class WebFacadeStub implements WebFacade {
@Override
String getSessionToken() { return "test-token" }
String getSessionId() { return httpSession?.getId() }
@Override
ServletContext getServletContext() {
......