Skip to content

Commit 8e6b6c4

Browse files
authored
Merge pull request #6 from bitcoder/improve_frontend
Improve frontend
2 parents 24bf466 + 833d1a6 commit 8e6b6c4

File tree

6 files changed

+129
-20
lines changed

6 files changed

+129
-20
lines changed

pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>org.springframework.boot</groupId>
88
<artifactId>spring-boot-starter-parent</artifactId>
9-
<version>3.2.2</version>
9+
<version>3.5.7</version>
1010
<relativePath /> <!-- lookup parent from repository -->
1111
</parent>
1212
<groupId>com.sergiofreire.xray.tutorials</groupId>
@@ -19,12 +19,12 @@
1919
<!-- the following lines were needed because for vscode -->
2020
<maven.compiler.source>${java.version}</maven.compiler.source>
2121
<maven.compiler.target>${java.version}</maven.compiler.target>
22-
<junit-jupiter.version>5.10.2</junit-jupiter.version>
23-
<xray-junit-extensions.version>0.7.3</xray-junit-extensions.version>
24-
<xray-maven-plugin.version>0.8.0</xray-maven-plugin.version>
25-
<maven-failsafe-plugin.version>3.2.5</maven-failsafe-plugin.version>
26-
<maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
27-
<jacoco.version>0.8.13</jacoco.version>
22+
<junit-jupiter.version>5.14.1</junit-jupiter.version>
23+
<xray-junit-extensions.version>0.9.0</xray-junit-extensions.version>
24+
<xray-maven-plugin.version>0.9.0</xray-maven-plugin.version>
25+
<maven-failsafe-plugin.version>3.5.4</maven-failsafe-plugin.version>
26+
<maven-surefire-plugin.version>3.5.4</maven-surefire-plugin.version>
27+
<jacoco.version>0.8.14</jacoco.version>
2828
<unit.coverage.file>${project.build.directory}/jacoco-output/jacoco-unit-tests.exec</unit.coverage.file>
2929
<it.coverage.file>${project.build.directory}/jacoco-output/jacoco-it-tests.exec</it.coverage.file>
3030
<merged.coverage.file>${project.build.directory}/jacoco-output/merged.exec</merged.coverage.file>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package com.sergiofreire.xray.tutorials.springboot.boundary;
22

3+
import org.springframework.stereotype.Controller;
34
import org.springframework.web.bind.annotation.GetMapping;
4-
import org.springframework.web.bind.annotation.RestController;
55

