Skip to content

fix:#681 Added cancel buttons on Edit Group page#702

Open
tonyb650 wants to merge 1 commit intodevelopfrom
tony/681-edit-group-cancel-buttons
Open

fix:#681 Added cancel buttons on Edit Group page#702
tonyb650 wants to merge 1 commit intodevelopfrom
tony/681-edit-group-cancel-buttons

Conversation

@tonyb650
Copy link
Copy Markdown
Contributor

@tonyb650 tonyb650 commented Nov 25, 2025

Description

Before:

Navigating away from the "Edit Group" page was unintuitive, with only the "< Back to Dashboard" link and no "Cancel" button.

After:

There are now 2 additional, more conventional ways to navigate back to the dashboard page: an "X" button in the upper-right corner and a "Cancel" button at the bottom of the page.

Closes #681

Additional information

This is a follow up to PR #633 which has been merged in and addressed the exact same issue for the "Create Group" page.

Screenshots

image image

Pre-submission checklist

  • Code builds and passes locally
  • PR title follows Conventional Commit format (e.g. test #001: created unit test for __ component)
  • Request reviews from the Peer Code Reviewers and Senior+ Code Reviewers groups
  • Thread has been created in Discord and PR is linked in gis-code-questions

Summary by CodeRabbit

  • New Features

    • Added a close (X) button to the group edit page header for quick navigation back to the dashboard.
    • Added a Cancel button alongside the Save Changes option in the footer.
  • Style

    • Enhanced responsive layout and button alignment for improved usability across different screen sizes.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Copy Markdown

vercel Bot commented Nov 25, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
elecretanta Ready Ready Preview Comment Nov 25, 2025 5:45pm
elecretanta-storybook Ready Ready Preview Comment Nov 25, 2025 5:45pm
elecretanta-unit-test Ready Ready Preview Comment Nov 25, 2025 5:45pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 25, 2025

Walkthrough

The Edit Group page now includes a close button (X icon) in the header and a cancel button in the footer, both navigating to the dashboard. Corresponding test suite refactored from create group tests to edit group tests with new mocks and reorganized test structure.

Changes

Cohort / File(s) Summary
Edit Group UI Updates
app/gift-exchanges/[id]/edit/page.tsx
Added X dismiss button in header and Cancel button in footer, both linking to dashboard. Imported X icon from lucide-react. Adjusted header/title spacing and footer action layout for responsive alignment.
Edit Group Test Suite Refactoring
app/gift-exchanges/[id]/edit/page.test.tsx
Refactored test structure from create group to edit group tests. Added Next.js router mocks (useRouter, useParams), global environment shims (ResizeObserver, fetch). Replaced timer-based date setup with static mocks. Added tests for X button and Cancel button href assertions. Reorganized calendar tests with dedicated describe block.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EditGroupPage as Edit Group Page
    participant Router

    User->>EditGroupPage: View page
    alt Close/Cancel Interaction
        User->>EditGroupPage: Click X button or Cancel button
        EditGroupPage->>Router: Navigate to /dashboard
        Router->>User: Redirect to dashboard
    else Save/Delete Actions
        User->>EditGroupPage: Click Save Changes or Delete Group
        EditGroupPage->>EditGroupPage: Handle group update/deletion
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Test refactoring scope: Full restructuring of test suite from create-group to edit-group context requires careful verification of all mocks and test organization
  • New button assertions: Verify Close and Cancel button href assertions match expected dashboard navigation paths
  • Calendar test reorganization: Ensure past-date disablement behavior is correctly preserved within nested describe blocks
  • Mock setup: Confirm Next.js router mocks (useRouter, useParams) and global environment shims are properly configured

Poem

🐰 Hoppy refactors bring us joy,
Close buttons, cancel buttons—what a ploy!
Dashboard awaits with open arms wide,
Tests reorganized, side by side.
Edit group page, now complete and bright!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix:#681 Added cancel buttons on Edit Group page' clearly and specifically describes the main change: adding cancel buttons to the Edit Group page to address issue #681.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from issue #681: adds an X close button in the header and a Cancel button in the footer, both navigating to the dashboard, mirroring the Create Group page behavior.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #681. The modifications include header/footer UI updates, router navigation setup, and corresponding test coverage—all aligned with the cancel button implementation requirements.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tony/681-edit-group-cancel-buttons

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Comment @coderabbitai help to get the list of available commands and usage tips.

@shashilo shashilo requested review from a team and shashilo and removed request for a team, bethanyann, nickytonline and shashilo November 25, 2025 17:45
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
app/gift-exchanges/[id]/edit/page.tsx (1)

413-432: Simplify spacing utilities to avoid conflicts.

The combination of space-x-2 space-y-2 alongside sm:gap-3 with sm:space-x-0 sm:space-y-0 creates redundant and potentially conflicting spacing rules. At the small breakpoint, gap-3 is applied while space utilities are reset to 0, but at smaller screens both sets of utilities are active.

Consider simplifying to:

-<div className="sm:flex sm:justify-center md:justify-end sm:gap-3 mx-3 space-x-2 space-y-2 sm:space-x-0 sm:space-y-0">
+<div className="flex flex-col sm:flex-row sm:justify-center md:justify-end gap-2 sm:gap-3 mx-3">

This approach uses flex-col for mobile (stacked buttons) and flex-row at sm+ breakpoints, with gap handling all spacing consistently.

app/gift-exchanges/[id]/edit/page.test.tsx (1)

66-98: Consider testing Calendar integration within EditGroupPage.

The current test renders the Calendar component in isolation rather than as part of EditGroupPage. This verifies the Calendar's behavior but doesn't test its integration with the form (e.g., the exchange date calendar's dependency on giftDrawingDate).

Consider adding an integration test:

it('disables past dates for drawing date calendar in EditGroupPage', async () => {
  render(<EditGroupPage />);
  
  // Wait for component to load
  await screen.findByText('Edit Secret Santa Page');
  
  // Open drawing date calendar
  const drawingDateButton = screen.getByRole('button', { name: /gift drawing date/i });
  fireEvent.click(drawingDateButton);
  
  // Verify past dates are disabled
  const pastDate = screen.getByText('13');
  expect(pastDate).toBeDisabled();
});

Alternatively, if this test is meant to verify the Calendar component itself, consider moving it to the Calendar component's test file.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 494fc61 and 22cdaec.

📒 Files selected for processing (2)
  • app/gift-exchanges/[id]/edit/page.test.tsx (1 hunks)
  • app/gift-exchanges/[id]/edit/page.tsx (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/gift-exchanges/[id]/edit/page.test.tsx (1)
app/gift-exchanges/[id]/edit/page.tsx (1)
  • EditGroupPage (85-439)
🔇 Additional comments (5)
app/gift-exchanges/[id]/edit/page.tsx (3)

19-19: LGTM!

The X icon import is correctly added and used in the header close button.


76-78: LGTM!

Formatting adjustment aligns with code style conventions.


195-201: LGTM!

The X button implementation correctly uses the asChild pattern with Next.js Link for client-side navigation to the dashboard. The data-testid attribute enables proper test coverage.

app/gift-exchanges/[id]/edit/page.test.tsx (2)

44-53: LGTM!

The test correctly verifies that the X button navigates to the dashboard. Once the Supabase auth mock is added (as noted in the previous comment), this test will properly validate the full component rendering.


55-64: LGTM!

The test correctly verifies the Cancel button's navigation behavior and uses accessible queries with getByRole.

Comment on lines +5 to +27
jest.mock('next/navigation', () => ({
useRouter: () => ({
push: jest.fn(),
refresh: jest.fn(),
}),
useParams: () => ({
id: 'mock-group-id',
}),
}));

beforeEach(() => {
jest.useFakeTimers();
jest.setSystemTime(currentDate);
class MockResizeObserver {
observe() {}
unobserve() {}
disconnect() {}
}

global.ResizeObserver = MockResizeObserver;
global.fetch = jest
.fn()
.mockResolvedValue({
ok: true,
json: () => Promise.resolve({ owner_id: '1', name: '' }),
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add Supabase auth mock and complete the fetch mock data.

The component uses supabase.auth.getUser() to verify ownership (lines 114-119 in page.tsx), but there's no mock for the Supabase client. Additionally, the fetch mock returns incomplete data that doesn't match the form's expected structure.

Add the following mocks:

+jest.mock('@/lib/supabase/client', () => ({
+  createClient: () => ({
+    auth: {
+      getUser: jest.fn().mockResolvedValue({
+        data: { user: { id: '1' } },
+        error: null,
+      }),
+    },
+  }),
+}));
+
 global.ResizeObserver = MockResizeObserver;
 global.fetch = jest
   .fn()
   .mockResolvedValue({
     ok: true,
-    json: () => Promise.resolve({ owner_id: '1', name: '' }),
+    json: () => Promise.resolve({
+      id: 'mock-group-id',
+      owner_id: '1',
+      name: 'Test Group',
+      description: 'Test Description',
+      drawing_date: '2025-12-20',
+      exchange_date: '2025-12-25',
+      budget: '10-20',
+      group_image: '/images/group-1.png',
+    }),
   });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
jest.mock('next/navigation', () => ({
useRouter: () => ({
push: jest.fn(),
refresh: jest.fn(),
}),
useParams: () => ({
id: 'mock-group-id',
}),
}));
beforeEach(() => {
jest.useFakeTimers();
jest.setSystemTime(currentDate);
class MockResizeObserver {
observe() {}
unobserve() {}
disconnect() {}
}
global.ResizeObserver = MockResizeObserver;
global.fetch = jest
.fn()
.mockResolvedValue({
ok: true,
json: () => Promise.resolve({ owner_id: '1', name: '' }),
});
jest.mock('next/navigation', () => ({
useRouter: () => ({
push: jest.fn(),
refresh: jest.fn(),
}),
useParams: () => ({
id: 'mock-group-id',
}),
}));
jest.mock('@/lib/supabase/client', () => ({
createClient: () => ({
auth: {
getUser: jest.fn().mockResolvedValue({
data: { user: { id: '1' } },
error: null,
}),
},
}),
}));
class MockResizeObserver {
observe() {}
unobserve() {}
disconnect() {}
}
global.ResizeObserver = MockResizeObserver;
global.fetch = jest
.fn()
.mockResolvedValue({
ok: true,
json: () => Promise.resolve({
id: 'mock-group-id',
owner_id: '1',
name: 'Test Group',
description: 'Test Description',
drawing_date: '2025-12-20',
exchange_date: '2025-12-25',
budget: '10-20',
group_image: '/images/group-1.png',
}),
});

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds cancel buttons to the Edit Group page, matching the UX improvements previously implemented for the Create Group page in PR #633. The changes provide users with more intuitive navigation options beyond the "Back to Dashboard" link.

Key Changes:

  • Added an X button in the upper-right corner of the Edit Group form
  • Added a Cancel button in the footer alongside the existing Save Changes and Delete Group buttons
  • Updated styling and layout for better responsive behavior

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
app/gift-exchanges/[id]/edit/page.tsx Adds X button to header and Cancel button to footer, updates responsive styling for button layout
app/gift-exchanges/[id]/edit/page.test.tsx Adds test coverage for new X and Cancel buttons, reorganizes existing Calendar tests into better structure

/>
<div className="flex md:justify-start justify-center md:m-5 m-0 w-full">
<Button className="m-2" type="submit">
<div className="sm:flex sm:justify-center md:justify-end sm:gap-3 mx-3 space-x-2 space-y-2 sm:space-x-0 sm:space-y-0">
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The container div uses conflicting spacing utilities: space-x-2 space-y-2 are applied at the base level but then overridden with sm:space-x-0 sm:space-y-0 on small screens. This creates inconsistent spacing behavior.

On screens smaller than sm breakpoint, both space-x-2 and space-y-2 are applied, which will add spacing in both directions. This can cause layout issues since the buttons will stack vertically but also have horizontal spacing.

Consider using a consistent approach like the Create Group page (flex gap-2 justify-center md:justify-end p-3) or conditionally applying spacing based on flex direction.

Suggested change
<div className="sm:flex sm:justify-center md:justify-end sm:gap-3 mx-3 space-x-2 space-y-2 sm:space-x-0 sm:space-y-0">
<div className="flex flex-col sm:flex-row gap-2 justify-center md:justify-end p-3">

Copilot uses AI. Check for mistakes.
@@ -1,36 +1,99 @@
import { Calendar } from '@/components/Calendar/calendar';
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing copyright header. Test files in this codebase should include:

// Copyright (c) Gridiron Survivor.
// Licensed under the MIT License.

This can be seen in other test files like app/create-group-page/page.test.tsx.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Comment on lines 16 to +19
import { Check, ChevronsUpDown, ChevronLeft } from 'lucide-react';
import { Input } from '@/components/Input/Input';
import { Button } from '@/components/Button/button';
import { CalendarIcon } from 'lucide-react';
import { CalendarIcon, X } from 'lucide-react';
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CalendarIcon and X imports from lucide-react on line 19 should be combined with the other lucide-react imports on line 16.

Currently:

import { Check, ChevronsUpDown, ChevronLeft } from 'lucide-react';
...
import { CalendarIcon, X } from 'lucide-react';

Should be:

import { CalendarIcon, Check, ChevronsUpDown, ChevronLeft, X } from 'lucide-react';

This follows the pattern used in app/create-group-page/page.tsx line 16.

Copilot uses AI. Check for mistakes.
Comment on lines +196 to +200
<Button variant="ghost" asChild data-testid="x-button">
<Link href="/dashboard">
<X className="text-black" />
</Link>
</Button>
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The X button lacks an accessible label for screen readers. Users relying on assistive technologies won't know what this button does.

Add an aria-label to the Button component:

<Button variant="ghost" asChild data-testid="x-button" aria-label="Close and return to dashboard">
  <Link href="/dashboard">
    <X className="text-black" />
  </Link>
</Button>

The same issue should be addressed in the Create Group page if not already fixed.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 2, 2025

@shashilo I've opened a new pull request, #709, to work on those changes. Once the pull request is ready, I'll request review from you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Edit Group page should have cancel button(s)

4 participants