diff --git a/.yarn/cache/@typescript-eslint-parser-npm-8.52.0-7f2ce4b0cb-f221411fb3.zip b/.yarn/cache/@typescript-eslint-parser-npm-8.52.0-7f2ce4b0cb-f221411fb3.zip deleted file mode 100644 index 9678160ce31..00000000000 Binary files a/.yarn/cache/@typescript-eslint-parser-npm-8.52.0-7f2ce4b0cb-f221411fb3.zip and /dev/null differ diff --git a/.yarn/cache/@typescript-eslint-parser-npm-8.58.0-b119008382-0498e593b1.zip b/.yarn/cache/@typescript-eslint-parser-npm-8.58.0-b119008382-0498e593b1.zip new file mode 100644 index 00000000000..5331075904a Binary files /dev/null and b/.yarn/cache/@typescript-eslint-parser-npm-8.58.0-b119008382-0498e593b1.zip differ diff --git a/.yarn/cache/@typescript-eslint-project-service-npm-8.52.0-300ac97b84-bfa786007e.zip b/.yarn/cache/@typescript-eslint-project-service-npm-8.52.0-300ac97b84-bfa786007e.zip deleted file mode 100644 index b33b7ca540d..00000000000 Binary files a/.yarn/cache/@typescript-eslint-project-service-npm-8.52.0-300ac97b84-bfa786007e.zip and /dev/null differ diff --git a/.yarn/cache/@typescript-eslint-project-service-npm-8.58.0-2f5db67888-fab2601f76.zip b/.yarn/cache/@typescript-eslint-project-service-npm-8.58.0-2f5db67888-fab2601f76.zip new file mode 100644 index 00000000000..2af4a7d733c Binary files /dev/null and b/.yarn/cache/@typescript-eslint-project-service-npm-8.58.0-2f5db67888-fab2601f76.zip differ diff --git a/.yarn/cache/@typescript-eslint-scope-manager-npm-8.52.0-df1e126940-89d9c04cd2.zip b/.yarn/cache/@typescript-eslint-scope-manager-npm-8.52.0-df1e126940-89d9c04cd2.zip deleted file mode 100644 index 689ac309fce..00000000000 Binary files a/.yarn/cache/@typescript-eslint-scope-manager-npm-8.52.0-df1e126940-89d9c04cd2.zip and /dev/null differ diff --git a/.yarn/cache/@typescript-eslint-scope-manager-npm-8.58.0-417ab9bd74-97293f1215.zip b/.yarn/cache/@typescript-eslint-scope-manager-npm-8.58.0-417ab9bd74-97293f1215.zip new file mode 100644 index 00000000000..37bb504e54f Binary files /dev/null and b/.yarn/cache/@typescript-eslint-scope-manager-npm-8.58.0-417ab9bd74-97293f1215.zip differ diff --git a/.yarn/cache/@typescript-eslint-tsconfig-utils-npm-8.52.0-451ec8941e-5b26227ab5.zip b/.yarn/cache/@typescript-eslint-tsconfig-utils-npm-8.52.0-451ec8941e-5b26227ab5.zip deleted file mode 100644 index b87f99cd6e6..00000000000 Binary files a/.yarn/cache/@typescript-eslint-tsconfig-utils-npm-8.52.0-451ec8941e-5b26227ab5.zip and /dev/null differ diff --git a/.yarn/cache/@typescript-eslint-tsconfig-utils-npm-8.53.0-e57b543e4a-91f1f02ec8.zip b/.yarn/cache/@typescript-eslint-tsconfig-utils-npm-8.53.0-e57b543e4a-91f1f02ec8.zip deleted file mode 100644 index 9a0ce4618e7..00000000000 Binary files a/.yarn/cache/@typescript-eslint-tsconfig-utils-npm-8.53.0-e57b543e4a-91f1f02ec8.zip and /dev/null differ diff --git a/.yarn/cache/@typescript-eslint-tsconfig-utils-npm-8.58.0-93afe183e9-4f47212c0e.zip b/.yarn/cache/@typescript-eslint-tsconfig-utils-npm-8.58.0-93afe183e9-4f47212c0e.zip new file mode 100644 index 00000000000..9d76c6b5103 Binary files /dev/null and b/.yarn/cache/@typescript-eslint-tsconfig-utils-npm-8.58.0-93afe183e9-4f47212c0e.zip differ diff --git a/.yarn/cache/@typescript-eslint-tsconfig-utils-npm-8.58.1-1b734c80ea-4a5cf9a5eb.zip b/.yarn/cache/@typescript-eslint-tsconfig-utils-npm-8.58.1-1b734c80ea-4a5cf9a5eb.zip new file mode 100644 index 00000000000..6d204777aeb Binary files /dev/null and b/.yarn/cache/@typescript-eslint-tsconfig-utils-npm-8.58.1-1b734c80ea-4a5cf9a5eb.zip differ diff --git a/.yarn/cache/@typescript-eslint-types-npm-8.52.0-dd9057d59e-05a630c5d2.zip b/.yarn/cache/@typescript-eslint-types-npm-8.52.0-dd9057d59e-05a630c5d2.zip deleted file mode 100644 index c599e298939..00000000000 Binary files a/.yarn/cache/@typescript-eslint-types-npm-8.52.0-dd9057d59e-05a630c5d2.zip and /dev/null differ diff --git a/.yarn/cache/@typescript-eslint-types-npm-8.53.0-0716cabaaf-36ee696a92.zip b/.yarn/cache/@typescript-eslint-types-npm-8.53.0-0716cabaaf-36ee696a92.zip deleted file mode 100644 index 6a0082ac4bb..00000000000 Binary files a/.yarn/cache/@typescript-eslint-types-npm-8.53.0-0716cabaaf-36ee696a92.zip and /dev/null differ diff --git a/.yarn/cache/@typescript-eslint-types-npm-8.58.0-6ca1ef66f6-c68eac0bc2.zip b/.yarn/cache/@typescript-eslint-types-npm-8.58.0-6ca1ef66f6-c68eac0bc2.zip new file mode 100644 index 00000000000..231416a1d35 Binary files /dev/null and b/.yarn/cache/@typescript-eslint-types-npm-8.58.0-6ca1ef66f6-c68eac0bc2.zip differ diff --git a/.yarn/cache/@typescript-eslint-types-npm-8.58.1-d1e6eadeb2-447e1351af.zip b/.yarn/cache/@typescript-eslint-types-npm-8.58.1-d1e6eadeb2-447e1351af.zip new file mode 100644 index 00000000000..5a87113de6a Binary files /dev/null and b/.yarn/cache/@typescript-eslint-types-npm-8.58.1-d1e6eadeb2-447e1351af.zip differ diff --git a/.yarn/cache/@typescript-eslint-typescript-estree-npm-8.52.0-3ae3386e3a-4e699f44a0.zip b/.yarn/cache/@typescript-eslint-typescript-estree-npm-8.52.0-3ae3386e3a-4e699f44a0.zip deleted file mode 100644 index 81404e1d25e..00000000000 Binary files a/.yarn/cache/@typescript-eslint-typescript-estree-npm-8.52.0-3ae3386e3a-4e699f44a0.zip and /dev/null differ diff --git a/.yarn/cache/@typescript-eslint-typescript-estree-npm-8.58.0-b5ce251b74-4d6c4175e8.zip b/.yarn/cache/@typescript-eslint-typescript-estree-npm-8.58.0-b5ce251b74-4d6c4175e8.zip new file mode 100644 index 00000000000..cd69592d1e0 Binary files /dev/null and b/.yarn/cache/@typescript-eslint-typescript-estree-npm-8.58.0-b5ce251b74-4d6c4175e8.zip differ diff --git a/.yarn/cache/@typescript-eslint-visitor-keys-npm-8.52.0-a4de6f1d15-4d841402cc.zip b/.yarn/cache/@typescript-eslint-visitor-keys-npm-8.52.0-a4de6f1d15-4d841402cc.zip deleted file mode 100644 index 9159b56e61a..00000000000 Binary files a/.yarn/cache/@typescript-eslint-visitor-keys-npm-8.52.0-a4de6f1d15-4d841402cc.zip and /dev/null differ diff --git a/.yarn/cache/@typescript-eslint-visitor-keys-npm-8.58.0-e580e25b62-50b0779e19.zip b/.yarn/cache/@typescript-eslint-visitor-keys-npm-8.58.0-e580e25b62-50b0779e19.zip new file mode 100644 index 00000000000..1d21768e5ff Binary files /dev/null and b/.yarn/cache/@typescript-eslint-visitor-keys-npm-8.58.0-e580e25b62-50b0779e19.zip differ diff --git a/.yarn/cache/balanced-match-npm-4.0.4-fd666b3c7f-fb07bb66a0.zip b/.yarn/cache/balanced-match-npm-4.0.4-fd666b3c7f-fb07bb66a0.zip new file mode 100644 index 00000000000..35e2154ef17 Binary files /dev/null and b/.yarn/cache/balanced-match-npm-4.0.4-fd666b3c7f-fb07bb66a0.zip differ diff --git a/.yarn/cache/brace-expansion-npm-5.0.5-b81f6c30d6-f259b2ddf0.zip b/.yarn/cache/brace-expansion-npm-5.0.5-b81f6c30d6-f259b2ddf0.zip new file mode 100644 index 00000000000..967461aa45e Binary files /dev/null and b/.yarn/cache/brace-expansion-npm-5.0.5-b81f6c30d6-f259b2ddf0.zip differ diff --git a/.yarn/cache/eslint-visitor-keys-npm-4.2.1-435d5be22a-3ee00fc6a7.zip b/.yarn/cache/eslint-visitor-keys-npm-4.2.1-435d5be22a-3ee00fc6a7.zip deleted file mode 100644 index bea4ce38dd9..00000000000 Binary files a/.yarn/cache/eslint-visitor-keys-npm-4.2.1-435d5be22a-3ee00fc6a7.zip and /dev/null differ diff --git a/.yarn/cache/eslint-visitor-keys-npm-5.0.1-30a44b062b-f9cc1a57b7.zip b/.yarn/cache/eslint-visitor-keys-npm-5.0.1-30a44b062b-f9cc1a57b7.zip new file mode 100644 index 00000000000..571ee153768 Binary files /dev/null and b/.yarn/cache/eslint-visitor-keys-npm-5.0.1-30a44b062b-f9cc1a57b7.zip differ diff --git a/.yarn/cache/minimatch-npm-10.2.5-f1c8297822-19e87a931a.zip b/.yarn/cache/minimatch-npm-10.2.5-f1c8297822-19e87a931a.zip new file mode 100644 index 00000000000..21b0f628deb Binary files /dev/null and b/.yarn/cache/minimatch-npm-10.2.5-f1c8297822-19e87a931a.zip differ diff --git a/.yarn/cache/ts-api-utils-npm-2.4.0-1179124e9a-d6b2b3b6ca.zip b/.yarn/cache/ts-api-utils-npm-2.4.0-1179124e9a-d6b2b3b6ca.zip deleted file mode 100644 index 7ddfe9f181c..00000000000 Binary files a/.yarn/cache/ts-api-utils-npm-2.4.0-1179124e9a-d6b2b3b6ca.zip and /dev/null differ diff --git a/.yarn/cache/ts-api-utils-npm-2.5.0-6bde2b2eb9-d5f1936f56.zip b/.yarn/cache/ts-api-utils-npm-2.5.0-6bde2b2eb9-d5f1936f56.zip new file mode 100644 index 00000000000..9c4219f86e1 Binary files /dev/null and b/.yarn/cache/ts-api-utils-npm-2.5.0-6bde2b2eb9-d5f1936f56.zip differ diff --git a/package.json b/package.json index ba3d648fe2e..221f1f8cd20 100644 --- a/package.json +++ b/package.json @@ -188,7 +188,7 @@ "@types/testing-library__react": "10.2.0", "@types/url-parse": "^1.4.8", "@typescript-eslint/eslint-plugin": "5.62.0", - "@typescript-eslint/parser": "8.52.0", + "@typescript-eslint/parser": "8.58.0", "amphtml-validator": "1.0.38", "babel-jest": "30.3.0", "babel-loader": "10.1.1", diff --git a/src/app/components/SaveArticleButton/index.test.tsx b/src/app/components/SaveArticleButton/index.test.tsx index 709b17cd8e7..5725d917643 100644 --- a/src/app/components/SaveArticleButton/index.test.tsx +++ b/src/app/components/SaveArticleButton/index.test.tsx @@ -10,8 +10,11 @@ describe('SaveArticleButton', () => { const defaultProps = { articleId: '123', service: 'hindi', + title: 'Test Article Title', }; + const mockHandleSaveAction = jest.fn(); + afterEach(() => { jest.clearAllMocks(); }); @@ -21,6 +24,7 @@ describe('SaveArticleButton', () => { showButton: false, isSaved: false, isLoading: false, + handleSaveAction: mockHandleSaveAction, }); const { container } = render(); @@ -32,6 +36,7 @@ describe('SaveArticleButton', () => { showButton: true, isSaved: false, isLoading: false, + handleSaveAction: mockHandleSaveAction, }); render(); @@ -43,6 +48,7 @@ describe('SaveArticleButton', () => { showButton: true, isSaved: true, isLoading: false, + handleSaveAction: mockHandleSaveAction, }); render(); @@ -54,6 +60,7 @@ describe('SaveArticleButton', () => { showButton: true, isSaved: false, isLoading: true, + handleSaveAction: mockHandleSaveAction, }); render(); @@ -62,4 +69,36 @@ describe('SaveArticleButton', () => { expect(button).toHaveTextContent('Loading...'); expect(button).toBeDisabled(); }); + + test('calls handleSaveAction with save when button is clicked and not saved', async () => { + mockedUseUASButton.mockReturnValue({ + showButton: true, + isSaved: false, + isLoading: false, + handleSaveAction: mockHandleSaveAction, + }); + + render(); + screen.getByRole('button').click(); + + expect(mockHandleSaveAction).toHaveBeenCalledWith('save'); + expect(mockHandleSaveAction).toHaveBeenCalledTimes(1); + }); + + test('passes title to useUASButton hook', () => { + mockedUseUASButton.mockReturnValue({ + showButton: true, + isSaved: false, + isLoading: false, + handleSaveAction: mockHandleSaveAction, + }); + + render(); + + expect(mockedUseUASButton).toHaveBeenCalledWith({ + articleId: '123', + service: 'hindi', + title: 'Test Article Title', + }); + }); }); diff --git a/src/app/components/SaveArticleButton/index.tsx b/src/app/components/SaveArticleButton/index.tsx index 2587917a198..00b0a1f7c25 100644 --- a/src/app/components/SaveArticleButton/index.tsx +++ b/src/app/components/SaveArticleButton/index.tsx @@ -4,17 +4,25 @@ import styles from './index.styles'; interface SaveArticleButtonProps { articleId: string; service: string; + title: string; } + /** A button component that allows users to save an article for later reading, * showing the button based on user sign in status and feature toggles, * and displaying the saved status, loading state, and handling errors from the UAS API. * FUTURE TODO : Implement button click handler to toggle saved state */ -const SaveArticleButton = ({ articleId, service }: SaveArticleButtonProps) => { - const { showButton, isSaved, isLoading, error } = useUASButton({ - articleId, - service, - }); +const SaveArticleButton = ({ + articleId, + service, + title, +}: SaveArticleButtonProps) => { + const { showButton, isSaved, isLoading, error, handleSaveAction } = + useUASButton({ + articleId, + service, + title, + }); if (!showButton) { return null; @@ -43,6 +51,7 @@ const SaveArticleButton = ({ articleId, service }: SaveArticleButtonProps) => {