mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-05 00:14:18 +00:00
fix: say Draft saved on Ctrl+S also when autosave already had everything
The shortcut help test now counts two Ctrl + K entries (command palette and Insert link), and the Cc/Bcc key test waits for the To field's opening focus first.
This commit is contained in:
@@ -37,7 +37,9 @@ describe('keyboard shortcuts help per app', () => {
|
||||
nav.pathname = '/';
|
||||
render(<KeyboardShortcutsModal isOpen onClose={() => {}} />);
|
||||
expect(screen.getAllByText('or').length).toBeGreaterThan(0);
|
||||
expect(screen.getAllByText('Ctrl + K').length).toBe(1);
|
||||
// The command palette, and Insert link in the composer.
|
||||
expect(screen.getAllByText('Ctrl + K').length).toBe(2);
|
||||
expect(screen.queryByText('⌘ + K')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -418,10 +418,18 @@ describe('composer close guard with a follow-up', () => {
|
||||
const subject = screen.getByDisplayValue('Half-written more');
|
||||
expect(fireEvent.keyDown(subject, { key: 's', ctrlKey: true })).toBe(false);
|
||||
await waitFor(() => expect(createDraft).toHaveBeenCalledTimes(1));
|
||||
|
||||
// Nothing new to save: it still says so.
|
||||
await waitFor(() => expect(screen.getByTestId('composer-save-status')).toHaveAttribute('data-status', 'idle'), { timeout: 4000 });
|
||||
fireEvent.keyDown(subject, { key: 's', ctrlKey: true });
|
||||
await waitFor(() => expect(screen.getByTestId('composer-save-status')).toHaveAttribute('data-status', 'saved'));
|
||||
expect(createDraft).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('shows Cc on Ctrl+Shift+C and Bcc on Ctrl+Shift+B, and puts the cursor there', async () => {
|
||||
renderWithCloseRef();
|
||||
// A new message puts the cursor in To shortly after it opens; let that pass.
|
||||
await act(async () => { await new Promise((r) => setTimeout(r, 250)); });
|
||||
const subject = screen.getByDisplayValue('Half-written more');
|
||||
expect(fireEvent.keyDown(subject, { key: 'C', ctrlKey: true, shiftKey: true })).toBe(false);
|
||||
await waitFor(() => expect(document.activeElement).toBe(screen.getByRole('combobox', { name: 'cc_label' })));
|
||||
|
||||
@@ -4846,7 +4846,14 @@ export function EmailComposer({
|
||||
const key = e.key.toLowerCase();
|
||||
if (hasPrimaryModifier && !e.altKey && !e.shiftKey && key === 's') {
|
||||
e.preventDefault();
|
||||
if (!isSavingAndClosing) void saveDraft({ announce: true });
|
||||
// Says "Draft saved" also when autosave already had everything.
|
||||
if (!isSavingAndClosing) {
|
||||
void saveDraft({ announce: true }).then((id) => {
|
||||
if (!id || saveFailedRef.current) return;
|
||||
setSaveStatus('saved');
|
||||
setTimeout(() => setSaveStatus((status) => (status === 'saved' ? 'idle' : status)), 2000);
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (hasPrimaryModifier && !e.altKey && e.shiftKey && (key === 'c' || key === 'b')) {
|
||||
|
||||
Reference in New Issue
Block a user