Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style cleanup #946

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
tab_width = 100 # don't use tabs!
trim_trailing_whitespace = true

[*.{js,ts,yml}]
indent_size = 2
4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
203742c5f9106f5467f9d188cba80bbb2548df9e
a7a1df303a23742e422a371acab3fac81be46c78
09add7ee75270e23fea56ed6e8a6b0e1749faccb
07433d2d2b3b64d6a99eb2336845b78f8f46b2cc
380 changes: 187 additions & 193 deletions build.gradle.kts

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions frontend/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
{
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"react"
],
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
"plugin:anti-trojan-source/recommended"
],
"plugins": [
"@typescript-eslint",
"react"
],
"rules": {
"semi": "warn"
},
"settings": {
"react": {
"version": "detect"
}
},
"rules": {
"semi": "warn"
}
}

14 changes: 7 additions & 7 deletions frontend/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import { defineConfig } from 'cypress'

export default defineConfig({
"reporter": "cypress-multi-reporters",
"reporterOptions": {
"configFile": "reporter-config.json"
},
"requestTimeout": 80000,
"screenshotsFolder": "../build/reports/cypress/screenshots",
"videosFolder": "../build/reports/cypress/videos",
e2e: {
"viewportHeight": 1080,
"viewportWidth": 1920
"e2e": {
"baseUrl": "https://localhost:8443",
"supportFile" : false,
},
"requestTimeout": 80000,
"viewportHeight": 1080,
"viewportWidth": 1920,
"env": {
"username": "user",
"password": "password"
},
"reporterOptions": {
"configFile": "reporter-config.json"
}
})
36 changes: 18 additions & 18 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{
"name": "jumpstart",
"version": "0.1.0",
"private": true,
"proxy": "https://localhost:8443",
"scripts": {
"start": "vite",
"build": "tsc && vite build",
"test": "vitest run",
"cypress-open": "cypress open",
"cypress-run": "rm -rf ../build/reports/cypress || true && cypress run"
"version": "0.1.0",
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"dependencies": {
"@date-io/core": "2.17.0",
Expand Down Expand Up @@ -52,16 +57,11 @@
"vite": "4.4.7",
"vitest": "0.33.0"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
"scripts": {
"build": "tsc && vite build",
"cypress-open": "cypress open",
"cypress-run": "rm -rf ../build/reports/cypress || true && cypress run",
"start": "vite",
"test": "vitest run"
}
}
26 changes: 13 additions & 13 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "react-jsx",
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
]
},
"include": [
"src"
Expand Down
5 changes: 2 additions & 3 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import path from "path";

// https://vitejs.dev/config/
export default defineConfig({
clearScreen: false,
plugins: [react()],
build: {
outDir: "build",
},
plugins: [react()],
clearScreen: false,
server: {
port: 3000,
proxy: {
Expand All @@ -29,4 +29,3 @@ export default defineConfig({
},
},
});

Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

@SpringBootApplication
public class JumpstartApplication {
static {
// Ensure UTC is the default timezone so all date/time handling is done using UTC consistently
TimeZone.setDefault(TimeZone.getTimeZone(ZoneOffset.UTC));
}
static {
// Ensure UTC is the default timezone so all date/time handling is done using UTC consistently
TimeZone.setDefault(TimeZone.getTimeZone(ZoneOffset.UTC));
}

@SuppressWarnings("java:S4823") // false positive; see https://jira.sonarsource.com/browse/SONARJAVA-2906
public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@Controller
public class HomeController {
@GetMapping(value = "/")
@GetMapping(value = "/")
public String index() {
return "forward:index.html";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@
@Configuration
public class FixedUsernamePasswordSecurityConfiguration {

@Bean
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
public SecurityFilterChain filterChain(final @NonNull HttpSecurity http) throws Exception {
return
http
.authorizeHttpRequests(authorizeHttpRequests -> authorizeHttpRequests
.anyRequest()
.authenticated())
.formLogin(withDefaults())
.httpBasic(withDefaults())
.build();
}
@Bean
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
public SecurityFilterChain filterChain(final @NonNull HttpSecurity http) throws Exception {
return
http
.authorizeHttpRequests(authorizeHttpRequests -> authorizeHttpRequests
.anyRequest()
.authenticated())
.formLogin(withDefaults())
.httpBasic(withDefaults())
.build();
}

@Bean
public InMemoryUserDetailsManager userDetailsService() {
@SuppressWarnings("deprecation")
final UserDetails user = User.withDefaultPasswordEncoder()
.username("user")
.password("password")
.roles("USER")
.build();
return new InMemoryUserDetailsManager(user);
}
@Bean
public InMemoryUserDetailsManager userDetailsService() {
@SuppressWarnings("deprecation")
final UserDetails user = User.withDefaultPasswordEncoder()
.username("user")
.password("password")
.roles("USER")
.build();
return new InMemoryUserDetailsManager(user);
}

}
86 changes: 43 additions & 43 deletions src/test/java/com/integralblue/demo/jumpstart/CypressTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,52 +29,52 @@
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"spring.datasource.url=${internal.datasource.url}&TC_REUSABLE=true"})
@Slf4j
/* default */ class CypressTest {
//see: https://candrews.integralblue.com/2021/08/cypress-testing-integrated-with-gradle-and-spring-boot/
//see: https://candrews.integralblue.com/2021/08/cypress-testing-integrated-with-gradle-and-spring-boot/

@LocalServerPort
private int port;
@LocalServerPort
private int port;

private static String cypressVersion;
private static String cypressVersion;

@BeforeAll
/* default */ static void beforeAll() throws Exception {
cypressVersion = getCypressVersion();
log.info("Tests will run using Cypress version {}", cypressVersion);
}
@BeforeAll
/* default */ static void beforeAll() throws Exception {
cypressVersion = getCypressVersion();
log.info("Tests will run using Cypress version {}", cypressVersion);
}

@Test
/* default */ void testCypress() throws Exception {
Testcontainers.exposeHostPorts(port); // allow the container to access the running web application
try (GenericContainer<?> container = new GenericContainer<>("cypress/included:" + cypressVersion)) {
container.addFileSystemBind(Path.of(".").toAbsolutePath().toString(), "/src", BindMode.READ_WRITE, SelinuxContext.SHARED);
container
.withLogConsumer(new Slf4jLogConsumer(log))
.withEnv("CYPRESS_baseUrl", String.format("https://%s:%d", GenericContainer.INTERNAL_HOST_HOSTNAME, port))
.withWorkingDirectory("/src/frontend")
.withStartupCheckStrategy(
new OneShotStartupCheckStrategy().withTimeout(Duration.ofHours(1))
).start();
assertThat(container.getLogs()).contains("All specs passed!");
}
}
@Test
/* default */ void testCypress() throws Exception {
Testcontainers.exposeHostPorts(port); // allow the container to access the running web application
try (GenericContainer<?> container = new GenericContainer<>("cypress/included:" + cypressVersion)) {
container.addFileSystemBind(Path.of(".").toAbsolutePath().toString(), "/src", BindMode.READ_WRITE, SelinuxContext.SHARED);
container
.withLogConsumer(new Slf4jLogConsumer(log))
.withEnv("CYPRESS_baseUrl", String.format("https://%s:%d", GenericContainer.INTERNAL_HOST_HOSTNAME, port))
.withWorkingDirectory("/src/frontend")
.withStartupCheckStrategy(
new OneShotStartupCheckStrategy().withTimeout(Duration.ofHours(1))
).start();
assertThat(container.getLogs()).contains("All specs passed!");
}
}

/** Get the installed version of Cypress.
*
* This approach ensures that as the version of Cypress specified in package management changes,
* this tests will always use the same version.
* @return installed version of Cypress.
* @throws Exception if something goes wrong
*/
private static String getCypressVersion() throws Exception {
String cmd = "./gradlew";
if (System.getProperty("os.name").startsWith("Win")) {
cmd = "./gradlew.bat";
}
final Process process = Runtime.getRuntime().exec(new String[]{cmd, "npmCypressVersion"}, null, new File("."));
Assert.state(process.waitFor() == 0,"Cypress version command did not complete successfully");
final String output = StreamUtils.copyToString(process.getInputStream(), StandardCharsets.UTF_8);
final Matcher matcher = Pattern.compile("Cypress package version: (?<version>\\d++(?:\\.\\d++)++)").matcher(output);
Assert.state(matcher.find(), "Could not determine Cypress version from command output. Output: " + output);
return matcher.group("version");
}
/** Get the installed version of Cypress.
*
* This approach ensures that as the version of Cypress specified in package management changes,
* this tests will always use the same version.
* @return installed version of Cypress.
* @throws Exception if something goes wrong
*/
private static String getCypressVersion() throws Exception {
String cmd = "./gradlew";
if (System.getProperty("os.name").startsWith("Win")) {
cmd = "./gradlew.bat";
}
final Process process = Runtime.getRuntime().exec(new String[]{cmd, "npmCypressVersion"}, null, new File("."));
Assert.state(process.waitFor() == 0,"Cypress version command did not complete successfully");
final String output = StreamUtils.copyToString(process.getInputStream(), StandardCharsets.UTF_8);
final Matcher matcher = Pattern.compile("Cypress package version: (?<version>\\d++(?:\\.\\d++)++)").matcher(output);
Assert.state(matcher.find(), "Could not determine Cypress version from command output. Output: " + output);
return matcher.group("version");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

@SpringBootTest
/* default */ class JumpstartApplicationTests {
@Autowired
private JumpstartApplication application;
@Autowired
private JumpstartApplication application;

@Test
/* default */ void contextLoads() {
assertThat(application).isNotNull();
// do nothing; this test just ensure that the Spring context loads
}
@Test
/* default */ void contextLoads() {
assertThat(application).isNotNull();
// do nothing; this test just ensure that the Spring context loads
}
}
Loading