mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-24 21:29:00 +00:00
38 lines
1.5 KiB
Java
38 lines
1.5 KiB
Java
package nu.marginalia.livecapture;
|
|
|
|
import org.junit.jupiter.api.Assertions;
|
|
import org.junit.jupiter.api.BeforeAll;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.testcontainers.containers.GenericContainer;
|
|
import org.testcontainers.junit.jupiter.Testcontainers;
|
|
import org.testcontainers.utility.DockerImageName;
|
|
|
|
import java.net.URI;
|
|
|
|
@Testcontainers
|
|
public class BrowserlessClientTest {
|
|
static GenericContainer<?> container = new GenericContainer<>(DockerImageName.parse("browserless/chrome")).withExposedPorts(3000);
|
|
|
|
@BeforeAll
|
|
public static void setup() {
|
|
container.start();
|
|
}
|
|
|
|
@Test
|
|
public void testContent() throws Exception {
|
|
try (var client = new BrowserlessClient(URI.create("http://" + container.getHost() + ":" + container.getMappedPort(3000)))) {
|
|
var content = client.content("https://www.marginalia.nu/", BrowserlessClient.GotoOptions.defaultValues());
|
|
Assertions.assertNotNull(content, "Content should not be null");
|
|
Assertions.assertFalse(content.isBlank(), "Content should not be empty");
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void testScreenshot() throws Exception {
|
|
try (var client = new BrowserlessClient(URI.create("http://" + container.getHost() + ":" + container.getMappedPort(3000)))) {
|
|
var screenshot = client.screenshot("https://www.marginalia.nu/", BrowserlessClient.GotoOptions.defaultValues(), BrowserlessClient.ScreenshotOptions.defaultValues());
|
|
Assertions.assertNotNull(screenshot, "Screenshot should not be null");
|
|
}
|
|
}
|
|
}
|