๐ (dashboard): Move Notifications section above Organisations
Changes
2 files changed, +46 -15
MODIFY
src/main/resources/templates/HomeResource/dashboard.html
+15 -15
@@ -27,21 +27,6 @@
27
27
{/if}
28
28
</section>
29
29
30
-{#if !orgs.isEmpty()}
31
-<section class="dashboard-section">
32
- <h2>Organisations</h2>
33
- <table>
34
- <tr><th>Organisation</th><th>Your role</th></tr>
35
- {#for membership in orgs}
36
- <tr class="row-link">
37
- <td class="cell-link"><a class="mono" href="/orgs/{membership.organisation.name}"><span class="av-fallback">{membership.organisation.name.charAt(0)}</span> {membership.organisation.name}</a></td>
38
- <td><span class="badge">{membership.role.name().toLowerCase()}</span></td>
39
- </tr>
40
- {/for}
41
- </table>
42
-</section>
43
-{/if}
44
-
45
30
<section class="dashboard-section">
46
31
<h2>Notifications</h2>
47
32
{#if notifications.isEmpty()}
@@ -60,6 +45,21 @@
60
45
{/if}
61
46
</section>
62
47
48
+{#if !orgs.isEmpty()}
49
+<section class="dashboard-section">
50
+ <h2>Organisations</h2>
51
+ <table>
52
+ <tr><th>Organisation</th><th>Your role</th></tr>
53
+ {#for membership in orgs}
54
+ <tr class="row-link">
55
+ <td class="cell-link"><a class="mono" href="/orgs/{membership.organisation.name}"><span class="av-fallback">{membership.organisation.name.charAt(0)}</span> {membership.organisation.name}</a></td>
56
+ <td><span class="badge">{membership.role.name().toLowerCase()}</span></td>
57
+ </tr>
58
+ {/for}
59
+ </table>
60
+</section>
61
+{/if}
62
+
63
63
<section class="dashboard-section">
64
64
<h2>All repositories</h2>
65
65
<table>
MODIFY
src/test/java/de/workaround/web/DashboardTest.java
+31 -0
@@ -4,7 +4,9 @@
4
4
5
5
import org.junit.jupiter.api.Test;
6
6
7
+import de.workaround.account.OrganisationService;
7
8
import de.workaround.git.GitRepositoryService;
9
+import de.workaround.model.Organisation;
8
10
import de.workaround.model.Repository;
9
11
import de.workaround.model.User;
10
12
import io.quarkus.test.junit.QuarkusTest;
@@ -29,6 +31,9 @@
29
31
@Inject
30
32
User.Repo userRepo;
31
33
34
+ @Inject
35
+ OrganisationService organisations;
36
+
32
37
@Test
33
38
@TestSecurity(user = "dash-alice")
34
39
void authenticatedHomeRendersThreeSections()
@@ -62,6 +67,26 @@
62
67
}
63
68
64
69
@Test
70
+ @TestSecurity(user = "dash-order")
71
+ void notificationsSectionAppearsBeforeOrganisations()
72
+ {
73
+ User user = persistUser("dash-order");
74
+ createOrg(user);
75
+
76
+ String body = given()
77
+ .when().get("/")
78
+ .then().statusCode(200)
79
+ .extract().body().asString();
80
+
81
+ int notifications = body.indexOf("<h2>Notifications</h2>");
82
+ int organisations = body.indexOf("<h2>Organisations</h2>");
83
+ org.junit.jupiter.api.Assertions.assertTrue(notifications >= 0, "Notifications section missing");
84
+ org.junit.jupiter.api.Assertions.assertTrue(organisations >= 0, "Organisations section missing");
85
+ org.junit.jupiter.api.Assertions.assertTrue(notifications < organisations,
86
+ "Notifications section must come before Organisations");
87
+ }
88
+
89
+ @Test
65
90
@TestSecurity(user = "dash-pin")
66
91
void pinningARepositoryReflectsInThePinnedSection()
67
92
{
@@ -135,6 +160,12 @@
135
160
}
136
161
137
162
@Transactional
163
+ Organisation createOrg(User creator)
164
+ {
165
+ return organisations.create(creator, "dashorg-" + unique(), null);
166
+ }
167
+
168
+ @Transactional
138
169
User persistUser(String name)
139
170
{
140
171
User existing = userRepo.findByOidcSubOptional(name).orElse(null);