mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-22 09:08:01 +01:00
Fixed react bundle getting exported when export is disabled
Caused by missing checks before react export. Affects issues: - #3384
This commit is contained in:
parent
ae85f39871
commit
c8d0cc91b6
@ -166,6 +166,12 @@ public class Exporter extends FileExporter {
|
||||
}
|
||||
|
||||
public void exportReact() throws ExportException {
|
||||
if (config.isFalse(ExportSettings.PLAYER_PAGES)
|
||||
&& config.isFalse(ExportSettings.SERVER_PAGE)
|
||||
&& config.isFalse(ExportSettings.PLAYERS_PAGE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Path toDirectory = config.getPageExportPath();
|
||||
|
||||
try {
|
||||
|
@ -19,6 +19,7 @@ package com.djrapitops.plan.delivery.export;
|
||||
import com.djrapitops.plan.PlanSystem;
|
||||
import com.djrapitops.plan.exceptions.ExportException;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.ExportSettings;
|
||||
import extension.FullSystemExtension;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
@ -28,12 +29,12 @@ import org.junit.jupiter.api.function.Executable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertAll;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@ExtendWith(FullSystemExtension.class)
|
||||
class ReactExporterTest {
|
||||
@ -50,6 +51,7 @@ class ReactExporterTest {
|
||||
|
||||
@Test
|
||||
void allReactFilesAreExported(PlanConfig config, Exporter exporter) throws ExportException, IOException {
|
||||
config.set(ExportSettings.SERVER_PAGE, true);
|
||||
Path exportPath = config.getPageExportPath();
|
||||
exporter.exportReact();
|
||||
|
||||
@ -65,4 +67,26 @@ class ReactExporterTest {
|
||||
.map(path -> (Executable) () -> assertTrue(filesExported.contains(path)))
|
||||
.toList());
|
||||
}
|
||||
|
||||
@Test
|
||||
void noReactFilesAreExported(PlanConfig config, Exporter exporter) throws ExportException, IOException {
|
||||
config.set(ExportSettings.PLAYER_PAGES, false);
|
||||
config.set(ExportSettings.SERVER_PAGE, false);
|
||||
config.set(ExportSettings.PLAYERS_PAGE, false);
|
||||
Path exportPath = config.getPageExportPath();
|
||||
Files.deleteIfExists(exportPath);
|
||||
|
||||
exporter.exportReact();
|
||||
|
||||
assertFalse(Files.exists(exportPath), () -> {
|
||||
try {
|
||||
return "Some files got exported: " + Files.list(exportPath)
|
||||
.map(path -> path.relativize(exportPath))
|
||||
.map(s -> s + "\n")
|
||||
.toList();
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user