Skip to content

Commit

Permalink
Merge pull request #1944 from openzim/I1931-suppress-webm-element-in-…
Browse files Browse the repository at this point in the history
…multimedia-test

Suppress webm file in media content e2e test, minor fixes for the forceRender test
  • Loading branch information
VadimKovalenkoSNF committed Nov 13, 2023
2 parents 99da4fd + 5c45741 commit cb4f7a2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
23 changes: 13 additions & 10 deletions test/e2e/forceRender.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ describe('forceRender', () => {
mwActionApiPath: 'w/api.php',
}

beforeAll(async () => {
afterAll(async () => {
await execa('redis-cli flushall', { shell: true })
rimraf.sync(`./${testId}`)
const redisScan = await execa('redis-cli --scan', { shell: true })
// Redis has been cleared
expect(redisScan.stdout).toEqual('')
})

test('Scrape article from bm.wikipedia.org using WikimediaDesktop render', async () => {
Expand All @@ -33,24 +37,23 @@ describe('forceRender', () => {
} else {
console.log('Zimcheck not installed, skipping test')
}

rimraf.sync(`./${testId}`)
const redisScan = await execa('redis-cli --scan', { shell: true })
// Redis has been cleared
expect(redisScan.stdout).toEqual('')
})

test('Scrape article from bm.wikipedia.org should throw error when using VisualEditor render', async () => {
const forceRender = 'VisualEditor'
expect(async () => {
try {
await mwoffliner.execute({ ...parameters, forceRender })
}).rejects.toThrowError()
} catch (err) {
expect(err).toReturn()
}
})

test('Scrape article from bm.wikipedia.org should throw error when using wrong render', async () => {
const forceRender = 'unknownRenderName'
expect(async () => {
try {
await mwoffliner.execute({ ...parameters, forceRender })
}).rejects.toThrowError()
} catch (err) {
expect(err.message).toEqual('Unable to find specific API end-point to retrieve article HTML')
}
})
})
28 changes: 12 additions & 16 deletions test/e2e/multimediaContent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,15 @@ const parameters = {
articleList: 'User:Kelson/MWoffliner_CI_reference',
redis: process.env.REDIS,
customZimDescription: 'Example of the description',
forceRender: 'WikimediaDesktop',
}

await testRenders(
parameters,
async (outFiles) => {
describe('Multimedia', () => {
switch (outFiles[0].renderer) {
// TODO: blocked by issues/1925
case 'WikimediaMobile':
break
case 'WikimediaDesktop':
test(`check multimedia content from wikipedia test page for ${outFiles[0]?.renderer} renderer`, async () => {
test('check multimedia content from wikipedia test page for WikimediaDesktop renderer', async () => {
await execa('redis-cli flushall', { shell: true })

expect(outFiles[0].status.articles.success).toEqual(1)
Expand All @@ -35,7 +31,8 @@ await testRenders(
expect(mediaFiles.split('\n').sort()).toEqual(
[
'I/Kiwix_-_WikiArabia_Cairo_2017.pdf',
'I/Kiwix_Hackathon_2017_Florence_WikiFundi.webm.120p.vp9.webm',
// TODO: This file is no longer write into image namespace, see issues/1943. Probably, it shouldn't be there earlier
// 'I/Kiwix_Hackathon_2017_Florence_WikiFundi.webm.120p.vp9.webm',
'I/Kiwix_Hackathon_2017_Florence_WikiFundi.webm.jpg',
'I/Kiwix_icon.svg.png',
'I/Local_Forecast_-_Elevator_(ISRC_USUAN1300012).mp3.ogg',
Expand All @@ -49,7 +46,7 @@ await testRenders(
})
break
case 'VisualEditor':
test(`check multimedia content from wikipedia test page for ${outFiles[0]?.renderer} renderer`, async () => {
test('check multimedia content from wikipedia test page for VisualEditor renderer', async () => {
await execa('redis-cli flushall', { shell: true })

expect(outFiles[0].status.articles.success).toEqual(1)
Expand All @@ -59,7 +56,8 @@ await testRenders(
expect(mediaFiles.split('\n').sort()).toEqual(
[
'I/Kiwix_-_WikiArabia_Cairo_2017.pdf',
'I/Kiwix_Hackathon_2017_Florence_WikiFundi.webm.120p.vp9.webm',
// TODO: This file is no longer write into image namespace, see issues/1943. Probably, it shouldn't be there earlier
'I/Kiwix_Hackathon_2017_Florence_WikiFundi.webm.240p.vp9.webm',
'I/Kiwix_Hackathon_2017_Florence_WikiFundi.webm.jpg',
'I/Kiwix_icon.svg.png',
'I/Local_Forecast_-_Elevator_(ISRC_USUAN1300012).mp3.ogg',
Expand All @@ -84,11 +82,8 @@ await testRenders(
describe('Multimedia for different formats', () => {
// TODO: blocked by issues/1925
switch (outFiles[0].renderer) {
// TODO: blocked by issues/1925
case 'WikimediaMobile':
break
case 'WikimediaDesktop':
test(`check multimedia content from wikipedia test page with different formates for ${outFiles[0]?.renderer} renderer`, async () => {
test('check multimedia content from wikipedia test page with different formates for WikimediaDesktop renderer', async () => {
await execa('redis-cli flushall', { shell: true })

expect(outFiles).toHaveLength(4)
Expand Down Expand Up @@ -129,7 +124,8 @@ await testRenders(
expect(mediaFiles.split('\n').sort()).toEqual(
[
// 'I/Kiwix_-_WikiArabia_Cairo_2017.pdf', // this file was omitted by nopdf parameter
'I/Kiwix_Hackathon_2017_Florence_WikiFundi.webm.120p.vp9.webm',
// TODO: This file is no longer write into image namespace, see issues/1943. Probably, it shouldn't be there earlier
// 'I/Kiwix_Hackathon_2017_Florence_WikiFundi.webm.120p.vp9.webm',
'I/Kiwix_Hackathon_2017_Florence_WikiFundi.webm.jpg',
'I/Kiwix_icon.svg.png',
'I/Local_Forecast_-_Elevator_(ISRC_USUAN1300012).mp3.ogg',
Expand All @@ -145,7 +141,7 @@ await testRenders(
})
break
case 'VisualEditor':
test(`check multimedia content from wikipedia test page with different formates for ${outFiles[0]?.renderer} renderer`, async () => {
test('check multimedia content from wikipedia test page with different formates for VisualEditor renderer', async () => {
await execa('redis-cli flushall', { shell: true })

expect(outFiles).toHaveLength(4)
Expand Down Expand Up @@ -186,12 +182,12 @@ await testRenders(
expect(mediaFiles.split('\n').sort()).toEqual(
[
// 'I/Kiwix_-_WikiArabia_Cairo_2017.pdf', // this file was omitted by nopdf parameter
'I/Kiwix_Hackathon_2017_Florence_WikiFundi.webm.120p.vp9.webm',
'I/Kiwix_Hackathon_2017_Florence_WikiFundi.webm.240p.vp9.webm',
'I/Kiwix_Hackathon_2017_Florence_WikiFundi.webm.jpg',
'I/Kiwix_icon.svg.png',
'I/Local_Forecast_-_Elevator_(ISRC_USUAN1300012).mp3.ogg',
'I/page1-120px-Kiwix_-_WikiArabia_Cairo_2017.pdf.jpg',
'I/page1-640px-Kiwix_-_WikiArabia_Cairo_2017.pdf.jpg',
'I/page1-1500px-Kiwix_-_WikiArabia_Cairo_2017.pdf.jpg',
].sort(),
)
}
Expand Down

0 comments on commit cb4f7a2

Please sign in to comment.