Skip to content

ci: update remote browsers in saucelabs and browserstack #24468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cdk-experimental/menu/context-menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe('CdkContextMenuTrigger', () => {

it('should focus the first menuitem when the context menu is opened', () => {
openContextMenu();
expect(document.querySelector(':focus')!.id).toEqual('first_menu_item');
expect(document.activeElement!.id).toEqual('first_menu_item');
});
});

Expand Down
6 changes: 3 additions & 3 deletions src/cdk-experimental/menu/menu-bar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -986,8 +986,8 @@ describe('MenuBar', () => {
dispatchMouseEvent(menuBarNativeItems[0], 'mouseenter');
detectChanges();

expect(document.querySelector(':focus')).not.toEqual(menuBarNativeItems[0]);
expect(document.querySelector(':focus')).not.toEqual(menuBarNativeItems[1]);
expect(document.activeElement).not.toEqual(menuBarNativeItems[0]);
expect(document.activeElement).not.toEqual(menuBarNativeItems[1]);
},
);

Expand Down Expand Up @@ -1089,7 +1089,7 @@ describe('MenuBar', () => {

dispatchKeyboardEvent(nativeMenus[0], 'keydown', DOWN_ARROW);

expect(document.querySelector(':focus')).toEqual(fileMenuNativeItems[1]);
expect(document.activeElement).toEqual(fileMenuNativeItems[1]);
},
);

Expand Down
2 changes: 1 addition & 1 deletion src/cdk-experimental/menu/menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ describe('Menu', () => {
dispatchKeyboardEvent(document, 'keydown', TAB);
nativeMenu.focus();

expect(document.querySelector(':focus')).toEqual(nativeMenuItems[0]);
expect(document.activeElement).toEqual(nativeMenuItems[0]);
});
});

