-
Notifications
You must be signed in to change notification settings - Fork 71
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
implement revert logic by using originalSelector #603
Conversation
@@ -18,6 +19,7 @@ const AssertionCardSelectorList: React.FC<IProps> = ({selectorList, pseudoSelect | |||
<S.SelectorValueText>{value}</S.SelectorValueText> | |||
</S.Selector> | |||
))} | |||
<S.SelectorValueText>{originalSelector}</S.SelectorValueText> | |||
{pseudoSelector && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only showing for debugging proposes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, should we remove it then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -11,6 +11,7 @@ const AssertionResults = ({allPassed = false, results = []}: TRawAssertionResult | |||
id: uniqueId(), | |||
selector, | |||
spanIds: AssertionService.getSpanIds(resultList), | |||
originalSelector: selector, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
creating the field on AsserionResult
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want this in the model? I see we also have a assertionResultsToDefinitionList
in web/src/redux/slices/TestDefinition.slice.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is good here for the moment, but I get your point
setSelectedAssertion: CaseReducer<ITestDefinitionState, PayloadAction<string>>; | ||
}, | ||
'testDefinition' | ||
>({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add better typescript typings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm always up for this. Should this mean that we can drop the types from each of the reducer functions as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return { | ||
...def, | ||
...definition, | ||
originalSelector: def.originalSelector, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to ensure originalDefinition is carried over
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @cescoferraro gj man, I left some comments and concerns. Let me know what you think
@@ -17,8 +18,15 @@ interface TAssertionCardProps { | |||
onEdit(assertionResult: TAssertionResultEntry): void; | |||
} | |||
|
|||
export function useRevertDefinitionCallback(originalSelector: string): () => void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having the dispatch here, we should be able to wrap it up at the TestDefinitionProvider
like the rest of the functions.
{isDraft && ( | ||
<> | ||
<S.StatusTag>draft</S.StatusTag> | ||
<Tooltip color="white" title="Revert Assertion"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is kind of weird that both the tooltip an the actual message have the same text
@@ -18,6 +19,7 @@ const AssertionCardSelectorList: React.FC<IProps> = ({selectorList, pseudoSelect | |||
<S.SelectorValueText>{value}</S.SelectorValueText> | |||
</S.Selector> | |||
))} | |||
<S.SelectorValueText>{originalSelector}</S.SelectorValueText> | |||
{pseudoSelector && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, should we remove it then?
setSelectedAssertion: CaseReducer<ITestDefinitionState, PayloadAction<string>>; | ||
}, | ||
'testDefinition' | ||
>({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm always up for this. Should this mean that we can drop the types from each of the reducer functions as well?
console.log('=========='); | ||
console.log(current(d)); | ||
console.log(originalSelector); | ||
if (d?.originalSelector === originalSelector) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when the user tries to revert a newly created assertion? in that case we should wipe it from the store isn't it?
if (def.selector === selector) return definition; | ||
if (def.originalSelector === selector) | ||
return { | ||
...def, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can avoid spreading the original dev, we can just do it for the new def + the original selector
9a7e6d9
to
03ed2af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @cescoferraro I added some questions 😬
@@ -11,6 +11,7 @@ const AssertionResults = ({allPassed = false, results = []}: TRawAssertionResult | |||
id: uniqueId(), | |||
selector, | |||
spanIds: AssertionService.getSpanIds(resultList), | |||
originalSelector: selector, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is good here for the moment, but I get your point
{payload: {definition, selector}}: PayloadAction<{definition: TTestDefinitionEntry; selector: string}> | ||
) { | ||
revertDefinition(state, {payload: {originalSelector}}) { | ||
// @ts-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are we ignoring here?
// @ts-ignore | ||
state.definitionList = state.definitionList | ||
.map(d => { | ||
if (d?.originalSelector === originalSelector) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this cover the scenario of reverting a newly created assertion?
{isDraft && ( | ||
<> | ||
<S.StatusTag>draft</S.StatusTag> | ||
<Button type="link" data-cy="assertion-action-revert" onClick={resetDefinition}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if this onClick also needs the e.stopPropagation();
similar to what we have in the Edit/Delete icons.
This PR add revert logic to individual assertions
Changes
Checklist