Skip to content

Commit 8021816

Browse files
authored
Bug Fix: handle non existent data field in paginated data (#1359)
* Bug Fix: handle non existent data in page The new list user saved searches returns no data field in the page if there is none. A logged in user will get this error in the console: ``` TypeError: a.data is not iterable (cannot read property undefined) ``` This solves that * remove console assertion
1 parent 15a066a commit 8021816

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

e2e/tests/overview-page.spec.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
*/
1616

1717
import {test, expect, Request} from '@playwright/test';
18-
import {gotoOverviewPageUrl, getOverviewPageFeatureCount} from './utils';
18+
import {
19+
gotoOverviewPageUrl,
20+
getOverviewPageFeatureCount,
21+
loginAsUser,
22+
} from './utils';
1923

2024
test('matches the screenshot', async ({page}) => {
2125
await gotoOverviewPageUrl(page, 'http://localhost:5555/');
@@ -258,6 +262,12 @@ test('Typing slash focuses on searchbox', async ({page}) => {
258262
await expect(searchbox).toHaveAttribute('value', 'def/ghi');
259263
});
260264

265+
test('newly logged in user should see no errors (toasts)', async ({page}) => {
266+
await loginAsUser(page, 'fresh user');
267+
await gotoOverviewPageUrl(page, 'http://localhost:5555/');
268+
await expect(page.locator('.toast')).toHaveCount(0);
269+
});
270+
261271
test.describe('saved searches', () => {
262272
test('unauthenticated user can load a public saved search and navigate pages', async ({
263273
page,

frontend/src/static/js/api/client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ export class APIClient {
269269
);
270270

271271
nextPageToken = page?.metadata?.next_page_token;
272-
allData.push(...page.data);
272+
allData.push(...(page.data ?? []));
273273
offset += (page.data || []).length;
274274
} while (nextPageToken !== undefined);
275275

util/cmd/load_test_users/main.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,10 @@ func getUsers() []User {
116116
EmailVerified: true,
117117
UserID: "abcdedf1234567892",
118118
},
119+
// This user should have no data and should be used to replicate the experience of a newly logged in user.
119120
{
120-
Name: "test user 3",
121-
Email: "test.user.3@example.com",
121+
Name: "fresh user",
122+
Email: "fresh[email protected]",
122123
EmailVerified: true,
123124
UserID: "abcdedf1234567893",
124125
},

0 commit comments

Comments
 (0)