equinor / videx-wellog

Well log components
https://equinor.github.io/videx-wellog/
MIT License
20 stars 7 forks source link

[BUG] Wrong type of actual parameter in D3 .style() function #142

Open Vladimir-Kokin opened 2 years ago

Vladimir-Kokin commented 2 years ago

A test of component which used videx-wellog library craches inside D3 library code The test (https://github.com/equinor/webviz-subsurface-components/pull/776) is written for Jest environment

FAIL src/lib/components/WellLogViewer/WellLogViewer.test.tsx
  ● Test Well Log Viewer Component › snapshot test

    TypeError: name.toLowerCase is not a function

      366 |     logController.scaleHandler = scaleHandler;
      367 |     logController.domain = minmaxPrimaryAxis;
    > 368 |     logController.setTracks(tracks);
          |                   ^
      369 | }
      370 |
      371 | function addTrackMouseEventListner(   

This error is due to a BUG in videx-wellog (file log-controller.ts, function _trackEnter):

    if (showLegend) {
      newtracks.append('div')
        .classed('track-legend', true)
        .classed('hidden', legendHeight <= 0)
        .style([attr.size], `${legendHeight}px`);

The last line should reads (without square brackets! because the first parameter should be a string not an array of strings):

.style(attr.size, `${legendHeight}px`);

The same bug is in function _trackUpdate

    if (showLegend) {
      const legend = selection.select('.track-legend');
      legend
        .style([sizeAttr], `${legendHeight}px`)

It is unclear why these bugs leads to crash only in test environment

See also https://github.com/equinor/webviz-subsurface-components/issues/803

Brynjulf commented 2 years ago

Nice catch, mind making a pull request to fix this?