mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-05 00:14:18 +00:00
fix: name no identity on your own messages in the reader
The badge test said a differing sender name gets "via <identity>"; that badge is gone, so it now checks that nothing is shown and that the sub-address tag still is.
This commit is contained in:
@@ -4,7 +4,8 @@ import React from 'react';
|
||||
import { EmailIdentityBadge } from '../email-identity-badge';
|
||||
import type { Email, Identity } from '@/lib/jmap/types';
|
||||
|
||||
// A draft or sent mail from "User A" showed "User A via User A".
|
||||
// A draft or sent mail from "User A" showed "User A via User A", and any
|
||||
// other own message "via <identity>".
|
||||
|
||||
const identity = { id: 'id-1', name: 'User A', email: 'usera@example.org' } as Identity;
|
||||
const fromUser = (name: string) => ({ from: [{ name, email: 'usera@example.org' }], to: [] }) as unknown as Email;
|
||||
@@ -15,9 +16,16 @@ describe('EmailIdentityBadge', () => {
|
||||
expect(container.textContent).toBe('');
|
||||
});
|
||||
|
||||
it('names the identity when the sender name differs', () => {
|
||||
it('names no identity on your own message, whatever the sender name', () => {
|
||||
// "via <identity>" read like a delegation warning; the address under the
|
||||
// name already says which of your addresses sent it.
|
||||
const { container } = render(<EmailIdentityBadge email={fromUser('Support Desk')} identities={[identity]} />);
|
||||
// The translation mock returns the key of the "via {name}" text.
|
||||
expect(container.textContent).toContain('identity_short');
|
||||
expect(container.textContent).toBe('');
|
||||
});
|
||||
|
||||
it('still shows the sub-address tag', () => {
|
||||
const email = { from: [{ name: 'Support Desk', email: 'usera+news@example.org' }], to: [] } as unknown as Email;
|
||||
const { container } = render(<EmailIdentityBadge email={email} identities={[identity]} />);
|
||||
expect(container.textContent).toContain('news');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -111,7 +111,11 @@ export function EmailIdentityBadge({
|
||||
return null;
|
||||
}
|
||||
|
||||
// Full view for email viewer - now shows compact badges only
|
||||
// Full view for email viewer - the sub-address tag only. A message of your
|
||||
// own named its identity ("via <identity>"), which read like a delegation
|
||||
// warning; the sender's address, shown right under the name, already says
|
||||
// which of your addresses sent it.
|
||||
if (!displayTag) return null;
|
||||
return (
|
||||
<div className={cn('inline-flex items-center gap-2', className)}>
|
||||
{/* Sub-address tag badge */}
|
||||
@@ -130,21 +134,6 @@ export function EmailIdentityBadge({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Identity badge (only if identity has a name and no sub-address tag) */}
|
||||
{!displayTag && matchingIdentity && showIdentityName && (
|
||||
<div
|
||||
className={cn(
|
||||
'inline-flex items-center gap-1 px-2 py-0.5 rounded-md',
|
||||
'bg-secondary text-muted-foreground border border-border',
|
||||
'text-xs font-medium'
|
||||
)}
|
||||
title={t('identity_name', { name: matchingIdentity.name })}
|
||||
aria-label={t('identity_name', { name: matchingIdentity.name })}
|
||||
>
|
||||
<Mail className="w-3 h-3" />
|
||||
<span>{t('identity_short', { name: matchingIdentity.name })}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user