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!

fix: preserve practice recovery and approved background work

Amruth Pillai5e554337013a
diff --git a/apps/mobile/src/features/workspace/hooks.ts b/apps/mobile/src/features/workspace/hooks.ts
index 368443bfe..0ed173f44 100644
--- a/apps/mobile/src/features/workspace/hooks.ts
+++ b/apps/mobile/src/features/workspace/hooks.ts
@@ -201,7 +201,6 @@ export function useGenerate(applicationId: string | null) {
const queryClient = useQueryClient();
const connection = useHasAIProvider();
const controller = useRef<AbortController | null>(null);
- useEffect(() => () => controller.current?.abort(), [applicationId]);
const mutation = useMutation({
mutationKey: orpc.career.generate.mutationKey(),
mutationFn: (input: GenerateInput) => {
diff --git a/apps/mobile/src/features/workspace/tabs/practise.tsx b/apps/mobile/src/features/workspace/tabs/practise.tsx
index 0662db1f3..0f69da0e4 100644
--- a/apps/mobile/src/features/workspace/tabs/practise.tsx
+++ b/apps/mobile/src/features/workspace/tabs/practise.tsx
@@ -126,7 +126,9 @@ function Practise({ application, version, interview, speak: speakFirst, story, w
return (
<View style={{ gap: space.s3 }}>
<Banner tone="warn" message={t`This story is unavailable or uses facts that are switched off.`} />
- <Button variant="secondary" label={t`Practice another question`} onPress={() => go("practise")} />
+ {application && (
+ <Button variant="secondary" label={t`Practice another question`} onPress={() => go("practise")} />
+ )}
</View>
);
@@ -168,7 +170,16 @@ function Practise({ application, version, interview, speak: speakFirst, story, w
return (
<View style={{ gap: space.s4 }}>
{viewing ? (
- <SavedAttempt item={viewing} />
+ <View style={{ gap: space.s3 }}>
+ {application === null && (
+ <Button
+ variant="secondary"
+ label={t({ message: "Practice", context: "Button: rehearse interview answers" })}
+ onPress={() => go("practise")}
+ />
+ )}
+ <SavedAttempt item={viewing} />
+ </View>
) : saved.isPending ? (
<Skeleton height={space.s12 * 6} />
) : (
diff --git a/apps/web/src/features/career/hooks.ts b/apps/web/src/features/career/hooks.ts
index b69aae95a..af83840ec 100644
--- a/apps/web/src/features/career/hooks.ts
+++ b/apps/web/src/features/career/hooks.ts
@@ -263,7 +263,6 @@ export function useGenerate(applicationId: string | null) {
const connection = useDefaultProvider();
const { provider } = connection;
const controller = useRef<AbortController | null>(null);
- useEffect(() => () => controller.current?.abort(), [applicationId]);
const mutation = useMutation({
mutationKey: orpc.career.generate.mutationKey(),
mutationFn: (input: GenerateInput) => {
diff --git a/apps/web/src/features/career/workspace/practise.tsx b/apps/web/src/features/career/workspace/practise.tsx
index b7474b2d9..bf5581e57 100644
--- a/apps/web/src/features/career/workspace/practise.tsx
+++ b/apps/web/src/features/career/workspace/practise.tsx
@@ -149,9 +149,11 @@ export function PractiseTab({ application, version, interview, speak, story, war
<Trans>This story is unavailable or uses facts that are switched off.</Trans>
)}
</span>
- <Button variant="secondary" onClick={() => go("practise")}>
- <Trans>Practice another question</Trans>
- </Button>
+ {application && (
+ <Button variant="secondary" onClick={() => go("practise")}>
+ <Trans>Practice another question</Trans>
+ </Button>
+ )}
</Notice>
);
@@ -168,7 +170,14 @@ export function PractiseTab({ application, version, interview, speak, story, war
return (
<div className="grid items-start gap-5 @3xl:grid-cols-[minmax(0,1fr)_280px]">
{viewing ? (
- <SavedAttempt item={viewing} />
+ <div className="grid gap-3">
+ {application === null && (
+ <Button variant="secondary" className="justify-self-start" onClick={() => go("practise")}>
+ <Trans context="Button: rehearse interview answers">Practice</Trans>
+ </Button>
+ )}
+ <SavedAttempt item={viewing} />
+ </div>
) : saved.isPending ? (
<div className="grid gap-4">
<Skeleton className="h-40 rounded-xl" />
diff --git a/apps/web/src/features/career/workspace/workspace.test.tsx b/apps/web/src/features/career/workspace/workspace.test.tsx
index b811459ba..91defaf76 100644
--- a/apps/web/src/features/career/workspace/workspace.test.tsx
+++ b/apps/web/src/features/career/workspace/workspace.test.tsx
@@ -933,3 +933,19 @@ it.each(["first receipt", "legacy"] as const)("opens the correct recorded answer
fireEvent.click(await screen.findByRole("button", { name: "View recorded answers" }));
expect(go).toHaveBeenCalledWith("apply", { version: kind === "legacy" ? later.id : first.id });
});
+
+it("keeps approved practice generation running when its tab unmounts", async () => {
+ const pending = deferred<{ item: null }>();
+ api.generate.mockReturnValueOnce(pending.promise);
+ const view = mount(<PractiseTab {...props} />);
+ fireEvent.change(screen.getByRole("textbox", { name: "Your answer" }), {
+ target: { value: "I coordinated the fictional recovery." },
+ });
+ fireEvent.click(screen.getByRole("button", { name: "Get feedback" }));
+ await waitFor(() => expect(api.generate).toHaveBeenCalledTimes(1));
+ const signal = api.generate.mock.calls[0]?.[1]?.signal as AbortSignal;
+ expect(signal).toBeDefined();
+ view.unmount();
+ expect(signal.aborted).toBe(false);
+ await act(async () => pending.resolve({ item: null }));
+});
diff --git a/tests/e2e/specs/standalone-story-practice.spec.ts b/tests/e2e/specs/standalone-story-practice.spec.ts
index 3c3d9285e..56c6bdaf5 100644
--- a/tests/e2e/specs/standalone-story-practice.spec.ts
+++ b/tests/e2e/specs/standalone-story-practice.spec.ts
@@ -132,6 +132,10 @@ for (const width of [1440, 390])
await page.reload();
await expect(page.getByText("Practice without an application", { exact: true })).toBeVisible();
await expect(page.getByText(/I restored fictional service by coordinating the response/).first()).toBeVisible();
+ await page.getByRole("button", { name: /I restored fictional service by coordinating the response/ }).click();
+ await expect(page.getByRole("textbox", { name: "Your answer", exact: true })).toHaveCount(0);
+ await page.getByRole("button", { name: "Practice", exact: true }).click();
+ await expect(page.getByRole("radio", { name: "Type", exact: true })).toBeVisible();
if (width === 1440)
await page.screenshot({
path: info.outputPath("standalone-story-practice.png"),
@@ -150,6 +154,9 @@ test("unbacked or switched-off story does not offer a practice action that will
await page.goto(`/dashboard/career/knowledge/stories/${story.id}?practice=true`);
await expect(page.getByText(/This story has no facts in use here/)).toBeVisible();
await expect(page.getByRole("button", { name: /Get feedback/ })).toHaveCount(0);
+ await expect(page.getByRole("button", { name: "Practice another question", exact: true })).toHaveCount(0);
+ await page.getByRole("button", { name: "Back to stories", exact: true }).click();
+ await expect(page).not.toHaveURL(/practice=true/);
});
test("shared practice preserves strict generation and saved-work selectors", async ({ authPage: page }) => {