From fcbb44c107bf9ec8498ac45448bbc1e132d1f247 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 27 Jan 2025 13:11:20 -0300 Subject: [PATCH 1/6] Create prismic-deploy.yml --- .github/workflows/prismic-deploy.yml | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/prismic-deploy.yml diff --git a/.github/workflows/prismic-deploy.yml b/.github/workflows/prismic-deploy.yml new file mode 100644 index 0000000000..0d56aac1a6 --- /dev/null +++ b/.github/workflows/prismic-deploy.yml @@ -0,0 +1,47 @@ +name: Prismic Deploy Trigger + +on: + workflow_dispatch: + inputs: + skip-cache: + description: "Skip Cache" + required: true + default: true + type: boolean + environment: + description: "Environment to deploy (e.g., staging or production)" + required: true + default: "staging" + sha: + description: "Commit SHA to deploy" + required: false + netlify-alias: + description: "Netlify alias for the deployment" + required: false + cache-modifier: + description: "Cache modifier for build" + required: false + + repository_dispatch: + types: + - prismic-webhook + +jobs: + cache-modifier: + uses: ./.github/workflows/cache-modifier.yml + with: + skip-cache: ${{ github.event.inputs.skip-cache }} + + call-deploy: + uses: ./.github/workflows/deploy.yml + needs: [cache-modifier] + secrets: inherit + permissions: + pull-requests: write + with: + environment: ${{ github.event.inputs.environment || github.event.client_payload.environment || 'staging' }} + sha: ${{ github.event.inputs.sha || github.event.client_payload.sha || github.sha }} + netlify-context: production + netlify-alias: ${{ github.event.inputs.netlify_alias || github.event.client_payload.netlify_alias || '' }} + runner-label: ${{ vars.STAGING_RUNNER_LABEL }} + cache-modifier: ${{ needs.cache-modifier.outputs.cache-modifier }} \ No newline at end of file From 53534de1852dde37e212dc0e9d00b8d683f76041 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 27 Jan 2025 15:38:52 -0300 Subject: [PATCH 2/6] Add splitChar prop to form components for customizable tag splitting --- .../forms/SubmissionWizard/StepThree.js | 4 ++++ site/gatsby-site/src/components/forms/Tags.js | 15 ++++++++++++--- .../src/components/forms/TagsControl.js | 2 ++ .../src/components/forms/TagsInputGroup.js | 10 +++++++++- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/site/gatsby-site/src/components/forms/SubmissionWizard/StepThree.js b/site/gatsby-site/src/components/forms/SubmissionWizard/StepThree.js index de569035bb..47543fb6f7 100644 --- a/site/gatsby-site/src/components/forms/SubmissionWizard/StepThree.js +++ b/site/gatsby-site/src/components/forms/SubmissionWizard/StepThree.js @@ -360,6 +360,7 @@ const FormDetails = ({ touched={touched} values={values} errors={errors} + splitChar={false} /> @@ -377,6 +378,7 @@ const FormDetails = ({ touched={touched} values={values} errors={errors} + splitChar={false} /> @@ -394,6 +396,7 @@ const FormDetails = ({ touched={touched} values={values} errors={errors} + splitChar={false} /> @@ -411,6 +414,7 @@ const FormDetails = ({ touched={touched} values={values} errors={errors} + splitChar={false} /> diff --git a/site/gatsby-site/src/components/forms/Tags.js b/site/gatsby-site/src/components/forms/Tags.js index d9783d1ab8..f88abd6e81 100644 --- a/site/gatsby-site/src/components/forms/Tags.js +++ b/site/gatsby-site/src/components/forms/Tags.js @@ -14,13 +14,20 @@ export default function Tags({ className, allowNew = true, stayOpen = false, + splitChar = ',', }) { const [open, setOpen] = useState(false); const ref = useRef(null); const commitTag = (tag) => { - const splitTags = tag.split(',').map((tag) => tag.trim()); + let splitTags = []; + + if (splitChar) { + tag.split(splitChar).map((tag) => tag.trim()); + } else { + splitTags = [tag.trim()]; + } onChange(value ? value.concat(splitTags) : splitTags); ref.current.clear(); @@ -31,10 +38,12 @@ export default function Tags({ className={`Typeahead ${className || ''}`} inputProps={{ id: inputId, name }} onKeyDown={(e) => { - if (e.key === ',') { + if (splitChar && e.key === splitChar) { e.preventDefault(); } - if (['Enter', ','].includes(e.key) && e.target.value) { + const splitChars = splitChar ? ['Enter', splitChar] : ['Enter']; + + if (splitChars.includes(e.key) && e.target.value) { commitTag(e.target.value); } }} diff --git a/site/gatsby-site/src/components/forms/TagsControl.js b/site/gatsby-site/src/components/forms/TagsControl.js index 45746b4a83..d52e4384c9 100644 --- a/site/gatsby-site/src/components/forms/TagsControl.js +++ b/site/gatsby-site/src/components/forms/TagsControl.js @@ -10,6 +10,7 @@ const TagsControl = ({ disabled = false, options = undefined, handleChange = undefined, + splitChar = ',', }) => { const { 0: { value }, @@ -36,6 +37,7 @@ const TagsControl = ({ disabled, className, options, + splitChar, }} /> ); diff --git a/site/gatsby-site/src/components/forms/TagsInputGroup.js b/site/gatsby-site/src/components/forms/TagsInputGroup.js index ace7382442..feecc0f71a 100644 --- a/site/gatsby-site/src/components/forms/TagsInputGroup.js +++ b/site/gatsby-site/src/components/forms/TagsInputGroup.js @@ -16,6 +16,7 @@ const TagsInputGroup = ({ disabled = false, options = undefined, popoverName = null, + splitChar = ',', ...props }) => { const [optional, setOptional] = useState(true); @@ -42,7 +43,14 @@ const TagsInputGroup = ({ data-cy={props['data-cy']} >
From 726a4c06fad051483efcc8258ac06f1919ccc452 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 27 Jan 2025 15:45:19 -0300 Subject: [PATCH 3/6] Add test for handling commas in developers, deployers, harmed parties, and implicated systems fields --- .../playwright/e2e-full/submit.spec.ts | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/site/gatsby-site/playwright/e2e-full/submit.spec.ts b/site/gatsby-site/playwright/e2e-full/submit.spec.ts index b8d89a08aa..7527d908c0 100644 --- a/site/gatsby-site/playwright/e2e-full/submit.spec.ts +++ b/site/gatsby-site/playwright/e2e-full/submit.spec.ts @@ -1717,5 +1717,65 @@ test.describe('The Submit form', () => { await expect(page.locator(':text("Please review. Some data is missing.")')).not.toBeVisible(); }); + test('Should allow commas in developers, deployers, harmed_parties, and implicated_systems', async ({ page }) => { + await init(); + await conditionalIntercept( + page, + '**/parseNews**', + () => true, + parseNews, + 'parseNews' + ); + + await trackRequest( + page, + '**/graphql', + (req) => req.postDataJSON().operationName == 'FindSubmissions', + 'findSubmissions' + ); + + await page.goto(url); + + await waitForRequest('findSubmissions'); + + await page.locator('input[name="url"]').fill( + `https://www.arstechnica.com/gadgets/2017/11/youtube-to-crack-down-on-inappropriate-content-masked-as-kids-cartoons/` + ); + + await page.locator('button:has-text("Fetch info")').click(); + + await waitForRequest('parseNews'); + + await page.locator('[name="incident_date"]').fill('2020-01-01'); + + await expect(page.locator('.form-has-errors')).not.toBeVisible(); + + await page.locator('[data-cy="to-step-2"]').click(); + + await page.locator('[data-cy="to-step-3"]').click(); + + await page.locator('input[name="developers"]').fill('This developer has a comma in its name, test'); + await page.keyboard.press('Enter'); + + await expect(page.locator('text=Each alleged Developer must have at least 3 characters and less than 200')).not.toBeVisible(); + + // Check for deployers field + await page.locator('input[name="deployers"]').fill('This deployer has a comma in its name, test'); + await page.keyboard.press('Enter'); + await expect(page.locator('text=Each alleged Deployer must have at least 3 characters and less than 200')).not.toBeVisible(); + + // Check for harmed_parties field + await page.locator('input[name="harmed_parties"]').fill('This harmed_parties has a comma in its name, test'); + await page.keyboard.press('Enter'); + await expect(page.locator('text=Each alleged Harmed parties must have at least 3 characters and less than 200')).not.toBeVisible(); + + await page.locator('input[name="implicated_systems"]').fill('This implicated_systems has a comma in its name, test'); + await page.keyboard.press('Enter'); + await expect(page.locator('text=Each alleged Implicated AI system must have at least 3 characters and less than 200')).not.toBeVisible(); + + await page.locator('button[type="submit"]').click(); + await expect(page.locator('.tw-toast:has-text("Report successfully added to review queue. You can see your submission")')).toBeVisible(); + await expect(page.locator(':text("Please review. Some data is missing.")')).not.toBeVisible(); + }); }); \ No newline at end of file From 44c7d79d844bc19746df90743ab8d8a7351d3dee Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Wed, 29 Jan 2025 14:12:14 -0300 Subject: [PATCH 4/6] Fix tag splitting logic to correctly assign split tags to variable --- site/gatsby-site/src/components/forms/Tags.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/gatsby-site/src/components/forms/Tags.js b/site/gatsby-site/src/components/forms/Tags.js index f88abd6e81..fa073780b5 100644 --- a/site/gatsby-site/src/components/forms/Tags.js +++ b/site/gatsby-site/src/components/forms/Tags.js @@ -24,7 +24,7 @@ export default function Tags({ let splitTags = []; if (splitChar) { - tag.split(splitChar).map((tag) => tag.trim()); + splitTags = tag.split(splitChar).map((tag) => tag.trim()); } else { splitTags = [tag.trim()]; } From cdc930042fd696151e3d135e667566efbfba239e Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Wed, 29 Jan 2025 15:53:19 -0300 Subject: [PATCH 5/6] Remove Prismic deploy workflow configuration --- .github/workflows/prismic-deploy.yml | 47 ---------------------------- 1 file changed, 47 deletions(-) delete mode 100644 .github/workflows/prismic-deploy.yml diff --git a/.github/workflows/prismic-deploy.yml b/.github/workflows/prismic-deploy.yml deleted file mode 100644 index 0d56aac1a6..0000000000 --- a/.github/workflows/prismic-deploy.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Prismic Deploy Trigger - -on: - workflow_dispatch: - inputs: - skip-cache: - description: "Skip Cache" - required: true - default: true - type: boolean - environment: - description: "Environment to deploy (e.g., staging or production)" - required: true - default: "staging" - sha: - description: "Commit SHA to deploy" - required: false - netlify-alias: - description: "Netlify alias for the deployment" - required: false - cache-modifier: - description: "Cache modifier for build" - required: false - - repository_dispatch: - types: - - prismic-webhook - -jobs: - cache-modifier: - uses: ./.github/workflows/cache-modifier.yml - with: - skip-cache: ${{ github.event.inputs.skip-cache }} - - call-deploy: - uses: ./.github/workflows/deploy.yml - needs: [cache-modifier] - secrets: inherit - permissions: - pull-requests: write - with: - environment: ${{ github.event.inputs.environment || github.event.client_payload.environment || 'staging' }} - sha: ${{ github.event.inputs.sha || github.event.client_payload.sha || github.sha }} - netlify-context: production - netlify-alias: ${{ github.event.inputs.netlify_alias || github.event.client_payload.netlify_alias || '' }} - runner-label: ${{ vars.STAGING_RUNNER_LABEL }} - cache-modifier: ${{ needs.cache-modifier.outputs.cache-modifier }} \ No newline at end of file From 474c3fe1c323bd98f6b27740afdb8ec3d0a1808d Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 3 Feb 2025 10:43:11 -0300 Subject: [PATCH 6/6] Update SubmissionWizard to use null for splitChar instead of false --- .../src/components/forms/SubmissionWizard/StepThree.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/site/gatsby-site/src/components/forms/SubmissionWizard/StepThree.js b/site/gatsby-site/src/components/forms/SubmissionWizard/StepThree.js index 6d493a3c8d..599fdfc311 100644 --- a/site/gatsby-site/src/components/forms/SubmissionWizard/StepThree.js +++ b/site/gatsby-site/src/components/forms/SubmissionWizard/StepThree.js @@ -360,7 +360,7 @@ const FormDetails = ({ touched={touched} values={values} errors={errors} - splitChar={false} + splitChar={null} /> @@ -378,7 +378,7 @@ const FormDetails = ({ touched={touched} values={values} errors={errors} - splitChar={false} + splitChar={null} /> @@ -396,7 +396,7 @@ const FormDetails = ({ touched={touched} values={values} errors={errors} - splitChar={false} + splitChar={null} /> @@ -414,7 +414,7 @@ const FormDetails = ({ touched={touched} values={values} errors={errors} - splitChar={false} + splitChar={null} />