/server and /players pages back to tests

This commit is contained in:
Rsl1122 2019-05-03 17:48:41 +03:00
parent 71e21389fb
commit d2391755df

View File

@ -26,6 +26,9 @@ import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.locale.lang.ErrorPageLang; import com.djrapitops.plan.system.locale.lang.ErrorPageLang;
import com.djrapitops.plan.system.settings.config.PlanConfig; import com.djrapitops.plan.system.settings.config.PlanConfig;
import com.djrapitops.plan.system.settings.paths.WebserverSettings; import com.djrapitops.plan.system.settings.paths.WebserverSettings;
import com.djrapitops.plan.system.webserver.cache.PageId;
import com.djrapitops.plan.system.webserver.cache.ResponseCache;
import com.jayway.awaitility.Awaitility;
import extension.SeleniumExtension; import extension.SeleniumExtension;
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
@ -42,6 +45,7 @@ import utilities.mocks.PluginMockComponent;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
@ -62,6 +66,7 @@ class JSErrorRegressionTest {
public static PluginMockComponent component; public static PluginMockComponent component;
private static PlanSystem bukkitSystem; private static PlanSystem bukkitSystem;
private static UUID serverUUID;
@BeforeAll @BeforeAll
static void setUpClass(@TempDir Path tempDir) throws Exception { static void setUpClass(@TempDir Path tempDir) throws Exception {
@ -72,6 +77,7 @@ class JSErrorRegressionTest {
config.set(WebserverSettings.PORT, TEST_PORT_NUMBER); config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
bukkitSystem.enable(); bukkitSystem.enable();
serverUUID = bukkitSystem.getServerInfo().getServerUUID();
savePlayerData(); savePlayerData();
} }
@ -80,9 +86,9 @@ class JSErrorRegressionTest {
Database database = dbSystem.getDatabase(); Database database = dbSystem.getDatabase();
UUID uuid = TestConstants.PLAYER_ONE_UUID; UUID uuid = TestConstants.PLAYER_ONE_UUID;
database.executeTransaction(new PlayerRegisterTransaction(uuid, () -> 1000L, "name")); database.executeTransaction(new PlayerRegisterTransaction(uuid, () -> 1000L, "name"));
Session session = new Session(uuid, TestConstants.SERVER_UUID, 1000L, "world", "SURVIVAL"); Session session = new Session(uuid, serverUUID, 1000L, "world", "SURVIVAL");
session.endSession(11000L); session.endSession(11000L);
database.executeTransaction(new WorldNameStoreTransaction(TestConstants.SERVER_UUID, "world")); database.executeTransaction(new WorldNameStoreTransaction(serverUUID, "world"));
database.executeTransaction(new SessionEndTransaction(session)); database.executeTransaction(new SessionEndTransaction(session));
} }
@ -112,30 +118,30 @@ class JSErrorRegressionTest {
assertFalse(driver.getPageSource(), driver.getPageSource().contains(ErrorPageLang.NOT_PLAYED_404.getDefault())); assertFalse(driver.getPageSource(), driver.getPageSource().contains(ErrorPageLang.NOT_PLAYED_404.getDefault()));
} }
// @Test TODO Figure out why /network page is shown @Test
// void serverPageDoesNotHaveJavascriptErrors(WebDriver driver) { void serverPageDoesNotHaveJavascriptErrors(WebDriver driver) {
// System.out.println("Testing Server Page"); System.out.println("Testing Server Page");
// // Open the page that has refreshing info // Open the page that has refreshing info
// driver.get("http://localhost:" + TEST_PORT_NUMBER + "/server"); driver.get("http://localhost:" + TEST_PORT_NUMBER + "/server");
// assertFalse(driver.getPageSource(), driver.getPageSource().contains("500 Internal Error occurred")); assertFalse(driver.getPageSource(), driver.getPageSource().contains("500 Internal Error occurred"));
//
// // Wait until Plan caches analysis results
// Awaitility.await()
// .atMost(10, TimeUnit.SECONDS)
// .until(() -> ResponseCache.isCached(PageId.SERVER.of(TestConstants.SERVER_UUID)));
//
// // Open the page with analysis stuff
// SeleniumExtension.newTab(driver);
// driver.get("http://localhost:" + TEST_PORT_NUMBER + "/server");
// assertFalse(driver.getPageSource(), driver.getPageSource().contains("500 Internal Error occurred"));
// }
// @Test TODO Figure out why /network players page is shown // Wait until Plan caches analysis results
// void playersPageDoesNotHaveJavascriptErrors(WebDriver driver) { Awaitility.await()
// System.out.println("Testing Players Page"); .atMost(10, TimeUnit.SECONDS)
// driver.get("http://localhost:" + TEST_PORT_NUMBER + "/players"); .until(() -> ResponseCache.loadResponse(PageId.SERVER.of(serverUUID)) != null);
// assertFalse(driver.getPageSource(), driver.getPageSource().contains("500 Internal Error occurred"));
// } // Open the page with analysis stuff
SeleniumExtension.newTab(driver);
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/server");
assertFalse(driver.getPageSource(), driver.getPageSource().contains("500 Internal Error occurred"));
}
@Test
void playersPageDoesNotHaveJavascriptErrors(WebDriver driver) {
System.out.println("Testing Players Page");
driver.get("http://localhost:" + TEST_PORT_NUMBER + "/players");
assertFalse(driver.getPageSource(), driver.getPageSource().contains("500 Internal Error occurred"));
}
@Test @Test
void debugPageDoesNotHaveJavascriptErrors(WebDriver driver) { void debugPageDoesNotHaveJavascriptErrors(WebDriver driver) {