Skip to content

GAUD-10062: expose waitForElem#993

Open
dlockhart wants to merge 2 commits into
mainfrom
GAUD-10062/expose-waitForElem
Open

GAUD-10062: expose waitForElem#993
dlockhart wants to merge 2 commits into
mainfrom
GAUD-10062/expose-waitForElem

Conversation

@dlockhart
Copy link
Copy Markdown
Member

In somewhat rare circumstances, changing a component's state can cause a totally different set of components within it to render. One example might be putting it into an error state. When this happens, awaiting updateComplete isn't often enough, as those new nested components might have language terms that need to load or they may need to do their own asynchronous work.

To solve this, we expose waitForElem -- which is already used internally by the original fixture call.

@dlockhart dlockhart requested a review from a team as a code owner May 21, 2026 20:43
Comment thread src/browser/fixture.js
if (typeof update === 'object' && Promise.resolve(update) === update) {
await update;
if (awaitLoadingComplete && typeof elem.getLoadingComplete === 'function') {
await elem.getLoadingComplete();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've also flipped the order here. We first wait for getLoadingComplete and then we wait for updateComplete. The reasoning here is that almost always getLoadingComplete resolving is going to trigger some kind of state change, so we wait for updateComplete after that.

Comment thread README.md
```

### Accessibility Testing with aXe
### Accessibility Testing with axe
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

While I was here...

Comment on lines +356 to +361
elem.slow = true;
const waitPromise = waitForElem(elem);
await waitUntil(() => resolves.has('slow'));
timeouts.push(setTimeout(() => resolves.get('slow')(), 50));
await waitPromise;
expect(elem.shadowRoot.querySelector(slowElem).finished).to.be.true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we be concerned that the waitUntil is actually the thing delaying long enough to make the expect pass? Can we use hasChanged or an event instead? Does setting slow on the original fixture not hold waitForElem until everything is done?

Suggested change
elem.slow = true;
const waitPromise = waitForElem(elem);
await waitUntil(() => resolves.has('slow'));
timeouts.push(setTimeout(() => resolves.get('slow')(), 50));
await waitPromise;
expect(elem.shadowRoot.querySelector(slowElem).finished).to.be.true;
const waitPromise = waitForElem(elem);
elem.slow = true;
await waitPromise;
expect(elem.shadowRoot.querySelector(slowElem).finished).to.be.true;
Image

Like waitPromise is never going to resolve before elem.slow is set, and then that would kick off the update cycle and should hold the await until finished is set... I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants