Repository: GoogleChromeLabs/ps-analysis-tool
Pull request #726 (2024-06-25 12:31:37)

Fix: Samesite value in cookie table CSV.
## Description
This package aims to resolve the path and fix the same site values in CLI generated cookie table csv.

## Relevant Technical Choices

<!-- Please describe your changes. -->

## Testing Instructions

<!--
How can the changes in this PR be verified?
Please provide step-by-step instructions to test the changes.
-->

## Additional Information:

<!-- Any other information. -->

## Screenshot/Screencast

<!-- Please provide Screenshot/Screencast, if applicable -->

---

## Checklist

<!-- Check these after PR creation -->

- [x] I have thoroughly tested this code to the best of my abilities.
- [x] I have reviewed the code myself before requesting a review.
- ~[ ] This code is covered by unit tests to verify that it works as intended.~
- [ ] The QA of this PR is done by a member of the QA team (to be checked by QA).




Patch:
diff --git a/packages/design-system/src/components/table/utils/generateCLICookieTableCSV.ts b/packages/design-system/src/components/table/utils/generateCLICookieTableCSV.ts
index 2a0e68f7..13bf0538 100644
--- a/packages/design-system/src/components/table/utils/generateCLICookieTableCSV.ts
+++ b/packages/design-system/src/components/table/utils/generateCLICookieTableCSV.ts
@@ -48,7 +48,8 @@ const generateCLICookieTableCSV = (cookies: CookieTableData[]): Blob => {
         : I18n.getMessage('thirdParty'),
       cookie.parsedCookie.domain || ' ',
       cookie.parsedCookie.partitionKey || ' ',
-      cookie.parsedCookie.samesite,
+      //@ts-ignore
+      cookie.parsedCookie?.sameSite ?? cookie.parsedCookie?.samesite,
       I18n.getMessage(
         cookie.analytics?.category?.toLowerCase() || 'uncategorized'
       ),
diff --git a/packages/i18n/src/i18n.ts b/packages/i18n/src/i18n.ts
index a8120eb4..a96fd275 100644
--- a/packages/i18n/src/i18n.ts
+++ b/packages/i18n/src/i18n.ts
@@ -18,6 +18,7 @@
  */
 import { existsSync, readFileSync } from 'fs';
 import { IntlMessageFormat } from 'intl-messageformat';
+import path from 'path';
 
 /**
  * Class representing Internationalization (i18n) functionality.
@@ -139,11 +140,19 @@ class I18n {
 
     for (const _locale of localeArray) {
       if (
-        existsSync(`packages/i18n/_locales/messages/${_locale}/messages.json`)
+        existsSync(
+          path.resolve(
+            __dirname +
+              `../../../i18n/_locales/messages/${_locale}/messages.json`
+          )
+        )
       ) {
         const messages = JSON.parse(
           readFileSync(
-            `packages/i18n/_locales/messages/${_locale}/messages.json`,
+            path.resolve(
+              __dirname +
+                `../../../i18n/_locales/messages/${_locale}/messages.json`
+            ),
             {
               encoding: 'utf-8',
             }
diff --git a/webpack.shared.cjs b/webpack.shared.cjs
index 5c3e0a18..c6958353 100644
--- a/webpack.shared.cjs
+++ b/webpack.shared.cjs
@@ -28,6 +28,7 @@ module.exports = {
           fullySpecified: false,
           fallback: {
             fs: false,
+            path: false,
           },
         },
         use: [


Test patch:
diff --git a/packages/i18n/src/tests/i18n.ts b/packages/i18n/src/tests/i18n.ts
index 1358ede0..430fafd2 100644
--- a/packages/i18n/src/tests/i18n.ts
+++ b/packages/i18n/src/tests/i18n.ts
@@ -18,6 +18,7 @@
  * External dependencies.
  */
 import fs from 'fs';
+import path from 'path';
 
 /**
  * Internal dependencies.
@@ -86,12 +87,16 @@ describe('I18n', () => {
     await I18n.loadCLIMessagesData(locale);
 
     expect(existsSyncMock).toHaveBeenCalledWith(
-      'packages/i18n/_locales/messages/hi/messages.json'
+      path.resolve(
+        __dirname + `../../../../i18n/_locales/messages/hi/messages.json`
+      )
     );
     expect(existsSyncMock).toHaveBeenCalledTimes(1);
 
     expect(readFileSyncMock).toHaveBeenCalledWith(
-      'packages/i18n/_locales/messages/hi/messages.json',
+      path.resolve(
+        __dirname + `../../../../i18n/_locales/messages/hi/messages.json`
+      ),
       {
         encoding: 'utf-8',
       }