Skip to content

Commit 1f7e538

Browse files
chore(dialog): adds screenshot tests
PiperOrigin-RevId: 511353583
1 parent 0d862c3 commit 1f7e538

File tree

4 files changed

+32
-12
lines changed

4 files changed

+32
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ FAB | 🟢 | 🔴 | 🔴
3838
Icon button | 🟢 | 🔴 | 🔴
3939
Checkbox | 🟢 | 🟢 | 🔴
4040
Chips | 🔴 | 🔴 | 🔴
41-
Dialog | 🟢 | 🔴 | 🔴
41+
Dialog | 🟢 | 🟢 | 🔴
4242
Divider | 🟢 | 🟢 | 🟡
4343
Elevation | 🟢 | 🔴 | 🔴
4444
Focus ring | 🟢 | 🔴 | 🔴

dialog/harness.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,29 @@ export class DialogHarness extends Harness<Dialog> {
1919
HTMLDialogElement;
2020
}
2121

22-
async isOpening() {
23-
await this.element.updateComplete;
24-
return Boolean(this.element.open && this.element.hasAttribute('opening'));
22+
isOpening() {
23+
// Test access to state
24+
// tslint:disable-next-line:no-dict-access-on-struct-type
25+
return Boolean(this.element.open && this.element['opening']);
2526
}
2627

27-
async isClosing() {
28-
await this.element.updateComplete;
29-
return Boolean(!this.element.open && this.element.hasAttribute('closing'));
28+
isClosing() {
29+
// Test access to state
30+
// tslint:disable-next-line:no-dict-access-on-struct-type
31+
return Boolean(!this.element.open && this.element['closing']);
3032
}
3133

3234
async transitionComplete() {
35+
await this.element.updateComplete;
3336
let resolve = () => {};
3437
const doneTransitioning = new Promise<void>(resolver => {
3538
resolve = () => {
3639
resolver();
3740
};
3841
});
39-
if (await this.isOpening()) {
42+
if (this.isOpening()) {
4043
this.element.addEventListener('opened', resolve, {once: true});
41-
} else if (await this.isClosing()) {
44+
} else if (this.isClosing()) {
4245
this.element.addEventListener('closed', resolve, {once: true});
4346
} else {
4447
resolve();

dialog/lib/dialog.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,13 @@ export class Dialog extends LitElement {
384384
// Compute desired transition duration.
385385
const duration = msFromTimeCSSValue(getComputedStyle(this).getPropertyValue(
386386
this.open ? OPENING_TRANSITION_PROP : CLOSING_TRANSITION_PROP));
387-
await new Promise(r => {
388-
setTimeout(r, duration);
389-
});
387+
let promise = this.updateComplete;
388+
if (duration > 0) {
389+
promise = new Promise((r) => {
390+
setTimeout(r, duration);
391+
});
392+
}
393+
await promise;
390394
this.opening = false;
391395
this.closing = false;
392396
if (!this.open && this.dialogElement.open) {

dialog/test/window_size.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"capabilities": {
3+
"goog:chromeOptions": {
4+
"args": ["--window-position=0,0", "--window-size=599,800"]
5+
},
6+
"moz:firefoxOptions": {
7+
"args": ["-width=599","-height=800"]
8+
}
9+
},
10+
"extension": {
11+
"xvfbResolution": "599x800x24"
12+
}
13+
}

0 commit comments

Comments
 (0)