Skip to content

Commit

Permalink
Added swapping out of the Button for Waiting to Start state.˚
Browse files Browse the repository at this point in the history
  • Loading branch information
tedyoung committed Mar 6, 2024
1 parent a0e2198 commit e8a3b79
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ public static String htmlFor(EnsembleTimer ensembleTimer) {
// language=html
private static String htmlForWaitingToStart(EnsembleTimer ensembleTimer) {
return """
<swap-container id='timer-control-button' hx-swap-oob='innerHTML'>
<button id="timer-control-button"
hx-swap-oob="outerHTML"
hx-swap="none"
hx-post="/admin/start-timer/%s"
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Start Timer
</swap-container>
"""
</button>
""".formatted(ensembleTimer.ensembleId().id())
+ htmlForTimerContainer(ensembleTimer);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.jitterted.mobreg.adapter.out.websocket;

import com.jitterted.mobreg.domain.EnsembleId;
import com.jitterted.mobreg.domain.EnsembleTimer;
import com.jitterted.mobreg.domain.EnsembleTimerFactory;
import org.junit.jupiter.api.Test;
Expand All @@ -12,15 +13,19 @@ class TimerToHtmlTransformerTest {

@Test
void waitingToStartTimerHtmlIsCorrect() {
EnsembleTimer ensembleTimer = EnsembleTimerFactory.createTimerWith4MinuteDuration();
EnsembleTimer ensembleTimer = EnsembleTimerFactory.createTimerWith4MinuteDurationAndIdOf(EnsembleId.of(57));

String timerHtml = TimerToHtmlTransformer.htmlFor(ensembleTimer);

assertThat(timerHtml)
.isEqualTo("""
<swap-container id='timer-control-button' hx-swap-oob='innerHTML'>
<button id="timer-control-button"
hx-swap-oob="outerHTML"
hx-swap="none"
hx-post="/admin/start-timer/57"
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Start Timer
</swap-container>
</button>
<div id="timer-container"
class="circle circle-running"
style="background: conic-gradient(lightgreen 0% 100.000000%, black 100.000000% 100%);">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ public static Fixture create4MinuteTimerInFinishedState() {
}

public static EnsembleTimer createTimerWith4MinuteDuration() {
return new EnsembleTimer(IRRELEVANT_ENSEMBLE_ID,
return createTimerWith4MinuteDurationAndIdOf(IRRELEVANT_ENSEMBLE_ID);
}

public static EnsembleTimer createTimerWith4MinuteDurationAndIdOf(EnsembleId ensembleId) {
return new EnsembleTimer(ensembleId,
IRRELEVANT_NAME,
List.of(IRRELEVANT_MEMBER_ID1, IRRELEVANT_MEMBER_ID2, IRRELEVANT_MEMBER_ID3),
Duration.ofMinutes(4));
Expand Down

0 comments on commit e8a3b79

Please sign in to comment.