Skip to content
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

Tests are failing on local master and CI #13347

Closed
mremiszewski opened this issue Jan 27, 2023 · 18 comments
Closed

Tests are failing on local master and CI #13347

mremiszewski opened this issue Jan 27, 2023 · 18 comments
Assignees
Labels
squad:core Issue to be handled by the Core team. type:bug This issue reports a buggy (incorrect) behavior.

Comments

@mremiszewski
Copy link
Contributor

mremiszewski commented Jan 27, 2023

📝 Provide detailed reproduction steps (if any)

Some tests are failing

  1. packages\ckeditor5-image\tests\integration.js
    image
  2. packages\ckeditor5-table\tests\ui\inserttableview.js
    image
  3. rect-not-in-dom (kind of not specific?) - it may be just a result of previous failures
    image

✔️ Expected result

Tests should complete without failure

❌ Actual result

CI is failing because of these errors.

❓ Possible solution

Reproduction steps in comments.

📃 Other details

  • Browser: Chrome 109
  • OS: Win 11, iOS
  • First affected CKEditor version: tested on 35.4 and 36.0

If you'd like to see this fixed sooner, add a 👍 reaction to this post.

@mremiszewski mremiszewski added the type:bug This issue reports a buggy (incorrect) behavior. label Jan 27, 2023
@mremiszewski
Copy link
Contributor Author

Reproduction steps:

Image integration. It happens when the browser is not focused.

  1. git checkout master && git pull
  2. yarn run test --files="image/integration" --watch
  3. Open http://localhost:9876/debug.html or similar if your Karma server is running on a different port.
  4. Open developer tools (F12) and focus on the console
  5. Refresh the page and observe failed test

TableInsert. It also happens when the browser is not focused.

  1. git checkout master && git pull
  2. yarn run test --files="table/ui/inserttableview" --watch
  3. Open http://localhost:9876/debug.html or similar if your Karma server is running on a different port.
  4. Open developer tools (F12) and focus on the console
  5. Refresh the page and observe failed test
     

@mremiszewski mremiszewski added squad:core Issue to be handled by the Core team. status:in-progress Set automatically when an issue lands in the "In progress" column. We are working on it. labels Jan 27, 2023
@mremiszewski mremiszewski self-assigned this Jan 30, 2023
@niegowski
Copy link
Contributor

  1. yarn run test --files="image/integration" --watch

This can be fixed by adding:

newEditor.ui.focusTracker.isFocused = true;

At the beginning of that test.

@niegowski
Copy link
Contributor

  1. yarn run test --files="table/ui/inserttableview" --watch

This one is tricky because it relies on DOM element.focus() and focus event that seems not to get fired if the page is not focused. It could be sth related to the browser change.

@niegowski
Copy link
Contributor

The 2 above tests fixed/disabled in commit 9496e5e.

Seems that the rect-source-not-in-dom is still failing. I'm trying to find where and why.

@niegowski
Copy link
Contributor

Finally, I found what was causing the rect-source-not-in-dom warning. This was happening in the TooltipManager that was trying to pin BalloonPanelView to the BlockToolbar#buttonView and it's handled in the debounced method without checking whether the button is still visible. 

Draft branch (without updated tests for CC): https://github.com/ckeditor/ckeditor5/compare/ck/13347

This all problems are caused by the fact that for an unknown reason, the integration CI is running tests in a blurred Chrome window. Maybe we should try to handle this problem on the CI side by providing --browsers=ChromeHeadless an option to auto tests (this is fixing tests locally).

Apart from the above, I noticed plenty of misc and random errors like this:

ERROR in ./packages/ckeditor5-basic-styles/src/bold/boldui.ts
Module build failed (from ./node_modules/ts-loader/index.js):
Error: TypeScript emitted no output for /Users/kuba/WebstormProjects/ckeditor5/packages/ckeditor5-basic-styles/src/bold/boldui.ts.

@Reinmar
Copy link
Member

Reinmar commented Feb 1, 2023

This all problems are caused by the fact that for an unknown reason, the integration CI is running tests in a blurred Chrome window. Maybe we should try to handle this problem on the CI side by providing --browsers=ChromeHeadless an option to auto tests (this is fixing tests locally).

What do you mean by "option to auto tests"? How does it help locally?

