Skip to content

Commit

Permalink
add waitfornetworkidle
Browse files Browse the repository at this point in the history
  • Loading branch information
alexprudhomme committed Sep 19, 2024
1 parent 0932ef8 commit b1ec210
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,15 @@ test.describe('with a carousel', () => {
);
});
});

test('with no recommendations returned by the API, should render placeholders', async ({
recsList,
page,
}) => {
await recsList.noRecommendations();
await recsList.load({story: 'default'});
await recsList.hydrated.waitFor();

await page.waitForLoadState('networkidle');
await expect(recsList.placeholder.first()).toBeVisible();
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,21 @@ export class AtomicCommerceRecsListPageObject extends BasePageObject<'atomic-rec
get prevButton() {
return this.page.getByLabel('Previous');
}

async noRecommendations() {
await this.page.route(
'**/search/v2?organizationId=searchuisamples',
async (route) => {
const response = await route.fetch();
const body = await response.json();
body.results = [];
await route.fulfill({
response,
json: body,
});
}
);

return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const meta: Meta = {
<div>
<h1>External components of interface #2</h1>
<atomic-external selector="#interface-2">
<atomic-search-box textarea></atomic-search-box>
<atomic-search-box></atomic-search-box>
<atomic-query-summary></atomic-query-summary>
<atomic-facet field="author" label="Author"></atomic-facet>
</atomic-external>
Expand All @@ -48,7 +48,7 @@ const meta: Meta = {
>
<atomic-format-currency currency="USD"></atomic-format-currency>
</atomic-numeric-facet>
<atomic-search-box textarea></atomic-search-box>
<atomic-search-box></atomic-search-box>
<atomic-result-list></atomic-result-list>
</atomic-search-interface>
</div>
Expand Down

0 comments on commit b1ec210

Please sign in to comment.