Skip to content
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
32 changes: 32 additions & 0 deletions e2e/tests/api/retros.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,38 @@ test.describe("Retro API", { tag: ["@api", "@retro"] }, () => {
});
});

test("POST /users/{userId}/retros creates retro with phase time limit and auto-advance settings", async ({
request,
registeredApiUser,
}) => {
const retroName = "Test API Create Retro with Timer";
const brainstormVisibility = "visible";
const maxVotes = 3;
const phaseTimeLimitMin = 15;
const phaseAutoAdvance = false;

const response = await registeredApiUser.context.post(
`users/${registeredApiUser.user.id}/retros`,
{
data: {
retroName,
brainstormVisibility,
maxVotes,
phaseTimeLimitMin,
phaseAutoAdvance,
},
},
);
expect(response.ok()).toBeTruthy();
const retro = await response.json();
expect(retro.data).toMatchObject({
name: retroName,
brainstormVisibility,
phase_time_limit_min: phaseTimeLimitMin,
phase_auto_advance: phaseAutoAdvance,
});
});

test("GET /users/{userId}/retros returns object in array when retros associated to user", async ({
request,
registeredApiUser,
Expand Down
63 changes: 63 additions & 0 deletions e2e/tests/retro/retro.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test.describe("Retro page", { tag: ["@retro"] }, () => {
let retroPhaseGroup = { id: "" };
let retroPhaseVote = { id: "" };
let retroPhaseActionItem = { id: "" };
let retroEditSettings = { id: "" };

test.beforeAll(async ({ registeredPage, verifiedPage, adminPage }) => {
const commonRetro = {
Expand Down Expand Up @@ -40,6 +41,9 @@ test.describe("Retro page", { tag: ["@retro"] }, () => {
retroPhaseActionItem = await registeredPage.createRetro({
...commonRetro,
});
retroEditSettings = await registeredPage.createRetro({
...commonRetro,
});
});

test(
Expand Down Expand Up @@ -205,4 +209,63 @@ test.describe("Retro page", { tag: ["@retro"] }, () => {
await bp.retroActionItemInput.press("Enter");
expect(await bp.page.getByText(actionItem2));
});

test("facilitator can edit retro settings with phase time limit", async ({
registeredPage,
}) => {
const bp = new RetroPage(registeredPage.page);
await bp.goto(retroEditSettings.id);

// Open retro settings menu and click edit
await bp.page.click('[data-testid="retro-settings"]');
await bp.page.click('[data-testid="retro-edit"]');

// Set phase time limit to 15 minutes
await bp.page.fill("#phaseTimeLimitMin", "15");

// Disable auto-advance to test timer without auto-advance
await bp.page.uncheck("#phaseAutoAdvance");

// Save the changes
await bp.page.click('button[type="submit"]');

// Advance to brainstorm phase to test timer visibility
await bp.retroNextPhaseBtn.click();

// Verify timer is visible when phaseTimeLimitMin > 0
await expect(bp.page.locator('[data-testid="phase-timer"]')).toBeVisible();

// Verify timer shows minutes and seconds
await expect(bp.page.locator('[data-testid="phase-timer"]')).toContainText(
"m",
);
await expect(bp.page.locator('[data-testid="phase-timer"]')).toContainText(
"s",
);
});

test("timer does not show when phase time limit is 0", async ({
registeredPage,
}) => {
const bp = new RetroPage(registeredPage.page);
await bp.goto(retroEditSettings.id);

// Open retro settings menu and click edit
await bp.page.click('[data-testid="retro-settings"]');
await bp.page.click('[data-testid="retro-edit"]');

// Set phase time limit to 0 (no timer)
await bp.page.fill("#phaseTimeLimitMin", "0");

// Save the changes
await bp.page.click('button[type="submit"]');

// Advance to brainstorm phase
await bp.retroNextPhaseBtn.click();

// Verify timer is not visible when phaseTimeLimitMin = 0
await expect(
bp.page.locator('[data-testid="phase-timer"]'),
).not.toBeVisible();
});
});
6 changes: 3 additions & 3 deletions internal/db/retro/retro.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (d *Service) CreateRetro(
// EditRetro updates the retro by ID
func (d *Service) EditRetro(
retroID string, retroName string, joinCode string, facilitatorCode string,
maxVotes int, brainstormVisibility string, phaseAutoAdvance bool, hideVotesDuringVoting bool) error {
maxVotes int, brainstormVisibility string, phaseTimeLimitMin int, phaseAutoAdvance bool, hideVotesDuringVoting bool) error {
var encryptedJoinCode string
var encryptedFacilitatorCode string

Expand All @@ -139,10 +139,10 @@ func (d *Service) EditRetro(

if _, err := d.DB.Exec(`UPDATE thunderdome.retro
SET name = $2, join_code = $3, facilitator_code = $4, max_votes = $5,
brainstorm_visibility = $6, phase_auto_advance = $7, hide_votes_during_voting = $8, updated_date = NOW()
brainstorm_visibility = $6, phase_time_limit_min = $7, phase_auto_advance = $8, hide_votes_during_voting = $9, updated_date = NOW()
WHERE id = $1;`,
retroID, retroName, encryptedJoinCode, encryptedFacilitatorCode,
maxVotes, brainstormVisibility, phaseAutoAdvance, hideVotesDuringVoting,
maxVotes, brainstormVisibility, phaseTimeLimitMin, phaseAutoAdvance, hideVotesDuringVoting,
); err != nil {
return fmt.Errorf("edit retro query error: %v", err)
}
Expand Down
2 changes: 2 additions & 0 deletions internal/http/retro/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ func (b *Service) EditRetro(ctx context.Context, RetroID string, UserID string,
FacilitatorCode string `json:"facilitatorCode"`
MaxVotes int `json:"maxVotes"`
BrainstormVisibility string `json:"brainstormVisibility"`
PhaseTimeLimitMin int `json:"phaseTimeLimitMin"`
PhaseAutoAdvance bool `json:"phase_auto_advance"`
HideVotesDuringVoting bool `json:"hideVotesDuringVoting"`
}
Expand All @@ -498,6 +499,7 @@ func (b *Service) EditRetro(ctx context.Context, RetroID string, UserID string,
rb.FacilitatorCode,
rb.MaxVotes,
rb.BrainstormVisibility,
rb.PhaseTimeLimitMin,
rb.PhaseAutoAdvance,
rb.HideVotesDuringVoting,
)
Expand Down
2 changes: 1 addition & 1 deletion internal/http/retro/retro.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type UserDataSvc interface {
}

type RetroDataSvc interface {
EditRetro(retroID string, retroName string, joinCode string, facilitatorCode string, maxVotes int, brainstormVisibility string, phaseAutoAdvance bool, hideVotesDuringVoting bool) error
EditRetro(retroID string, retroName string, joinCode string, facilitatorCode string, maxVotes int, brainstormVisibility string, phaseTimeLimitMin int, phaseAutoAdvance bool, hideVotesDuringVoting bool) error
RetroGetByID(retroID string, userID string) (*thunderdome.Retro, error)
RetroConfirmFacilitator(retroID string, userID string) error
RetroGetUsers(retroID string) []*thunderdome.RetroUser
Expand Down
2 changes: 1 addition & 1 deletion internal/http/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ type PokerDataSvc interface {

type RetroDataSvc interface {
CreateRetro(ctx context.Context, ownerID, teamID string, retroName, joinCode, facilitatorCode string, maxVotes int, brainstormVisibility string, phaseTimeLimitMin int, phaseAutoAdvance bool, allowCumulativeVoting bool, hideVotesDuringVoting bool, templateID string) (*thunderdome.Retro, error)
EditRetro(retroID string, retroName string, joinCode string, facilitatorCode string, maxVotes int, brainstormVisibility string, phaseAutoAdvance bool, hideVotesDuringVoting bool) error
EditRetro(retroID string, retroName string, joinCode string, facilitatorCode string, maxVotes int, brainstormVisibility string, phaseTimeLimitMin int, phaseAutoAdvance bool, hideVotesDuringVoting bool) error
RetroGetByID(retroID string, userID string) (*thunderdome.Retro, error)
RetroGetByUser(userID string, limit int, offset int) ([]*thunderdome.Retro, int, error)
RetroConfirmFacilitator(retroID string, userID string) error
Expand Down
19 changes: 19 additions & 0 deletions ui/src/components/retro/EditRetro.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
facilitatorCode?: string;
maxVotes?: string;
brainstormVisibility?: string;
phaseTimeLimitMin?: string;
phaseAutoAdvance?: boolean;
hideVotesDuringVoting?: boolean;
}
Expand All @@ -28,6 +29,7 @@
facilitatorCode = $bindable(''),
maxVotes = $bindable('3'),
brainstormVisibility = $bindable('visible'),
phaseTimeLimitMin = $bindable('0'),
phaseAutoAdvance = $bindable(true),
hideVotesDuringVoting = $bindable(false),
}: Props = $props();
Expand Down Expand Up @@ -56,6 +58,7 @@
facilitatorCode,
maxVotes: parseInt(maxVotes, 10),
brainstormVisibility,
phaseTimeLimitMin: parseInt(phaseTimeLimitMin, 10),
phase_auto_advance: phaseAutoAdvance,
hideVotesDuringVoting,
};
Expand Down Expand Up @@ -126,6 +129,22 @@
</div>
</div>

<div class="mb-4">
<label class="block text-gray-700 dark:text-gray-400 text-sm font-bold mb-2" for="phaseTimeLimitMin">
{$LL.retroPhaseTimeLimitMinLabel()}
</label>
<div class="control">
<TextInput
name="phaseTimeLimitMin"
bind:value={phaseTimeLimitMin}
id="phaseTimeLimitMin"
type="number"
min="0"
max="59"
/>
</div>
</div>

<div class="mb-4">
<label class="text-gray-700 dark:text-gray-400 text-sm font-bold mb-2" for="brainstormVisibility">
{$LL.brainstormPhaseFeedbackVisibility()}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/retro/PhaseTimer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</script>

<div class="inline-block me-2 font-semibold dark:text-gray-200 md:text-lg" data-testid="phase-timer">
{#each Object.entries({ m, s }) as [key, value], i}
{#each Object.entries({ h, m, s }) as [key, value], i}
<span class="me-2">{padValue(value)}{key}</span>
{/each}
</div>
1 change: 1 addition & 0 deletions ui/src/pages/retro/Retro.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,7 @@
facilitatorCode={retro.facilitatorCode}
maxVotes={`${retro.maxVotes}`}
brainstormVisibility={retro.brainstormVisibility}
phaseTimeLimitMin={`${retro.phase_time_limit_min}`}
phaseAutoAdvance={retro.phase_auto_advance}
hideVotesDuringVoting={retro.hideVotesDuringVoting}
/>
Expand Down