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

Refactor Address input component test file to new format #3316

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

precious-onyenaucheya-ons
Copy link
Contributor

@precious-onyenaucheya-ons precious-onyenaucheya-ons commented Aug 23, 2024

What is the context of this PR?

Fixes: ONSdigital/design-team#132
This PR involves refactoring of the address input test document to follow the Given, When, Then testing approach.

How to review this PR

Functionality:

  • Run the test suite using: yarn test --testNamePattern="FOR: Macro: Address-input"

Does this testing refactor meet the following success criteria:

  • Clearly structured.
  • Follows naming conventions.
  • Consistent.
  • Concise.
  • Suited to our codebase.
  • Compatible with existing testing framework.

Look at the refactored code in relation to:

  • The original test document.
  • The macro file.
  • The macro options file.

Checklist

This needs to be completed by the person raising the PR.

  • I have selected the correct Assignee
  • I have linked the correct Issue

@precious-onyenaucheya-ons precious-onyenaucheya-ons added the Tech improvements Tech debt, cleanup, code standardisation etc. label Aug 23, 2024
@precious-onyenaucheya-ons precious-onyenaucheya-ons requested a review from a team August 23, 2024 07:05
Copy link

netlify bot commented Aug 23, 2024

Deploy Preview for ons-design-system-preview ready!

Name Link
🔨 Latest commit 7166e92
🔍 Latest deploy log https://app.netlify.com/sites/ons-design-system-preview/deploys/66f6aa600c3f0800083a66d4
😎 Deploy Preview https://deploy-preview-3316--ons-design-system-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@rmccar
Copy link
Contributor

rmccar commented Aug 23, 2024

I think part of the work on this was to move the examples like EXAMPLE_MANUAL_INPUT_FIELDS out into its own file and then be imported. Have a look at one of the ones Bali has done

@precious-onyenaucheya-ons precious-onyenaucheya-ons changed the title refactor address input test Refactor address-input test document Aug 23, 2024
@precious-onyenaucheya-ons precious-onyenaucheya-ons changed the title Refactor address-input test document Refactor address-input component test file to new format Sep 12, 2024
Copy link
Contributor

@balibirchlee balibirchlee left a comment

Choose a reason for hiding this comment

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

This is a difficult one because I think the macro options file is a bit unwieldy - I think this one will need a pretty major revamp from the original test file.
As there are a lot of required params - i would probably start with a "GIVEN: Params: required" and then do when/then's for each of those params
After that I would go through each macro option in order and do its given/when/then. if there's a group that makes sense to go together, then by all means group those, and just make sure it's obvious what params are being covered.

src/components/address-input/_macro.spec.js Outdated Show resolved Hide resolved
src/components/address-input/_macro.spec.js Outdated Show resolved Hide resolved
src/components/address-input/_macro.spec.js Outdated Show resolved Hide resolved
src/components/address-input/_macro.spec.js Outdated Show resolved Hide resolved
src/components/address-input/_macro.spec.js Outdated Show resolved Hide resolved
src/components/address-input/_macro.spec.js Outdated Show resolved Hide resolved
src/components/address-input/_macro.spec.js Outdated Show resolved Hide resolved
src/components/address-input/_macro.spec.js Outdated Show resolved Hide resolved
});
});

it('renders manualLinkText` when provided with a default value for `manualLink`', () => {
describe('WHEN: provided with a default value for manualLink', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

manualLink should be a given with two whens underneath that cover default and supplied values

src/components/address-input/_macro.spec.js Outdated Show resolved Hide resolved
src/components/address-input/_macro.spec.js Outdated Show resolved Hide resolved
src/components/address-input/_macro.spec.js Outdated Show resolved Hide resolved
src/components/address-input/_macro.spec.js Outdated Show resolved Hide resolved
src/components/address-input/_macro.spec.js Outdated Show resolved Hide resolved
@rmccar rmccar changed the title Refactor address-input component test file to new format Refactor Address input component test file to new format Sep 27, 2024
Copy link
Contributor

@rmccar rmccar left a comment

Choose a reason for hiding this comment

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

Couple of minor things

expect(results).toHaveNoViolations();
describe('FOR: Macro: Address-input', () => {
describe('GIVEN: Params: required', () => {
describe('WHEN: all required params are provided', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
describe('WHEN: all required params are provided', () => {
describe('WHEN: required params are provided', () => {

value: '12345 The Road',
width: '20@m',
error: { text: 'Server error: address line 2' },
test('THEN: it renders autosuggest component with expected parameters', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this should be "THEN: the provided attributes are passed through to the autosuggest component" because that is what it is testing

@rmccar rmccar added the Do not merge Don't merge this PR until this label is removed label Oct 2, 2024
@rmccar rmccar removed the Do not merge Don't merge this PR until this label is removed label Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tech improvements Tech debt, cleanup, code standardisation etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Testing refactor - Address input
4 participants