Skip to content

Commit 51b7118

Browse files
committed
test(mobile): cover the new attachment boundary in draft recovery
1 parent a1c89a0 commit 51b7118

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

‎apps/mobile/src/state/use-composer-drafts.test.ts‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ describe("mobile composer drafts", () => {
676676
return undefined;
677677
});
678678
const key = "environment-1:replace-file";
679-
const files = Array.from({ length: 8 }, (_, index) => ({
679+
const files = Array.from({ length: 20 }, (_, index) => ({
680680
id: `file-${index}`,
681681
type: "file" as const,
682682
name: `notes-${index}.txt`,
@@ -687,8 +687,8 @@ describe("mobile composer drafts", () => {
687687
appendComposerDraftAttachments(key, files, { appendReference: true });
688688
const firstLink = "[notes-0.txt](t3-context://v1/file/file-0)";
689689
const insertion = captureComposerDraftInsertion(key, { start: 0, end: firstLink.length });
690-
expect(countComposerDraftAttachmentsAfterSelection(key, insertion)).toBe(7);
691-
expect(getComposerDraftAfterSelection(key, insertion).context?.records).toHaveLength(7);
690+
expect(countComposerDraftAttachmentsAfterSelection(key, insertion)).toBe(19);
691+
expect(getComposerDraftAfterSelection(key, insertion).context?.records).toHaveLength(19);
692692
const replacement = { ...files[0]!, id: "replacement", fileUri: "file:///replacement.txt" };
693693
if (kind === "attachment") {
694694
expect(
@@ -716,7 +716,7 @@ describe("mobile composer drafts", () => {
716716
insertion,
717717
),
718718
).toBe(true);
719-
expect(getComposerDraftSnapshot(key).attachments).toHaveLength(8);
719+
expect(getComposerDraftSnapshot(key).attachments).toHaveLength(20);
720720
expect(getComposerDraftSnapshot(key).context?.records).toContainEqual(record);
721721
expect(getComposerDraftSnapshot(key).text).toBe(
722722
`${formatComposerContextReference(record)}${insertion.text.slice(firstLink.length)}`,
@@ -730,7 +730,7 @@ describe("mobile composer drafts", () => {
730730
}
731731
const draft = getComposerDraftSnapshot(key);
732732
expect(draft.attachments.map((file) => file.id)).not.toContain("file-0");
733-
expect(draft.attachments.slice(0, 7)).toEqual(files.slice(1));
733+
expect(draft.attachments.slice(0, 19)).toEqual(files.slice(1));
734734
expect(draft.context?.records.some((record) => record.contextId === "file-0")).toBe(false);
735735
await cleanup.promise;
736736
expect(composerAttachmentCleanupMocks.remove).toHaveBeenCalledWith(files[0]!.fileUri);
@@ -746,7 +746,7 @@ describe("mobile composer drafts", () => {
746746
return undefined;
747747
});
748748
const key = "environment-1:concurrent-import";
749-
const files = Array.from({ length: 8 }, (_, index) => ({
749+
const files = Array.from({ length: 20 }, (_, index) => ({
750750
id: `existing-${index}`,
751751
type: "file" as const,
752752
name: `notes-${index}.txt`,
@@ -906,7 +906,7 @@ describe("mobile composer drafts", () => {
906906
fileUri: `file:///documents/t3-composer-attachments/${id}.mov`,
907907
});
908908
const draftKey = "new-task:environment-1:project-cap";
909-
const existing = Array.from({ length: 7 }, (_, index) => makeAttachment(`held-${index}`));
909+
const existing = Array.from({ length: 19 }, (_, index) => makeAttachment(`held-${index}`));
910910
appAtomRegistry.set(composerDraftsAtom, {
911911
[draftKey]: { text: "send this", attachments: existing },
912912
});
@@ -918,7 +918,7 @@ describe("mobile composer drafts", () => {
918918

919919
expect(rejected).toBe(1);
920920
const draft = appAtomRegistry.get(composerDraftsAtom)[draftKey];
921-
expect(draft?.attachments).toHaveLength(8);
921+
expect(draft?.attachments).toHaveLength(20);
922922
expect(draft?.attachments.at(-1)?.id).toBe("incoming-1");
923923
await cleanup.promise;
924924
expect(composerAttachmentCleanupMocks.remove).toHaveBeenCalledExactlyOnceWith(
@@ -932,7 +932,7 @@ describe("mobile composer drafts", () => {
932932
{ allowOverflow: true },
933933
);
934934
expect(overflowRejected).toBe(0);
935-
expect(appAtomRegistry.get(composerDraftsAtom)[draftKey]?.attachments).toHaveLength(9);
935+
expect(appAtomRegistry.get(composerDraftsAtom)[draftKey]?.attachments).toHaveLength(21);
936936
});
937937

938938
it("keeps shared attachment files until every draft releases them", async () => {
@@ -2270,17 +2270,17 @@ describe("mobile composer drafts", () => {
22702270
previewUri: "data:image/png;base64,YWJj",
22712271
});
22722272
const existingImage = image("existing");
2273-
const sharedImages = Array.from({ length: 8 }, (_, index) => image(`shared-${index}`));
2273+
const sharedImages = Array.from({ length: 20 }, (_, index) => image(`shared-${index}`));
22742274

22752275
const merged = mergeComposerDraftContentState(
22762276
{ [draftKey]: { text: "", attachments: [existingImage] } },
22772277
draftKey,
22782278
{ text: "", attachments: sharedImages },
22792279
);
22802280

2281-
expect(merged[draftKey]?.attachments).toHaveLength(8);
2281+
expect(merged[draftKey]?.attachments).toHaveLength(20);
22822282
expect(merged[draftKey]?.attachments[0]).toEqual(existingImage);
2283-
expect(merged[draftKey]?.attachments.at(-1)?.id).toBe("shared-6");
2283+
expect(merged[draftKey]?.attachments.at(-1)?.id).toBe("shared-18");
22842284
});
22852285

22862286
it("restores the exact draft captured before an interrupted share import", () => {

0 commit comments

Comments
 (0)