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

Refactor unit tests to unblock CI #1862

Merged
merged 6 commits into from
Jul 27, 2023
Merged

Refactor unit tests to unblock CI #1862

merged 6 commits into from
Jul 27, 2023

Conversation

VadimKovalenkoSNF
Copy link
Collaborator

@VadimKovalenkoSNF VadimKovalenkoSNF commented Jul 19, 2023

  1. Removed test related to MCS.
  2. Removed tests that handle elements with the details tag.
  3. Refactored test that calculates article categories.
  4. Refactored e2e tests.

@codecov
Copy link

codecov bot commented Jul 19, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -1.14% ⚠️

Comparison is base (8bbde9d) 71.42% compared to head (8eea14a) 70.29%.

❗ Current head 8eea14a differs from pull request most recent head a23144f. Consider uploading reports for the commit a23144f to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1862      +/-   ##
==========================================
- Coverage   71.42%   70.29%   -1.14%     
==========================================
  Files          24       24              
  Lines        2625     2626       +1     
  Branches      595      596       +1     
==========================================
- Hits         1875     1846      -29     
- Misses        644      667      +23     
- Partials      106      113       +7     
Files Changed Coverage Δ
src/util/saveArticles.ts 82.44% <100.00%> (-0.15%) ⬇️

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@VadimKovalenkoSNF
Copy link
Collaborator Author

@kelson42 test coverage decreased because of the deprecated renderMCSArticle() method which is present here because this PR was dedicated to fix test issues only (link)

@kelson42
Copy link
Collaborator

@VadimKovalenkoSNF When you are ready, please request review to me.

Copy link
Collaborator

@kelson42 kelson42 left a comment

Choose a reason for hiding this comment

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

Removing the test does not sound to be the appropriate approach to me. Improving or updating test is the approach to follow.

test/unit/downloader.test.ts Show resolved Hide resolved
test/unit/mwApi.test.ts Outdated Show resolved Hide resolved
test/unit/saveArticles.test.ts Outdated Show resolved Hide resolved
@VadimKovalenkoSNF
Copy link
Collaborator Author

Failed tests with error:

Multimedia › check multimedia content from wikipedia test page with different formats

Need to investigate, local test went OK.

@VadimKovalenkoSNF VadimKovalenkoSNF marked this pull request as draft July 20, 2023 14:50
@kelson42
Copy link
Collaborator

Failed tests with error:

Multimedia › check multimedia content from wikipedia test page with different formats

Need to investigate, local test went OK.

Please comment out and open a ticket to be treated later in the milestone

@VadimKovalenkoSNF
Copy link
Collaborator Author

The ticket about empty sections handling is here - #1866

@VadimKovalenkoSNF
Copy link
Collaborator Author

@kelson42 To fix test pipeline, I had to roll back keepEmptyParagraphs option and temporary suppress applyOtherTreatments test block. The new version of keepEmptyParagraphs breaks multimedia content tests - these are tests that are running from zim files. Is it possible to run test/e2e/multimediaContent.test.ts locally with Zimcheck? I have these tests skipped locally with message Zimcheck not installed, skipping test.

@VadimKovalenkoSNF VadimKovalenkoSNF marked this pull request as ready for review July 25, 2023 15:57
@VadimKovalenkoSNF
Copy link
Collaborator Author

I updated the keepEmptyParagraphs option. The problem was that it didn't handle paragraphs with media content inside (e.g. <p><img src='image.jpg'></p> was considered as an empty paragraph. Now it is fixed).

Copy link
Collaborator

@kelson42 kelson42 left a comment

Choose a reason for hiding this comment

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

Feature --keepEmptyParagraphs (and the way how it should work when unset) seems not understood.

if (hasNoMediaContent) {
if (!paragraph.textContent || (paragraph.textContent && paragraph.textContent.trim().length === 0)) {
DU.deleteNode(paragraph)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This does not behave like it should. Either it removes user visible empty parapgraph (<h*> DOM node or similar or it's wrong). Here it just removes <p> elements under certain conditions which is neither what is expected or what it was doing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Got it. I brought back the original implementation of this for now.

const doc = domino.createDocument(LondonHtml)
const imgToGet = Array.from(doc.querySelectorAll('[data-mw-section-id="0"] img'))[0]
let imgToGetSrc = ''
if (imgToGet.getAttribute('src')) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand why there is a if here? Don't assume the HTML could change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's a good practice to check whether DOM element has a specific attribute before calling it directly.

}
expect(fewestChildren).toBeGreaterThan(0)
const paragraphs = Array.from(doc.querySelectorAll('p'))
expect(paragraphs.length).toEqual(2)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here same feedback as earlier, the feauture seems to be not understood.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I rollbacked tests and commented on them. We'll refer to this functionality later.

@kelson42 kelson42 merged commit ebb0249 into main Jul 27, 2023
4 checks passed
@kelson42 kelson42 deleted the fix-unit-tests branch July 27, 2023 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants