use of com.vaadin.flow.server.PwaConfiguration in project flow by vaadin.
the class TaskUpdateViteTest method usedSettings_matchThoseCreatedToSettingsFile.
@Test
public void usedSettings_matchThoseCreatedToSettingsFile() throws IOException {
TaskUpdateVite task = new TaskUpdateVite(temporaryFolder.getRoot(), "build");
task.execute();
File generatedConfigFile = new File(temporaryFolder.getRoot(), FrontendUtils.VITE_GENERATED_CONFIG);
String template = IOUtils.toString(generatedConfigFile.toURI(), StandardCharsets.UTF_8);
NodeTasks.Builder builder = new NodeTasks.Builder(Mockito.mock(Lookup.class), temporaryFolder.getRoot(), temporaryFolder.newFolder("generated"), temporaryFolder.newFolder("frontend"), "target");
TaskUpdateSettingsFile updateSettings = new TaskUpdateSettingsFile(builder, "theme", new PwaConfiguration());
updateSettings.execute();
File settings = new File(temporaryFolder.getRoot(), "target/" + DEV_SETTINGS_FILE);
JsonObject settingsJson = Json.parse(IOUtils.toString(settings.toURI(), StandardCharsets.UTF_8));
final Matcher matcher = Pattern.compile("settings\\.(?!json)([a-zA-z]*)").matcher(template);
StringBuilder faulty = new StringBuilder();
while (matcher.find()) {
if (!settingsJson.hasKey(matcher.group(1))) {
faulty.append(matcher.group(1)).append('\n');
}
}
Assert.assertTrue("Configuration uses settings keys\n" + faulty + "that are not generated in settings file.", faulty.toString().isEmpty());
}
use of com.vaadin.flow.server.PwaConfiguration in project flow by vaadin.
the class AbstractScannerPwaTest method should_findPwaOnAppShell.
@Test
public void should_findPwaOnAppShell() throws Exception {
PwaConfiguration pwaConfiguration = getPwaConfiguration(AppShellWithPwa.class);
assertEquals("PWA Application", pwaConfiguration.getAppName());
assertEquals("PWA", pwaConfiguration.getShortName());
assertEquals("Testing PWA", pwaConfiguration.getDescription());
assertEquals("minimal-ui", pwaConfiguration.getDisplay());
assertEquals("#eee", pwaConfiguration.getBackgroundColor());
assertEquals("#369", pwaConfiguration.getThemeColor());
assertEquals("pwa.png", pwaConfiguration.getIconPath());
assertEquals("appmanifest.json", pwaConfiguration.getManifestPath());
assertEquals("pwa.html", pwaConfiguration.getOfflinePath());
String[] expectedOfflineResources = { "pwa.js", "pwa.css" };
assertArrayEquals(expectedOfflineResources, pwaConfiguration.getOfflineResources().toArray());
}
use of com.vaadin.flow.server.PwaConfiguration in project flow by vaadin.
the class AbstractScannerPwaTest method should_returnDefaultConfiguration_When_NoAppShell.
@Test
public void should_returnDefaultConfiguration_When_NoAppShell() throws Exception {
PwaConfiguration pwaConfiguration = getPwaConfiguration(this.getClass());
assertEquals(PwaConfiguration.DEFAULT_NAME, pwaConfiguration.getAppName());
assertEquals("Flow PWA", pwaConfiguration.getShortName());
assertEquals("", pwaConfiguration.getDescription());
assertEquals(PwaConfiguration.DEFAULT_DISPLAY, pwaConfiguration.getDisplay());
assertEquals(PwaConfiguration.DEFAULT_BACKGROUND_COLOR, pwaConfiguration.getBackgroundColor());
assertEquals(PwaConfiguration.DEFAULT_THEME_COLOR, pwaConfiguration.getThemeColor());
assertEquals(PwaConfiguration.DEFAULT_ICON, pwaConfiguration.getIconPath());
assertEquals(PwaConfiguration.DEFAULT_PATH, pwaConfiguration.getManifestPath());
assertEquals(PwaConfiguration.DEFAULT_OFFLINE_PATH, pwaConfiguration.getOfflinePath());
String[] defaultOfflineResources = {};
assertArrayEquals(defaultOfflineResources, pwaConfiguration.getOfflineResources().toArray());
}
Aggregations