Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions src/main/java/testingbot/TestingBotBuildObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class TestingBotBuildObject implements Serializable {
private String testName;
private final boolean isPassed;
private String authHash;
private TestingbotTest test;
private String environmentName;

public TestingBotBuildObject(String sessionId, String className, String testName, boolean isPassed, String authHash, TestingbotTest test) {
Expand All @@ -20,7 +19,8 @@ public TestingBotBuildObject(String sessionId, String className, String testName
this.testName = testName;
this.isPassed = isPassed;
this.authHash = authHash;
this.test = test;
// TestingbotTest is only used here to derive the environment label; it is not stored (it is not
// marshalable under the JEP-200 class filter, and nothing reads it afterwards).
this.environmentName = test == null ? "" : test.getBrowser() + " | " + test.getOs();
}

Expand Down Expand Up @@ -81,20 +81,6 @@ public boolean getIsPassed() {
return isPassed;
}

/**
* @return the test
*/
public TestingbotTest getTest() {
return test;
}

/**
* @param test the test to set
*/
public void setTest(TestingbotTest test) {
this.test = test;
}

/**
* @return the authHash
*/
Expand Down
47 changes: 17 additions & 30 deletions src/main/java/testingbot/TestingBotTestEmbed.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@

import hudson.model.Run;
import jenkins.model.RunAction2;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.StaplerRequest2;
import org.kohsuke.stapler.StaplerResponse2;

import javax.servlet.ServletException;
import jakarta.servlet.ServletException;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

public class TestingBotTestEmbed implements RunAction2 {
private static final Logger logger = Logger.getLogger(TestingBotTestEmbed.class.getName());
private transient Run run;
private List<TestingBotBuildObject> ids;
private TestingBotBuildObject tbo;

public TestingBotTestEmbed(List<TestingBotBuildObject> ids) {
this.ids = ids;
Expand Down Expand Up @@ -48,43 +43,35 @@ public void onLoad(Run<?, ?> run) {
}

/**
*
* @param req Standard Request Object
* @param rsp Standard Response Object
* @throws IOException Unable to load show.jelly template
* @throws IOException Unable to load the view template
*/
@SuppressWarnings("unused") // used by stapler
public void doIndex(StaplerRequest req, StaplerResponse rsp)
public void doIndex(StaplerRequest2 req, StaplerResponse2 rsp)
throws IOException {
String sessionId = req.getParameter("sessionId");
for (TestingBotBuildObject tbo : this.ids) {
if (tbo.getSessionId().equals(sessionId)) {
this.tbo = tbo;
TestingBotBuildObject selected = null;
for (TestingBotBuildObject candidate : this.ids) {
if (candidate.getSessionId().equals(sessionId)) {
selected = candidate;
break;
}
}
if (this.tbo != null) {
try {
req.getView(this, "show.jelly").forward(req, rsp);
} catch (ServletException e) {
throw new IOException(e);
}
} else {
try {
req.getView(this, "index.jelly").forward(req, rsp);
} catch (ServletException e) {
throw new IOException(e);
}
// Pass the selection through the request (this action is shared across concurrent requests,
// so a per-instance field would let requests overwrite each other's selected session).
req.setAttribute("tbo", selected);
try {
req.getView(this, selected != null ? "show.jelly" : "index.jelly").forward(req, rsp);
} catch (ServletException e) {
throw new IOException(e);
}
}

public Run getRun() {
return run;
}

public TestingBotBuildObject getTbo() {
return tbo;
}

public List<TestingBotBuildObject> getSessionIds() {
return ids;
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/resources/testingbot/TestingBotTestEmbed/show.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
<st:include page="sidepanel.jelly" it="${it.run}" optional="true" />
</l:side-panel>
<l:main-panel>
<h1>${it.tbo.testName}</h1>
<a href="https://testingbot.com/tests/${it.tbo.sessionId}?auth=${it.tbo.authHash}&amp;ref=jenkins" target="_blank">View on TestingBot</a>
<j:set var="tbo" value="${request.getAttribute('tbo')}"/>
<h1>${tbo.testName}</h1>
<a href="https://testingbot.com/tests/${tbo.sessionId}?auth=${tbo.authHash}&amp;ref=jenkins" target="_blank">View on TestingBot</a>
<l:ajax>
<div>
<iframe src="https://testingbot.com/mini/?id=${it.tbo.sessionId}&amp;auth=${it.tbo.authHash}&amp;ref=jenkins" style="width: 100%; min-height: 100vh; border: none"></iframe>
<iframe src="https://testingbot.com/mini/?id=${tbo.sessionId}&amp;auth=${tbo.authHash}&amp;ref=jenkins" style="width: 100%; min-height: 100vh; border: none"></iframe>
</div>
</l:ajax>
</l:main-panel>
Expand Down