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 newSelectorLogic method #501

Merged
merged 4 commits into from
May 19, 2022
Merged

add newSelectorLogic method #501

merged 4 commits into from
May 19, 2022

Conversation

cescoferraro
Copy link
Contributor

This PR create a method to transform selectorList: IItemSelector[] to a selector string described here

Changes

  • nothing, just adds a new method

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

@cescoferraro cescoferraro requested a review from xoscar May 19, 2022 12:47
Copy link
Collaborator

@xoscar xoscar left a comment

Choose a reason for hiding this comment

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

Hey @cescoferraro I left some comments and concerns. Let me know what you think

@@ -0,0 +1,20 @@
import {IItemSelector} from '../../types/Assertion.types';

export function newSelectorLogic(selectorList: IItemSelector[]): string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's move this to the Assertion service

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can change this to be more verbose by doing something like:

const getFilters = (selectorList) => {
  return selectorList.map(({propertyName, operator, value, valueType}) => `${propertyName} ${operator || '='} ${getValue(value, valueType)}`);
}

const result `span[${getFilters(selectorList).join(' ')}]`;

result += selector.propertyName;
result += selector.operator ? ` ${selector.operator.toLowerCase()} ` : '=';
// add quotes if value is a string
if (selector.valueType === 'stringValue') result += `'`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should have a more complex way of creating this chunk to support the other value types.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Something like getValueString(value, valueType);

Then we can decide how to create each of them

@cescoferraro cescoferraro merged commit c80f10c into main May 19, 2022
@mathnogueira mathnogueira deleted the feat/new_selector_logic branch May 25, 2022 16:55
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.

2 participants