Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Test store data types update & fixes #427

Merged
merged 26 commits into from
Jan 8, 2019
Merged

Test store data types update & fixes #427

merged 26 commits into from
Jan 8, 2019

Conversation

T4rk1n
Copy link
Contributor

@T4rk1n T4rk1n commented Dec 28, 2018

Closes #422

@T4rk1n T4rk1n changed the title [WIP] Test store datatypes & fixes [WIP] Test store data types update & fixes Dec 28, 2018
* @param {any} oldData - The old data to compare
* @returns {boolean} The data has changed.
*/
function dataChanged(newData, oldData) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Beautiful, thank you!

const oldNull = R.isNil(old);
const newNull = R.isNil(data);
const oldNull = R.isNil(oldData);
const newNull = R.isNil(newData);
Copy link
Collaborator

Choose a reason for hiding this comment

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

isNil catches both undefined and null - and mostly that distinction is moot because undefined can't be sent via JSON, I guess. But we should be careful about it in objects, like {a: null} <-> {}

for (let i = 0; i < data.length; i++) {
if (dataCheck(data[i], old[i])) {
for (let i = 0; i < newData.length; i++) {
if (dataChanged(newData[i], oldData[i])) {
return true;
}
}
} else if (R.contains(type, ['String', 'Number'])) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

'Boolean'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Forgot about Boolean in all this type checks, thanks!

@T4rk1n
Copy link
Contributor Author

T4rk1n commented Dec 28, 2018

Look like removing the falsy check in componentDidUpdate fixed the basic types changes. 🎉

I added a type check:

if (type !== R.type(oldData)) {
    return true;
}

But it failed the test.

Added Boolean to valid types.

I'll add more edge cases test later.

@alexcjohnson
Copy link
Collaborator

I added a type check ... But it failed the test.

Can you say more? I don't see how that makes sense and I worry about remaining strange cases like #422 (comment) if this is omitted.

@T4rk1n
Copy link
Contributor Author

T4rk1n commented Dec 28, 2018

Can you say more?

Failure: AssertionError: '1' != '{"data": [1, 2, 3]}'

self.assertEqual(
assertion_text,
self.driver.find_element_by_css_selector(selector).text
text_equal
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, much nicer 🏆

In case anyone else hits this issue in the future: EC.text_to_be_present_in_element does a substring match, not a full value match. Makes sense in retrospect, given its name... so if the previous value is a substring of the new value you're expecting in the element you can get a premature match 💥

@T4rk1n T4rk1n changed the title [WIP] Test store data types update & fixes Test store data types update & fixes Jan 7, 2019
@T4rk1n
Copy link
Contributor Author

T4rk1n commented Jan 7, 2019

@alexcjohnson Please review.

('bool', False),
('empty-dict', {}),
('list-dict-1', [1, 2, {'data': [55, 66, 77], 'dummy': 'dum'}]),
('list-dict-1', [1, 2, {'data': [111, 99, 88]}]),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add the pathological items in my comments #422 (comment) and #422 (comment)? I think you fixed all those, but here's another one to add, that I think still fails:

dataChanged({a: 1, b: null}, {a: 1, c: 1}) // returns false, should be true

This is due to isNil conflating undefined and null - come to think of it, is there really a reason to treat those as equivalent? Perhaps we can just change the null check to:

if (oldNull || newNull) {
    return oldData !== newData; // which will distinguish null/undefined
}

@T4rk1n
Copy link
Contributor Author

T4rk1n commented Jan 8, 2019

@alexcjohnson Added the undef edge case and checking the data instead of the null fixed it. I think we're good now.

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

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

Excellent, thanks for the changes. 💃

@T4rk1n T4rk1n merged commit 52b804d into master Jan 8, 2019
@T4rk1n T4rk1n deleted the test-store-datatypes branch January 8, 2019 19:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants