-
Notifications
You must be signed in to change notification settings - Fork 0
[_]: feat/improved email pagination using anchor-based fetching #35
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
4b6a32e
fedde4b
20ca7c0
fc2ec78
46ad05f
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -144,6 +144,7 @@ const createEmailAddress = () => ({ | |||||
|
|
||||||
| export const getMockedMail = (): EmailResponse => ({ | ||||||
| id: faker.string.uuid(), | ||||||
| mailboxIds: [faker.string.alphanumeric(1), faker.string.alphanumeric(1)], | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use realistic mailbox IDs in fixtures. Line 147 generates 1-char mailbox IDs, but mailbox fixtures use UUIDs. This breaks referential realism and can hide mailbox-linking bugs in tests. Proposed fix- mailboxIds: [faker.string.alphanumeric(1), faker.string.alphanumeric(1)],
+ mailboxIds: [faker.string.uuid(), faker.string.uuid()],📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| threadId: faker.string.uuid(), | ||||||
| from: [createEmailAddress()], | ||||||
| to: [createEmailAddress()], | ||||||
|
|
@@ -167,6 +168,7 @@ export const getMockedMails = (count = 3): EmailListResponse => ({ | |||||
| const mail = getMockedMail(); | ||||||
| return { | ||||||
| id: mail.id, | ||||||
| mailboxIds: mail.mailboxIds, | ||||||
| threadId: mail.threadId, | ||||||
| from: mail.from, | ||||||
| to: mail.to, | ||||||
|
|
@@ -180,6 +182,8 @@ export const getMockedMails = (count = 3): EmailListResponse => ({ | |||||
| }; | ||||||
| }), | ||||||
| total: faker.number.int({ min: count, max: 500 }), | ||||||
| hasMoreMails: faker.datatype.boolean(), | ||||||
| nextAnchor: faker.string.uuid(), | ||||||
|
Comment on lines
+185
to
+186
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make pagination metadata deterministic and internally consistent. Lines 185-186 use random values; this can introduce flaky tests. Also, Proposed refactor-export const getMockedMails = (count = 3): EmailListResponse => ({
+export const getMockedMails = (
+ count = 3,
+ options: Partial<Pick<EmailListResponse, 'hasMoreMails' | 'nextAnchor'>> = {}
+): EmailListResponse => {
+ const hasMoreMails = options.hasMoreMails ?? false;
+ return {
emails: Array.from({ length: count }, () => {
const mail = getMockedMail();
return {
id: mail.id,
mailboxIds: mail.mailboxIds,
threadId: mail.threadId,
from: mail.from,
to: mail.to,
subject: mail.subject,
receivedAt: mail.receivedAt,
preview: mail.preview,
isRead: mail.isRead,
isFlagged: mail.isFlagged,
hasAttachment: mail.hasAttachment,
size: mail.size,
};
}),
total: faker.number.int({ min: count, max: 500 }),
- hasMoreMails: faker.datatype.boolean(),
- nextAnchor: faker.string.uuid(),
-});
+ hasMoreMails,
+ nextAnchor: hasMoreMails ? options.nextAnchor ?? faker.string.uuid() : '',
+ };
+};🤖 Prompt for AI Agents |
||||||
| }); | ||||||
|
|
||||||
| export const getMockedMailBoxes = (): MailboxResponse[] => [ | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.