Skip to content

Commit 0021d2c

Browse files
authored
test(tooltip/testing): disable tests on touch devices (#19447)
Currently the tooltip harness won't work on touch devices, because we don't simulate touch events. These changes temporarily disable the tests on unsupported devices until we can update the harness APIs.
1 parent 7e74064 commit 0021d2c

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/material/tooltip/testing/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ ng_test_library(
2424
srcs = ["shared.spec.ts"],
2525
deps = [
2626
":testing",
27+
"//src/cdk/platform",
2728
"//src/cdk/testing",
2829
"//src/cdk/testing/testbed",
2930
"//src/material/tooltip",

src/material/tooltip/testing/shared.spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ import {ComponentFixture, TestBed} from '@angular/core/testing';
55
import {MatTooltipModule} from '@angular/material/tooltip';
66
import {MatTooltipHarness} from '@angular/material/tooltip/testing/tooltip-harness';
77
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
8+
import {Platform} from '@angular/cdk/platform';
89

910
/** Shared tests to run on both the original and MDC-based tooltips. */
1011
export function runHarnessTests(
1112
tooltipModule: typeof MatTooltipModule, tooltipHarness: typeof MatTooltipHarness) {
13+
// TODO(COMP-322): whether the current test device is supported by the harness. At the time of
14+
// writing, we have to skip these tests on touch devices, because we don't have a way of
15+
// simulating touch events. This variable should be removed once the issue is resolved.
16+
let isSupported: boolean;
1217
let fixture: ComponentFixture<TooltipHarnessTest>;
1318
let loader: HarnessLoader;
1419

@@ -21,21 +26,36 @@ export function runHarnessTests(
2126
fixture = TestBed.createComponent(TooltipHarnessTest);
2227
fixture.detectChanges();
2328
loader = TestbedHarnessEnvironment.loader(fixture);
29+
30+
const platform = TestBed.inject(Platform);
31+
isSupported = !platform.IOS && !platform.ANDROID;
2432
});
2533

2634
it('should load all tooltip harnesses', async () => {
35+
if (!isSupported) {
36+
return;
37+
}
38+
2739
const tooltips = await loader.getAllHarnesses(tooltipHarness);
2840
expect(tooltips.length).toBe(2);
2941
});
3042

3143
it('should be able to show a tooltip', async () => {
44+
if (!isSupported) {
45+
return;
46+
}
47+
3248
const tooltip = await loader.getHarness(tooltipHarness.with({selector: '#one'}));
3349
expect(await tooltip.isOpen()).toBe(false);
3450
await tooltip.show();
3551
expect(await tooltip.isOpen()).toBe(true);
3652
});
3753

3854
it('should be able to hide a tooltip', async () => {
55+
if (!isSupported) {
56+
return;
57+
}
58+
3959
const tooltip = await loader.getHarness(tooltipHarness.with({selector: '#one'}));
4060
expect(await tooltip.isOpen()).toBe(false);
4161
await tooltip.show();
@@ -45,12 +65,20 @@ export function runHarnessTests(
4565
});
4666

4767
it('should be able to get the text of a tooltip', async () => {
68+
if (!isSupported) {
69+
return;
70+
}
71+
4872
const tooltip = await loader.getHarness(tooltipHarness.with({selector: '#one'}));
4973
await tooltip.show();
5074
expect(await tooltip.getTooltipText()).toBe('Tooltip message');
5175
});
5276

5377
it('should return empty when getting the tooltip text while closed', async () => {
78+
if (!isSupported) {
79+
return;
80+
}
81+
5482
const tooltip = await loader.getHarness(tooltipHarness.with({selector: '#one'}));
5583
expect(await tooltip.getTooltipText()).toBe('');
5684
});

0 commit comments

Comments
 (0)