This commit resolves the issue with the `:active` pseudo-class not
activating in mobile Safari on iOS devices. It introduces a workaround
specifically for mobile Safari on iOS/iPadOS to enable the `:active`
pseudo-class. This ensures a consistent and responsive user interface
in response to touch states on mobile Safari.
Other supporting changes:
- Introduce new test utility functions such as `createWindowEventSpies`
and `formatAssertionMessage` to improve code reusability and
maintainability.
- Improve browser detection:
- Add detection for iPadOS and Windows 10 Mobile.
- Add touch support detection to correctly determine iPadOS vs macOS.
- Fix misidentification of some Windows 10 Mobile platforms as Windows
Phone.
- Improve test coverage and refactor tests.
62 lines
1.9 KiB
TypeScript
62 lines
1.9 KiB
TypeScript
import { describe } from 'vitest';
|
|
import { OperatingSystem } from '@/domain/OperatingSystem';
|
|
import { convertPlatformToOs } from '@/presentation/electron/preload/NodeOsMapper';
|
|
import { formatAssertionMessage } from '@tests/shared/FormatAssertionMessage';
|
|
|
|
describe('NodeOsMapper', () => {
|
|
describe('convertPlatformToOs', () => {
|
|
describe('determines desktop OS', () => {
|
|
// arrange
|
|
interface IDesktopTestCase {
|
|
readonly nodePlatform: NodeJS.Platform;
|
|
readonly expectedOs: ReturnType<typeof convertPlatformToOs>;
|
|
}
|
|
const testScenarios: readonly IDesktopTestCase[] = [ // https://nodejs.org/api/process.html#process_process_platform
|
|
{
|
|
nodePlatform: 'aix',
|
|
expectedOs: undefined,
|
|
},
|
|
{
|
|
nodePlatform: 'darwin',
|
|
expectedOs: OperatingSystem.macOS,
|
|
},
|
|
{
|
|
nodePlatform: 'freebsd',
|
|
expectedOs: undefined,
|
|
},
|
|
{
|
|
nodePlatform: 'linux',
|
|
expectedOs: OperatingSystem.Linux,
|
|
},
|
|
{
|
|
nodePlatform: 'openbsd',
|
|
expectedOs: undefined,
|
|
},
|
|
{
|
|
nodePlatform: 'sunos',
|
|
expectedOs: undefined,
|
|
},
|
|
{
|
|
nodePlatform: 'win32',
|
|
expectedOs: OperatingSystem.Windows,
|
|
},
|
|
];
|
|
testScenarios.forEach(({ nodePlatform, expectedOs }) => {
|
|
it(nodePlatform, () => {
|
|
// act
|
|
const actualOs = convertPlatformToOs(nodePlatform);
|
|
// assert
|
|
expect(actualOs).to.equal(expectedOs, formatAssertionMessage([
|
|
`Expected: "${printResult(expectedOs)}"\n`,
|
|
`Actual: "${printResult(actualOs)}"\n`,
|
|
`Platform: "${nodePlatform}"`,
|
|
]));
|
|
function printResult(os: ReturnType<typeof convertPlatformToOs>): string {
|
|
return os === undefined ? 'undefined' : OperatingSystem[os];
|
|
}
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|