Expand Down
3 changes: 3 additions & 0 deletions src/cdk/table/table.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2435,6 +2435,9 @@ class StickyPositioningListenerTest implements StickyPositioningListener {
display: block;
width: 20px;
}
.cdk-header-row, .cdk-row, .cdk-footer-row {
display: flex;
}
`,
],
providers: [{provide: STICKY_POSITIONING_LISTENER, useExisting: StickyFlexLayoutCdkTableApp}],
Expand Down
24 changes: 20 additions & 4 deletions src/cdk/testing/testbed/unit-test-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,15 @@ export class UnitTestElement implements TestElement {
async click(
...args: [ModifierKeys?] | ['center', ModifierKeys?] | [number, number, ModifierKeys?]
): Promise<void> {
await this._dispatchMouseEventSequence('click', args, 0);
const isDisabled = (this.element as Partial<{disabled?: boolean}>).disabled === true;

// If the element is `disabled` and has a `disabled` property, we emit the mouse event
// sequence but not dispatch the `click` event. This is necessary to keep the behavior
// consistent with an actual user interaction. The click event is not necessarily
// automatically prevented by the browser. There is mismatch between Firefox and Chromium:
// https://bugzilla.mozilla.org/show_bug.cgi?id=329509.
// https://bugs.chromium.org/p/chromium/issues/detail?id=1115661.
await this._dispatchMouseEventSequence(isDisabled ? null : 'click', args, 0);
await this._stabilize();
}

Expand Down Expand Up @@ -284,9 +292,12 @@ export class UnitTestElement implements TestElement {
}
}

/** Dispatches all the events that are part of a mouse event sequence. */
/**
* Dispatches all the events that are part of a mouse event sequence
* and then emits a given primary event at the end, if speciifed.
*/
private async _dispatchMouseEventSequence(
name: string,
primaryEventName: string | null,
args: [ModifierKeys?] | ['center', ModifierKeys?] | [number, number, ModifierKeys?],
button?: number,
) {
Expand All @@ -313,11 +324,16 @@ export class UnitTestElement implements TestElement {
dispatchMouseEvent(this.element, 'mousedown', clientX, clientY, button, modifiers);
this._dispatchPointerEventIfSupported('pointerup', clientX, clientY, button);
dispatchMouseEvent(this.element, 'mouseup', clientX, clientY, button, modifiers);
dispatchMouseEvent(this.element, name, clientX, clientY, button, modifiers);

// If a primary event name is specified, emit it after the mouse event sequence.
if (primaryEventName !== null) {
dispatchMouseEvent(this.element, primaryEventName, clientX, clientY, button, modifiers);
}

// This call to _stabilize should not be needed since the callers will already do that them-
// selves. Nevertheless it breaks some tests in g3 without it. It needs to be investigated
// why removing breaks those tests.
// See: https://github.com/angular/components/pull/20758/files#r520886256.
await this._stabilize();
}
}
4 changes: 2 additions & 2 deletions src/material-experimental/menubar/menubar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ describe('MatMenuBar', () => {
it('should toggle focused items on left/right click', () => {
nativeMatMenubar.focus();

expect(document.querySelector(':focus')!.id).toBe('first');
expect(document.activeElement!.id).toBe('first');

dispatchKeyboardEvent(nativeMatMenubar, 'keydown', RIGHT_ARROW);
fixture.detectChanges();

expect(document.querySelector(':focus')!.id).toBe('second');
expect(document.activeElement!.id).toBe('second');
});
});

Expand Down
1 change: 0 additions & 1 deletion src/material/checkbox/testing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ng_test_library(
srcs = ["shared.spec.ts"],
deps = [
":testing",
"//src/cdk/platform",
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/checkbox",
Expand Down
8 changes: 0 additions & 8 deletions src/material/checkbox/testing/shared.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {Platform} from '@angular/cdk/platform';
import {HarnessLoader} from '@angular/cdk/testing';
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
import {Component} from '@angular/core';
Expand All @@ -15,7 +14,6 @@ export function runHarnessTests(
checkboxModule: typeof MatCheckboxModule,
checkboxHarness: typeof MatCheckboxHarness,
) {
let platform: Platform;
let fixture: ComponentFixture<CheckboxHarnessTest>;
let loader: HarnessLoader;

Expand All @@ -25,7 +23,6 @@ export function runHarnessTests(
declarations: [CheckboxHarnessTest],
}).compileComponents();

platform = TestBed.inject(Platform);
fixture = TestBed.createComponent(CheckboxHarnessTest);
fixture.detectChanges();
loader = TestbedHarnessEnvironment.loader(fixture);
Expand Down Expand Up @@ -155,11 +152,6 @@ export function runHarnessTests(
});

it('should not toggle disabled checkbox', async () => {
if (platform.FIREFOX) {
// do run this test on firefox as click events on the label of a disabled checkbox
// cause the value to be changed. https://bugzilla.mozilla.org/show_bug.cgi?id=1540995
return;
}
const disabledCheckbox = await loader.getHarness(checkboxHarness.with({label: 'Second'}));
expect(await disabledCheckbox.isChecked()).toBe(false);
await disabledCheckbox.toggle();
Expand Down
1 change: 0 additions & 1 deletion src/material/radio/testing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ng_test_library(
srcs = ["shared.spec.ts"],
deps = [
":testing",
"//src/cdk/platform",
"//src/cdk/testing",
"//src/cdk/testing/private",
"//src/cdk/testing/testbed",
Expand Down
10 changes: 0 additions & 10 deletions src/material/radio/testing/shared.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {Platform} from '@angular/cdk/platform';
import {HarnessLoader} from '@angular/cdk/testing';
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
import {Component} from '@angular/core';
Expand All @@ -13,7 +12,6 @@ export function runHarnessTests(
radioGroupHarness: typeof MatRadioGroupHarness,
radioButtonHarness: typeof MatRadioButtonHarness,
) {
let platform: Platform;
let fixture: ComponentFixture<MultipleRadioButtonsHarnessTest>;
let loader: HarnessLoader;

Expand All @@ -23,7 +21,6 @@ export function runHarnessTests(
declarations: [MultipleRadioButtonsHarnessTest],
}).compileComponents();

platform = TestBed.inject(Platform);
fixture = TestBed.createComponent(MultipleRadioButtonsHarnessTest);
fixture.detectChanges();
loader = TestbedHarnessEnvironment.loader(fixture);
Expand Down Expand Up @@ -243,13 +240,6 @@ export function runHarnessTests(
});

it('should not be able to check disabled radio-button', async () => {
if (platform.FIREFOX) {
// do run this test on firefox as click events on the label of the underlying
// input checkbox cause the value to be changed. Read more in the bug report:
// https://bugzilla.mozilla.org/show_bug.cgi?id=1540995
return;
}

fixture.componentInstance.disableAll = true;
fixture.detectChanges();

Expand Down
1 change: 0 additions & 1 deletion src/material/slide-toggle/testing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ng_test_library(
srcs = ["shared.spec.ts"],
deps = [
":testing",
"//src/cdk/platform",
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/slide-toggle",
Expand Down
10 changes: 0 additions & 10 deletions src/material/slide-toggle/testing/shared.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {Platform} from '@angular/cdk/platform';
import {HarnessLoader} from '@angular/cdk/testing';
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
import {Component} from '@angular/core';
Expand All @@ -12,7 +11,6 @@ export function runHarnessTests(
slideToggleModule: typeof MatSlideToggleModule,
slideToggleHarness: typeof MatSlideToggleHarness,
) {
let platform: Platform;
let fixture: ComponentFixture<SlideToggleHarnessTest>;
let loader: HarnessLoader;

Expand All @@ -22,7 +20,6 @@ export function runHarnessTests(
declarations: [SlideToggleHarnessTest],
}).compileComponents();

platform = TestBed.inject(Platform);
fixture = TestBed.createComponent(SlideToggleHarnessTest);
fixture.detectChanges();
loader = TestbedHarnessEnvironment.loader(fixture);
Expand Down Expand Up @@ -149,13 +146,6 @@ export function runHarnessTests(
});

it('should not toggle disabled slide-toggle', async () => {
if (platform.FIREFOX) {
// do not run this test on firefox as click events on the label of the underlying
// input checkbox cause the value to be changed. Read more in the bug report:
// https://bugzilla.mozilla.org/show_bug.cgi?id=1540995
return;
}

const disabledToggle = await loader.getHarness(slideToggleHarness.with({label: 'Second'}));
expect(await disabledToggle.isChecked()).toBe(false);
await disabledToggle.toggle();
Expand Down
4 changes: 2 additions & 2 deletions test/browser-providers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* - `saucelabs`: Launches the browser within Saucelabs
*/
const browserConfig = {
'iOS14': {unitTest: {target: 'saucelabs'}},
'Safari13': {unitTest: {target: 'browserstack'}},
'iOS15': {unitTest: {target: 'saucelabs'}},
'Safari15': {unitTest: {target: 'browserstack'}},
};

/** Exports all available custom Karma browsers. */
Expand Down
14 changes: 7 additions & 7 deletions test/karma-browsers.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"SAUCELABS_IOS14": {
"SAUCELABS_IOS15": {
"base": "SauceLabs",
"appiumVersion": "1.20.1",
"appiumVersion": "1.22.0",
"deviceOrientation": "portrait",
"browserName": "Safari",
"platformVersion": "14.3",
"platformVersion": "15.0",
"platformName": "iOS",
"deviceName": "iPhone 12 Pro Simulator"
"deviceName": "iPhone 13 Pro Max Simulator"
},
"BROWSERSTACK_SAFARI13": {
"BROWSERSTACK_SAFARI15": {
"base": "BrowserStack",
"browser": "Safari",
"browser_version": "13.1",
"browser_version": "15.0",
"os": "OS X",
"os_version": "Catalina"
"os_version": "Monterey"
}
}