Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ test('handles create dashboard button click', async () => {

const createButton = screen.getByRole('button', { name: /dashboard$/i });
await userEvent.click(createButton);
expect(assignMock).toHaveBeenCalledWith('/dashboard/new');
expect(assignMock).toHaveBeenCalledWith('/dashboard/new/');

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.

Suggestion: The test now expects the create-dashboard navigation to call window.location.assign with /dashboard/new/, but the implementation still navigates to /dashboard/new (without the trailing slash), so this assertion will fail and incorrectly flag the behavior as broken even though the component works as implemented. [logic error]

Severity Level: Minor ⚠️

Suggested change
expect(assignMock).toHaveBeenCalledWith('/dashboard/new/');
expect(assignMock).toHaveBeenCalledWith('/dashboard/new');
Why it matters? ⭐

The component calls navigateTo('/dashboard/new', { assign: true }) (see DashboardTable.tsx), which results in window.location.assign being invoked with '/dashboard/new' (no trailing slash). The test expects '/dashboard/new/' (with trailing slash) and will fail even though the component behavior is correct. Changing the assertion to '/dashboard/new' fixes a real logic mismatch between the test and implementation.

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/src/features/home/DashboardTable.test.tsx
**Line:** 244:244
**Comment:**
	*Logic Error: The test now expects the create-dashboard navigation to call `window.location.assign` with `/dashboard/new/`, but the implementation still navigates to `/dashboard/new` (without the trailing slash), so this assertion will fail and incorrectly flag the behavior as broken even though the component works as implemented.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.

});

test('switches to Other tab when available', async () => {
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/features/home/DashboardTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function DashboardTable({
name: t('Dashboard'),
buttonStyle: 'secondary',
onClick: () => {
navigateTo('/dashboard/new', { assign: true });
navigateTo('/dashboard/new/', { assign: true });
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/features/home/EmptyState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const LABELS = {
const REDIRECTS = {
create: {
[WelcomeTable.Charts]: '/chart/add',
[WelcomeTable.Dashboards]: '/dashboard/new',
[WelcomeTable.Dashboards]: '/dashboard/new/',
[WelcomeTable.SavedQueries]: makeUrl('/sqllab?new=true'),
},
viewAll: {
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/features/home/Menu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const dropdownItems = [
},
{
label: 'Dashboard',
url: '/dashboard/new',
url: '/dashboard/new/',
icon: 'fa-fw fa-dashboard',
perm: 'can_write',
view: 'Dashboard',
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/features/home/RightMenu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const dropdownItems = [
},
{
label: 'Dashboard',
url: '/dashboard/new',
url: '/dashboard/new/',
icon: 'fa-fw fa-dashboard',
perm: 'can_write',
view: 'Dashboard',
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/features/home/RightMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const RightMenu = ({
},
{
label: t('Dashboard'),
url: '/dashboard/new',
url: '/dashboard/new/',
icon: (
<Icons.DashboardOutlined data-test={`menu-item-${t('Dashboard')}`} />
),
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/pages/DashboardList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ function DashboardList(props: DashboardListProps) {
name: t('Dashboard'),
buttonStyle: 'primary',
onClick: () => {
navigateTo('/dashboard/new', { assign: true });
navigateTo('/dashboard/new/', { assign: true });
},
});
}
Expand Down
Loading