fix(browser): preserve unknown remote warning fallback

This commit is contained in:
Brennan Benson
2026-08-16 19:38:57 -07:00
parent e3ffb979dc
commit 3c05120a6c
2 changed files with 31 additions and 5 deletions
@@ -73,6 +73,26 @@ describe('emitBrowserCookieImportToast', () => {
expect(message).not.toContain('export')
})
it('uses the generic warning for a reason added by a newer runtime host', () => {
emitBrowserCookieImportToast(
{
...summary,
warning: {
code: 'cookies-undecryptable',
failedCookies: 3,
reason: 'newer-runtime-reason'
}
} as unknown as BrowserCookieImportSummary,
'Imported 0 cookies.',
'Remote Mac'
)
expect(warningToastMock).toHaveBeenCalledWith(
'3 cookies could not be decrypted and were skipped. Close the source browser completely and try the import again.'
)
expect(successToastMock).not.toHaveBeenCalled()
})
it('shows separate host-specific Google guidance after success', () => {
emitBrowserCookieImportToast(
{ ...summary, importedCookies: 2, skippedCookies: 1, googleCookiesSkipped: 1 },
@@ -4,6 +4,14 @@ import { translate } from '@/i18n/i18n'
type CookieImportWarning = NonNullable<BrowserCookieImportSummary['warning']>
function formatUnknownCookieImportWarning(failedCookies: number): string {
return translate(
'auto.lib.browser.cookie.import.toast.undecryptableUnknown',
'{{value0}} cookies could not be decrypted and were skipped. Close the source browser completely and try the import again.',
{ value0: failedCookies }
)
}
function formatCookieImportWarning(warning: CookieImportWarning): string {
switch (warning.code) {
case 'restart-fallback-unavailable':
@@ -48,12 +56,10 @@ function formatCookieImportWarning(warning: CookieImportWarning): string {
{ value0: warning.failedCookies }
)
case 'unknown':
return translate(
'auto.lib.browser.cookie.import.toast.undecryptableUnknown',
'{{value0}} cookies could not be decrypted and were skipped. Close the source browser completely and try the import again.',
{ value0: warning.failedCookies }
)
return formatUnknownCookieImportWarning(warning.failedCookies)
}
// Older clients can receive a reason added by a newer runtime host before their types know it.
return formatUnknownCookieImportWarning(warning.failedCookies)
}
}