@niegowski
Copy link
Contributor

What do you mean by "option to auto tests"? How does it help locally?

Headless Chrome seems to be focused all the time.

@Reinmar
Copy link
Member

Reinmar commented Feb 1, 2023

Apart from the above, I noticed plenty of misc and random errors like this:

Whenever seeing that error please investigate a bit more into the error that caused this one. As discussed on Monday, @pomek noticed that the original error is also logged. Knowing the root cause of these TS problems would help us understand whether it's related to module augmentation (of which we're aware already) or someting new.

@Reinmar
Copy link
Member

Reinmar commented Feb 1, 2023

What do you mean by "option to auto tests"? How does it help locally?

Headless Chrome seems to be focused all the time.

Interesting. Are we aware of any other differences between real Chrome and Headless Chrome? Perhaps HC would be faster too, making CI jobs shorter (and more stable). But at the same time, if it changes something more and would make tests unrealistic, switching to Headless Chrome would make no sense ;|

@niegowski
Copy link
Contributor

Whenever seeing that error please investigate a bit more into the error that caused this one. As discussed on Monday, @pomek noticed that the original error is also logged. Knowing the root cause of these TS problems would help us understand whether it's related to module augmentation (of which we're aware already) or someting new.

By random, I was talking about happening in different places on different files and after triggering tests multiple times it happened in different places almost every time without any changes in the code).

@niegowski
Copy link
Contributor

Interesting. Are we aware of any other differences between real Chrome and Headless Chrome? Perhaps HC would be faster too, making CI jobs shorter (and more stable). But at the same time, if it changes something more and would make tests unrealistic, switching to Headless Chrome would make no sense ;|

I'm using headless chrome locally to run tests for a few years now and did not notice any changes except its just a focused tab (and this annoying window is not appearing when starting tests).

@pomek
Copy link
Member

pomek commented Feb 2, 2023

In the past, we measured the time needed for executing tests using Headless Chrome and Chrome. It's more or less the same. But if we gain more stability, I am all for using HC instead of a standard browser.

@niegowski
Copy link
Contributor

niegowski commented Feb 2, 2023

I was trying to fix the "rect" problem but finally, it won't work because TooltipManager depends on ResizeObserver and it does not fire if the tab is in the background. 

I noticed that it's not about the page being focused or blurred but whether it is visible or in the background. Found this comment: karma-runner/karma-chrome-launcher#228 (comment) and tested it on our karma config and the tests started working. Without switching to ChromeHeadless. So this is another option, probably safer.

customLaunchers: {
    CHROME_TRAVIS_CI: {
        base: 'Chrome',
        flags: [ '--no-sandbox', '--disable-background-timer-throttling', '--js-flags="--expose-gc"' ]
    },
    CHROME_LOCAL: {
        base: 'Chrome',
        flags: [ '--disable-background-timer-throttling', '--js-flags="--expose-gc"', '--remote-debugging-port=9222', 
            '--disable-renderer-backgrounding', '--disable-backgrounding-occluded-windows' ]
    }
},

@niegowski
Copy link
Contributor

I also found this: https://github.com/karma-runner/karma-chrome-launcher/blob/master/index.js#L45-L47

Looks like by default, when running tests in Chrome, this flag should be enabled. Maybe we are overriding it? I'm not sure how customLaunchers work. I'm not sure if both flags are needed.

@niegowski
Copy link
Contributor

The 2 above tests fixed/disabled in commit 9496e5e.

Reverted in 2b6a3f2.

@niegowski
Copy link
Contributor

@pomek can we close this issue? Or we should keep it open to keep info about '--disable-renderer-backgrounding', '--disable-backgrounding-occluded-windows' until we add it the karma config?

@pomek
Copy link
Member

pomek commented Feb 6, 2023

☝️ it deserves to be extracted into a new issue. This issue is about failing tests. The new case could be about enabling additional flags in tests.

@niegowski
Copy link
Contributor

Extracted: #13407.

@CKEditorBot CKEditorBot removed the status:in-progress Set automatically when an issue lands in the "In progress" column. We are working on it. label Feb 6, 2023
@Reinmar Reinmar added this to the iteration 61 milestone Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
squad:core Issue to be handled by the Core team. type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

No branches or pull requests

5 participants