diff --git a/services/userPreferences.ts b/services/userPreferences.ts index e79ac5c7dc..8b23a8f467 100644 --- a/services/userPreferences.ts +++ b/services/userPreferences.ts @@ -359,7 +359,7 @@ export const DEFAULT_PREFERENCES: UserPreferences = { relaxedCodeValidation: true, urlWhitelist: { enabled: true, - patterns: ["cdk.linux.do"], + patterns: ["cdk\\.linux\\.do", "cdk\\.hybgzs\\.com", "qd\\.x666\\.me"], includeAccountSiteUrls: true, includeCheckInAndRedeemUrls: true, }, diff --git a/tests/services/redemptionAssist.test.ts b/tests/services/redemptionAssist.test.ts index 0a33b8805b..291f4f89c1 100644 --- a/tests/services/redemptionAssist.test.ts +++ b/tests/services/redemptionAssist.test.ts @@ -7,6 +7,13 @@ vi.mock("i18next", () => ({ t: (key: string) => key, })) +vi.mock("~/services/accountStorage", () => ({ + accountStorage: { + getEnabledAccounts: vi.fn().mockResolvedValue([]), + convertToDisplayData: vi.fn(() => []), + }, +})) + vi.mock("~/services/userPreferences", async (importOriginal) => { const actual = await importOriginal() @@ -64,4 +71,42 @@ describe("redemptionAssist shouldPrompt batch filtering", () => { promptableCodes: [validHex], }) }) + + it("allows prompt on common redemption sites by default", async () => { + vi.resetModules() + const { userPreferences } = await import("~/services/userPreferences") + const getPreferencesMock = vi.mocked(userPreferences.getPreferences) + + getPreferencesMock.mockResolvedValue(DEFAULT_PREFERENCES) + + const { handleRedemptionAssistMessage } = await import( + "~/services/redemptionAssist" + ) + + const validHex = "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6" + + const testUrls = [ + "https://cdk.hybgzs.com/entertainment/wheel", + "https://qd.x666.me", + ] + + for (const url of testUrls) { + const sendResponse = vi.fn() + + await handleRedemptionAssistMessage( + { + action: RuntimeActionIds.RedemptionAssistShouldPrompt, + url, + codes: [validHex], + }, + { tab: { id: 99 } } as any, + sendResponse, + ) + + expect(sendResponse).toHaveBeenCalledWith({ + success: true, + promptableCodes: [validHex], + }) + } + }) }) diff --git a/tests/services/userPreferences.test.ts b/tests/services/userPreferences.test.ts index 12ddc3d1d2..558ee4712b 100644 --- a/tests/services/userPreferences.test.ts +++ b/tests/services/userPreferences.test.ts @@ -30,7 +30,7 @@ describe("userPreferences", () => { ).toBe(true) expect( DEFAULT_PREFERENCES.redemptionAssist?.urlWhitelist.patterns, - ).toEqual(["cdk.linux.do"]) + ).toEqual(["cdk\\.linux\\.do", "cdk\\.hybgzs\\.com", "qd\\.x666\\.me"]) expect(DEFAULT_PREFERENCES.tempWindowFallbackReminder?.dismissed).toBe( false, )