Skip to content

Commit a9fffd7

Browse files
committed
WIP: attempt to get protractor working
1 parent fd53473 commit a9fffd7

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/cdk/testing/tests/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@ ng_e2e_test_library(
5454
"//src/cdk/testing",
5555
"//src/cdk/testing/private",
5656
"//src/cdk/testing/protractor",
57+
"@npm//kagekiri",
5758
],
5859
)

src/cdk/testing/tests/protractor.e2e.spec.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ import {
66
} from '@angular/cdk/testing';
77
import {expectAsyncError} from '@angular/cdk/testing/private';
88
import {ProtractorHarnessEnvironment} from '@angular/cdk/testing/protractor';
9-
import {browser} from 'protractor';
9+
import {browser, by, ElementFinder} from 'protractor';
1010
import {MainComponentHarness} from './harnesses/main-component-harness';
1111
import {SubComponentHarness, SubComponentSpecialHarness} from './harnesses/sub-component-harness';
12+
import {querySelectorAll as piercingQuerySelectorAll} from 'kagekiri';
13+
14+
const piercingQueryFn =
15+
(selector: string, root: ElementFinder) => root.all(by.js(function(this: any) {
16+
piercingQuerySelectorAll(selector, this);
17+
}));
1218

1319
describe('ProtractorHarnessEnvironment', () => {
1420
beforeEach(async () => {
@@ -456,6 +462,27 @@ describe('ProtractorHarnessEnvironment', () => {
456462
}
457463
});
458464
});
465+
466+
describe('shadow DOM interaction', () => {
467+
it('should not pierce shadow boundary by default', async () => {
468+
const harness = await ProtractorHarnessEnvironment.loader(piercingQueryFn)
469+
.getHarness(MainComponentHarness);
470+
expect(await harness.shadows()).toEqual([]);
471+
});
472+
473+
it('should pierce shadow boundary when using piercing query', async () => {
474+
const harness = await ProtractorHarnessEnvironment.loader(piercingQueryFn)
475+
.getHarness(MainComponentHarness);
476+
const shadows = await harness.shadows();
477+
expect(await Promise.all(shadows.map(el => el.text()))).toEqual(['Shadow 1', 'Shadow 2']);
478+
});
479+
480+
it('should allow querying across shadow boundary', async () => {
481+
const harness = await ProtractorHarnessEnvironment.loader(piercingQueryFn)
482+
.getHarness(MainComponentHarness);
483+
expect(await (await harness.deepShadow()).text()).toBe('Shadow 2');
484+
});
485+
});
459486
});
460487

461488
async function checkIsElement(result: ComponentHarness | TestElement, selector?: string) {

0 commit comments

Comments
 (0)