Skip to content
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.

Update harness to use integrated vdom from widget-core #70

Merged
merged 23 commits into from
Nov 7, 2017

Conversation

kitsonk
Copy link
Member

@kitsonk kitsonk commented Oct 26, 2017

Type: feature

The following has been addressed in the PR:

  • There is a related issue
  • All code matches the style guide
  • Unit or Functional tests are included in the PR

Description:

This PR updates the harness to be compatible with the integrated vdom from widget-core (PR dojo/widget-core#728.

It also makes a few other changes, some of them breaking:

  • Uses the Projector instead of accessing the virtual DOM projection directly.
  • Uses the Projector in a sandbox mode, therefore widgets are rendered on a document fragment instead of actually in the DOM. This is more consistent with the concepts of harnessing and unit testing. Actually that was causing issues on Safari I couldn't fully resolve. Basically Safari 9 doesn't like dispatching events on DOM owned by a document fragment.
  • Changes the types to make the harness easier to use with no need to explicitly pass generics with widgets. Also .setProperties and .setChildren will now properly type guard. This is a breaking change in that many cases people might have had to specify two generic arguments to have the harness work.

This will need to be updated once the upstream PR is merged and published.

@codecov
Copy link

codecov bot commented Oct 26, 2017

Codecov Report

Merging #70 into master will decrease coverage by 0.51%.
The diff coverage is 93.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #70      +/-   ##
==========================================
- Coverage   99.08%   98.56%   -0.52%     
==========================================
  Files          10       10              
  Lines         653      626      -27     
  Branches      160      163       +3     
==========================================
- Hits          647      617      -30     
- Misses          0        1       +1     
- Partials        6        8       +2
Impacted Files Coverage Δ
src/support/assertRender.ts 98.11% <100%> (+0.74%) ⬆️
src/support/d.ts 95.45% <66.66%> (-4.55%) ⬇️
src/support/sendEvent.ts 97.43% <93.33%> (-2.57%) ⬇️
src/harness.ts 97.87% <95.45%> (+0.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 80fc66a...2d74245. Read the comment docs.

@kitsonk
Copy link
Member Author

kitsonk commented Oct 26, 2017

The difference in code coverage is a red herring. Because there was quite a bit of code stripped because of leveraging the projector mixin from widget core, it is causing the code coverage to be 😭

@dylans dylans added this to the 2017.10 milestone Oct 27, 2017
@kitsonk kitsonk modified the milestones: 2017.10, beta.4 Oct 30, 2017
@kitsonk kitsonk changed the title WIP: Update harness to use integrated vdom from widget-core Update harness to use integrated vdom from widget-core Nov 7, 2017
Copy link
Member

@agubler agubler 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 small comments

}

if (Array.isArray(actual) && Array.isArray(expected)) {
assertChildren(actual, expected);
}
else if (Array.isArray(actual) || Array.isArray(expected)) {
throwAssertionError(actual, expected, message);
throwAssertionError(actual, expected, Array.isArray(actual) ? `Expected "${expected === null ? 'null' : typeof expected}" but got an array` : `Expected an array but got "${actual === null ? 'null' : typeof actual}"`, message);
Copy link
Member

Choose a reason for hiding this comment

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

nit: This is quite long

Copy link
Member Author

Choose a reason for hiding this comment

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

I refactored all the messages, you are right it was messy and unreadable.

src/harness.ts Outdated
if (vnode && vnode.domNode) {
target = vnode.domNode as Element;
const dnode = findDNodeByKey(this._widgetHarness.lastRender, key);
if (dnode && !isWNode(dnode)) {
Copy link
Member

Choose a reason for hiding this comment

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

any reason why not isHNode instead of !isWNode?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not that I can think of... Wasn't thinking.

@kitsonk
Copy link
Member Author

kitsonk commented Nov 7, 2017

The coverage is a bit of a red herring, as it is more related to the changes in widget-core causing some less branch coverage, plus the overall reduction of code because of the removal of the widget.classes logic.

@kitsonk
Copy link
Member Author

kitsonk commented Nov 7, 2017

I accidentally committed some change to the diagnostics of assert render that I had in another branch which I was going to submit after this PR, but they leaked in, so I merged the rest of them. Overall it just improves the information you get from assert render when something goes wrong, instead of scratching your head, so hopefully we can turn a blind eye.

@kitsonk kitsonk merged commit bd9be40 into dojo:master Nov 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants