`users.image` was null on every seeded customer, and it is the face on every review a pro has — `pro.reviews` selects it as `authorImage` — as well as the chat header. So the one screen meant to prove other people have used this rendered as a column of blank circles. Five customers now carry a portrait, seeded with the source url and rewritten to the bucket like pro_media, and the first of them — the dev-login account the demo signs in as — is Robert Pérez. assets:migrate only knew about pro_media and job photos, so an avatar would have stayed on someone else's CDN indefinitely. It has a users pass now, which also catches the provider avatar a social sign-in writes straight onto the row. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
55 lines
2.2 KiB
TypeScript
55 lines
2.2 KiB
TypeScript
/**
|
|
* The device labeller behind the security screen.
|
|
*
|
|
* The cases that matter are the impostors: every Chromium browser claims to be
|
|
* Chrome, every iOS browser claims to be Safari, and Edge claims both. A parser
|
|
* that gets the obvious strings right and these wrong is a parser that labels
|
|
* most of the world "Chrome".
|
|
*/
|
|
import { describe, expect, it } from 'vitest';
|
|
import { describeDevice } from '../src/lib/user-agent';
|
|
|
|
const UA = {
|
|
chromeWindows:
|
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36',
|
|
edgeWindows:
|
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0',
|
|
safariIphone:
|
|
'Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1',
|
|
chromeAndroid:
|
|
'Mozilla/5.0 (Linux; Android 15; Pixel 9) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Mobile Safari/537.36',
|
|
firefoxMac:
|
|
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:130.0) Gecko/20100101 Firefox/130.0',
|
|
};
|
|
|
|
describe('describeDevice', () => {
|
|
it('reads the plain cases', () => {
|
|
expect(describeDevice(UA.chromeWindows)).toBe('Chrome on Windows');
|
|
expect(describeDevice(UA.firefoxMac)).toBe('Firefox on Mac');
|
|
});
|
|
|
|
it('does not call Edge "Chrome", though Edge says it is', () => {
|
|
expect(describeDevice(UA.edgeWindows)).toBe('Edge on Windows');
|
|
});
|
|
|
|
it('does not call an iPhone a Mac, though it says "like Mac OS X"', () => {
|
|
expect(describeDevice(UA.safariIphone)).toBe('Safari on iPhone');
|
|
});
|
|
|
|
it('prefers Android over the Linux it is built on', () => {
|
|
expect(describeDevice(UA.chromeAndroid)).toBe('Chrome on Android');
|
|
});
|
|
|
|
it('returns what it knows when it only knows half', () => {
|
|
expect(describeDevice('Mozilla/5.0 (Windows NT 10.0)')).toBe('Windows');
|
|
expect(describeDevice('Firefox/130.0')).toBe('Firefox');
|
|
});
|
|
|
|
it('says nothing rather than guessing', () => {
|
|
expect(describeDevice(null)).toBeNull();
|
|
expect(describeDevice(undefined)).toBeNull();
|
|
expect(describeDevice('')).toBeNull();
|
|
expect(describeDevice('curl/8.7.1')).toBeNull();
|
|
});
|
|
});
|