6-
@RestController
6+
@Controller
77
public class IndexController {
88

99
@GetMapping("/")
1010
public String index() {
11-
return "Welcome to this amazing website!";
11+
return "index";
1212
}
1313

1414
}
Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,58 @@
1-
<!DOCTYPE HTML>
2-
<html xmlns:th="http://www.thymeleaf.org" lang="en">
3-
<head>
4-
<title>Getting Started: Serving Web Content</title>
5-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
1+
<!DOCTYPE html>
2+
<html lang="en" xmlns:th="http://www.thymeleaf.org">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="description" content="A simple Thymeleaf web page example saying hello to a user." />
8+
<meta name="robots" content="index, follow" />
9+
10+
<title>Hello Page</title>
11+
12+
<!-- Preconnect for faster font loading -->
13+
<link rel="preconnect" href="https://fonts.googleapis.com" />
14+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
15+
16+
<!-- Accessible, performant font -->
17+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">
18+
19+
<!-- Minimal inline CSS (fast load, high contrast) -->
20+
<style>
21+
body {
22+
font-family: 'Inter', system-ui, sans-serif;
23+
margin: 0;
24+
padding: 2rem;
25+
background-color: #ffffff;
26+
color: #111827;
27+
font-size: 1.125rem;
28+
line-height: 1.6;
29+
}
30+
main {
31+
max-width: 600px;
32+
margin: auto;
33+
text-align: center;
34+
}
35+
h1 {
36+
font-size: 2rem;
37+
color: #1d4ed8;
38+
margin-bottom: 1rem;
39+
}
40+
p {
41+
margin: 0;
42+
}
43+
</style>
644
</head>
45+
746
<body>
8-
<p th:text="|Hello, ${name}!|" />
47+
<main>
48+
<h1>Hello!</h1>
49+
<p th:text="|Hello, ${name}!|">Hello, Guest!</p>
50+
</main>
51+
52+
<!-- Lightweight script placeholder (deferred for performance) -->
53+
<script defer>
54+
// Example: Lighthouse likes scripts to be deferred
55+
console.info("Page loaded successfully.");
56+
</script>
957
</body>
10-
</html>
58+
</html>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!DOCTYPE html>
2+
<html lang="en" xmlns:th="http://www.thymeleaf.org">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="description" content="A simple Thymeleaf web page example saying hello to a user." />
8+
<meta name="robots" content="index, follow" />
9+
10+
<title>Hello Page</title>
11+
12+
<!-- Preconnect for faster font loading -->
13+
<link rel="preconnect" href="https://fonts.googleapis.com" />
14+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
15+
16+
<!-- Accessible, performant font -->
17+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">
18+
19+
<!-- Minimal inline CSS (fast load, high contrast) -->
20+
<style>
21+
body {
22+
font-family: 'Inter', system-ui, sans-serif;
23+
margin: 0;
24+
padding: 2rem;
25+
background-color: #ffffff;
26+
color: #111827;
27+
font-size: 1.125rem;
28+
line-height: 1.6;
29+
}
30+
main {
31+
max-width: 600px;
32+
margin: auto;
33+
text-align: center;
34+
}
35+
h1 {
36+
font-size: 2rem;
37+
color: #1d4ed8;
38+
margin-bottom: 1rem;
39+
}
40+
p {
41+
margin: 0;
42+
}
43+
</style>
44+
</head>
45+
46+
<body>
47+
<main>
48+
<h1>Welcome to this amazing website!</h1>
49+
</main>
50+
51+
<!-- Lightweight script placeholder (deferred for performance) -->
52+
<script defer>
53+
// Example: Lighthouse likes scripts to be deferred
54+
console.info("Page loaded successfully.");
55+
</script>
56+
</body>
57+
</html>

src/test/java/com/sergiofreire/xray/tutorials/springboot/IndexControllerIT.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.springframework.beans.factory.annotation.Autowired;
55
import org.springframework.boot.test.context.SpringBootTest;
66
import org.springframework.boot.test.web.client.TestRestTemplate;
7+
import org.springframework.http.HttpStatus;
78
import org.springframework.http.ResponseEntity;
89
import static org.assertj.core.api.Assertions.assertThat;
910

@@ -18,6 +19,9 @@ class IndexControllerIT {
1819
void getWelcomeMessage() throws Exception {
1920
ResponseEntity<String> response = template.getForEntity("/", String.class);
2021

21-
assertThat(response.getBody()).isEqualTo("Welcome to this amazing website!");
22+
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
23+
assertThat(response.getHeaders().getContentType()).toString().equals("text/html;charset=UTF-8");
24+
// che
25+
assertThat(response.getBody()).contains("Welcome to this amazing website!");
2226
}
2327
}

src/test/java/com/sergiofreire/xray/tutorials/springboot/IndexControllerMockedIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.sergiofreire.xray.tutorials.springboot;
22

3-
import static org.hamcrest.Matchers.equalTo;
3+
import static org.hamcrest.Matchers.containsString;
44
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
55
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
66
import org.junit.jupiter.api.Test;
@@ -30,6 +30,6 @@ class IndexControllerMockedIT {
3030
void getWelcomeMessage() throws Exception {
3131
mvc.perform(MockMvcRequestBuilders.get("/").accept(MediaType.TEXT_PLAIN))
3232
.andExpect(status().isOk())
33-
.andExpect(content().string(equalTo("Welcome to this amazing website!")));
33+
.andExpect(content().string(containsString("Welcome to this amazing website!")));
3434
}
3535
}

0 commit comments

Comments
 (0)