Fix touch state not being activated in iOS Safari
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.
This commit is contained in:
36
tests/unit/shared/Stubs/BrowserConditionStub.ts
Normal file
36
tests/unit/shared/Stubs/BrowserConditionStub.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { BrowserCondition, TouchSupportExpectation } from '@/infrastructure/RuntimeEnvironment/BrowserOs/BrowserCondition';
|
||||
|
||||
export class BrowserConditionStub implements BrowserCondition {
|
||||
public operatingSystem: OperatingSystem = OperatingSystem.Android;
|
||||
|
||||
public existingPartsInSameUserAgent: readonly string[] = [
|
||||
`[${BrowserConditionStub.name}] existing part`,
|
||||
];
|
||||
|
||||
public notExistingPartsInUserAgent?: readonly string[] = [
|
||||
`[${BrowserConditionStub.name}] non-existing part`,
|
||||
];
|
||||
|
||||
public touchSupport?: TouchSupportExpectation = undefined;
|
||||
|
||||
public withOperatingSystem(operatingSystem: OperatingSystem): this {
|
||||
this.operatingSystem = operatingSystem;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withExistingPartsInSameUserAgent(existingPartsInSameUserAgent: readonly string[]): this {
|
||||
this.existingPartsInSameUserAgent = existingPartsInSameUserAgent;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withNotExistingPartsInUserAgent(notExistingPartsInUserAgent?: readonly string[]): this {
|
||||
this.notExistingPartsInUserAgent = notExistingPartsInUserAgent;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withTouchSupport(touchSupport?: TouchSupportExpectation): this {
|
||||
this.touchSupport = touchSupport;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
17
tests/unit/shared/Stubs/BrowserEnvironmentStub.ts
Normal file
17
tests/unit/shared/Stubs/BrowserEnvironmentStub.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { BrowserEnvironment } from '@/infrastructure/RuntimeEnvironment/BrowserOs/BrowserOsDetector';
|
||||
|
||||
export class BrowserEnvironmentStub implements BrowserEnvironment {
|
||||
public isTouchSupported = false;
|
||||
|
||||
public userAgent = `[${BrowserEnvironmentStub.name}] User-Agent`;
|
||||
|
||||
public withIsTouchSupported(isTouchSupported: boolean): this {
|
||||
this.isTouchSupported = isTouchSupported;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withUserAgent(userAgent: string): this {
|
||||
this.userAgent = userAgent;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,15 @@
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { IBrowserOsDetector } from '@/infrastructure/RuntimeEnvironment/BrowserOs/IBrowserOsDetector';
|
||||
import { BrowserEnvironment, BrowserOsDetector } from '@/infrastructure/RuntimeEnvironment/BrowserOs/BrowserOsDetector';
|
||||
import { StubWithObservableMethodCalls } from './StubWithObservableMethodCalls';
|
||||
|
||||
export class BrowserOsDetectorStub implements IBrowserOsDetector {
|
||||
public detect(): OperatingSystem {
|
||||
export class BrowserOsDetectorStub
|
||||
extends StubWithObservableMethodCalls<BrowserOsDetector>
|
||||
implements BrowserOsDetector {
|
||||
public detect(environment: BrowserEnvironment): OperatingSystem {
|
||||
this.registerMethodCall({
|
||||
methodName: 'detect',
|
||||
args: [environment],
|
||||
});
|
||||
return OperatingSystem.BlackBerryTabletOS;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user