Skip to content
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

Add a vdiff demonstrating delayed content #5312

Merged
merged 6 commits into from
Jan 15, 2025
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
40 changes: 39 additions & 1 deletion components/dialog/test/dialog-mixin.vdiff.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
import '../dialog.js';
import { clickElem, expect, fixture, focusElem, html, oneEvent, sendKeys } from '@brightspace-ui/testing';
import { clickElem, defineCE, expect, fixture, focusElem, html, oneEvent, sendKeys } from '@brightspace-ui/testing';
import { footer, general } from './dialog-shared-contents.js';
import { LitElement } from 'lit';
import { LoadingCompleteMixin } from '../../../mixins/loading-complete/loading-complete-mixin.js';

const delayedTag = defineCE(
class extends LoadingCompleteMixin(LitElement) {
static get properties() {
return {
loaded: { type: Boolean }
};
}
constructor() {
super();
this.loaded = false;
}
render() {
return this.loaded ?
html`<div style="border: 2px solid green; margin: 200px;">Loaded</div>` :
html`<div style="border: 2px solid red; margin: 10px;">Loading...</div>`;
}
finishLoading() {
this.loaded = true;
this.resolveLoadingComplete();
}
}
);

describe('dialog-mixin', () => {

Expand Down Expand Up @@ -51,6 +76,19 @@ describe('dialog-mixin', () => {
});
});
});

it('delayed-content', async() => {
const el = await fixture(
`<d2l-dialog title-text="Delayed Dialog"><${delayedTag}></${delayedTag}></d2l-dialog>`,
{
awaitLoadingComplete: false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a special configuration option because otherwise the fixture call itself would wait for all the descendants to be loading-complete. In this case, we want to bypass that since we want to make sure that dialog itself waits for them.

}
);
setTimeout(() => el.querySelector(delayedTag).finishLoading(), 500);
el.opened = true;
await oneEvent(el, 'd2l-dialog-open');
await expect(document).to.be.golden();
});
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading