mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-22 17:18:40 +01:00
Ignore React Router Flag warning in logs during tests
This commit is contained in:
parent
d341c5b04a
commit
2c1087ba2b
@ -64,19 +64,22 @@ public class ExportTestUtilities {
|
|||||||
public static void assertNoLogs(List<LogEntry> logs, String endpoint) {
|
public static void assertNoLogs(List<LogEntry> logs, String endpoint) {
|
||||||
List<String> loggedLines = logs.stream()
|
List<String> loggedLines = logs.stream()
|
||||||
.map(log -> "\n" + log.getLevel().getName() + " " + log.getMessage())
|
.map(log -> "\n" + log.getLevel().getName() + " " + log.getMessage())
|
||||||
.filter(log -> !StringUtils.containsAny(log,
|
.filter(ExportTestUtilities::ignoredLogLines).toList();
|
||||||
"fonts.gstatic.com", "fonts.googleapis.com", "cdn.jsdelivr.net"
|
|
||||||
)).toList();
|
|
||||||
assertTrue(loggedLines.isEmpty(), () -> "Loading " + endpoint + ", Browser console included " + loggedLines.size() + " logs: " + loggedLines);
|
assertTrue(loggedLines.isEmpty(), () -> "Loading " + endpoint + ", Browser console included " + loggedLines.size() + " logs: " + loggedLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean ignoredLogLines(String log) {
|
||||||
|
return !StringUtils.containsAny(log,
|
||||||
|
"fonts.gstatic.com", "fonts.googleapis.com", "cdn.jsdelivr.net", "manifest.json",
|
||||||
|
"React Router Future Flag Warning" // TODO remove after update to react-router-dom v7
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public static void assertNoLogsExceptFaviconError(List<LogEntry> logs) {
|
public static void assertNoLogsExceptFaviconError(List<LogEntry> logs) {
|
||||||
List<String> loggedLines = logs.stream()
|
List<String> loggedLines = logs.stream()
|
||||||
.map(log -> "\n" + log.getLevel().getName() + " " + log.getMessage())
|
.map(log -> "\n" + log.getLevel().getName() + " " + log.getMessage())
|
||||||
.filter(log -> !log.contains("favicon.ico")
|
.filter(ExportTestUtilities::ignoredLogLines)
|
||||||
&& !log.contains("manifest.json")
|
.filter(log -> !log.contains("favicon.ico"))
|
||||||
&& !log.contains("fonts.gstatic.com")
|
|
||||||
&& !log.contains("fonts.googleapis.com"))
|
|
||||||
.toList();
|
.toList();
|
||||||
assertTrue(loggedLines.isEmpty(), () -> "Browser console included " + loggedLines.size() + " logs: " + loggedLines);
|
assertTrue(loggedLines.isEmpty(), () -> "Browser console included " + loggedLines.size() + " logs: " + loggedLines);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ import java.nio.file.Path;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static com.djrapitops.plan.delivery.export.ExportTestUtilities.assertNoLogs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test class is for catching any JavaScript errors.
|
* This test class is for catching any JavaScript errors.
|
||||||
@ -140,7 +140,7 @@ class JSErrorRegressionTest {
|
|||||||
logs.addAll(driver.manage().logs().get(LogType.CLIENT).getAll());
|
logs.addAll(driver.manage().logs().get(LogType.CLIENT).getAll());
|
||||||
logs.addAll(driver.manage().logs().get(LogType.BROWSER).getAll());
|
logs.addAll(driver.manage().logs().get(LogType.BROWSER).getAll());
|
||||||
|
|
||||||
assertNoLogs("'" + address + "',", logs);
|
assertNoLogs(logs, address);
|
||||||
} finally {
|
} finally {
|
||||||
locale.clear(); // Reset locale after test
|
locale.clear(); // Reset locale after test
|
||||||
}
|
}
|
||||||
@ -170,7 +170,7 @@ class JSErrorRegressionTest {
|
|||||||
logs.addAll(driver.manage().logs().get(LogType.CLIENT).getAll());
|
logs.addAll(driver.manage().logs().get(LogType.CLIENT).getAll());
|
||||||
logs.addAll(driver.manage().logs().get(LogType.BROWSER).getAll());
|
logs.addAll(driver.manage().logs().get(LogType.BROWSER).getAll());
|
||||||
|
|
||||||
assertNoLogs("Page link '" + address + "'->'" + href + "' issue: ", logs);
|
assertNoLogs(logs, "Page link '" + address + "'->'" + href + "'");
|
||||||
System.out.println("'" + address + "' has link to " + href);
|
System.out.println("'" + address + "' has link to " + href);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -190,12 +190,4 @@ class JSErrorRegressionTest {
|
|||||||
return getLinks(driver, attempt + 1);
|
return getLinks(driver, attempt + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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") && !log.contains("fonts.googleapis.com"))
|
|
||||||
.toList());
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user