Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre and post whitespace to TransactionID regex #420

Merged
merged 7 commits into from
Mar 27, 2024

Conversation

AndyEPhipps
Copy link
Contributor

@AndyEPhipps AndyEPhipps commented Mar 27, 2024

https://comicrelief.atlassian.net/browse/ENG-3193

TransactionID field in /update now allows for a trailing and/or leading whitespace in order to handle any copy-paste errors, and strips this out of the submission value itself, rather than messing with the input field value directly (which would bring in its own problems).

NB: this is passed as both transactionID and donationID in the payload; I think the latter is some legacy thing maybe, or possibly used by a third party? Either way, I'm doing the same for both.

Allowing the new spaces:
Screenshot 2024-03-27 at 10 27 06

Successful submission, showing the trimmed values:
Screenshot 2024-03-27 at 10 29 03

@AndyEPhipps AndyEPhipps self-assigned this Mar 27, 2024
@AndyEPhipps AndyEPhipps changed the title Add pre/post whitespace to regex Add pre and post whitespace to TransactionID regex Mar 27, 2024
@KrupaPammi
Copy link
Contributor

KrupaPammi commented Mar 27, 2024

Hi @AndyEPhipps, I tested this. The submission works when only one space is added after the transaction ID is pasted. Still, when I add two spaces after the transaction ID, I see the error message This transaction ID doesn't seem to be valid, please check your donation confirmation email or letter. Can we update the error message to what Rosie suggested in the ticket 'Please ensure there is no space included at the end of your transaction ID' when more spaces are added.

Screenshot 2024-03-27 at 12 03 04

@AndyEPhipps
Copy link
Contributor Author

AndyEPhipps commented Mar 27, 2024

Hi @AndyEPhipps, I tested this. The submission works when only one space is added after the transaction ID is pasted. Still, when I add two spaces after the transaction ID, I see the error message This transaction ID doesn't seem to be valid, please check your donation confirmation email or letter. Can we update the error message to what Rosie suggested in the ticket 'Please ensure there is no space included at the end of your transaction ID' when more spaces are added.

Screenshot 2024-03-27 at 12 03 04

Hi Krupa, yeah I only added 0 or 1 spaces to the regex, I guess it doesn't need to be limited to just 1.

Re: error message, I figured this was probably better UX to just take care of it behind the scenes (rather than having to build an edgecase into messaging); this was what @corinja suggested in planning but I'm easy either way.

@corinja
Copy link
Member

corinja commented Mar 27, 2024

Hi Krupa, yeah I only added 0 or 1 spaces to the regex, I guess it doesn't need to be limited to just 1.

Re: error message, I figured this was probably better UX to just take care of it behind the scenes (rather than having to build an edgecase into messaging); this was what @corinja suggested in planning but I'm easy either way.

Yeah, definitely better to strip all leading and trailing whitespace from whatever the input is. Only if that can't work for some reason should we resort to asking the user to do it.

@AndyEPhipps
Copy link
Contributor Author

I've updated the regex to cover 0+ spaces at the end and/or beginning of the transactionID value now.

I appreciate your attention to detail, @KrupaPammi, but I guess it's worth reflecting that solutions suggested by non-technical stakeholders aren't aaaaalways best? 😇

@AndyEPhipps
Copy link
Contributor Author

(I should've added the conversation to the ticket anyways, so that's my bad)

@KrupaPammi
Copy link
Contributor

Thanks for the fix @AndyEPhipps, sorry for being over-detailed; we don't want another request from the stakeholders for one space or 2 spaces issue :)

I've updated the regex to cover 0+ spaces at the end and beginning of the transactionID value now.

I appreciate your attention to detail, @KrupaPammi, but I guess it's worth reflecting that solutions suggested by non-technical stakeholders aren't aaaaalways best? 😇

@AndyEPhipps
Copy link
Contributor Author

No no, all good, @KrupaPammi! You asked me to do what the ticket called for, and I just didn't feed the 'requirements gathering' conversations into it, so you weren't to know. I also totally should've allowed for any number of spaces from the beginning, so that's a win 🥇

@@ -63,6 +63,16 @@ test.describe('Giftaid update form validation @sanity @nightly-sanity', () => {
await page.waitForSelector('div#field-error--transactionId > span');
await expect(page.locator('div#field-error--transactionId > span')).toContainText('This transaction ID doesn\'t seem to be valid, please check your donation confirmation email or letter');

// transaction ID number with space at the end should not show error message
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @KrupaPammi 🙌

@AndyEPhipps AndyEPhipps merged commit 40e85c9 into master Mar 27, 2024
7 checks passed
@AndyEPhipps AndyEPhipps deleted the ENG-3193_transaction_id_validation_ branch March 27, 2024 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants