Repository navigation
fix skeleton showing for declarative popup widgets #68
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1341,6 +1341,63 @@ defineFeature(feature, (test) => { | |||||||||||||||||||||
| }); | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| test("No loading skeleton is displayed for popup widgets before the popup is opened", ({ | ||||||||||||||||||||||
| given, | ||||||||||||||||||||||
| and, | ||||||||||||||||||||||
| when, | ||||||||||||||||||||||
| then, | ||||||||||||||||||||||
| }) => { | ||||||||||||||||||||||
| let el!: DeclarativePopupWidget; | ||||||||||||||||||||||
| let renderPromiseResolve!: () => void; | ||||||||||||||||||||||
| let renderPromise!: Promise<void>; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Background(given); | ||||||||||||||||||||||
| SquatchTenantIs(given); | ||||||||||||||||||||||
| SquatchTokenIs(and); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| and(/^the (.*) web-component is included in the page's HTML$/, (arg0) => { | ||||||||||||||||||||||
| el = specificWebComponentIsIncluded(arg0) as DeclarativePopupWidget; | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| and("the widget attribute is set to a valid SaaSquatch widget type", () => { | ||||||||||||||||||||||
| el.setAttribute("widget", "w/widget-type"); | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| when("the component starts loading", () => { | ||||||||||||||||||||||
| renderPromise = new Promise((resolve) => { | ||||||||||||||||||||||
| renderPromiseResolve = resolve; | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
| const originalRenderWidget = el.renderWidget.bind(el); | ||||||||||||||||||||||
| let proceedResolve: () => void; | ||||||||||||||||||||||
| const proceedPromise = new Promise<void>((r) => { | ||||||||||||||||||||||
| proceedResolve = r; | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
| vi.spyOn(el, "renderWidget").mockImplementation(async () => { | ||||||||||||||||||||||
| await proceedPromise; | ||||||||||||||||||||||
| await originalRenderWidget(); | ||||||||||||||||||||||
| renderPromiseResolve(); | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
| document.body.appendChild(el); | ||||||||||||||||||||||
| setTimeout(() => proceedResolve!(), 200); | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| then("no loading skeleton is injected into the shadow DOM", async () => { | ||||||||||||||||||||||
| // Give it time to potentially inject a skeleton, then confirm none exists | ||||||||||||||||||||||
| await new Promise((r) => setTimeout(r, 100)); | ||||||||||||||||||||||
| const skeleton = el.shadowRoot?.getElementById("loading-skeleton"); | ||||||||||||||||||||||
|
Comment on lines
+1385
to
+1387
|
||||||||||||||||||||||
| // Give it time to potentially inject a skeleton, then confirm none exists | |
| await new Promise((r) => setTimeout(r, 100)); | |
| const skeleton = el.shadowRoot?.getElementById("loading-skeleton"); | |
| await waitUntil( | |
| () => | |
| el.shadowRoot !== null && | |
| el.shadowRoot.getElementById("loading-skeleton") === null, | |
| "Expected shadowRoot to be attached without a loading skeleton" | |
| ); | |
| const skeleton = el.shadowRoot!.getElementById("loading-skeleton"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The skeleton HTML is still being imported/built unconditionally, but in the POPUP first-render path it’s now never appended anywhere. Consider restructuring so the dynamic import + skeletonContainer creation only happens when you’re actually going to inject a skeleton (EMBED always, POPUP only when an existing dialog container is found) to avoid unnecessary async work on initial popup load.