Skip to content

Commit

Permalink
Add draft_id to response (#1166)
Browse files Browse the repository at this point in the history
  • Loading branch information
Takaros999 authored Feb 6, 2025
1 parent 59a3d1e commit b286f38
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions web/api/v2/public/app/[app_id]/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ export async function GET(
locale,
);

// Add the draft_id to the response if it exists in the parsed metadata
if (parsedAppMetadata.id === draft_id) {
formattedMetadata = {
...formattedMetadata,
draft_id: draft_id,
};
}

if (formattedMetadata.app_id in nativeAppMetadata) {
const nativeAppItem = nativeAppMetadata[formattedMetadata.app_id];

Expand Down
1 change: 1 addition & 0 deletions web/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ export type AppStoreFormattedFields = Omit<
how_it_works: string;
how_to_connect: string;
};
draft_id?: string;
};

type NativeApp = {
Expand Down
3 changes: 3 additions & 0 deletions web/tests/api/v2/public/apps/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ describe("/api/public/app/[app_id]", () => {
expect(data.app_data.integration_url).toBe(
"https://example.com/integration-unverified",
);
expect(data.app_data.draft_id).toBe("2");
});

test("should select reviewer approved metadata when no draft_id provided", async () => {
Expand Down Expand Up @@ -501,6 +502,7 @@ describe("/api/public/app/[app_id]", () => {
expect(data.app_data.integration_url).toBe(
"https://example.com/integration",
);
expect(data.app_data.draft_id).toBeUndefined();
});

test("should fallback to first metadata when draft_id is invalid", async () => {
Expand Down Expand Up @@ -562,6 +564,7 @@ describe("/api/public/app/[app_id]", () => {
expect(data.app_data.integration_url).toBe(
"https://example.com/integration",
);
expect(data.app_data.draft_id).toBeUndefined();
});
});
});

0 comments on commit b286f38

Please sign in to comment.