-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove external category properly (#1215)
* remove external category properly * category validation * typefixes
- Loading branch information
1 parent
d57c644
commit 3ac0107
Showing
5 changed files
with
176 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -679,4 +679,64 @@ describe("/api/public/app/[app_id]", () => { | |
expect(data.error).toBe("Draft already verified"); | ||
}); | ||
}); | ||
describe("response integrity", () => { | ||
test("should return 500 when category is invalid", async () => { | ||
jest.mocked(getAppMetadataSdk).mockImplementation(() => ({ | ||
GetAppMetadata: jest.fn().mockResolvedValue({ | ||
app_metadata: [ | ||
{ | ||
id: "1", | ||
name: "Example App", | ||
app_id: "test-app", | ||
short_name: "test", | ||
logo_img_url: "logo.png", | ||
showcase_img_urls: ["showcase1.png", "showcase2.png"], | ||
hero_image_url: "hero.png", | ||
world_app_description: | ||
"This is an example app designed to showcase the capabilities of our platform.", | ||
world_app_button_text: "Use Integration", | ||
category: "INVALID!!", | ||
description: | ||
'{"description_overview":"fewf","description_how_it_works":"few","description_connect":"fewf"}', | ||
integration_url: "https://example.com/integration", | ||
app_website_url: "https://example.com", | ||
source_code_url: "https://github.com/example/app", | ||
whitelisted_addresses: ["0x1234", "0x5678"], | ||
app_mode: "mini-app", | ||
support_link: "[email protected]", | ||
supported_countries: ["us"], | ||
associated_domains: ["https://worldcoin.org"], | ||
contracts: ["0x0c892815f0B058E69987920A23FBb33c834289cf"], | ||
permit2_tokens: ["0x0c892815f0B058E69987920A23FBb33c834289cf"], | ||
supported_languages: ["en", "es"], | ||
is_reviewer_world_app_approved: true, | ||
verification_status: "verified", | ||
is_allowed_unlimited_notifications: false, | ||
max_notifications_per_day: 10, | ||
app: { | ||
team: { | ||
name: "Example Team", | ||
}, | ||
rating_sum: 10, | ||
rating_count: 3, | ||
}, | ||
}, | ||
], | ||
}), | ||
})); | ||
|
||
const request = new NextRequest( | ||
"https://cdn.test.com/api/public/app/test-app", | ||
{ | ||
headers: { | ||
host: "cdn.test.com", | ||
}, | ||
}, | ||
); | ||
const response = await GET(request, { params: { app_id: "test-app" } }); | ||
expect(response.status).toBe(500); | ||
const data = await response.json(); | ||
expect(data).toEqual({ error: "Invalid category" }); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -342,7 +342,7 @@ describe("/api/v2/public/apps", () => { | |
expect(await response.json()).toEqual({ | ||
app_rankings: { top_apps: [], highlights: [] }, | ||
all_category: AllCategory, | ||
categories: Categories, | ||
categories: Categories.filter((category) => category.id !== "external"), | ||
}); | ||
}); | ||
|
||
|
@@ -573,8 +573,8 @@ describe("/api/v2/public/apps", () => { | |
}, | ||
], | ||
}, | ||
categories: Categories.filter((category) => category.id !== "external"), | ||
all_category: AllCategory, | ||
categories: Categories, | ||
}); | ||
}); | ||
|
||
|
@@ -685,8 +685,73 @@ describe("/api/v2/public/apps", () => { | |
], | ||
highlights: [], | ||
}, | ||
categories: Categories.filter((category) => category.id !== "external"), | ||
all_category: AllCategory, | ||
categories: Categories, | ||
}); | ||
}); | ||
|
||
test("Error on invalid category", async () => { | ||
jest.mocked(getWebHighlightsSdk).mockImplementation(() => ({ | ||
GetHighlights: jest.fn().mockResolvedValue({ | ||
app_rankings: [{ rankings: [] }], | ||
}), | ||
})); | ||
jest.mocked(getHighlightsSdk).mockImplementation(() => ({ | ||
GetHighlights: jest.fn().mockResolvedValue({ | ||
highlights: [], | ||
}), | ||
})); | ||
|
||
jest.mocked(getAppsSdk).mockImplementation(() => ({ | ||
GetApps: jest.fn().mockResolvedValue({ | ||
top_apps: [ | ||
{ | ||
name: "Example App", | ||
app_id: "app_test_123", | ||
short_name: "test", | ||
logo_img_url: "logo.png", | ||
showcase_img_urls: ["showcase1.png", "showcase2.png"], | ||
hero_image_url: "hero.png", | ||
world_app_description: | ||
"This is an example app designed to showcase the capabilities of our platform.", | ||
world_app_button_text: "Use Integration", | ||
category: "INVALID!!", | ||
description: | ||
'{"description_overview":"fewf","description_how_it_works":"few","description_connect":"fewf"}', | ||
integration_url: "https://example.com/integration", | ||
app_website_url: "https://example.com", | ||
source_code_url: "https://github.com/example/app", | ||
whitelisted_addresses: ["0x1234", "0x5678"], | ||
app_mode: "mini-app", | ||
support_link: "[email protected]", | ||
associated_domains: ["https://worldcoin.org"], | ||
contracts: ["0x0c892815f0B058E69987920A23FBb33c834289cf"], | ||
permit2_tokens: ["0x0c892815f0B058E69987920A23FBb33c834289cf"], | ||
supported_countries: ["us"], | ||
supported_languages: ["en", "es"], | ||
verification_status: "verified", | ||
is_allowed_unlimited_notifications: false, | ||
max_notifications_per_day: 10, | ||
app: { | ||
team: { | ||
name: "Example Team", | ||
}, | ||
rating_sum: 10, | ||
rating_count: 3, | ||
}, | ||
}, | ||
], | ||
}), | ||
})); | ||
|
||
const request = new NextRequest("https://cdn.test.com/api/v2/public/apps", { | ||
headers: { | ||
host: "cdn.test.com", | ||
}, | ||
}); | ||
|
||
const response = await GET(request); | ||
|
||
expect(response.status).toEqual(500); | ||
}); | ||
}); |