Skip to content

Commit 38cccdd

Browse files
refactor(mobile): test composer persistence through the live decoder
1 parent eced382 commit 38cccdd

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ import {
159159
copyComposerDraftContentIfEmpty,
160160
copyComposerDraftContentState,
161161
decodePersistedComposerState,
162-
decodePersistedComposerDrafts,
163162
ensureComposerDraftsLoaded,
164163
type ComposerDraft,
165164
flushComposerDrafts,
@@ -252,12 +251,12 @@ describe("mobile composer drafts", () => {
252251
};
253252

254253
expect(
255-
decodePersistedComposerDrafts({
254+
decodePersistedComposerState({
256255
schemaVersion: 1,
257256
drafts: {
258257
"environment-1:thread-1": { text: "Review this file", attachments: [file] },
259258
},
260-
}),
259+
}).drafts,
261260
).toEqual({
262261
"environment-1:thread-1": { text: "Review this file", attachments: [file] },
263262
});
@@ -987,7 +986,7 @@ describe("mobile composer drafts", () => {
987986

988987
it("rejects persisted images without image bytes or a file URI", () => {
989988
expect(() =>
990-
decodePersistedComposerDrafts({
989+
decodePersistedComposerState({
991990
schemaVersion: 1,
992991
drafts: {
993992
"environment-1:thread-1": {
@@ -1010,7 +1009,7 @@ describe("mobile composer drafts", () => {
10101009

10111010
it("hydrates selector state even when the message content is empty", () => {
10121011
expect(
1013-
decodePersistedComposerDrafts({
1012+
decodePersistedComposerState({
10141013
schemaVersion: 1,
10151014
drafts: {
10161015
"new-task:environment-1:project-1": {
@@ -1030,7 +1029,7 @@ describe("mobile composer drafts", () => {
10301029
},
10311030
},
10321031
},
1033-
}),
1032+
}).drafts,
10341033
).toEqual({
10351034
"new-task:environment-1:project-1": {
10361035
text: "",
@@ -1053,18 +1052,18 @@ describe("mobile composer drafts", () => {
10531052

10541053
it("keeps legacy content-only drafts and rejects invalid selector state", () => {
10551054
expect(
1056-
decodePersistedComposerDrafts({
1055+
decodePersistedComposerState({
10571056
schemaVersion: 1,
10581057
drafts: {
10591058
"environment-1:thread-1": DRAFT,
10601059
},
1061-
}),
1060+
}).drafts,
10621061
).toEqual({
10631062
"environment-1:thread-1": DRAFT,
10641063
});
10651064

10661065
expect(() =>
1067-
decodePersistedComposerDrafts({
1066+
decodePersistedComposerState({
10681067
schemaVersion: 1,
10691068
drafts: {
10701069
"environment-1:thread-1": {

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,6 @@ export function decodePersistedComposerState(value: unknown): {
238238
};
239239
}
240240

241-
export function decodePersistedComposerDrafts(value: unknown): Record<string, ComposerDraft> {
242-
return decodePersistedComposerState(value).drafts;
243-
}
244-
245241
async function getComposerDraftsFile() {
246242
const { Directory, File, Paths } = await import("expo-file-system");
247243
const directory = new Directory(Paths.document, COMPOSER_DRAFTS_DIRECTORY);

0 commit comments

Comments
 (0)