-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: Cypress task log added, cypress commands file added, cypress get… (
#3489) * New: Cypress task log added, cypress commands file added, cypress getData command added. * let updated to const. Co-authored-by: Cahir O'Doherty <[email protected]> * explicit import removed, import still required. * Updated to make the data loading .json file and language agnostic * Revert changes to config.json * Revert unawait grunt server * Specify coursedir as variable * Allow multilanguage, alternate coursedir and build config in tests * Updated comments * Removed bad argument --------- Co-authored-by: Cahir O'Doherty <[email protected]> Co-authored-by: Oliver Foster <[email protected]>
- Loading branch information
1 parent
aef3a0d
commit ac5f28e
Showing
12 changed files
with
183 additions
and
20 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
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Submodule core
updated
15 files
+3 −0 | js/a11y.js | |
+4 −2 | js/models/questionModel.js | |
+1 −1 | js/router.js | |
+18 −1 | js/views/TooltipView.js | |
+10 −6 | js/views/navigationView.js | |
+1 −1 | package.json | |
+7 −6 | schema/article.model.schema | |
+7 −6 | schema/block.model.schema | |
+4 −12 | schema/component.model.schema | |
+4 −4 | schema/component.schema.json | |
+5 −5 | schema/content.schema.json | |
+7 −6 | schema/contentobject.model.schema | |
+9 −0 | schema/course.model.schema | |
+0 −1 | templates/header.jsx | |
+4 −2 | templates/notifyPopup.hbs |
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
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 |
---|---|---|
@@ -0,0 +1,109 @@ | ||
function getBuild() { | ||
try { | ||
return cy.fixture(`adapt/js/build.min.js`).then(build => { | ||
// Return for cy.getBuild().then(build => {}); | ||
// Expose this.build in cypress | ||
return cy.wrap(build).as('build'); | ||
}); | ||
} catch { | ||
cy.task('log', 'fail'); | ||
} | ||
} | ||
|
||
function getConfig() { | ||
return getBuild().then(build => { | ||
// Load the config.json | ||
return cy.fixture(`${build.coursedir}/config.json`).then(config => { | ||
// Return for cy.getConfig().then(config => {}); | ||
// Expose this.config in cypress | ||
return cy.wrap(config).as('config'); | ||
}); | ||
}); | ||
} | ||
|
||
function getData(languageCode = null) { | ||
try { | ||
// Setup data array | ||
const data = []; | ||
// Expose this.data in cypress | ||
cy.wrap(data).as('data'); | ||
// Allow adapt-style shorthand properties: | ||
// this.data.course, this.data.contentObjects, this.data.articles, etc | ||
Object.defineProperties(data, { | ||
course: { | ||
get() { | ||
return data.find(item => item._type === 'course'); | ||
}, | ||
enumerable: false | ||
}, | ||
contentObjects: { | ||
get() { | ||
return data.filter(item => ['menu','page'].includes(item._type)); | ||
}, | ||
enumerable: false | ||
}, | ||
articles: { | ||
get() { | ||
return data.filter(item => item._type === 'article'); | ||
}, | ||
enumerable: false | ||
}, | ||
blocks: { | ||
get() { | ||
return data.filter(item => item._type === 'block'); | ||
}, | ||
enumerable: false | ||
}, | ||
components: { | ||
get() { | ||
return data.filter(item => item._type === 'component'); | ||
}, | ||
enumerable: false | ||
} | ||
}); | ||
return getBuild().then(build => { | ||
const { | ||
coursedir, | ||
availableLanguageNames | ||
} = build; | ||
// Load the config.json | ||
return getConfig().then(config => { | ||
// Check that the specified language is available | ||
const defaultLanguage = config._defaultLanguage; | ||
languageCode = languageCode ?? defaultLanguage; | ||
if (!availableLanguageNames.includes(languageCode)) { | ||
throw new Error(`Language code is not available: ${languageCode}`); | ||
} | ||
// Load the language_data_manifest.js for the default or specified language | ||
cy.fixture(`${coursedir}/${languageCode}/language_data_manifest.js`).then(languageDataManifest => { | ||
// Load each of the files specified in the manifest | ||
languageDataManifest.forEach(localFilePath => { | ||
const filePath = `${coursedir}/${languageCode}/${localFilePath}` | ||
cy.fixture(filePath).then(fileData => { | ||
// Add __index__ and __path__ attributes to each object as in adapt | ||
// so that each object's origin can be identified later if necessary | ||
if (Array.isArray(fileData)) { | ||
fileData.forEach((item, index) => { | ||
item.__index__ = index; | ||
item.__path__ = filePath; | ||
}); | ||
data.push(...fileData); | ||
return; | ||
} | ||
fileData.__path__ = filePath; | ||
data.push(fileData); | ||
}); | ||
}); | ||
}); | ||
// Return for cy.getData(languageCode).then(data => {}); | ||
return cy.wrap(data); | ||
}); | ||
}); | ||
} catch { | ||
cy.task('log', 'fail'); | ||
} | ||
} | ||
|
||
Cypress.Commands.add('getBuild', getBuild); | ||
Cypress.Commands.add('getConfig', getConfig); | ||
Cypress.Commands.add('getData', getData); |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
describe('Config', function () { | ||
|
||
beforeEach(function () { | ||
cy.getConfig(); | ||
}); | ||
|
||
it('should have a valid direction', function () { | ||
expect(this.config._defaultDirection).to.be.oneOf(['ltr', 'rtl']); | ||
}); | ||
|
||
}); |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
describe('Languages', function () { | ||
|
||
beforeEach(function () { | ||
cy.getConfig().then(config => cy.getData(config._defaultLanguage)); | ||
}); | ||
|
||
it('should have the default language', function () { | ||
expect(this.build.availableLanguageNames).to.include(this.config._defaultLanguage); | ||
}); | ||
|
||
it('should have data for all specified languages', function () { | ||
this.build.availableLanguageNames.forEach(lang => { | ||
cy.getData(lang); | ||
}); | ||
}); | ||
|
||
}); |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
describe('Tracking Ids', function () { | ||
|
||
beforeEach(function () { | ||
cy.getBuild(); | ||
}); | ||
|
||
it('should have specified tracking ids for all specified languages', function () { | ||
const { | ||
trackingIdType, | ||
availableLanguageNames | ||
} = this.build; | ||
availableLanguageNames.forEach(lang => { | ||
cy.getData(lang).then(data => { | ||
const trackingIdItems = data.filter(item => item._type === trackingIdType); | ||
trackingIdItems.forEach(item => { | ||
expect(item).to.have.ownProperty('_trackingId'); | ||
}); | ||
}) | ||
}); | ||
}); | ||
|
||
}); |