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

Reduce dot notation chaining in cypress tests #1919

Open
scottqueen-bixal opened this issue Nov 5, 2024 · 0 comments
Open

Reduce dot notation chaining in cypress tests #1919

scottqueen-bixal opened this issue Nov 5, 2024 · 0 comments

Comments

@scottqueen-bixal
Copy link
Collaborator

Description

we have lengthy dot notation assignments due to nested data,

for example:

current

const relationshipId =
  EN_DOLO_MOCK_DATA.data.lifeEventForm.sectionsEligibilityCriteria[0].section
    .fieldsets[1].fieldset.inputs[0].inputCriteria.id
const relationshipValue =
  EN_DOLO_MOCK_DATA.data.lifeEventForm.sectionsEligibilityCriteria[0].section
    .fieldsets[1].fieldset.inputs[0].inputCriteria.values[1].value

lets explore ways to reduce this with functional programing,

const getInputCriteria = (data, criteriaLocation: { fieldSetsIndex, inputIndex }) => {
 ...
 return value
}

// getInputCriteria(data[<sectionIndex>], criteriaLocation: { fieldSetsIndex, inputIndex });

const data = EN_DOLO_MOCK_DATA.data.lifeEventForm.sectionsEligibilityCriteria

const relationshipCriteria =  getInputCriteria(data[0], criteriaLocation: {
        fieldSetsIndex: 1,
        inputIndex: 0,
})

// And then when we want to call dot notations we can call it from the criteria, ie.

console.log(relationshipCriteria.id);
console.log(relationshipCriteria.values[1].value);

User Story

No response

Acceptance Criteria

No response

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

No branches or pull requests

1 participant