diff --git a/player/app-data/fixture-content-list.json b/player/app-data/fixture-content-list.json index cf5cf5c8e..f17947ba7 100644 --- a/player/app-data/fixture-content-list.json +++ b/player/app-data/fixture-content-list.json @@ -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", diff --git a/player/public/fixture-stories/content_preview/index.html b/player/public/fixture-stories/content_preview/index.html new file mode 100644 index 000000000..69cd6aaff --- /dev/null +++ b/player/public/fixture-stories/content_preview/index.html @@ -0,0 +1,150 @@ + + + + HTML Content + + + + + + +

Content player test

+
+ +
+ + + \ No newline at end of file diff --git a/player/public/fixture-stories/content_preview/logo.png b/player/public/fixture-stories/content_preview/logo.png new file mode 100644 index 000000000..6692c0f4c Binary files /dev/null and b/player/public/fixture-stories/content_preview/logo.png differ diff --git a/player/public/fixture-stories/content_preview/preview b/player/public/fixture-stories/content_preview/preview new file mode 120000 index 000000000..9f9ae2eee --- /dev/null +++ b/player/public/fixture-stories/content_preview/preview @@ -0,0 +1 @@ +/home/dell/Documents/git/sunbird-content-player/player/www/preview \ No newline at end of file diff --git a/player/public/fixture-stories/content_preview/test/localData.json b/player/public/fixture-stories/content_preview/test/localData.json new file mode 100644 index 000000000..ee5461f57 --- /dev/null +++ b/player/public/fixture-stories/content_preview/test/localData.json @@ -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" + } + ] + } +} \ No newline at end of file diff --git a/player/public/functional_test/__tests__/pdfContent.js b/player/public/functional_test/__tests__/pdfContent.js index 41c878a49..6df171c1c 100644 --- a/player/public/functional_test/__tests__/pdfContent.js +++ b/player/public/functional_test/__tests__/pdfContent.js @@ -25,7 +25,7 @@ describe( page: page, dirName: __dirname, scriptName: scriptName, - onlyFailures: true + onlyFailures: false }; await jestscreenshot.init(options); }, timeout) diff --git a/player/public/functional_test/__tests__/preview.js b/player/public/functional_test/__tests__/preview.js new file mode 100644 index 000000000..0da3c2d72 --- /dev/null +++ b/player/public/functional_test/__tests__/preview.js @@ -0,0 +1,65 @@ +/** + * Functional test cases for question set + * @author rahul shukla + * @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') + + 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 +) \ No newline at end of file diff --git a/player/public/functional_test/__tests__/questionset.js b/player/public/functional_test/__tests__/questionset.js index a38b6ab52..bf76527c6 100644 --- a/player/public/functional_test/__tests__/questionset.js +++ b/player/public/functional_test/__tests__/questionset.js @@ -54,25 +54,30 @@ describe( 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(38)') + await page.screenshot({path: '__tests__/screenshots/fixture_stories.png'}); }) it('Should open question set', async() => { const playQuestion = await page.waitForSelector('body > div:nth-child(7) > div > ion-pane > ion-content > div > div:nth-child(38)') await playQuestion.click() + await page.screenshot({path: '__tests__/screenshots/onclick_questionset.png'}); }) it('Zoom button should open the image in zoomed view', async () => { const zoomImg = await page.waitForSelector('#org-ekstep-contentrenderer-questionunit-questionComponent-ZoomImg') await zoomImg.click() + await page.screenshot({path: '__tests__/screenshots/onzoom_image.png'}); }) it('check pop exists or not', async()=>{ const popup = await page.waitForSelector('#image-model-popup > div.popup-full-body > div > div') await popup.click() + await page.screenshot({path: '__tests__/screenshots/afterpop_close.png'}); }) it('Test for title', async () => { const title = await page.waitForSelector('#mcq-question-container > div.question-content-container > div > div.hiding-container > div > p') + await page.screenshot({path: '__tests__/screenshots/test_title.png'}); }) it('Question title font size should be same in Mobile and Web and height and width should be different', async() => { @@ -84,15 +89,18 @@ describe( await page.waitForSelector('#mcq-question-container > div.question-content-container > div > div.hiding-container > div > p') const btnStylesInMobile = await page.$eval('#mcq-question-container > div.question-content-container > div > div.hiding-container > div > p', btnStylesInMobile => JSON.parse(JSON.stringify(getComputedStyle(btnStylesInMobile)))); // console.info("font size is" + btnStylesInWeb.fontsize) - expect(btnStylesInWeb.fontsize).toEqual(btnStylesInMobile.fontsize) - expect(btnStylesInWeb.height).not.toEqual(btnStylesInMobile.height) - expect(btnStylesInWeb.width).not.toEqual(btnStylesInMobile.width) + expect(parseFloat(btnStylesInWeb.fontsize)).toEqual(parseFloat(btnStylesInMobile.fontsize)) + expect(parseFloat(btnStylesInWeb.height)).not.toEqual(parseFloat(btnStylesInMobile.height)) + expect(parseFloat(btnStylesInWeb.width)).not.toEqual(parseFloat(btnStylesInMobile.width)) }) it('Test for Question Set', async () => { await page.setViewport({width: 1280,height: 800}) const playQuestion = await page.waitForSelector('body > div:nth-child(7) > div > ion-pane > ion-content > div > div:nth-child(38)') await playQuestion.click() + }) + + it('Test for mcq', async() => { await page.waitForSelector('#mcq-question-container > div.question-content-container > div > div.hiding-container > div > p') const wrongAnswer = await page.waitForSelector('#mcq-question-container > div.bg-graphics-2 > div.outer-option-container.horizontal > div > div > div:nth-child(2)') const nextButton = await page.waitForSelector('body > div:nth-child(8) > div > div > custom-next-navigation > div > a > img') @@ -106,9 +114,16 @@ describe( await nextButton.click() const nextPopupButton = await page.waitForSelector('#popup-buttons-container > div') await nextPopupButton.click() + }) + + it('Skipping match test',async() => { + const nextButton = await page.waitForSelector('body > div:nth-child(8) > div > div > custom-next-navigation > div > a > img') await nextButton.click() const popupNextButton = await page.waitForSelector('#popup-buttons-container > div.left.button') await popupNextButton.click() + }) + + it('Input type test', async() => { await page.waitForSelector('#ans-field1'); await page.evaluate(() => { document.querySelector('#ans-field1').value = 'jupiter'; @@ -117,45 +132,66 @@ describe( await page.evaluate(() => { document.querySelector('#ans-field2').value = 'mercury'; }); + await page.screenshot({path: '__tests__/screenshots/setting_fields.png'}); + const nextButton = await page.waitForSelector('body > div:nth-child(8) > div > div > custom-next-navigation > div > a > img') await nextButton.click(); - const nextPopupButton2 = await page.waitForSelector('#popup-buttons-container > div') - await nextPopupButton2.click(); + const nextPopupButton = await page.waitForSelector('#popup-buttons-container > div') + await nextPopupButton.click(); + }) + + it('Skipping arranging test', async() => { + const nextButton = await page.waitForSelector('body > div:nth-child(8) > div > div > custom-next-navigation > div > a > img') await nextButton.click() - const popupNextButton2 = await page.waitForSelector('#popup-buttons-container > div.left.button') - await popupNextButton2.click() + const popupNextButton = await page.waitForSelector('#popup-buttons-container > div.left.button') + await popupNextButton.click() + }) + it('Sentence creation test', async() => { + const select0 = await page.waitForSelector('#w0') + await select0.click() + await page.screenshot({path: '__tests__/screenshots/setting_what.png'}); - const select1 = await page.waitForSelector('#w0') + const select1 = await page.waitForSelector('#w1') await select1.click() + await page.screenshot({path: '__tests__/screenshots/setting_are.png'}); - const select2 = await page.waitForSelector('#w1') + const select2 = await page.waitForSelector('#w2') await select2.click() + await page.screenshot({path: '__tests__/screenshots/setting_you.png'}); const select3 = await page.waitForSelector('#w3') await select3.click() + await page.screenshot({path: '__tests__/screenshots/setting_looking.png'}); const select4 = await page.waitForSelector('#w4') await select4.click() + await page.screenshot({path: '__tests__/screenshots/setting_for.png'}); const select5 = await page.waitForSelector('#w5') await select5.click() + await page.screenshot({path: '__tests__/screenshots/setting_questionmark.png'}); + const nextButton = await page.waitForSelector('body > div:nth-child(8) > div > div > custom-next-navigation > div > a > img') await nextButton.click() - const nextPopupButton3 = await page.waitForSelector('#popup-buttons-container > div') - await nextPopupButton3.click(); - + const nextPopupButton = await page.waitForSelector('#popup-buttons-container > div') + await nextPopupButton.click(); + }) + + it('Rating and comment test', async() => { const ratingFour = await page.waitForSelector('#gcFbPopup > div.gc-popup-new.gc-fc-popup > div.gc-popup-body-new > div > div:nth-child(1) > div:nth-child(4) > img') - ratingFour.click() + await ratingFour.click() + await page.screenshot({path: '__tests__/screenshots/four_rating.png'}); await page.waitForSelector('#commentText'); await page.evaluate(() => { document.querySelector('#commentText').value = 'test comment'; }); + await page.screenshot({path: '__tests__/screenshots/comment_rating.png'}); const submitButton = await page.waitForSelector('#gcFbPopup > div.gc-popup-new.gc-fc-popup > div.gc-popup-body-new > div') await submitButton.click() - - - }) + await page.screenshot({path: '__tests__/screenshots/submit_rating.png'}); + }) + }, timeout diff --git a/player/public/functional_test/makefile b/player/public/functional_test/makefile deleted file mode 100644 index 2191a4396..000000000 --- a/player/public/functional_test/makefile +++ /dev/null @@ -1,13 +0,0 @@ -.PHONY: dev test help -.DEFAULT_GOAL: help - -default: help - -help: ## Output available commands - @echo "Available commands:" - @echo - @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' - -ci_test: - @docker-compose build ci_test - @docker-compose run --rm ci_test \ No newline at end of file diff --git a/player/public/functional_test/package.json b/player/public/functional_test/package.json index 8ff368a36..d002ed788 100644 --- a/player/public/functional_test/package.json +++ b/player/public/functional_test/package.json @@ -24,6 +24,7 @@ }, "devDependencies": { "jest-html-reporter": "^2.8.0", - "jest-html-reporters": "^1.2.1" + "jest-html-reporters": "^1.2.1", + "jest-sonar-reporter": "^2.0.0" } }