Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

test: compose native fixtures with grouped documents

Amruth Pillaibeb6b242fb6d
diff --git a/apps/mobile/scripts/experience.test.mjs b/apps/mobile/scripts/experience.test.mjs
index 59fa9834a..344d54ceb 100644
--- a/apps/mobile/scripts/experience.test.mjs
+++ b/apps/mobile/scripts/experience.test.mjs
@@ -469,7 +469,7 @@ const nativeInterviewCalendar = load("features/application-detail/calendar.ts",
});
let applicationDocuments = [];
let rejectDocumentLink = false;
-let creatingApplicationLetter = false;
+let documentLinkPromise;
let stageUpdate = (input) => calls.push(input);
let stageUpdateAsync = (input) =>
new Promise((resolve, reject) => stageUpdate(input, { onSuccess: resolve, onError: reject }));
@@ -487,7 +487,6 @@ const { StageStepper, NextStepCard, WhatYouSent, Timeline } = load("features/app
"./hooks": {
useDocuments: () => ({ data: applicationDocuments }),
useDetailMutations: () => ({
- createLetter: { isPending: creatingApplicationLetter },
addNote: {},
updateEntry: {},
deleteEntry: {},
@@ -508,6 +507,7 @@ const { StageStepper, NextStepCard, WhatYouSent, Timeline } = load("features/app
linkApplication: async (input) => {
calls.push({ documentLink: input });
if (rejectDocumentLink) throw new Error("Unavailable");
+ await documentLinkPromise;
},
},
},
@@ -856,11 +856,18 @@ assert.deepEqual(calls.filter((call) => call?.documentLink).at(-1).documentLink,
id: "existing-letter",
applicationId: "job-a",
});
-creatingApplicationLetter = true;
+let finishDocumentLink;
+documentLinkPromise = new Promise((resolve) => (finishDocumentLink = resolve));
+control(tree, "Use Fictional Cedar — Portfolio · Resume").onPress();
tree = render(WhatYouSent, { application });
assert.equal(control(tree, "Use Fictional Cedar — Portfolio · Resume").disabled, true);
assert.equal(control(tree, "Use an existing letter").disabled, true);
-creatingApplicationLetter = false;
+finishDocumentLink();
+await settle();
+documentLinkPromise = undefined;
+tree = render(WhatYouSent, { application });
+assert.equal(control(tree, "Use Fictional Cedar — Portfolio · Resume").disabled, false);
+assert.equal(control(tree, "Use an existing letter").disabled, false);
applicationDocuments = [];
console.log("PASS native company-matched resume/letter selection, revision guard, pending state and failed-link retry");
diff --git a/apps/mobile/scripts/layout.test.mjs b/apps/mobile/scripts/layout.test.mjs
index df608f4f0..fe6e9782e 100644
--- a/apps/mobile/scripts/layout.test.mjs
+++ b/apps/mobile/scripts/layout.test.mjs
@@ -4,6 +4,7 @@ import assert from "node:assert/strict";
import { readdirSync, readFileSync } from "node:fs";
import { createRequire } from "node:module";
import { i18n } from "@lingui/core";
+import { groupDocumentsByApplication, groupIsExpanded } from "@reactive-resume/schema/applications/document-groups";
i18n.loadAndActivate({ locale: "en-US", messages: {} });
@@ -576,6 +577,7 @@ const librarySession = load("features/documents/library-session.ts", {
"@/auth/session": { getAccountScope: () => libraryAccountScope },
});
const { DocumentsLibrary } = load("features/documents/library.tsx", {
+ "@reactive-resume/schema/applications/document-groups": { groupDocumentsByApplication, groupIsExpanded },
"./library-session": librarySession,
"@legendapp/list/reanimated": { AnimatedLegendList: "FlatList" },
"./document-sheets": { DocumentSheets: "DocumentSheets" },
@@ -737,7 +739,8 @@ const sheetDocument = { type: "resume", id: "restore-sheet", trashedAt: new Date
documentQuery = { ...originalDocumentQuery, data: { ...originalDocumentQuery.data, items: [sheetDocument], total: 1 } };
render(DocumentsLibrary, { trashed: true });
let trashList = nodes(render(DocumentsLibrary, { trashed: true })).find((node) => node.type === "FlatList");
-const trashItem = trashList.props.renderItem({ item: sheetDocument, index: 0 });
+assert.equal(trashList.props.data[0].document, sheetDocument);
+const trashItem = trashList.props.renderItem({ item: trashList.props.data[0], index: 0 });
// Row body is wrapped by the motion frame; its menu opens the sheet owned by DocumentsLibrary.
nodes(trashItem)
.find((node) => typeof node.props.onMenu === "function")