mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-10-31 16:13:15 +00:00
fix: put Delete folder last in the folder menu, after Refresh
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import type { Mailbox } from '@/lib/jmap/types';
|
||||
|
||||
// R6: destructive entries come last. The folder menu had Refresh after
|
||||
// "Delete folder".
|
||||
|
||||
vi.mock('@/components/email/rules-menu', () => ({ FolderRulesSubMenu: () => null }));
|
||||
|
||||
const { MailboxContextMenu } = await import('../mailbox-context-menu');
|
||||
|
||||
const folder = { id: 'p', name: 'Projects', sortOrder: 1, totalEmails: 2, unreadEmails: 0, myRights: {} } as unknown as Mailbox;
|
||||
|
||||
describe('MailboxContextMenu', () => {
|
||||
it('ends with Empty folder and Delete folder', () => {
|
||||
render(
|
||||
<MailboxContextMenu
|
||||
target={{ kind: 'mailbox', mailbox: folder, hasChildren: false }}
|
||||
position={{ x: 0, y: 0 }}
|
||||
isOpen
|
||||
onClose={vi.fn()}
|
||||
menuRef={{ current: null }}
|
||||
mailboxes={[folder]}
|
||||
onEmptyFolder={vi.fn()}
|
||||
onDeleteFolder={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
onImportEmail={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
const labels = screen.getAllByRole('menuitem').map((item) => item.textContent);
|
||||
expect(labels.slice(-2)).toEqual(['empty_folder_generic', 'delete_folder']);
|
||||
expect(labels).toContain('refresh');
|
||||
});
|
||||
});
|
||||
@@ -293,7 +293,14 @@ export function MailboxContextMenu({
|
||||
onClick={() => handleAction(() => onImportEmail?.(mailbox.id))}
|
||||
disabled={!onImportEmail || !canAddItems}
|
||||
/>
|
||||
<ContextMenuItem
|
||||
icon={RefreshCw}
|
||||
label={t("refresh")}
|
||||
onClick={() => handleAction(onRefresh!)}
|
||||
disabled={!onRefresh}
|
||||
/>
|
||||
|
||||
{/* Destructive entries last (R6). */}
|
||||
<ContextMenuSeparator />
|
||||
|
||||
<ContextMenuItem
|
||||
@@ -311,15 +318,6 @@ export function MailboxContextMenu({
|
||||
destructive
|
||||
testId="mailbox-delete"
|
||||
/>
|
||||
|
||||
<ContextMenuSeparator />
|
||||
|
||||
<ContextMenuItem
|
||||
icon={RefreshCw}
|
||||
label={t("refresh")}
|
||||
onClick={() => handleAction(onRefresh!)}
|
||||
disabled={!onRefresh}
|
||||
/>
|
||||
</ContextMenu>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user