Skip to content

Commit b8192d2

Browse files
committed
test(multiple): remove checks for popover from test (#32622)
After #32422 all our test environments should support popovers. These changes remove some workarounds meant to handle browsers that don't support it. (cherry picked from commit 14479d4)
1 parent 96a20fd commit b8192d2

File tree

3 files changed

+8
-39
lines changed

3 files changed

+8
-39
lines changed

src/cdk/overlay/position/flexible-connected-position-strategy.spec.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2992,10 +2992,6 @@ describe('FlexibleConnectedPositionStrategy', () => {
29922992
});
29932993

29942994
it('should be able to opt into placing the overlay inside an adjacent popover element', () => {
2995-
if (!('showPopover' in document.body)) {
2996-
return;
2997-
}
2998-
29992995
attachOverlay({positionStrategy, usePopover: true});
30002996

30012997
expect(containerElement.contains(overlayRef.hostElement)).toBe(false);
@@ -3004,10 +3000,6 @@ describe('FlexibleConnectedPositionStrategy', () => {
30043000
});
30053001

30063002
it('should re-attach the popover next to the origin element', () => {
3007-
if (!('showPopover' in document.body)) {
3008-
return;
3009-
}
3010-
30113003
attachOverlay({positionStrategy, usePopover: true});
30123004
expect(originElement.nextElementSibling).toBe(overlayRef.hostElement);
30133005

@@ -3020,10 +3012,6 @@ describe('FlexibleConnectedPositionStrategy', () => {
30203012
});
30213013

30223014
it('should insert the overlay as a child of a custom element', () => {
3023-
if (!('showPopover' in document.body)) {
3024-
return;
3025-
}
3026-
30273015
positionStrategy.withPopoverLocation({type: 'parent', element: customHostElement});
30283016
attachOverlay({positionStrategy, usePopover: true});
30293017

@@ -3033,10 +3021,6 @@ describe('FlexibleConnectedPositionStrategy', () => {
30333021
});
30343022

30353023
it('should insert the overlay as a child of the origin', () => {
3036-
if (!('showPopover' in document.body)) {
3037-
return;
3038-
}
3039-
30403024
positionStrategy.withPopoverLocation({type: 'parent', element: originElement});
30413025
attachOverlay({positionStrategy, usePopover: true});
30423026

src/material/autocomplete/autocomplete.spec.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Direction} from '@angular/cdk/bidi';
22
import {DOWN_ARROW, ENTER, ESCAPE, SPACE, TAB, UP_ARROW} from '@angular/cdk/keycodes';
3-
import {OverlayContainer, OverlayModule, createCloseScrollStrategy} from '@angular/cdk/overlay';
3+
import {OverlayModule, createCloseScrollStrategy} from '@angular/cdk/overlay';
44
import {_supportsShadowDom} from '@angular/cdk/platform';
55
import {ScrollDispatcher} from '@angular/cdk/scrolling';
66
import {
@@ -62,9 +62,6 @@ import {
6262
} from './index';
6363

6464
describe('MatAutocomplete', () => {
65-
const supportsPopover = 'showPopover' in document.body;
66-
let overlayContainerElement: HTMLElement;
67-
6865
// Creates a test component fixture.
6966
function createComponent<T>(component: Type<T>, providers: Provider[] = []) {
7067
TestBed.configureTestingModule({
@@ -74,21 +71,17 @@ describe('MatAutocomplete', () => {
7471
],
7572
});
7673

77-
overlayContainerElement = TestBed.inject(OverlayContainer).getContainerElement();
7874
return TestBed.createComponent<T>(component);
7975
}
8076

8177
function getOverlayHost(fixture: ComponentFixture<unknown>): HTMLElement | null {
82-
return supportsPopover
83-
? fixture.nativeElement.querySelector('.cdk-overlay-popover')
84-
: overlayContainerElement.querySelector('.cdk-overlay-connected-position-bounding-box');
78+
return fixture.nativeElement.querySelector('.cdk-overlay-popover');
8579
}
8680

8781
function getBackdrop(fixture: ComponentFixture<unknown>): HTMLElement | null {
88-
const selector = '.cdk-overlay-backdrop';
89-
return supportsPopover
90-
? getOverlayHost(fixture)?.querySelector(selector) || null
91-
: overlayContainerElement.querySelector(selector);
82+
return (
83+
fixture.nativeElement.querySelector('.cdk-overlay-popover .cdk-overlay-backdrop') || null
84+
);
9285
}
9386

9487
describe('panel toggling', () => {

src/material/select/select.spec.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
TAB,
1616
UP_ARROW,
1717
} from '@angular/cdk/keycodes';
18-
import {OverlayContainer, OverlayModule, createCloseScrollStrategy} from '@angular/cdk/overlay';
18+
import {OverlayModule, createCloseScrollStrategy} from '@angular/cdk/overlay';
1919
import {ScrollDispatcher} from '@angular/cdk/scrolling';
2020
import {
2121
createKeyboardEvent,
@@ -76,7 +76,6 @@ import {
7676
const DEFAULT_TYPEAHEAD_DEBOUNCE_INTERVAL = 200;
7777

7878
describe('MatSelect', () => {
79-
const supportsPopover = 'showPopover' in document.body;
8079
let dir: WritableSignal<Direction>;
8180
let scrolledSubject = new Subject();
8281

@@ -97,18 +96,11 @@ describe('MatSelect', () => {
9796
});
9897

9998
function getOverlayHost(fixture: ComponentFixture<unknown>): HTMLElement | null {
100-
return supportsPopover
101-
? fixture.nativeElement.querySelector('.cdk-overlay-popover')
102-
: TestBed.inject(OverlayContainer)
103-
.getContainerElement()
104-
.querySelector('.cdk-overlay-connected-position-bounding-box');
99+
return fixture.nativeElement.querySelector('.cdk-overlay-popover');
105100
}
106101

107102
function getBackdrop(fixture: ComponentFixture<unknown>): HTMLElement | null {
108-
const parent = supportsPopover
109-
? fixture.nativeElement
110-
: TestBed.inject(OverlayContainer).getContainerElement();
111-
return parent.querySelector('.cdk-overlay-backdrop');
103+
return fixture.nativeElement.querySelector('.cdk-overlay-backdrop');
112104
}
113105

114106
describe('core', () => {

0 commit comments

Comments
 (0)