mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-29 11:26:25 -05:00
app: treat pure Chromium UA as supported for extension banner
Match Chromium/ as well as Chrome/ so builds that omit Chrome in the user agent still see the install nudge. Cover with a unit test.
This commit is contained in:
parent
db7603012e
commit
c79127e7da
2 changed files with 12 additions and 1 deletions
|
|
@ -3,6 +3,7 @@ import {render, screen, waitFor} from '../../test-utils';
|
|||
import {ExtensionInstallSuggestion} from './ExtensionInstallSuggestion';
|
||||
|
||||
const CHROME_UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36';
|
||||
const CHROMIUM_UA = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chromium/147.0.0.0 Safari/537.36';
|
||||
const FIREFOX_UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:128.0) Gecko/20100101 Firefox/128.0';
|
||||
const SAFARI_UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15';
|
||||
|
||||
|
|
@ -57,6 +58,15 @@ describe('ExtensionInstallSuggestion', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('renders the install message on pure Chromium (Chromium/ without Chrome/)', async () => {
|
||||
setUserAgent(CHROMIUM_UA);
|
||||
render(<ExtensionInstallSuggestion/>);
|
||||
await waitFor(
|
||||
() => expect(screen.getByText(/Install the WROLPi browser extension/i)).toBeInTheDocument(),
|
||||
{timeout: 1500},
|
||||
);
|
||||
});
|
||||
|
||||
it('renders nothing on Safari even when the marker is absent', async () => {
|
||||
setUserAgent(SAFARI_UA);
|
||||
render(<ExtensionInstallSuggestion/>);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ export function detectBrowser() {
|
|||
if (ua.includes('Firefox')) return 'firefox';
|
||||
if (ua.includes('Edg/')) return 'chromium';
|
||||
if (ua.includes('OPR/') || ua.includes('Opera')) return 'chromium';
|
||||
if (ua.includes('Chrome')) return 'chromium';
|
||||
// Pure Chromium builds may advertise Chromium/ without Chrome/.
|
||||
if (ua.includes('Chrome') || ua.includes('Chromium')) return 'chromium';
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue