-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1933 from openzim/1930-apply-test-coverage-for-al…
…l-endpoins Apply test coverage for all endpoins
- Loading branch information
Showing
20 changed files
with
789 additions
and
901 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,58 @@ | ||
import * as mwoffliner from '../../src/mwoffliner.lib.js' | ||
import { execa } from 'execa' | ||
import rimraf from 'rimraf' | ||
import { zimcheckAvailable, zimcheck } from '../util.js' | ||
import 'dotenv/config' | ||
import { jest } from '@jest/globals' | ||
import { testAllRenders } from '../testAllRenders.js' | ||
|
||
jest.setTimeout(10000) | ||
|
||
describe('articleList', () => { | ||
const now = new Date() | ||
const testId = `mwo-test-${+now}` | ||
|
||
const articleList = 'Kiwix,Wikipedia,Internet,Real-time computer graphics' | ||
const articleListToIgnore = 'Wikipedia, Internet' | ||
const listMinusIgnore = 2 | ||
const parameters = { | ||
mwUrl: 'https://en.wikipedia.org', | ||
adminEmail: 'test@kiwix.org', | ||
articleList, | ||
articleListToIgnore, | ||
outputDirectory: testId, | ||
redis: process.env.REDIS, | ||
format: ['nopic'], | ||
forceRender: 'WikimediaDesktop', | ||
} | ||
|
||
test('articleList and articleListIgnore check', async () => { | ||
await execa('redis-cli flushall', { shell: true }) | ||
|
||
const outFiles = await mwoffliner.execute(parameters) | ||
|
||
// Created 1 output | ||
expect(outFiles).toHaveLength(1) | ||
|
||
for (const dump of outFiles) { | ||
if (dump.nopic) { | ||
// Output has right amount of articles | ||
expect(dump.status.articles.success).toEqual(listMinusIgnore) | ||
// Output has no failed article | ||
expect(dump.status.articles.fail).toEqual(0) | ||
const articleList = 'Kiwix,Wikipedia,Internet,Real-time computer graphics' | ||
const articleListToIgnore = 'Wikipedia, Internet' | ||
|
||
const parameters = { | ||
mwUrl: 'https://en.wikipedia.org', | ||
adminEmail: 'test@kiwix.org', | ||
articleList, | ||
articleListToIgnore, | ||
redis: process.env.REDIS, | ||
format: ['nopic'], | ||
} | ||
|
||
await testAllRenders(parameters, async (outFiles) => { | ||
describe('articleList', () => { | ||
const now = new Date() | ||
const testId = `mwo-test-${+now}` | ||
const listMinusIgnore = 2 | ||
|
||
test(`articleList and articleListIgnore check using ${outFiles[0].renderer} renderer`, async () => { | ||
await execa('redis-cli flushall', { shell: true }) | ||
|
||
// Created 1 output | ||
expect(outFiles).toHaveLength(1) | ||
|
||
for (const dump of outFiles) { | ||
if (dump.nopic) { | ||
// Output has right amount of articles | ||
expect(dump.status.articles.success).toEqual(listMinusIgnore) | ||
// Output has no failed article | ||
expect(dump.status.articles.fail).toEqual(0) | ||
} | ||
} | ||
} | ||
|
||
// Scraped selected articles from wikipedia en'); | ||
if (await zimcheckAvailable()) { | ||
await expect(zimcheck(outFiles[0].outFile)).resolves.not.toThrowError() | ||
} 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('') | ||
|
||
// Scraped selected articles from wikipedia en'); | ||
// TODO: Blocked by issues/1931 | ||
/* | ||
if (await zimcheckAvailable()) { | ||
await expect(zimcheck(outFiles[0].outFile)).resolves.not.toThrowError() | ||
} 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('') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,58 @@ | ||
import * as mwoffliner from '../../src/mwoffliner.lib.js' | ||
import { zimdump } from '../util.js' | ||
import { testAllRenders } from '../testAllRenders.js' | ||
import { execa } from 'execa' | ||
import { jest } from '@jest/globals' | ||
import rimraf from 'rimraf' | ||
import { zimcheckAvailable, zimcheck } from '../util.js' | ||
import 'dotenv/config.js' | ||
import { jest } from '@jest/globals' | ||
import { zimdumpAvailable, zimdump } from '../util.js' | ||
|
||
jest.setTimeout(200000) | ||
|
||
describe('bm', () => { | ||
const now = new Date() | ||
const testId = `mwo-test-${+now}` | ||
|
||
const parameters = { | ||
mwUrl: 'https://bm.wikipedia.org', | ||
adminEmail: 'test@kiwix.org', | ||
outputDirectory: testId, | ||
redis: process.env.REDIS, | ||
format: ['nopic'], | ||
forceRender: 'WikimediaDesktop', | ||
} | ||
|
||
test('Simple articleList', async () => { | ||
await execa('redis-cli flushall', { shell: true }) | ||
|
||
const outFiles = await mwoffliner.execute(parameters) | ||
|
||
// Created 1 output | ||
expect(outFiles).toHaveLength(1) | ||
|
||
for (const dump of outFiles) { | ||
if (dump.nopic) { | ||
// nopic has enough files | ||
expect(dump.status.files.success).toBeGreaterThan(14) | ||
// nopic has enough redirects | ||
expect(dump.status.redirects.written).toBeGreaterThan(170) | ||
// nopic has enough articles | ||
expect(dump.status.articles.success).toBeGreaterThan(700) | ||
} | ||
} | ||
|
||
if (await zimcheckAvailable()) { | ||
const parameters = { | ||
mwUrl: 'https://bm.wikipedia.org', | ||
adminEmail: 'test@kiwix.org', | ||
redis: process.env.REDIS, | ||
format: ['nopic'], | ||
} | ||
|
||
await testAllRenders(parameters, async (outFiles) => { | ||
describe('e2e test for bm.wikipedia.org', () => { | ||
// TODO: blocked by issues/1931 | ||
/* | ||
test(`test zim integrity for ${outFiles[0]?.renderer} renderer`, async () => { | ||
await expect(zimcheck(outFiles[0].outFile)).resolves.not.toThrowError() | ||
} else { | ||
console.log('Zimcheck not installed, skipping test') | ||
} | ||
|
||
if (await zimdumpAvailable()) { | ||
const discussionArticlesStr = await zimdump(`list --ns A/Discussion ${outFiles[0].outFile}`) | ||
// Articles with "Discussion" namespace should be only with option addNamespaces: 1 | ||
expect(discussionArticlesStr.length).toBe(0) | ||
} else { | ||
console.log('Zimdump not installed, skipping test') | ||
} | ||
|
||
// TODO: clear test dir | ||
rimraf.sync(`./${testId}`) | ||
|
||
const redisScan = await execa('redis-cli --scan', { shell: true }) | ||
// Redis has been cleared | ||
expect(redisScan.stdout).toEqual('') | ||
}) | ||
|
||
test('Articles with "Discussion" namespace', async () => { | ||
await execa('redis-cli flushall', { shell: true }) | ||
}) | ||
*/ | ||
|
||
test(`Simple articleList for ${outFiles[0]?.renderer} renderer`, async () => { | ||
// Created 1 output | ||
expect(outFiles).toHaveLength(1) | ||
|
||
for (const dump of outFiles) { | ||
if (dump.nopic) { | ||
// nopic has enough files | ||
expect(dump.status.files.success).toBeGreaterThan(14) | ||
// nopic has enough redirects | ||
expect(dump.status.redirects.written).toBeGreaterThan(170) | ||
// nopic has enough articles | ||
expect(dump.status.articles.success).toBeGreaterThan(700) | ||
} | ||
} | ||
}) | ||
|
||
const outFiles = await mwoffliner.execute({ ...parameters, addNamespaces: 1 }) | ||
// Created 1 output | ||
expect(outFiles).toHaveLength(1) | ||
test(`Articles with "Discussion" namespace for ${outFiles[0]?.renderer} renderer`, async () => { | ||
await execa('redis-cli flushall', { shell: true }) | ||
const outFiles = await mwoffliner.execute({ ...parameters, addNamespaces: 1 }) | ||
|
||
if (await zimdumpAvailable()) { | ||
// Created 1 output | ||
expect(outFiles).toHaveLength(1) | ||
const discussionArticlesStr = await zimdump(`list --ns A/Discussion ${outFiles[0].outFile}`) | ||
const discussionArticlesList = discussionArticlesStr.match(/Discussion:/g) | ||
expect(discussionArticlesList.length).toBeGreaterThan(30) | ||
} else { | ||
console.log('Zimdump not installed, skipping test') | ||
} | ||
|
||
// TODO: clear test dir | ||
rimraf.sync(`./${testId}`) | ||
}) | ||
|
||
const redisScan = await execa('redis-cli --scan', { shell: true }) | ||
// Redis has been cleared | ||
expect(redisScan.stdout).toEqual('') | ||
afterAll(() => { | ||
rimraf.sync(`./${outFiles[0].testId}`) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,34 @@ | ||
import * as mwoffliner from '../../src/mwoffliner.lib.js' | ||
import { execa } from 'execa' | ||
import { zimcheck } from '../util.js' | ||
import rimraf from 'rimraf' | ||
import { zimcheckAvailable, zimcheck } from '../util.js' | ||
import { testAllRenders } from '../testAllRenders.js' | ||
import 'dotenv/config.js' | ||
import { jest } from '@jest/globals' | ||
|
||
jest.setTimeout(200000) | ||
|
||
const describeIf = process.env.S3_URL ? describe : describe.skip | ||
describeIf('Check image downloading from S3 using optimisationCacheUrl parameter', () => { | ||
const now = new Date() | ||
const testId = `mwo-test-${+now}` | ||
|
||
const parameters = { | ||
mwUrl: 'https://fr.wikipedia.org', | ||
adminEmail: 'test@kiwix.org', | ||
outputDirectory: testId, | ||
redis: process.env.REDIS, | ||
articleList: 'Paris', | ||
format: ['nodet'], | ||
optimisationCacheUrl: process.env.S3_URL, | ||
forceRender: 'WikimediaDesktop', | ||
} | ||
|
||
test('right scrapping from fr.wikipedia.org with optimisationCacheUrl parameter', async () => { | ||
await execa('redis-cli flushall', { shell: true }) | ||
|
||
const outFiles = await mwoffliner.execute(parameters) | ||
|
||
if (await zimcheckAvailable()) { | ||
const parameters = { | ||
mwUrl: 'https://fr.wikipedia.org', | ||
adminEmail: 'test@kiwix.org', | ||
redis: process.env.REDIS, | ||
articleList: 'Paris', | ||
format: ['nodet'], | ||
optimisationCacheUrl: process.env.S3_URL, | ||
} | ||
|
||
await testAllRenders(parameters, async (outFiles) => { | ||
describeIf('Check image downloading from S3 using optimisationCacheUrl parameter', () => { | ||
test(`right scrapping from fr.wikipedia.org with optimisationCacheUrl parameter for ${outFiles[0]?.renderer} renderer`, async () => { | ||
await expect(zimcheck(outFiles[0].outFile)).resolves.not.toThrowError() | ||
} 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('') | ||
await execa('redis-cli flushall', { shell: true }) | ||
|
||
const redisScan = await execa('redis-cli --scan', { shell: true }) | ||
expect(redisScan.stdout).toEqual('') | ||
}) | ||
afterAll(() => { | ||
rimraf.sync(`./${outFiles[0].testId}`) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.