Skip to content

Commit

Permalink
fix: shorten file names for selenium video recording
Browse files Browse the repository at this point in the history
  • Loading branch information
gschlueter-jaconi committed Sep 9, 2022
1 parent 3c192ca commit 61227ec
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/integrationTest/java/io/jaconi/morp/SeleniumIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;

import java.io.File;
import java.time.Duration;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -49,8 +50,9 @@ static class Config {
.withNetwork(containerSetup.getNetwork())
.withNetworkAliases("chrome")
.withCapabilities(new ChromeOptions())
.withStartupTimeout(Duration.ofSeconds(30));
//.withRecordingMode(BrowserWebDriverContainer.VncRecordingMode.RECORD_ALL, new File("./build/"));
.withStartupTimeout(Duration.ofSeconds(30))
.withRecordingMode(BrowserWebDriverContainer.VncRecordingMode.SKIP, new File("./build/"))
.withRecordingFileFactory(new TruncatedRecordingFileFactory());

protected RemoteWebDriver driver;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.jaconi.morp;

import org.testcontainers.containers.DefaultRecordingFileFactory;
import org.testcontainers.containers.VncRecordingContainer;

import java.io.File;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

import static org.apache.commons.lang3.StringUtils.substringAfter;
import static org.apache.commons.lang3.StringUtils.substringBefore;

public class TruncatedRecordingFileFactory extends DefaultRecordingFileFactory {

@Override
public File recordingFileForTest(File vncRecordingDirectory, String prefix, boolean succeeded) {
return super.recordingFileForTest(vncRecordingDirectory, transformPrefix(prefix), succeeded);
}

@Override
public File recordingFileForTest(File vncRecordingDirectory, String prefix, boolean succeeded, VncRecordingContainer.VncRecordingFormat recordingFormat) {
return super.recordingFileForTest(vncRecordingDirectory, transformPrefix(prefix), succeeded, recordingFormat);
}

private String transformPrefix(String prefix) {
var decodedPrefix = URLDecoder.decode(prefix, StandardCharsets.UTF_8);

decodedPrefix = substringAfter(decodedPrefix,"/");
decodedPrefix = substringBefore(decodedPrefix, "(") + substringAfter(decodedPrefix, ")");

return URLEncoder.encode(decodedPrefix, StandardCharsets.UTF_8);
}
}

0 comments on commit 61227ec

Please sign in to comment.