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

Issue #SB-0000 fix: content player function test cases for content preview #358

Open
wants to merge 4 commits into
base: functional-test
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions player/app-data/fixture-content-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,41 @@
"isAvailable": true,
"path": "fixture-stories/content_player"
},
{
"identifier": "org.ekstep.contentpreview",
"mimeType": "application/vnd.ekstep.html-archive",
"contentData": {
"hierarchyInfo": [
{
"contentType": "textbook",
"identifier": "do_2125251490189148161635"
},
{
"contentType": "textbookunit",
"identifier": "do_2125251493823201281636"
}
],
"questionnaire": null,
"appIcon": "fixture-stories/content_preview/logo.png",
"subject": "literacy_v2",
"description": "content_preview",
"name": "Content preview test",
"owner": "Gourav More",
"downloadUrl": "",
"checksum": null,
"loadingMessage": "Without requirements or design, programming is the art of adding bugs to an empty text file. ...",
"concepts": [{
"identifier": "LO1",
"name": "Receptive Vocabulary",
"objectType": "Concept"
}],
"identifier": "org.ekstep.contentpreview",
"grayScaleAppIcon": null,
"pkgVersion": 1
},
"isAvailable": true,
"path": "fixture-stories/content_preview"
},
{
"identifier": "org.ekstep.customeval",
"mimeType": "application/vnd.ekstep.ecml-archive",
Expand Down
150 changes: 150 additions & 0 deletions player/public/fixture-stories/content_preview/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML Content</title>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="default-src * data: filesystem:; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; font-src *;" >
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
</head>
<body>

<h1 style="text-align: center;">Content player test</h1>
<div class="content-player">
<iframe id="previewContentIframe" title="player" src="preview/preview.html" style="width:100%;height:100vh;border:none;"></iframe>
</div>
<script type="text/javascript">
var previewContentIframe = document.getElementById('previewContentIframe');
window.onload = function() {
setTimeout(function() {
var metadata = {
"streamingUrl": "https://ekstep-public-prod.s3-ap-south-1.amazonaws.com/content/ecml/do_312473549722288128119665-latest",
"publish_type": "public",
"keywords": [
"Story"
],
"subject": "English",
"channel": "in.ekstep",
"downloadUrl": "do_312473549722288128119665/1531308826198_do_312473549722288128119665.zip",
"language": [
"English"
],
"mimeType": "application/vnd.ekstep.ecml-archive",
"source": "",
"variants": null,
"objectType": "Content",
"appIcon": "do_312473549722288128119665/0c5509c8c7cf945b1b23dacc66a05c0d_1522654872904.jpeg",
"gradeLevel": [
"Class 7"
],
"appId": "ekstep_portal",
"copyType": "Enhance",
"collaborators": [
"5469"
],
"contentEncoding": "gzip",
"artifactUrl": "do_312473549722288128119665/1531308826198_do_312473549722288128119665.zip",
"contentType": "Resource",
"lastUpdatedBy": "539",
"identifier": "do_312473549722288128119665",
"audience": [
"Learner"
],
"visibility": "Default",
"consumerId": "62e15662-bb09-439f-86e2-d65bd84f3c23",
"mediaType": "content",
"osId": "org.ekstep.quiz.app",
"ageGroup": [
">10"
],
"lastPublishedBy": "539",
"languageCode": "en",
"tags": [
"Story"
],
"prevState": "Review",
"lastPublishedOn": "2018-07-11T11:33:47.231+0000",
"domain": [
"literacy"
],
"name": "The Squirrel",
"publisher": "",
"attributions": [
""
],
"status": "Live",
"template": "",
"totalQuestions": 5,
"code": "org.ekstep.literacy.story.16782.fork",
"publishError": null,
"origin": "do_31243457742290944024273",
"description": "Students Resources",
"idealScreenSize": "normal",
"posterImage": "do_312473549722288128119665/0c5509c8c7cf945b1b23dacc66a05c0d_1522654872904.jpeg",
"createdOn": "2018-04-02T06:21:52.584+0000",
"contentDisposition": "inline",
"lastUpdatedOn": "2018-07-11T11:33:12.141+0000",
"owner": "Aprajita Tomar",
"creator": "Aprajita Tomar",
"os": [
"All"
],
"flagReasons": null,
"totalScore": 5,
"pkgVersion": 1,
"versionKey": "1531308792141",
"idealScreenDensity": "hdpi",
"framework": "NCF",
"lastSubmittedOn": "2018-05-18T01:40:15.750+0000",
"createdBy": "6116",
"compatibilityLevel": 2,
"board": "CBSE",
"resourceType": "Read"
}

var configuration = {
"context": {
"mode": "edit",
"contentId": "do_112694410769801216167",
"sid": "7W23qQKd_n4wT17sxVeLsG55t2FOZ6Bi",
"uid": "874ed8a5-782e-4f6c-8f36-e0288455901e",
"channel": "b00bc992ef25f1a9a8d63291e20efc8d",
"pdata": {
"id": "dev.sunbird.portal",
"ver": "1.14.0",
"pid": "sunbird-portal.contenteditor"
},
"app": [],
"dims": [],
"partner": []
},
"config": {
"repos": [
"/sunbird-plugins/renderer"
],
"plugins": [
{
"id": "org.sunbird.player.endpage",
"ver": 1.1,
"type": "plugin"
}
],
"splash": {
"text": "",
"icon": "",
"bgImage": "assets/icons/splacebackground_1.png",
"webLink": ""
},
"overlay": {
"showUser": false
},
"showEndPage": false
},
"metadata": metadata,
"data": ""
}
previewContentIframe.contentWindow.initializePreview(configuration);
}, 1000);
};
</script>
</body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions player/public/fixture-stories/content_preview/preview
120 changes: 120 additions & 0 deletions player/public/fixture-stories/content_preview/test/localData.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"content": [{
"identifier": "do_20043647",
"mimeType": "application/vnd.ekstep.html-archive",
"localData": {
"questionnaire": null,
"appIcon": "fixture-stories/HTMLContent/logo.png",
"subject": "literacy_v2",
"description": "HTML Content",
"name": "HTML Content",
"downloadUrl": "",
"checksum": null,
"loadingMessage": "Without requirements or design, programming is the art of adding bugs to an empty text file. ...",
"concepts": [{
"identifier": "LO1",
"name": "Receptive Vocabulary",
"objectType": "Concept"
}],
"config": {
"languageL2": "en",
"sid": "de305d54-75b4-431b-adb2-eb6b9e546013",
"uid": "123e4567-e89b-12d3-a456-426655440000",
"did": "ff305d54-85b4-341b-da2f-eb6b9e5460fa",
"level": "5"
},
"identifier": "do_20043647",
"grayScaleAppIcon": null,
"pkgVersion": 1
},
"isAvailable": true,
"path": "fixture-stories/HTMLContent"
},{
"identifier": "do_20045479",
"mimeType": "application/vnd.ekstep.html-archive",
"localData": {
"questionnaire": null,
"appIcon": "fixture-stories/HTMLContent/logo.png",
"subject": "literacy_v2",
"description": "HTML Content2",
"name": "HTML Content2",
"downloadUrl": "",
"checksum": null,
"loadingMessage": "Without requirements or design, programming is the art of adding bugs to an empty text file. ...",
"concepts": [{
"identifier": "LO1",
"name": "Receptive Vocabulary",
"objectType": "Concept"
}],
"config": {
"theme": "blue",
"language": "english"
},
"identifier": "do_20045479",
"grayScaleAppIcon": null,
"pkgVersion": 1
},
"isAvailable": true,
"path": "fixture-stories/HTMLContent2"
}
],
"languageSearch":{
"words": [
{
"identifier": "en_2",
"score": 1.0,
"lemma": "cat",
"pictures": [
"https://s3.amazon.com/ekstep-public/language_assets/cat.jpg"
],
"pronunciations": [
"https://s3.amazon.com/ekstep-public/language_assets/cat.mp3"
]
},
{
"identifier": "en_5",
"score": 1.0,
"lemma": "tiger",
"pictures": [
"https://s3.amazon.com/ekstep-public/language_assets/tiger.jpg"
],
"pronunciations": [
"https://s3.amazon.com/ekstep-public/language_assets/tiger.mp3"
]
},
{
"identifier": "en_1",
"score": 0.8,
"lemma": "rat",
"pictures": [
"https://s3.amazon.com/ekstep-public/language_assets/rat.jpg"
],
"pronunciations": [
"https://s3.amazon.com/ekstep-public/language_assets/rat.mp3"
]
}
],
"relations": [
{
"score": "6.4",
"title": "",
"list": [
"en_2",
"en_5",
"en_1"
],
"relation": "akshara_boundary"
},
{
"score": "4.5",
"title": "",
"list": [
"en_12",
"en_11",
"en_20"
],
"relation": "akshara_boundary"
}
]
}
}
2 changes: 1 addition & 1 deletion player/public/functional_test/__tests__/pdfContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe(
page: page,
dirName: __dirname,
scriptName: scriptName,
onlyFailures: true
onlyFailures: false
};
await jestscreenshot.init(options);
}, timeout)
Expand Down
65 changes: 65 additions & 0 deletions player/public/functional_test/__tests__/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* Functional test cases for question set
* @author rahul shukla <[email protected]>
* @todo To use image diff we need to ignore options container in MCQ cause it always shuffle
* @link https://github.com/americanexpress/jest-image-snapshot#ignoring-parts-of-the-image-snapshot-if-using-puppeteer
*/

