fix: only test mobile curriculum on english (#45558)
This commit is contained in:
committed by
GitHub
parent
b2a96e0a09
commit
07cfc8b83b
@ -2,52 +2,59 @@ const path = require('path');
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const { AssertionError } = require('chai');
|
const { AssertionError } = require('chai');
|
||||||
const { getChallengesForLang } = require('../../../curriculum/getChallenges');
|
const { getChallengesForLang } = require('../../../curriculum/getChallenges');
|
||||||
|
const envData = require('../../../config/env.json');
|
||||||
const { buildMobileCurriculum } = require('./build-mobile-curriculum');
|
const { buildMobileCurriculum } = require('./build-mobile-curriculum');
|
||||||
const { mobileSchemaValidator } = require('./mobileSchema');
|
const { mobileSchemaValidator } = require('./mobileSchema');
|
||||||
|
|
||||||
describe('mobile curriculum build', () => {
|
if (envData.clientLocale == 'english' && !envData.showUpcomingChanges) {
|
||||||
const mobileStaticPath = path.resolve(__dirname, '../../../client/static');
|
describe('mobile curriculum build', () => {
|
||||||
const blockIntroPath = path.resolve(
|
const mobileStaticPath = path.resolve(__dirname, '../../../client/static');
|
||||||
__dirname,
|
const blockIntroPath = path.resolve(
|
||||||
'../../../client/i18n/locales/english/intro.json'
|
__dirname,
|
||||||
);
|
'../../../client/i18n/locales/english/intro.json'
|
||||||
|
|
||||||
const validateMobileSuperBlock = mobileSchemaValidator();
|
|
||||||
|
|
||||||
let curriculum;
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
|
||||||
curriculum = await getChallengesForLang('english');
|
|
||||||
await buildMobileCurriculum(curriculum);
|
|
||||||
}, 20000);
|
|
||||||
|
|
||||||
test('the mobile curriculum should have a static folder with multiple files', () => {
|
|
||||||
expect(fs.existsSync(`${mobileStaticPath}/mobile`)).toBe(true);
|
|
||||||
|
|
||||||
expect(fs.readdirSync(`${mobileStaticPath}/mobile`).length).toBeGreaterThan(
|
|
||||||
0
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const validateMobileSuperBlock = mobileSchemaValidator();
|
||||||
|
|
||||||
|
let curriculum;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
curriculum = await getChallengesForLang('english');
|
||||||
|
await buildMobileCurriculum(curriculum);
|
||||||
|
}, 20000);
|
||||||
|
|
||||||
|
test('the mobile curriculum should have a static folder with multiple files', () => {
|
||||||
|
expect(fs.existsSync(`${mobileStaticPath}/mobile`)).toBe(true);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
fs.readdirSync(`${mobileStaticPath}/mobile`).length
|
||||||
|
).toBeGreaterThan(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('the mobile curriculum should have access to the intro.json file', () => {
|
||||||
|
expect(fs.existsSync(blockIntroPath)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('the files generated should have the correct schema', () => {
|
||||||
|
const fileArray = fs.readdirSync(`${mobileStaticPath}/mobile`);
|
||||||
|
|
||||||
|
fileArray
|
||||||
|
.filter(fileInArray => fileInArray !== 'availableSuperblocks.json')
|
||||||
|
.forEach(fileInArray => {
|
||||||
|
const fileContent = fs.readFileSync(
|
||||||
|
`${mobileStaticPath}/mobile/${fileInArray}`
|
||||||
|
);
|
||||||
|
|
||||||
|
const result = validateMobileSuperBlock(JSON.parse(fileContent));
|
||||||
|
|
||||||
|
if (result.error) {
|
||||||
|
throw new AssertionError(result.error, `file: ${fileInArray}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
test('the mobile curriculum should have access to the intro.json file', () => {
|
describe.skip('Mobile curriculum is not localized', () => {
|
||||||
expect(fs.existsSync(blockIntroPath)).toBe(true);
|
test.todo('localized tests');
|
||||||
});
|
});
|
||||||
|
}
|
||||||
test('the files generated should have the correct schema', () => {
|
|
||||||
const fileArray = fs.readdirSync(`${mobileStaticPath}/mobile`);
|
|
||||||
|
|
||||||
fileArray
|
|
||||||
.filter(fileInArray => fileInArray !== 'availableSuperblocks.json')
|
|
||||||
.forEach(fileInArray => {
|
|
||||||
const fileContent = fs.readFileSync(
|
|
||||||
`${mobileStaticPath}/mobile/${fileInArray}`
|
|
||||||
);
|
|
||||||
|
|
||||||
const result = validateMobileSuperBlock(JSON.parse(fileContent));
|
|
||||||
|
|
||||||
if (result.error) {
|
|
||||||
throw new AssertionError(result.error, `file: ${fileInArray}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
Reference in New Issue
Block a user