Filter out fonts.gstatic.com from test logs

This should sort out ERR_NETWORK_CHANGED error that appears from time to time
This commit is contained in:
Aurora Lahtela 2023-01-22 13:12:36 +02:00
parent 4f0d15b320
commit e0d80cb3b4
3 changed files with 5 additions and 11 deletions

View File

@ -55,7 +55,7 @@ import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static com.djrapitops.plan.delivery.export.ExportTestUtilities.assertNoLogsExceptFaviconError;
/**
* This test class is for catching any JavaScript errors.
@ -166,16 +166,8 @@ class ExportJSErrorRegressionTest {
logs.addAll(driver.manage().logs().get(LogType.CLIENT).getAll());
logs.addAll(driver.manage().logs().get(LogType.BROWSER).getAll());
assertNoLogs(logs);
assertNoLogsExceptFaviconError(logs);
})
).collect(Collectors.toList());
}
private void assertNoLogs(List<LogEntry> logs) {
List<String> loggedLines = logs.stream()
.map(log -> "\n" + log.getLevel().getName() + " " + log.getMessage())
.filter(line -> !line.contains("favicon.ico"))
.toList();
assertTrue(loggedLines.isEmpty(), () -> "Browser console included " + loggedLines.size() + " logs: " + loggedLines);
}
}

View File

@ -63,6 +63,7 @@ public class ExportTestUtilities {
public static void assertNoLogs(List<LogEntry> logs) {
List<String> loggedLines = logs.stream()
.map(log -> "\n" + log.getLevel().getName() + " " + log.getMessage())
.filter(log -> !log.contains("fonts.gstatic.com"))
.toList();
assertTrue(loggedLines.isEmpty(), () -> "Browser console included " + loggedLines.size() + " logs: " + loggedLines);
}
@ -70,7 +71,7 @@ public class ExportTestUtilities {
public static void assertNoLogsExceptFaviconError(List<LogEntry> logs) {
List<String> loggedLines = logs.stream()
.map(log -> "\n" + log.getLevel().getName() + " " + log.getMessage())
.filter(log -> !log.contains("favicon.ico") && !log.contains("manifest.json"))
.filter(log -> !log.contains("favicon.ico") && !log.contains("manifest.json") && !log.contains("fonts.gstatic.com"))
.toList();
assertTrue(loggedLines.isEmpty(), () -> "Browser console included " + loggedLines.size() + " logs: " + loggedLines);
}

View File

@ -208,6 +208,7 @@ class JSErrorRegressionTest {
private void assertNoLogs(String testName, List<LogEntry> logs) {
assertTrue(logs.isEmpty(), () -> testName + "Browser console included " + logs.size() + " logs: " + logs.stream()
.map(log -> "\n" + log.getLevel().getName() + " " + log.getMessage())
.filter(log -> !log.contains("fonts.gstatic.com"))
.toList());
}
}