- 
                Notifications
    
You must be signed in to change notification settings  - Fork 8.5k
 
ui/resize_checker 👉 src/plugins/kibana_utils #44750
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
Conversation
| 
           Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?  | 
    
31381d2    to
    931ed53      
    Compare
  
    | 
           retest  | 
    
          💔 Build Failed | 
    
        
          
                ...gins/canvas/public/components/workpad_page/workpad_interactive_page/interaction_boundary.tsx
              
                Outdated
          
            Show resolved
            Hide resolved
        
      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.
ML edits LGTM
| 
           Pinging @elastic/kibana-app-arch  | 
    
| 
           retest  | 
    
          💔 Build Failed | 
    
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 @sainthkh
Thank you for this PR!
I added a couple of small comments.
However, although I understand you explanation on why you had to mock Element, I'm not sure why this PR would have caused any problems with these tests, that are working on master.
Could you please see if you can get the test working the way they were?
        
          
                src/legacy/core_plugins/console/public/src/sense_editor_resize.js
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                ...gins/canvas/public/components/workpad_page/workpad_interactive_page/interaction_boundary.tsx
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | 
           In #44366, it says to jest-ify tests. So, I did. (Also, I didn't know that I had to run tests with  I rerun the integration test in my local Ubuntu setup and found that the test passed without fail.  | 
    
| 
           what was the reason for reverting tests to karma ?  | 
    
| 
           I might have misunderstood the comment. But it was the request of @lizozom. As you know, test:dev doesn't work with jest. So, I had to revert it to mocha and karma.  | 
    
| 
           you can run jest tests with   | 
    
| 
           ui/public tests are run by  And @lizozom's request was to make tests work in that setup.  | 
    
6e2743d    to
    ae30316      
    Compare
  
    | 
           @elasticmachine merge upstream  | 
    
    
      
        1 similar comment
      
    
  
    | 
           @elasticmachine merge upstream  | 
    
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.
We have a convention of naming those IResizeChecker
| 
           @elasticmachine merge upstream  | 
    
| 
           jenkins tests this  | 
    
        
          
                ...ole/np_ready/public/application/containers/editor/legacy/subscribe_console_resize_checker.ts
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | 
           Hey @sainthkh the tests and functional test look great.  | 
    
| 
           Jenkins, test this  | 
    
          💔 Build Failed
  | 
    
| 
           1. Typecheck failed because of #49349 merged to master yesterday. It removed  2. About ResizeChecker and context: When  As  (In the code fix above, I just focused on removing  3. It seems that something went wrong with merging master. Infra failed without any error message. So, I decided to start from scratch. And the result is below.  | 
    
5145490    to
    418b3fa      
    Compare
  
    418b3fa    to
    c4808ae      
    Compare
  
    | 
           jenkins test this  | 
    
| 
           @sainthkh this looks good. Let me test this.  | 
    
          💚 Build Succeeded | 
    
| 
           @elasticmachine merge upstream  | 
    
| 
           jenkins test this  | 
    
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.
LGTM.
@sainthkh error is due to an error on master.
Once it's fixed, I'll merge :)
          💔 Build Failed | 
    
| 
           @elasticmachine merge upstream  | 
    
| 
           jenkins test this  | 
    
| 
           retest  | 
    
          💚 Build Succeeded | 
    
* Moved ResizeChecker to kibana_utils. * Removed ResizeChecker from __LEGACY.
…her [skip ci] * upstream/master: (54 commits) allows plugins to define validation schema for "enabled" flag (elastic#50286) Add retry to find.existsByDisplayedByCssSelector (elastic#48734) [i18n] integrate latest translations (elastic#50864) ui/resize_checker 👉 src/plugins/kibana_utils (elastic#44750) Fix @reach/router types (elastic#50863) [ML] Adding ML node warning to overview and analytics pages (elastic#50766) Bump storybook dependencies (elastic#50752) [APM Replace usage of idx with optional chaining (elastic#50849) [SIEM] Fix eslint errors (elastic#49713) Improve "Browser client is out of date" error message (elastic#50296) [SIEM][Detection Engine] REST API improvements and changes from UI/UX feedback (elastic#50797) Move @kbn/es-query into data plugin - es-query folder (elastic#50182) Index Management new platform migration (elastic#49359) Increase retry for cloud snapshot to finish (elastic#50781) Removing EuiCode from inside EuiPanel (elastic#50683) [SIEM] Tests for search_after and bulk index (elastic#50129) Make babel understand TypeScript 3.7 syntax (elastic#50772) Fixing mocha tests and broken password change status codes (elastic#50704) [Canvas] Use compressed forms in sidebar (elastic#49419) Add labels to shell scripts in Jenkins (elastic#49657) ...
Summary
Fixes #44366.
Note: this PR removes passing down
ResizeCheckeras a dependency to console, and replaces it with importing fromplugins/kibana_utils.Why custom mock?
1.
In
resize_checker.test.ts, custom mocks are added. I usedMockElementinstead ofjsdomelement created bydocument.createElement('div'). I mockedresize-observer-polyfill.All of this happened because
Element instanceof Objectisfalse.Let me explain.
In
resize-observer-polyfill'sobserver(), it checks several things before adding target to observation.One of them is
Element instanceof Object. It should betrueto pass the test. But it fails if we run the code in jest environment. (I cannot be sure why, but it seems that it isfalseto determine we're running the code in a real browser or console environment.)The thing we need to test is whether the callback function works correctly, not
resize-observer-polyfilldoes.Because of that, I decided to bypass
resize-observer-polyfill. That's why it is mocked.2.
Besides,
clientHeightandclientWidthis readonly. We can reset them withObject.defineProperty(). But this doesn't send any message to the created element.It just complicates the problem. So, I created
MockElement. And added some simple implementation for them.In real browser code, resizing elements should be like
div.style.height = '100px'. But it doesn't send any event in jest environment. So, I addedMockElementand changed theclientHeightdirectly.3.
I named event
resizebecause it is used in the code.Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.- [ ] This was checked for cross-browser compatibility, including a check against IE11- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support- [ ] Documentation was added for features that require explanation or tutorials- [ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers