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

Modularizing e2e tests #1898

Merged
merged 14 commits into from
Oct 5, 2023
Merged

Modularizing e2e tests #1898

merged 14 commits into from
Oct 5, 2023

Conversation

VadimKovalenkoSNF
Copy link
Collaborator

Fixes #1887

@VadimKovalenkoSNF
Copy link
Collaborator Author

Here is the first stage of applying multiple render API for tests. I realized that the best way to test multiple API is to add renderName option to CLI, which will allow to extend parameters for each e2e test. Moreover, we preserved this ability in the renderer builder when choosing specific option. I started with bm wiki, it’s a good example of wiki that has only WikimediaDesktop but not VisualEditor API. Each e2e test can sequentially apply the necessary renderer taken from renderName option. @kelson42 , let me know if this approach makes sense to you.

@codecov
Copy link

codecov bot commented Aug 31, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (d2768ef) 74.74% compared to head (6b51e74) 74.60%.
Report is 2 commits behind head on main.

❗ Current head 6b51e74 differs from pull request most recent head 3c5a0d0. Consider uploading reports for the commit 3c5a0d0 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1898      +/-   ##
==========================================
- Coverage   74.74%   74.60%   -0.14%     
==========================================
  Files          33       33              
  Lines        2811     2812       +1     
  Branches      626      626              
==========================================
- Hits         2101     2098       -3     
- Misses        613      618       +5     
+ Partials       97       96       -1     
Files Coverage Δ
src/mwoffliner.lib.ts 74.81% <100.00%> (+0.09%) ⬆️
src/util/const.ts 100.00% <100.00%> (ø)

... and 4 files with indirect coverage changes

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

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.

I have left a few comments

test/e2e/rendererList.test.ts Outdated Show resolved Hide resolved
src/parameterList.ts Outdated Show resolved Hide resolved
test/e2e/rendererList.ts Outdated Show resolved Hide resolved
test/e2e/rendererList.test.ts Outdated Show resolved Hide resolved
test/e2e/bm.e2e.test.ts Outdated Show resolved Hide resolved
@kelson42
Copy link
Collaborator

kelson42 commented Sep 6, 2023

@VadimKovalenkoSNF Can you please:

  • Fix a few comments regarding the code allowing to force a dedicated render
  • Move this part in an other PR (wihtout the testing part)

That way, I would merge straight, as this LGTM. We could then keep this PR for focus on the testing only.

@kelson42
Copy link
Collaborator

kelson42 commented Sep 8, 2023

@VadimKovalenkoSNF This PR should be rebased/revamped, now that I have merged #1901. Hopefully, then I will better understand the way how you solve the problem.

const outFiles = await mwoffliner.execute(parameters)
await expect(zimcheck(outFiles[0].outFile)).resolves.not.toThrowError()

const articleFromDump = await zimdump(`show --url A/${parameters.articleList} ${outFiles[0].outFile}`)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is the ability to get an article HTML form dump and test it directly along with other dump output. This might be useful for e2e testing.

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 really understand why yor comment come here, but zimcheck should be run everywhere, so why I have eachtime to request it? Create a test template/fonction/classs so this is part is present only once in the whole codebase.

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.

Once we are at the end of the simplification, we should fix the nodet test as well.

test/e2e/bm.e2e.test.ts Outdated Show resolved Hide resolved
test/e2e/rendererList.test.ts Outdated Show resolved Hide resolved
test/e2e/rendererList.test.ts Outdated Show resolved Hide resolved
Comment on lines 79 to 89
describe('Treatments e2e', () => {
for (const renderer of renderers) {
if (renderer === 'WikimediaDesktop') {
test('WikimediaDesktop e2e', async () => {
await commonTreatmentTest(renderer)
})
}
if (renderer === 'VisualEditor') {
test('VisualEditor e2e', async () => {
await commonTreatmentTest(renderer)
})
}
}
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can do better: should be doable in 3 lines.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done, pls check.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Better, but why we have an if on Render names? All renders should be tested.

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 made it just for safety for cases if some wiki doesn't support a specific wiki.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test file has been refactored and renamed to test/e2e/en.e2e.test.ts.

test/e2e/treatments.e2e.test.ts Outdated Show resolved Hide resolved
test/e2e/treatments.e2e.test.ts Outdated Show resolved Hide resolved
Comment on lines 10 to 19
jest.setTimeout(200000)

let zimcheckIsAvailable
let zimdumpIsAvailable

beforeAll(async () => {
zimcheckIsAvailable = await zimcheckAvailable()
zimdumpIsAvailable = await zimdumpAvailable()
})

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we could avoid to do that for each test, this would be really better. No way to do simpler?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This beforeAll hook is placed outside describe blocks, so it will execute only once.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The problem is not the execution time, but that we have to place this piece of code almost in all e2e test.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not an execution problem, it's a code problem, these lines should be only once coded in the whole codebase.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done in test/testAllRenders.ts

test/e2e/treatments.e2e.test.ts Outdated Show resolved Hide resolved
@VadimKovalenkoSNF
Copy link
Collaborator Author

VadimKovalenkoSNF commented Sep 22, 2023

Once we are at the end of the simplification, we should fix the nodet test as well.

I fixed this in the scope of this PR.

@VadimKovalenkoSNF
Copy link
Collaborator Author

There is a side effect of e2e testing of all renderers is drastically increased time of test running.

@kelson42
Copy link
Collaborator

kelson42 commented Sep 26, 2023

There is a side effect of e2e testing of all renderers is drastically increased time of test running.

Yes, this will be a problem and we will have to handle it at some point (but not now) to have e2e which are smaller/quicker to execute, so no scrape with many articles

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.

Still too complex, we should have one test with no boilerplate, nothing which is repeated from test to test

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.

A lot better, but still a few things to fix

test/testAllRenders.ts Outdated Show resolved Hide resolved
test/testAllRenders.ts Outdated Show resolved Hide resolved
test/unit/saveArticles.test.ts Outdated Show resolved Hide resolved
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.

Test zimcheck/zimdump only once in the whole test process!
rebase

@kelson42 kelson42 merged commit af4f200 into main Oct 5, 2023
1 check passed
@kelson42 kelson42 deleted the 1887-e2e-modularized branch October 5, 2023 04:46
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.

One or two e2e tests should be modularized
2 participants