const timeout = 50000

const typingSpeed = 50

let jestscreenshot = require('@jeeyah/jestscreenshot');
const devices = require('puppeteer/DeviceDescriptors');

const { toMatchImageSnapshot } = require('jest-image-snapshot');
expect.extend({ toMatchImageSnapshot });

describe(
'Sunbird Player functional testing - preview testing',
() => {
let page
beforeAll(async () => {
jest.setTimeout(timeout)
page = await global.__BROWSER__.newPage()
await page.goto('http://127.0.0.1:3000')
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we still running player ? or we just need to play from the preview folder


await page.setViewport({width: 1280,height: 800})
// const metrics = await page.metrics();
// console.info(metrics);
let path = require('path');
let scriptName = path.basename(__filename).replace('.js', '');
let options = {
page: page,
dirName: __dirname,
scriptName: scriptName,
onlyFailures: true
};
await jestscreenshot.init(options);
}, timeout)

afterEach(async () => {
await page.waitFor(5000)
})

afterAll(async () => {
jestscreenshot.cleanup(function () {
if (browser) {
browser.close();
}
done();
});
await page.close()
})

it('Player shell loaded with fixture stories', async () => {
await page.waitForSelector('body > div:nth-child(7) > div > ion-pane > ion-content > div > div:nth-child(3)')
})

it('Should open content player', async() => {
const playQuestion = await page.waitForSelector('body > div:nth-child(7) > div > ion-pane > ion-content > div > div:nth-child(3)')
await playQuestion.click()
})
},
timeout
)
Loading