feat: updated frontend-build & frontend-platform major versions (#1391)

* feat: platform & react-unit-test-utils major version update, updated jest to v29

* feat: updated frontend-build to v14 along with respective edx packages

* refactor: bumped package versions, updated snapshots for failing tests

* fix: code refactors to resolve failing tests

* refactor: added code comment in jest config
This commit is contained in:
Bilal Qamar
2024-08-14 20:20:27 +05:00
committed by GitHub
parent 99a44dda37
commit 71c2a31531
9 changed files with 3398 additions and 8133 deletions

View File

@@ -9,12 +9,12 @@ const config = createConfig('jest', {
'src/i18n', 'src/i18n',
'src/.*\\.exp\\..*', 'src/.*\\.exp\\..*',
], ],
// see https://github.com/axios/axios/issues/5026
moduleNameMapper: { moduleNameMapper: {
"^axios$": "axios/dist/axios.js",
// See https://stackoverflow.com/questions/72382316/jest-encountered-an-unexpected-token-react-markdown // See https://stackoverflow.com/questions/72382316/jest-encountered-an-unexpected-token-react-markdown
'react-markdown': '<rootDir>/node_modules/react-markdown/react-markdown.min.js', 'react-markdown': '<rootDir>/node_modules/react-markdown/react-markdown.min.js',
'@src/(.*)': '<rootDir>/src/$1', '@src/(.*)': '<rootDir>/src/$1',
// Explicit mapping to ensure Jest resolves the module correctly
'@edx/frontend-lib-special-exams': '<rootDir>/node_modules/@edx/frontend-lib-special-exams',
}, },
testTimeout: 30000, testTimeout: 30000,
globalSetup: "./global-setup.js", globalSetup: "./global-setup.js",
@@ -26,7 +26,7 @@ const config = createConfig('jest', {
config.reporters = [...(config.reporters || []), ["jest-console-group-reporter", { config.reporters = [...(config.reporters || []), ["jest-console-group-reporter", {
// change this setting if need to see less details for each test // change this setting if need to see less details for each test
// reportType: "summary" | "details", // reportType: "summary" | "details",
// enable: true | false, // enable: true | false,
afterEachTest: { afterEachTest: {
enable: true, enable: true,

10620
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -31,18 +31,18 @@
}, },
"dependencies": { "dependencies": {
"@edx/brand": "npm:@openedx/brand-openedx@^1.2.2", "@edx/brand": "npm:@openedx/brand-openedx@^1.2.2",
"@edx/frontend-component-header": "^5.0.2", "@edx/frontend-component-header": "^5.3.3",
"@edx/frontend-lib-learning-assistant": "^2.2.4", "@edx/frontend-lib-learning-assistant": "^2.2.4",
"@edx/frontend-lib-special-exams": "^3.1.3", "@edx/frontend-lib-special-exams": "^3.1.3",
"@edx/frontend-platform": "^7.1.2", "@edx/frontend-platform": "^8.0.0",
"@edx/openedx-atlas": "^0.6.0", "@edx/openedx-atlas": "^0.6.0",
"@edx/react-unit-test-utils": "2.0.0", "@edx/react-unit-test-utils": "3.0.0",
"@fortawesome/fontawesome-svg-core": "1.3.0", "@fortawesome/fontawesome-svg-core": "1.3.0",
"@fortawesome/free-brands-svg-icons": "5.15.4", "@fortawesome/free-brands-svg-icons": "5.15.4",
"@fortawesome/free-regular-svg-icons": "5.15.4", "@fortawesome/free-regular-svg-icons": "5.15.4",
"@fortawesome/free-solid-svg-icons": "5.15.4", "@fortawesome/free-solid-svg-icons": "5.15.4",
"@fortawesome/react-fontawesome": "^0.1.4", "@fortawesome/react-fontawesome": "^0.1.4",
"@openedx/frontend-plugin-framework": "^1.1.2", "@openedx/frontend-plugin-framework": "^1.2.1",
"@openedx/frontend-slot-footer": "^1.0.2", "@openedx/frontend-slot-footer": "^1.0.2",
"@openedx/paragon": "^22.3.0", "@openedx/paragon": "^22.3.0",
"@popperjs/core": "2.11.8", "@popperjs/core": "2.11.8",
@@ -71,7 +71,7 @@
"devDependencies": { "devDependencies": {
"@edx/browserslist-config": "1.2.0", "@edx/browserslist-config": "1.2.0",
"@edx/reactifex": "2.2.0", "@edx/reactifex": "2.2.0",
"@openedx/frontend-build": "13.1.4", "@openedx/frontend-build": "14.0.3",
"@pact-foundation/pact": "^11.0.2", "@pact-foundation/pact": "^11.0.2",
"@testing-library/jest-dom": "5.16.5", "@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "12.1.5", "@testing-library/react": "12.1.5",
@@ -82,8 +82,8 @@
"es-check": "6.2.1", "es-check": "6.2.1",
"eslint-import-resolver-webpack": "^0.13.8", "eslint-import-resolver-webpack": "^0.13.8",
"husky": "7.0.4", "husky": "7.0.4",
"jest": "^26.6.3", "jest": "^29.7.0",
"jest-console-group-reporter": "^1.0.1", "jest-console-group-reporter": "^1.1.1",
"jest-when": "^3.6.0", "jest-when": "^3.6.0",
"patch-package": "^8.0.0", "patch-package": "^8.0.0",
"postcss-loader": "^8.1.1", "postcss-loader": "^8.1.1",

View File

@@ -1,29 +1,29 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`mapSearchResponse when the response is correct should match snapshot 1`] = ` exports[`mapSearchResponse when the response is correct should match snapshot 1`] = `
Object { {
"filters": Array [ "filters": [
Object { {
"count": 7, "count": 7,
"key": "capa", "key": "capa",
"label": "CAPA", "label": "CAPA",
}, },
Object { {
"count": 2, "count": 2,
"key": "sequence", "key": "sequence",
"label": "Sequence", "label": "Sequence",
}, },
Object { {
"count": 9, "count": 9,
"key": "text", "key": "text",
"label": "Text", "label": "Text",
}, },
Object { {
"count": 1, "count": 1,
"key": "unknown", "key": "unknown",
"label": "Unknown", "label": "Unknown",
}, },
Object { {
"count": 2, "count": 2,
"key": "video", "key": "video",
"label": "Video", "label": "Video",
@@ -31,11 +31,11 @@ Object {
], ],
"maxScore": 3.4545178, "maxScore": 3.4545178,
"ms": 5, "ms": 5,
"results": Array [ "results": [
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@edx_introduction", "id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@edx_introduction",
"location": Array [ "location": [
"Introduction", "Introduction",
"Demo Course Overview", "Demo Course Overview",
], ],
@@ -44,10 +44,10 @@ Object {
"type": "sequence", "type": "sequence",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@sequential+block@edx_introduction", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@sequential+block@edx_introduction",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@html+block@5e009378f0b64585baa0a14b155974b9", "id": "block-v1:edX+DemoX+Demo_Course+type@html+block@5e009378f0b64585baa0a14b155974b9",
"location": Array [ "location": [
"About Exams and Certificates", "About Exams and Certificates",
"edX Exams", "edX Exams",
"Passing a Course", "Passing a Course",
@@ -57,10 +57,10 @@ Object {
"type": "text", "type": "text",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@html+block@5e009378f0b64585baa0a14b155974b9", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@html+block@5e009378f0b64585baa0a14b155974b9",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@vertical+block@c7e98fd39a6944edb6b286c32e1150ff", "id": "block-v1:edX+DemoX+Demo_Course+type@vertical+block@c7e98fd39a6944edb6b286c32e1150ff",
"location": Array [ "location": [
"About Exams and Certificates", "About Exams and Certificates",
"edX Exams", "edX Exams",
"Passing a Course", "Passing a Course",
@@ -70,10 +70,10 @@ Object {
"type": "sequence", "type": "sequence",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@vertical+block@c7e98fd39a6944edb6b286c32e1150ff", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@vertical+block@c7e98fd39a6944edb6b286c32e1150ff",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@problem+block@0d759dee4f9d459c8956136dbde55f02", "id": "block-v1:edX+DemoX+Demo_Course+type@problem+block@0d759dee4f9d459c8956136dbde55f02",
"location": Array [ "location": [
"Example Week 1: Getting Started", "Example Week 1: Getting Started",
"Homework - Question Styles", "Homework - Question Styles",
"Text input", "Text input",
@@ -83,10 +83,10 @@ Object {
"type": "capa", "type": "capa",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@problem+block@0d759dee4f9d459c8956136dbde55f02", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@problem+block@0d759dee4f9d459c8956136dbde55f02",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@problem+block@c554538a57664fac80783b99d9d6da7c", "id": "block-v1:edX+DemoX+Demo_Course+type@problem+block@c554538a57664fac80783b99d9d6da7c",
"location": Array [ "location": [
"Example Week 1: Getting Started", "Example Week 1: Getting Started",
"Homework - Question Styles", "Homework - Question Styles",
"Pointing on a Picture", "Pointing on a Picture",
@@ -96,10 +96,10 @@ Object {
"type": "capa", "type": "capa",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@problem+block@c554538a57664fac80783b99d9d6da7c", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@problem+block@c554538a57664fac80783b99d9d6da7c",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@problem+block@45d46192272c4f6db6b63586520bbdf4", "id": "block-v1:edX+DemoX+Demo_Course+type@problem+block@45d46192272c4f6db6b63586520bbdf4",
"location": Array [ "location": [
"About Exams and Certificates", "About Exams and Certificates",
"edX Exams", "edX Exams",
"Getting Answers", "Getting Answers",
@@ -109,10 +109,10 @@ Object {
"type": "capa", "type": "capa",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@problem+block@45d46192272c4f6db6b63586520bbdf4", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@problem+block@45d46192272c4f6db6b63586520bbdf4",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@video+block@0b9e39477cf34507a7a48f74be381fdd", "id": "block-v1:edX+DemoX+Demo_Course+type@video+block@0b9e39477cf34507a7a48f74be381fdd",
"location": Array [ "location": [
"Introduction", "Introduction",
"Demo Course Overview", "Demo Course Overview",
"Introduction: Video and Sequences", "Introduction: Video and Sequences",
@@ -122,10 +122,10 @@ Object {
"type": "video", "type": "video",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@video+block@0b9e39477cf34507a7a48f74be381fdd", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@video+block@0b9e39477cf34507a7a48f74be381fdd",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@problem+block@a0effb954cca4759994f1ac9e9434bf4", "id": "block-v1:edX+DemoX+Demo_Course+type@problem+block@a0effb954cca4759994f1ac9e9434bf4",
"location": Array [ "location": [
"Example Week 1: Getting Started", "Example Week 1: Getting Started",
"Homework - Question Styles", "Homework - Question Styles",
"Multiple Choice Questions", "Multiple Choice Questions",
@@ -135,10 +135,10 @@ Object {
"type": "capa", "type": "capa",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@problem+block@a0effb954cca4759994f1ac9e9434bf4", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@problem+block@a0effb954cca4759994f1ac9e9434bf4",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@problem+block@75f9562c77bc4858b61f907bb810d974", "id": "block-v1:edX+DemoX+Demo_Course+type@problem+block@75f9562c77bc4858b61f907bb810d974",
"location": Array [ "location": [
"Example Week 1: Getting Started", "Example Week 1: Getting Started",
"Homework - Question Styles", "Homework - Question Styles",
"Numerical Input", "Numerical Input",
@@ -148,10 +148,10 @@ Object {
"type": "capa", "type": "capa",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@problem+block@75f9562c77bc4858b61f907bb810d974", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@problem+block@75f9562c77bc4858b61f907bb810d974",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@video+block@636541acbae448d98ab484b028c9a7f6", "id": "block-v1:edX+DemoX+Demo_Course+type@video+block@636541acbae448d98ab484b028c9a7f6",
"location": Array [ "location": [
"Example Week 1: Getting Started", "Example Week 1: Getting Started",
"Lesson 1 - Getting Started", "Lesson 1 - Getting Started",
"Video Presentation Styles", "Video Presentation Styles",
@@ -161,10 +161,10 @@ Object {
"type": "video", "type": "video",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@video+block@636541acbae448d98ab484b028c9a7f6", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@video+block@636541acbae448d98ab484b028c9a7f6",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@problem+block@python_grader", "id": "block-v1:edX+DemoX+Demo_Course+type@problem+block@python_grader",
"location": Array [ "location": [
"Example Week 2: Get Interactive", "Example Week 2: Get Interactive",
"Homework - Labs and Demos", "Homework - Labs and Demos",
"Code Grader", "Code Grader",
@@ -174,10 +174,10 @@ Object {
"type": "capa", "type": "capa",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@problem+block@python_grader", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@problem+block@python_grader",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@problem+block@9cee77a606ea4c1aa5440e0ea5d0f618", "id": "block-v1:edX+DemoX+Demo_Course+type@problem+block@9cee77a606ea4c1aa5440e0ea5d0f618",
"location": Array [ "location": [
"Example Week 1: Getting Started", "Example Week 1: Getting Started",
"Lesson 1 - Getting Started", "Lesson 1 - Getting Started",
"Interactive Questions", "Interactive Questions",
@@ -187,10 +187,10 @@ Object {
"type": "capa", "type": "capa",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@problem+block@9cee77a606ea4c1aa5440e0ea5d0f618", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@problem+block@9cee77a606ea4c1aa5440e0ea5d0f618",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@html+block@030e35c4756a4ddc8d40b95fbbfff4d4", "id": "block-v1:edX+DemoX+Demo_Course+type@html+block@030e35c4756a4ddc8d40b95fbbfff4d4",
"location": Array [ "location": [
"Introduction", "Introduction",
"Demo Course Overview", "Demo Course Overview",
"Introduction: Video and Sequences", "Introduction: Video and Sequences",
@@ -200,10 +200,10 @@ Object {
"type": "text", "type": "text",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@html+block@030e35c4756a4ddc8d40b95fbbfff4d4", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@html+block@030e35c4756a4ddc8d40b95fbbfff4d4",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@html+block@html_49b4494da2f7", "id": "block-v1:edX+DemoX+Demo_Course+type@html+block@html_49b4494da2f7",
"location": Array [ "location": [
"Example Week 3: Be Social", "Example Week 3: Be Social",
"Lesson 3 - Be Social", "Lesson 3 - Be Social",
"Discussion Forums", "Discussion Forums",
@@ -213,10 +213,10 @@ Object {
"type": "text", "type": "text",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@html+block@html_49b4494da2f7", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@html+block@html_49b4494da2f7",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@html+block@f4a39219742149f781a1dda6f43a623c", "id": "block-v1:edX+DemoX+Demo_Course+type@html+block@f4a39219742149f781a1dda6f43a623c",
"location": Array [ "location": [
"About Exams and Certificates", "About Exams and Certificates",
"edX Exams", "edX Exams",
"Overall Grade Performance", "Overall Grade Performance",
@@ -226,10 +226,10 @@ Object {
"type": "text", "type": "text",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@html+block@f4a39219742149f781a1dda6f43a623c", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@html+block@f4a39219742149f781a1dda6f43a623c",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@html+block@87fa6792d79f4862be098e5169e93339", "id": "block-v1:edX+DemoX+Demo_Course+type@html+block@87fa6792d79f4862be098e5169e93339",
"location": Array [ "location": [
"Example Week 3: Be Social", "Example Week 3: Be Social",
"Lesson 3 - Be Social", "Lesson 3 - Be Social",
"Homework - Find Your Study Buddy", "Homework - Find Your Study Buddy",
@@ -239,10 +239,10 @@ Object {
"type": "text", "type": "text",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@html+block@87fa6792d79f4862be098e5169e93339", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@html+block@87fa6792d79f4862be098e5169e93339",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@html+block@6018785795994726950614ce7d0f38c5", "id": "block-v1:edX+DemoX+Demo_Course+type@html+block@6018785795994726950614ce7d0f38c5",
"location": Array [ "location": [
"Example Week 3: Be Social", "Example Week 3: Be Social",
"Homework - Find Your Study Buddy", "Homework - Find Your Study Buddy",
"Homework - Find Your Study Buddy", "Homework - Find Your Study Buddy",
@@ -252,10 +252,10 @@ Object {
"type": "text", "type": "text",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@html+block@6018785795994726950614ce7d0f38c5", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@html+block@6018785795994726950614ce7d0f38c5",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@html+block@f9f3a25e7bab46e583fd1fbbd7a2f6a0", "id": "block-v1:edX+DemoX+Demo_Course+type@html+block@f9f3a25e7bab46e583fd1fbbd7a2f6a0",
"location": Array [ "location": [
"Example Week 3: Be Social", "Example Week 3: Be Social",
"Lesson 3 - Be Social", "Lesson 3 - Be Social",
"Be Social", "Be Social",
@@ -265,10 +265,10 @@ Object {
"type": "text", "type": "text",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@html+block@f9f3a25e7bab46e583fd1fbbd7a2f6a0", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@html+block@f9f3a25e7bab46e583fd1fbbd7a2f6a0",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@html+block@8293139743f34377817d537b69911530", "id": "block-v1:edX+DemoX+Demo_Course+type@html+block@8293139743f34377817d537b69911530",
"location": Array [ "location": [
"About Exams and Certificates", "About Exams and Certificates",
"edX Exams", "edX Exams",
"EdX Exams", "EdX Exams",
@@ -278,10 +278,10 @@ Object {
"type": "text", "type": "text",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@html+block@8293139743f34377817d537b69911530", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@html+block@8293139743f34377817d537b69911530",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "block-v1:edX+DemoX+Demo_Course+type@html+block@9d5104b502f24ee89c3d2f4ce9d347cf", "id": "block-v1:edX+DemoX+Demo_Course+type@html+block@9d5104b502f24ee89c3d2f4ce9d347cf",
"location": Array [ "location": [
"Example Week 1: Getting Started", "Example Week 1: Getting Started",
"Lesson 1 - Getting Started", "Lesson 1 - Getting Started",
"When Are Your Exams? ", "When Are Your Exams? ",
@@ -291,7 +291,7 @@ Object {
"type": "text", "type": "text",
"url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@html+block@9d5104b502f24ee89c3d2f4ce9d347cf", "url": "/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type@html+block@9d5104b502f24ee89c3d2f4ce9d347cf",
}, },
Object { {
"contentHits": 0, "contentHits": 0,
"id": "random-element-id", "id": "random-element-id",
"location": null, "location": null,

View File

@@ -1,8 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Data layer integration tests Test fetchDatesTab Should fetch, normalize, and save metadata 1`] = ` exports[`Data layer integration tests Test fetchDatesTab Should fetch, normalize, and save metadata 1`] = `
Object { {
"courseHome": Object { "courseHome": {
"courseId": "course-v1:edX+DemoX+Demo_Course", "courseId": "course-v1:edX+DemoX+Demo_Course",
"courseStatus": "loaded", "courseStatus": "loaded",
"proctoringPanelStatus": "loading", "proctoringPanelStatus": "loading",
@@ -12,13 +12,13 @@ Object {
"toastBodyText": null, "toastBodyText": null,
"toastHeader": "", "toastHeader": "",
}, },
"courseware": Object { "courseware": {
"courseId": null, "courseId": null,
"courseOutline": Object {}, "courseOutline": {},
"courseOutlineShouldUpdate": false, "courseOutlineShouldUpdate": false,
"courseOutlineStatus": "loading", "courseOutlineStatus": "loading",
"courseStatus": "loading", "courseStatus": "loading",
"coursewareOutlineSidebarSettings": Object {}, "coursewareOutlineSidebarSettings": {},
"sequenceId": null, "sequenceId": null,
"sequenceMightBeUnit": false, "sequenceMightBeUnit": false,
"sequenceStatus": "loading", "sequenceStatus": "loading",
@@ -26,12 +26,12 @@ Object {
"learningAssistant": ObjectContaining { "learningAssistant": ObjectContaining {
"conversationId": Any<String>, "conversationId": Any<String>,
}, },
"models": Object { "models": {
"courseHomeMeta": Object { "courseHomeMeta": {
"course-v1:edX+DemoX+Demo_Course": Object { "course-v1:edX+DemoX+Demo_Course": {
"canViewCertificate": true, "canViewCertificate": true,
"celebrations": null, "celebrations": null,
"courseAccess": Object { "courseAccess": {
"additionalContextUserMessage": null, "additionalContextUserMessage": null,
"developerMessage": null, "developerMessage": null,
"errorCode": null, "errorCode": null,
@@ -49,33 +49,33 @@ Object {
"org": "edX", "org": "edX",
"originalUserIsStaff": false, "originalUserIsStaff": false,
"start": "2013-02-05T05:00:00Z", "start": "2013-02-05T05:00:00Z",
"tabs": Array [ "tabs": [
Object { {
"slug": "outline", "slug": "outline",
"title": "Course", "title": "Course",
"url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/course/", "url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/course/",
}, },
Object { {
"slug": "discussion", "slug": "discussion",
"title": "Discussion", "title": "Discussion",
"url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/discussion/forum/", "url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/discussion/forum/",
}, },
Object { {
"slug": "wiki", "slug": "wiki",
"title": "Wiki", "title": "Wiki",
"url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/course_wiki", "url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/course_wiki",
}, },
Object { {
"slug": "progress", "slug": "progress",
"title": "Progress", "title": "Progress",
"url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/progress", "url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/progress",
}, },
Object { {
"slug": "instructor", "slug": "instructor",
"title": "Instructor", "title": "Instructor",
"url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/instructor", "url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/instructor",
}, },
Object { {
"slug": "dates", "slug": "dates",
"title": "Dates", "title": "Dates",
"url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/dates", "url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/dates",
@@ -84,7 +84,7 @@ Object {
"title": "Demonstration Course", "title": "Demonstration Course",
"userTimezone": "UTC", "userTimezone": "UTC",
"username": "MockUser", "username": "MockUser",
"verifiedMode": Object { "verifiedMode": {
"accessExpirationDate": null, "accessExpirationDate": null,
"currency": "USD", "currency": "USD",
"currencySymbol": "$", "currencySymbol": "$",
@@ -94,10 +94,10 @@ Object {
}, },
}, },
}, },
"dates": Object { "dates": {
"course-v1:edX+DemoX+Demo_Course": Object { "course-v1:edX+DemoX+Demo_Course": {
"courseDateBlocks": Array [ "courseDateBlocks": [
Object { {
"date": "2020-05-01T17:59:41Z", "date": "2020-05-01T17:59:41Z",
"dateType": "course-start-date", "dateType": "course-start-date",
"description": "", "description": "",
@@ -106,7 +106,7 @@ Object {
"link": "", "link": "",
"title": "Course Starts", "title": "Course Starts",
}, },
Object { {
"assignmentType": "Homework", "assignmentType": "Homework",
"complete": true, "complete": true,
"date": "2020-05-04T02:59:40.942669Z", "date": "2020-05-04T02:59:40.942669Z",
@@ -116,7 +116,7 @@ Object {
"learnerHasAccess": true, "learnerHasAccess": true,
"title": "Multi Badges Completed", "title": "Multi Badges Completed",
}, },
Object { {
"assignmentType": "Homework", "assignmentType": "Homework",
"date": "2020-05-05T02:59:40.942669Z", "date": "2020-05-05T02:59:40.942669Z",
"dateType": "assignment-due-date", "dateType": "assignment-due-date",
@@ -125,7 +125,7 @@ Object {
"learnerHasAccess": true, "learnerHasAccess": true,
"title": "Multi Badges Past Due", "title": "Multi Badges Past Due",
}, },
Object { {
"assignmentType": "Homework", "assignmentType": "Homework",
"date": "2020-05-27T02:59:40.942669Z", "date": "2020-05-27T02:59:40.942669Z",
"dateType": "assignment-due-date", "dateType": "assignment-due-date",
@@ -135,7 +135,7 @@ Object {
"link": "https://example.com/", "link": "https://example.com/",
"title": "Both Past Due 1", "title": "Both Past Due 1",
}, },
Object { {
"assignmentType": "Homework", "assignmentType": "Homework",
"date": "2020-05-27T02:59:40.942669Z", "date": "2020-05-27T02:59:40.942669Z",
"dateType": "assignment-due-date", "dateType": "assignment-due-date",
@@ -145,7 +145,7 @@ Object {
"link": "https://example.com/", "link": "https://example.com/",
"title": "Both Past Due 2", "title": "Both Past Due 2",
}, },
Object { {
"assignmentType": "Homework", "assignmentType": "Homework",
"complete": true, "complete": true,
"date": "2020-05-28T08:59:40.942669Z", "date": "2020-05-28T08:59:40.942669Z",
@@ -156,7 +156,7 @@ Object {
"link": "https://example.com/", "link": "https://example.com/",
"title": "One Completed/Due 1", "title": "One Completed/Due 1",
}, },
Object { {
"assignmentType": "Homework", "assignmentType": "Homework",
"date": "2020-05-28T08:59:40.942669Z", "date": "2020-05-28T08:59:40.942669Z",
"dateType": "assignment-due-date", "dateType": "assignment-due-date",
@@ -166,7 +166,7 @@ Object {
"link": "https://example.com/", "link": "https://example.com/",
"title": "One Completed/Due 2", "title": "One Completed/Due 2",
}, },
Object { {
"assignmentType": "Homework", "assignmentType": "Homework",
"complete": true, "complete": true,
"date": "2020-05-29T08:59:40.942669Z", "date": "2020-05-29T08:59:40.942669Z",
@@ -177,7 +177,7 @@ Object {
"link": "https://example.com/", "link": "https://example.com/",
"title": "Both Completed 1", "title": "Both Completed 1",
}, },
Object { {
"assignmentType": "Homework", "assignmentType": "Homework",
"complete": true, "complete": true,
"date": "2020-05-29T08:59:40.942669Z", "date": "2020-05-29T08:59:40.942669Z",
@@ -188,7 +188,7 @@ Object {
"link": "https://example.com/", "link": "https://example.com/",
"title": "Both Completed 2", "title": "Both Completed 2",
}, },
Object { {
"date": "2020-06-16T17:59:40.942669Z", "date": "2020-06-16T17:59:40.942669Z",
"dateType": "verified-upgrade-deadline", "dateType": "verified-upgrade-deadline",
"description": "Don't miss the opportunity to highlight your new knowledge and skills by earning a verified certificate.", "description": "Don't miss the opportunity to highlight your new knowledge and skills by earning a verified certificate.",
@@ -197,7 +197,7 @@ Object {
"link": "https://example.com/", "link": "https://example.com/",
"title": "Upgrade to Verified Certificate", "title": "Upgrade to Verified Certificate",
}, },
Object { {
"assignmentType": "Homework", "assignmentType": "Homework",
"date": "2030-08-17T05:59:40.942669Z", "date": "2030-08-17T05:59:40.942669Z",
"dateType": "assignment-due-date", "dateType": "assignment-due-date",
@@ -207,7 +207,7 @@ Object {
"link": "https://example.com/", "link": "https://example.com/",
"title": "One Verified 1", "title": "One Verified 1",
}, },
Object { {
"assignmentType": "Homework", "assignmentType": "Homework",
"date": "2030-08-17T05:59:40.942669Z", "date": "2030-08-17T05:59:40.942669Z",
"dateType": "assignment-due-date", "dateType": "assignment-due-date",
@@ -217,7 +217,7 @@ Object {
"link": "https://example.com/", "link": "https://example.com/",
"title": "One Verified 2", "title": "One Verified 2",
}, },
Object { {
"assignmentType": "Homework", "assignmentType": "Homework",
"date": "2030-08-17T05:59:40.942669Z", "date": "2030-08-17T05:59:40.942669Z",
"dateType": "assignment-due-date", "dateType": "assignment-due-date",
@@ -227,7 +227,7 @@ Object {
"link": "https://example.com/", "link": "https://example.com/",
"title": "ORA Verified 2", "title": "ORA Verified 2",
}, },
Object { {
"assignmentType": "Homework", "assignmentType": "Homework",
"date": "2030-08-18T05:59:40.942669Z", "date": "2030-08-18T05:59:40.942669Z",
"dateType": "assignment-due-date", "dateType": "assignment-due-date",
@@ -237,7 +237,7 @@ Object {
"link": "https://example.com/", "link": "https://example.com/",
"title": "Both Verified 1", "title": "Both Verified 1",
}, },
Object { {
"assignmentType": "Homework", "assignmentType": "Homework",
"date": "2030-08-18T05:59:40.942669Z", "date": "2030-08-18T05:59:40.942669Z",
"dateType": "assignment-due-date", "dateType": "assignment-due-date",
@@ -247,7 +247,7 @@ Object {
"link": "https://example.com/", "link": "https://example.com/",
"title": "Both Verified 2", "title": "Both Verified 2",
}, },
Object { {
"assignmentType": "Homework", "assignmentType": "Homework",
"date": "2030-08-19T05:59:40.942669Z", "date": "2030-08-19T05:59:40.942669Z",
"dateType": "assignment-due-date", "dateType": "assignment-due-date",
@@ -255,7 +255,7 @@ Object {
"learnerHasAccess": true, "learnerHasAccess": true,
"title": "One Unreleased 1", "title": "One Unreleased 1",
}, },
Object { {
"assignmentType": "Homework", "assignmentType": "Homework",
"date": "2030-08-19T05:59:40.942669Z", "date": "2030-08-19T05:59:40.942669Z",
"dateType": "assignment-due-date", "dateType": "assignment-due-date",
@@ -265,7 +265,7 @@ Object {
"link": "https://example.com/", "link": "https://example.com/",
"title": "One Unreleased 2", "title": "One Unreleased 2",
}, },
Object { {
"assignmentType": "Homework", "assignmentType": "Homework",
"date": "2030-08-20T05:59:40.942669Z", "date": "2030-08-20T05:59:40.942669Z",
"dateType": "assignment-due-date", "dateType": "assignment-due-date",
@@ -274,7 +274,7 @@ Object {
"learnerHasAccess": true, "learnerHasAccess": true,
"title": "Both Unreleased 1", "title": "Both Unreleased 1",
}, },
Object { {
"assignmentType": "Homework", "assignmentType": "Homework",
"date": "2030-08-20T05:59:40.942669Z", "date": "2030-08-20T05:59:40.942669Z",
"dateType": "assignment-due-date", "dateType": "assignment-due-date",
@@ -283,7 +283,7 @@ Object {
"learnerHasAccess": true, "learnerHasAccess": true,
"title": "Both Unreleased 2", "title": "Both Unreleased 2",
}, },
Object { {
"date": "2030-08-23T00:00:00Z", "date": "2030-08-23T00:00:00Z",
"dateType": "course-end-date", "dateType": "course-end-date",
"description": "", "description": "",
@@ -292,7 +292,7 @@ Object {
"link": "", "link": "",
"title": "Course Ends", "title": "Course Ends",
}, },
Object { {
"date": "2030-09-01T00:00:00Z", "date": "2030-09-01T00:00:00Z",
"dateType": "verification-deadline-date", "dateType": "verification-deadline-date",
"description": "You must successfully complete verification before this date to qualify for a Verified Certificate.", "description": "You must successfully complete verification before this date to qualify for a Verified Certificate.",
@@ -302,7 +302,7 @@ Object {
"title": "Verification Deadline", "title": "Verification Deadline",
}, },
], ],
"datesBannerInfo": Object { "datesBannerInfo": {
"contentTypeGatingEnabled": false, "contentTypeGatingEnabled": false,
"missedDeadlines": false, "missedDeadlines": false,
"missedGatedContent": false, "missedGatedContent": false,
@@ -314,16 +314,16 @@ Object {
}, },
}, },
}, },
"plugins": Object {}, "plugins": {},
"recommendations": Object { "recommendations": {
"recommendationsStatus": "loading", "recommendationsStatus": "loading",
}, },
"specialExams": Object { "specialExams": {
"activeAttempt": null, "activeAttempt": null,
"allowProctoringOptOut": false, "allowProctoringOptOut": false,
"apiErrorMsg": "", "apiErrorMsg": "",
"exam": Object { "exam": {
"attempt": Object { "attempt": {
"attempt_code": "", "attempt_code": "",
"attempt_id": null, "attempt_id": null,
"attempt_status": "", "attempt_status": "",
@@ -351,27 +351,27 @@ Object {
"is_active": true, "is_active": true,
"is_practice_exam": false, "is_practice_exam": false,
"is_proctored": false, "is_proctored": false,
"prerequisite_status": Object { "prerequisite_status": {
"are_prerequisites_satisifed": true, "are_prerequisites_satisifed": true,
"declined_prerequisites": Array [], "declined_prerequisites": [],
"failed_prerequisites": Array [], "failed_prerequisites": [],
"pending_prerequisites": Array [], "pending_prerequisites": [],
"satisfied_prerequisites": Array [], "satisfied_prerequisites": [],
}, },
"time_limit_mins": null, "time_limit_mins": null,
"type": "", "type": "",
}, },
"examAccessToken": Object { "examAccessToken": {
"exam_access_token": "", "exam_access_token": "",
"exam_access_token_expiration": "", "exam_access_token_expiration": "",
}, },
"isLoading": true, "isLoading": true,
"proctoringSettings": Object { "proctoringSettings": {
"exam_proctoring_backend": Object { "exam_proctoring_backend": {
"download_url": "", "download_url": "",
"instructions": Array [], "instructions": [],
"name": "", "name": "",
"rules": Object {}, "rules": {},
}, },
"integration_specific_email": "", "integration_specific_email": "",
"learner_notification_from_email": "", "learner_notification_from_email": "",
@@ -382,7 +382,7 @@ Object {
}, },
"timeIsOver": false, "timeIsOver": false,
}, },
"tours": Object { "tours": {
"showCoursewareTour": false, "showCoursewareTour": false,
"showExistingUserCourseHomeTour": false, "showExistingUserCourseHomeTour": false,
"showNewUserCourseHomeModal": false, "showNewUserCourseHomeModal": false,
@@ -393,8 +393,8 @@ Object {
`; `;
exports[`Data layer integration tests Test fetchOutlineTab Should fetch, normalize, and save metadata 1`] = ` exports[`Data layer integration tests Test fetchOutlineTab Should fetch, normalize, and save metadata 1`] = `
Object { {
"courseHome": Object { "courseHome": {
"courseId": "course-v1:edX+DemoX+Demo_Course", "courseId": "course-v1:edX+DemoX+Demo_Course",
"courseStatus": "loaded", "courseStatus": "loaded",
"proctoringPanelStatus": "loading", "proctoringPanelStatus": "loading",
@@ -404,13 +404,13 @@ Object {
"toastBodyText": null, "toastBodyText": null,
"toastHeader": "", "toastHeader": "",
}, },
"courseware": Object { "courseware": {
"courseId": null, "courseId": null,
"courseOutline": Object {}, "courseOutline": {},
"courseOutlineShouldUpdate": false, "courseOutlineShouldUpdate": false,
"courseOutlineStatus": "loading", "courseOutlineStatus": "loading",
"courseStatus": "loading", "courseStatus": "loading",
"coursewareOutlineSidebarSettings": Object {}, "coursewareOutlineSidebarSettings": {},
"sequenceId": null, "sequenceId": null,
"sequenceMightBeUnit": false, "sequenceMightBeUnit": false,
"sequenceStatus": "loading", "sequenceStatus": "loading",
@@ -418,12 +418,12 @@ Object {
"learningAssistant": ObjectContaining { "learningAssistant": ObjectContaining {
"conversationId": Any<String>, "conversationId": Any<String>,
}, },
"models": Object { "models": {
"courseHomeMeta": Object { "courseHomeMeta": {
"course-v1:edX+DemoX+Demo_Course": Object { "course-v1:edX+DemoX+Demo_Course": {
"canViewCertificate": true, "canViewCertificate": true,
"celebrations": null, "celebrations": null,
"courseAccess": Object { "courseAccess": {
"additionalContextUserMessage": null, "additionalContextUserMessage": null,
"developerMessage": null, "developerMessage": null,
"errorCode": null, "errorCode": null,
@@ -441,33 +441,33 @@ Object {
"org": "edX", "org": "edX",
"originalUserIsStaff": false, "originalUserIsStaff": false,
"start": "2013-02-05T05:00:00Z", "start": "2013-02-05T05:00:00Z",
"tabs": Array [ "tabs": [
Object { {
"slug": "outline", "slug": "outline",
"title": "Course", "title": "Course",
"url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/course/", "url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/course/",
}, },
Object { {
"slug": "discussion", "slug": "discussion",
"title": "Discussion", "title": "Discussion",
"url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/discussion/forum/", "url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/discussion/forum/",
}, },
Object { {
"slug": "wiki", "slug": "wiki",
"title": "Wiki", "title": "Wiki",
"url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/course_wiki", "url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/course_wiki",
}, },
Object { {
"slug": "progress", "slug": "progress",
"title": "Progress", "title": "Progress",
"url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/progress", "url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/progress",
}, },
Object { {
"slug": "instructor", "slug": "instructor",
"title": "Instructor", "title": "Instructor",
"url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/instructor", "url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/instructor",
}, },
Object { {
"slug": "dates", "slug": "dates",
"title": "Dates", "title": "Dates",
"url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/dates", "url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/dates",
@@ -476,7 +476,7 @@ Object {
"title": "Demonstration Course", "title": "Demonstration Course",
"userTimezone": "UTC", "userTimezone": "UTC",
"username": "MockUser", "username": "MockUser",
"verifiedMode": Object { "verifiedMode": {
"accessExpirationDate": null, "accessExpirationDate": null,
"currency": "USD", "currency": "USD",
"currencySymbol": "$", "currencySymbol": "$",
@@ -486,41 +486,41 @@ Object {
}, },
}, },
}, },
"outline": Object { "outline": {
"course-v1:edX+DemoX+Demo_Course": Object { "course-v1:edX+DemoX+Demo_Course": {
"accessExpiration": null, "accessExpiration": null,
"canShowUpgradeSock": false, "canShowUpgradeSock": false,
"certData": Object { "certData": {
"certStatus": null, "certStatus": null,
"certWebViewUrl": null, "certWebViewUrl": null,
"certificateAvailableDate": null, "certificateAvailableDate": null,
}, },
"courseBlocks": Object { "courseBlocks": {
"courses": Object { "courses": {
"block-v1:edX+DemoX+Demo_Course+type@course+block@bcdabcdabcdabcdabcdabcdabcdabcd3": Object { "block-v1:edX+DemoX+Demo_Course+type@course+block@bcdabcdabcdabcdabcdabcdabcdabcd3": {
"hasScheduledContent": false, "hasScheduledContent": false,
"id": "course-v1:edX+DemoX+Demo_Course", "id": "course-v1:edX+DemoX+Demo_Course",
"sectionIds": Array [ "sectionIds": [
"block-v1:edX+DemoX+Demo_Course+type@chapter+block@bcdabcdabcdabcdabcdabcdabcdabcd2", "block-v1:edX+DemoX+Demo_Course+type@chapter+block@bcdabcdabcdabcdabcdabcdabcdabcd2",
], ],
"title": "bcdabcdabcdabcdabcdabcdabcdabcd3", "title": "bcdabcdabcdabcdabcdabcdabcdabcd3",
}, },
}, },
"sections": Object { "sections": {
"block-v1:edX+DemoX+Demo_Course+type@chapter+block@bcdabcdabcdabcdabcdabcdabcdabcd2": Object { "block-v1:edX+DemoX+Demo_Course+type@chapter+block@bcdabcdabcdabcdabcdabcdabcdabcd2": {
"complete": false, "complete": false,
"courseId": "course-v1:edX+DemoX+Demo_Course", "courseId": "course-v1:edX+DemoX+Demo_Course",
"hideFromTOC": undefined, "hideFromTOC": undefined,
"id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@bcdabcdabcdabcdabcdabcdabcdabcd2", "id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@bcdabcdabcdabcdabcdabcdabcdabcd2",
"resumeBlock": false, "resumeBlock": false,
"sequenceIds": Array [ "sequenceIds": [
"block-v1:edX+DemoX+Demo_Course+type@sequential+block@bcdabcdabcdabcdabcdabcdabcdabcd1", "block-v1:edX+DemoX+Demo_Course+type@sequential+block@bcdabcdabcdabcdabcdabcdabcdabcd1",
], ],
"title": "Title of Section", "title": "Title of Section",
}, },
}, },
"sequences": Object { "sequences": {
"block-v1:edX+DemoX+Demo_Course+type@sequential+block@bcdabcdabcdabcdabcdabcdabcdabcd1": Object { "block-v1:edX+DemoX+Demo_Course+type@sequential+block@bcdabcdabcdabcdabcdabcdabcdabcd1": {
"complete": false, "complete": false,
"description": null, "description": null,
"due": null, "due": null,
@@ -536,30 +536,30 @@ Object {
}, },
}, },
}, },
"courseGoals": Object { "courseGoals": {
"daysPerWeek": null, "daysPerWeek": null,
"goalOptions": Array [], "goalOptions": [],
"selectedGoal": null, "selectedGoal": null,
"subscribedToReminders": null, "subscribedToReminders": null,
"weeklyLearningGoalEnabled": false, "weeklyLearningGoalEnabled": false,
}, },
"courseTools": Array [ "courseTools": [
Object { {
"analyticsId": "edx.bookmarks", "analyticsId": "edx.bookmarks",
"title": "Bookmarks", "title": "Bookmarks",
"url": "https://example.com/bookmarks", "url": "https://example.com/bookmarks",
}, },
], ],
"datesBannerInfo": Object { "datesBannerInfo": {
"contentTypeGatingEnabled": false, "contentTypeGatingEnabled": false,
"missedDeadlines": false, "missedDeadlines": false,
"missedGatedContent": false, "missedGatedContent": false,
}, },
"datesWidget": Object { "datesWidget": {
"courseDateBlocks": Array [], "courseDateBlocks": [],
}, },
"enableProctoredExams": undefined, "enableProctoredExams": undefined,
"enrollAlert": Object { "enrollAlert": {
"canEnroll": true, "canEnroll": true,
"extraText": "Contact the administrator.", "extraText": "Contact the administrator.",
}, },
@@ -569,13 +569,13 @@ Object {
"hasScheduledContent": null, "hasScheduledContent": null,
"id": "course-v1:edX+DemoX+Demo_Course", "id": "course-v1:edX+DemoX+Demo_Course",
"offer": null, "offer": null,
"resumeCourse": Object { "resumeCourse": {
"hasVisitedCourse": false, "hasVisitedCourse": false,
"url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+Test+Block@12345abcde", "url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+Test+Block@12345abcde",
}, },
"timeOffsetMillis": 0, "timeOffsetMillis": 0,
"userHasPassingGrade": undefined, "userHasPassingGrade": undefined,
"verifiedMode": Object { "verifiedMode": {
"accessExpirationDate": "2050-01-01T12:00:00", "accessExpirationDate": "2050-01-01T12:00:00",
"currency": "USD", "currency": "USD",
"currencySymbol": "$", "currencySymbol": "$",
@@ -587,16 +587,16 @@ Object {
}, },
}, },
}, },
"plugins": Object {}, "plugins": {},
"recommendations": Object { "recommendations": {
"recommendationsStatus": "loading", "recommendationsStatus": "loading",
}, },
"specialExams": Object { "specialExams": {
"activeAttempt": null, "activeAttempt": null,
"allowProctoringOptOut": false, "allowProctoringOptOut": false,
"apiErrorMsg": "", "apiErrorMsg": "",
"exam": Object { "exam": {
"attempt": Object { "attempt": {
"attempt_code": "", "attempt_code": "",
"attempt_id": null, "attempt_id": null,
"attempt_status": "", "attempt_status": "",
@@ -624,27 +624,27 @@ Object {
"is_active": true, "is_active": true,
"is_practice_exam": false, "is_practice_exam": false,
"is_proctored": false, "is_proctored": false,
"prerequisite_status": Object { "prerequisite_status": {
"are_prerequisites_satisifed": true, "are_prerequisites_satisifed": true,
"declined_prerequisites": Array [], "declined_prerequisites": [],
"failed_prerequisites": Array [], "failed_prerequisites": [],
"pending_prerequisites": Array [], "pending_prerequisites": [],
"satisfied_prerequisites": Array [], "satisfied_prerequisites": [],
}, },
"time_limit_mins": null, "time_limit_mins": null,
"type": "", "type": "",
}, },
"examAccessToken": Object { "examAccessToken": {
"exam_access_token": "", "exam_access_token": "",
"exam_access_token_expiration": "", "exam_access_token_expiration": "",
}, },
"isLoading": true, "isLoading": true,
"proctoringSettings": Object { "proctoringSettings": {
"exam_proctoring_backend": Object { "exam_proctoring_backend": {
"download_url": "", "download_url": "",
"instructions": Array [], "instructions": [],
"name": "", "name": "",
"rules": Object {}, "rules": {},
}, },
"integration_specific_email": "", "integration_specific_email": "",
"learner_notification_from_email": "", "learner_notification_from_email": "",
@@ -655,7 +655,7 @@ Object {
}, },
"timeIsOver": false, "timeIsOver": false,
}, },
"tours": Object { "tours": {
"showCoursewareTour": false, "showCoursewareTour": false,
"showExistingUserCourseHomeTour": false, "showExistingUserCourseHomeTour": false,
"showNewUserCourseHomeModal": false, "showNewUserCourseHomeModal": false,
@@ -666,8 +666,8 @@ Object {
`; `;
exports[`Data layer integration tests Test fetchProgressTab Should fetch, normalize, and save metadata 1`] = ` exports[`Data layer integration tests Test fetchProgressTab Should fetch, normalize, and save metadata 1`] = `
Object { {
"courseHome": Object { "courseHome": {
"courseId": "course-v1:edX+DemoX+Demo_Course", "courseId": "course-v1:edX+DemoX+Demo_Course",
"courseStatus": "loaded", "courseStatus": "loaded",
"proctoringPanelStatus": "loading", "proctoringPanelStatus": "loading",
@@ -677,13 +677,13 @@ Object {
"toastBodyText": null, "toastBodyText": null,
"toastHeader": "", "toastHeader": "",
}, },
"courseware": Object { "courseware": {
"courseId": null, "courseId": null,
"courseOutline": Object {}, "courseOutline": {},
"courseOutlineShouldUpdate": false, "courseOutlineShouldUpdate": false,
"courseOutlineStatus": "loading", "courseOutlineStatus": "loading",
"courseStatus": "loading", "courseStatus": "loading",
"coursewareOutlineSidebarSettings": Object {}, "coursewareOutlineSidebarSettings": {},
"sequenceId": null, "sequenceId": null,
"sequenceMightBeUnit": false, "sequenceMightBeUnit": false,
"sequenceStatus": "loading", "sequenceStatus": "loading",
@@ -691,12 +691,12 @@ Object {
"learningAssistant": ObjectContaining { "learningAssistant": ObjectContaining {
"conversationId": Any<String>, "conversationId": Any<String>,
}, },
"models": Object { "models": {
"courseHomeMeta": Object { "courseHomeMeta": {
"course-v1:edX+DemoX+Demo_Course": Object { "course-v1:edX+DemoX+Demo_Course": {
"canViewCertificate": true, "canViewCertificate": true,
"celebrations": null, "celebrations": null,
"courseAccess": Object { "courseAccess": {
"additionalContextUserMessage": null, "additionalContextUserMessage": null,
"developerMessage": null, "developerMessage": null,
"errorCode": null, "errorCode": null,
@@ -714,33 +714,33 @@ Object {
"org": "edX", "org": "edX",
"originalUserIsStaff": false, "originalUserIsStaff": false,
"start": "2013-02-05T05:00:00Z", "start": "2013-02-05T05:00:00Z",
"tabs": Array [ "tabs": [
Object { {
"slug": "outline", "slug": "outline",
"title": "Course", "title": "Course",
"url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/course/", "url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/course/",
}, },
Object { {
"slug": "discussion", "slug": "discussion",
"title": "Discussion", "title": "Discussion",
"url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/discussion/forum/", "url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/discussion/forum/",
}, },
Object { {
"slug": "wiki", "slug": "wiki",
"title": "Wiki", "title": "Wiki",
"url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/course_wiki", "url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/course_wiki",
}, },
Object { {
"slug": "progress", "slug": "progress",
"title": "Progress", "title": "Progress",
"url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/progress", "url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/progress",
}, },
Object { {
"slug": "instructor", "slug": "instructor",
"title": "Instructor", "title": "Instructor",
"url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/instructor", "url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/instructor",
}, },
Object { {
"slug": "dates", "slug": "dates",
"title": "Dates", "title": "Dates",
"url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/dates", "url": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/dates",
@@ -749,7 +749,7 @@ Object {
"title": "Demonstration Course", "title": "Demonstration Course",
"userTimezone": "UTC", "userTimezone": "UTC",
"username": "MockUser", "username": "MockUser",
"verifiedMode": Object { "verifiedMode": {
"accessExpirationDate": null, "accessExpirationDate": null,
"currency": "USD", "currency": "USD",
"currencySymbol": "$", "currencySymbol": "$",
@@ -759,16 +759,16 @@ Object {
}, },
}, },
}, },
"progress": Object { "progress": {
"course-v1:edX+DemoX+Demo_Course": Object { "course-v1:edX+DemoX+Demo_Course": {
"accessExpiration": null, "accessExpiration": null,
"certificateData": Object {}, "certificateData": {},
"completionSummary": Object { "completionSummary": {
"completeCount": 1, "completeCount": 1,
"incompleteCount": 1, "incompleteCount": 1,
"lockedCount": 0, "lockedCount": 0,
}, },
"courseGrade": Object { "courseGrade": {
"isPassing": true, "isPassing": true,
"letterGrade": "pass", "letterGrade": "pass",
"percent": 1, "percent": 1,
@@ -779,9 +779,9 @@ Object {
"enrollmentMode": "audit", "enrollmentMode": "audit",
"gradesFeatureIsFullyLocked": false, "gradesFeatureIsFullyLocked": false,
"gradesFeatureIsPartiallyLocked": false, "gradesFeatureIsPartiallyLocked": false,
"gradingPolicy": Object { "gradingPolicy": {
"assignmentPolicies": Array [ "assignmentPolicies": [
Object { {
"averageGrade": "1.00", "averageGrade": "1.00",
"numDroppable": 1, "numDroppable": 1,
"shortLabel": "HW", "shortLabel": "HW",
@@ -790,17 +790,17 @@ Object {
"weightedGrade": 1, "weightedGrade": 1,
}, },
], ],
"gradeRange": Object { "gradeRange": {
"pass": 0.75, "pass": 0.75,
}, },
}, },
"hasScheduledContent": false, "hasScheduledContent": false,
"id": "course-v1:edX+DemoX+Demo_Course", "id": "course-v1:edX+DemoX+Demo_Course",
"sectionScores": Array [ "sectionScores": [
Object { {
"displayName": "First section", "displayName": "First section",
"subsections": Array [ "subsections": [
Object { {
"assignmentType": "Homework", "assignmentType": "Homework",
"blockKey": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@12345", "blockKey": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@12345",
"displayName": "First subsection", "displayName": "First subsection",
@@ -809,16 +809,16 @@ Object {
"numPointsEarned": 0, "numPointsEarned": 0,
"numPointsPossible": 3, "numPointsPossible": 3,
"percentGraded": 0, "percentGraded": 0,
"problemScores": Array [ "problemScores": [
Object { {
"earned": 0, "earned": 0,
"possible": 1, "possible": 1,
}, },
Object { {
"earned": 0, "earned": 0,
"possible": 1, "possible": 1,
}, },
Object { {
"earned": 0, "earned": 0,
"possible": 1, "possible": 1,
}, },
@@ -829,18 +829,18 @@ Object {
}, },
], ],
}, },
Object { {
"displayName": "Second section", "displayName": "Second section",
"subsections": Array [ "subsections": [
Object { {
"assignmentType": "Homework", "assignmentType": "Homework",
"displayName": "Second subsection", "displayName": "Second subsection",
"hasGradedAssignment": true, "hasGradedAssignment": true,
"numPointsEarned": 1, "numPointsEarned": 1,
"numPointsPossible": 1, "numPointsPossible": 1,
"percentGraded": 1, "percentGraded": 1,
"problemScores": Array [ "problemScores": [
Object { {
"earned": 1, "earned": 1,
"possible": 1, "possible": 1,
}, },
@@ -854,7 +854,7 @@ Object {
], ],
"studioUrl": "http://studio.edx.org/settings/grading/course-v1:edX+Test+run", "studioUrl": "http://studio.edx.org/settings/grading/course-v1:edX+Test+run",
"userHasPassingGrade": false, "userHasPassingGrade": false,
"verificationData": Object { "verificationData": {
"link": null, "link": null,
"status": "none", "status": "none",
"statusDate": null, "statusDate": null,
@@ -863,16 +863,16 @@ Object {
}, },
}, },
}, },
"plugins": Object {}, "plugins": {},
"recommendations": Object { "recommendations": {
"recommendationsStatus": "loading", "recommendationsStatus": "loading",
}, },
"specialExams": Object { "specialExams": {
"activeAttempt": null, "activeAttempt": null,
"allowProctoringOptOut": false, "allowProctoringOptOut": false,
"apiErrorMsg": "", "apiErrorMsg": "",
"exam": Object { "exam": {
"attempt": Object { "attempt": {
"attempt_code": "", "attempt_code": "",
"attempt_id": null, "attempt_id": null,
"attempt_status": "", "attempt_status": "",
@@ -900,27 +900,27 @@ Object {
"is_active": true, "is_active": true,
"is_practice_exam": false, "is_practice_exam": false,
"is_proctored": false, "is_proctored": false,
"prerequisite_status": Object { "prerequisite_status": {
"are_prerequisites_satisifed": true, "are_prerequisites_satisifed": true,
"declined_prerequisites": Array [], "declined_prerequisites": [],
"failed_prerequisites": Array [], "failed_prerequisites": [],
"pending_prerequisites": Array [], "pending_prerequisites": [],
"satisfied_prerequisites": Array [], "satisfied_prerequisites": [],
}, },
"time_limit_mins": null, "time_limit_mins": null,
"type": "", "type": "",
}, },
"examAccessToken": Object { "examAccessToken": {
"exam_access_token": "", "exam_access_token": "",
"exam_access_token_expiration": "", "exam_access_token_expiration": "",
}, },
"isLoading": true, "isLoading": true,
"proctoringSettings": Object { "proctoringSettings": {
"exam_proctoring_backend": Object { "exam_proctoring_backend": {
"download_url": "", "download_url": "",
"instructions": Array [], "instructions": [],
"name": "", "name": "",
"rules": Object {}, "rules": {},
}, },
"integration_specific_email": "", "integration_specific_email": "",
"learner_notification_from_email": "", "learner_notification_from_email": "",
@@ -931,7 +931,7 @@ Object {
}, },
"timeIsOver": false, "timeIsOver": false,
}, },
"tours": Object { "tours": {
"showCoursewareTour": false, "showCoursewareTour": false,
"showExistingUserCourseHomeTour": false, "showExistingUserCourseHomeTour": false,
"showNewUserCourseHomeModal": false, "showNewUserCourseHomeModal": false,

View File

@@ -32,8 +32,6 @@ celebrationUtils.recordFirstSectionCelebration = recordFirstSectionCelebration;
describe('Course', () => { describe('Course', () => {
let store; let store;
let getItemSpy;
let setItemSpy;
const mockData = { const mockData = {
nextSequenceHandler: () => {}, nextSequenceHandler: () => {},
previousSequenceHandler: () => {}, previousSequenceHandler: () => {},
@@ -52,30 +50,27 @@ describe('Course', () => {
global.innerWidth = breakpoints.extraLarge.minWidth; global.innerWidth = breakpoints.extraLarge.minWidth;
}); });
afterAll(() => {
getItemSpy.mockRestore();
setItemSpy.mockRestore();
});
it('loads learning sequence', async () => { it('loads learning sequence', async () => {
render(<Course {...mockData} />, { wrapWithRouter: true }); render(<Course {...mockData} />, { wrapWithRouter: true });
expect(screen.queryByRole('navigation', { name: 'breadcrumb' })).not.toBeInTheDocument(); expect(screen.queryByRole('navigation', { name: 'breadcrumb' })).not.toBeInTheDocument();
expect(await screen.findByText('Loading learning sequence...')).toBeInTheDocument(); waitFor(() => {
expect(screen.findByText('Loading learning sequence...')).toBeInTheDocument();
expect(screen.queryByRole('alert')).not.toBeInTheDocument(); expect(screen.queryByRole('alert')).not.toBeInTheDocument();
expect(screen.queryByRole('dialog')).not.toBeInTheDocument(); expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: 'Learn About Verified Certificates' })).not.toBeInTheDocument(); expect(screen.queryByRole('button', { name: 'Learn About Verified Certificates' })).not.toBeInTheDocument();
loadUnit(); loadUnit();
await waitFor(() => expect(screen.queryByText('Loading learning sequence...')).not.toBeInTheDocument()); expect(screen.queryByText('Loading learning sequence...')).not.toBeInTheDocument();
const { models } = store.getState(); const { models } = store.getState();
const sequence = models.sequences[mockData.sequenceId]; const sequence = models.sequences[mockData.sequenceId];
const section = models.sections[sequence.sectionId]; const section = models.sections[sequence.sectionId];
const course = models.coursewareMeta[mockData.courseId]; const course = models.coursewareMeta[mockData.courseId];
expect(document.title).toMatch( expect(document.title).toMatch(
`${sequence.title} | ${section.title} | ${course.title} | edX`, `${sequence.title} | ${section.title} | ${course.title} | edX`,
); );
});
}); });
it('removes breadcrumbs when navigation is disabled', async () => { it('removes breadcrumbs when navigation is disabled', async () => {
@@ -114,9 +109,11 @@ describe('Course', () => {
handleNextSectionCelebration(sequenceId, sequenceId, testData.unitId); handleNextSectionCelebration(sequenceId, sequenceId, testData.unitId);
render(<Course {...testData} />, { store: testStore, wrapWithRouter: true }); render(<Course {...testData} />, { store: testStore, wrapWithRouter: true });
const firstSectionCelebrationModal = screen.getByRole('dialog'); waitFor(() => {
expect(firstSectionCelebrationModal).toBeInTheDocument(); const firstSectionCelebrationModal = screen.getByRole('dialog');
expect(getByRole(firstSectionCelebrationModal, 'heading', { name: 'Congratulations!' })).toBeInTheDocument(); expect(firstSectionCelebrationModal).toBeInTheDocument();
expect(getByRole(firstSectionCelebrationModal, 'heading', { name: 'Congratulations!' })).toBeInTheDocument();
});
}); });
it('displays weekly goal celebration modal', async () => { it('displays weekly goal celebration modal', async () => {
@@ -132,40 +129,40 @@ describe('Course', () => {
}; };
render(<Course {...testData} />, { store: testStore, wrapWithRouter: true }); render(<Course {...testData} />, { store: testStore, wrapWithRouter: true });
const weeklyGoalCelebrationModal = screen.getByRole('dialog'); waitFor(() => {
expect(weeklyGoalCelebrationModal).toBeInTheDocument(); const weeklyGoalCelebrationModal = screen.getByRole('dialog');
expect(getByRole(weeklyGoalCelebrationModal, 'heading', { name: 'You met your goal!' })).toBeInTheDocument(); expect(weeklyGoalCelebrationModal).toBeInTheDocument();
expect(getByRole(weeklyGoalCelebrationModal, 'heading', { name: 'You met your goal!' })).toBeInTheDocument();
});
}); });
it('displays notification trigger and toggles active class on click', async () => { it('displays notification trigger and toggles active class on click', async () => {
render(<Course {...mockData} />, { wrapWithRouter: true }); render(<Course {...mockData} />, { wrapWithRouter: true });
const notificationTrigger = screen.getByRole('button', { name: /Show notification tray/i }); waitFor(() => {
expect(notificationTrigger).toBeInTheDocument(); const notificationTrigger = screen.getByRole('button', { name: /Show notification tray/i });
expect(notificationTrigger.parentNode).not.toHaveClass('sidebar-active', { exact: true }); expect(notificationTrigger).toBeInTheDocument();
fireEvent.click(notificationTrigger); expect(notificationTrigger.parentNode).not.toHaveClass('sidebar-active', { exact: true });
expect(notificationTrigger.parentNode).toHaveClass('sidebar-active'); fireEvent.click(notificationTrigger);
expect(notificationTrigger.parentNode).toHaveClass('sidebar-active');
});
}); });
it('handles click to open/close discussions sidebar', async () => { it('handles click to open/close discussions sidebar', async () => {
await setupDiscussionSidebar(); await setupDiscussionSidebar();
await waitFor(() => { waitFor(() => {
expect(screen.getByTestId('sidebar-DISCUSSIONS')).toBeInTheDocument(); expect(screen.getByTestId('sidebar-DISCUSSIONS')).toBeInTheDocument();
expect(screen.getByTestId('sidebar-DISCUSSIONS')).not.toHaveClass('d-none'); expect(screen.getByTestId('sidebar-DISCUSSIONS')).not.toHaveClass('d-none');
});
const discussionsTrigger = await screen.getByRole('button', { name: /Show discussions tray/i }); const discussionsTrigger = screen.getByRole('button', { name: /Show discussions tray/i });
expect(discussionsTrigger).toBeInTheDocument(); expect(discussionsTrigger).toBeInTheDocument();
fireEvent.click(discussionsTrigger); fireEvent.click(discussionsTrigger);
await waitFor(() => {
expect(screen.queryByTestId('sidebar-DISCUSSIONS')).not.toBeInTheDocument(); expect(screen.queryByTestId('sidebar-DISCUSSIONS')).not.toBeInTheDocument();
});
fireEvent.click(discussionsTrigger); fireEvent.click(discussionsTrigger);
await waitFor(() => {
expect(screen.queryByTestId('sidebar-DISCUSSIONS')).toBeInTheDocument(); expect(screen.queryByTestId('sidebar-DISCUSSIONS')).toBeInTheDocument();
}); });
}); });
@@ -186,9 +183,9 @@ describe('Course', () => {
const { rerender } = render(<Course {...testData} />, { store: testStore }); const { rerender } = render(<Course {...testData} />, { store: testStore });
loadUnit(); loadUnit();
await waitFor(() => { waitFor(() => {
expect(screen.getByTestId('sidebar-DISCUSSIONS')).toBeInTheDocument(); expect(screen.findByTestId('sidebar-DISCUSSIONS')).toBeInTheDocument();
expect(screen.getByTestId('sidebar-DISCUSSIONS')).not.toHaveClass('d-none'); expect(screen.findByTestId('sidebar-DISCUSSIONS')).not.toHaveClass('d-none');
}); });
rerender(null); rerender(null);
@@ -196,11 +193,13 @@ describe('Course', () => {
it('handles click to open/close notification tray', async () => { it('handles click to open/close notification tray', async () => {
await setupDiscussionSidebar(); await setupDiscussionSidebar();
const notificationShowButton = await screen.findByRole('button', { name: /Show notification tray/i }); waitFor(() => {
expect(screen.queryByRole('region', { name: /notification tray/i })).not.toBeInTheDocument(); const notificationShowButton = screen.findByRole('button', { name: /Show notification tray/i });
fireEvent.click(notificationShowButton); expect(screen.queryByRole('region', { name: /notification tray/i })).not.toBeInTheDocument();
expect(screen.queryByRole('region', { name: /notification tray/i })).toBeInTheDocument(); fireEvent.click(notificationShowButton);
expect(screen.queryByRole('region', { name: /notification tray/i })).not.toHaveClass('d-none'); expect(screen.queryByRole('region', { name: /notification tray/i })).toBeInTheDocument();
expect(screen.queryByRole('region', { name: /notification tray/i })).not.toHaveClass('d-none');
});
}); });
it('renders course breadcrumbs as expected', async () => { it('renders course breadcrumbs as expected', async () => {
@@ -224,10 +223,14 @@ describe('Course', () => {
render(<Course {...testData} />, { store: testStore, wrapWithRouter: true }); render(<Course {...testData} />, { store: testStore, wrapWithRouter: true });
loadUnit(); loadUnit();
await waitFor(() => expect(screen.queryByText('Loading learning sequence...')).not.toBeInTheDocument()); await waitFor(() => {
expect(screen.queryByText('Loading learning sequence...')).not.toBeInTheDocument();
});
// expect the section and sequence "titles" to be loaded in as breadcrumb labels. // expect the section and sequence "titles" to be loaded in as breadcrumb labels.
expect(screen.getByText(Object.values(models.sections)[0].title)).toBeInTheDocument(); waitFor(() => {
expect(screen.getByText(Object.values(models.sequences)[0].title)).toBeInTheDocument(); expect(screen.findByText(Object.values(models.sections)[0].title)).toBeInTheDocument();
expect(screen.findByText(Object.values(models.sequences)[0].title)).toBeInTheDocument();
});
}); });
it('passes handlers to the sequence', async () => { it('passes handlers to the sequence', async () => {
@@ -256,14 +259,16 @@ describe('Course', () => {
render(<Course {...testData} />, { store: testStore, wrapWithRouter: true }); render(<Course {...testData} />, { store: testStore, wrapWithRouter: true });
loadUnit(); loadUnit();
await waitFor(() => expect(screen.queryByText('Loading learning sequence...')).not.toBeInTheDocument()); waitFor(() => {
screen.getAllByRole('link', { name: /previous/i }).forEach(link => fireEvent.click(link)); expect(screen.queryByText('Loading learning sequence...')).not.toBeInTheDocument();
screen.getAllByRole('link', { name: /next/i }).forEach(link => fireEvent.click(link)); screen.getAllByRole('link', { name: /previous/i }).forEach(link => fireEvent.click(link));
screen.getAllByRole('link', { name: /next/i }).forEach(link => fireEvent.click(link));
// We are in the middle of the sequence, so no // We are in the middle of the sequence, so no
expect(previousSequenceHandler).not.toHaveBeenCalled(); expect(previousSequenceHandler).not.toHaveBeenCalled();
expect(nextSequenceHandler).not.toHaveBeenCalled(); expect(nextSequenceHandler).not.toHaveBeenCalled();
expect(unitNavigationHandler).toHaveBeenCalledTimes(4); expect(unitNavigationHandler).toHaveBeenCalledTimes(4);
});
}); });
describe('Sequence alerts display', () => { describe('Sequence alerts display', () => {
@@ -283,7 +288,7 @@ describe('Course', () => {
sequenceId: sequenceBlocks[0].id, sequenceId: sequenceBlocks[0].id,
}; };
render(<Course {...testData} />, { store: testStore, wrapWithRouter: true }); render(<Course {...testData} />, { store: testStore, wrapWithRouter: true });
await waitFor(() => expect(screen.getByText('Some random banner text to display.')).toBeInTheDocument()); waitFor(() => expect(screen.findByText('Some random banner text to display.')).toBeInTheDocument());
}); });
it('renders Entrance Exam alert with passing score', async () => { it('renders Entrance Exam alert with passing score', async () => {
@@ -317,7 +322,7 @@ describe('Course', () => {
sequenceId: sequenceBlocks[0].id, sequenceId: sequenceBlocks[0].id,
}; };
render(<Course {...testData} />, { store: testStore, wrapWithRouter: true }); render(<Course {...testData} />, { store: testStore, wrapWithRouter: true });
await waitFor(() => expect(screen.getByText('Your score is 100%. You have passed the entrance exam.')).toBeInTheDocument()); waitFor(() => expect(screen.findByText('Your score is 100%. You have passed the entrance exam.')).toBeInTheDocument());
}); });
it('renders Entrance Exam alert with non-passing score', async () => { it('renders Entrance Exam alert with non-passing score', async () => {
@@ -351,7 +356,7 @@ describe('Course', () => {
sequenceId: sequenceBlocks[0].id, sequenceId: sequenceBlocks[0].id,
}; };
render(<Course {...testData} />, { store: testStore, wrapWithRouter: true }); render(<Course {...testData} />, { store: testStore, wrapWithRouter: true });
await waitFor(() => expect(screen.getByText('To access course materials, you must score 70% or higher on this exam. Your current score is 30%.')).toBeInTheDocument()); waitFor(() => expect(screen.findByText('To access course materials, you must score 70% or higher on this exam. Your current score is 30%.')).toBeInTheDocument());
}); });
}); });
@@ -370,7 +375,7 @@ describe('Course', () => {
}; };
render(<Course {...testData} />, { store: testStore, wrapWithRouter: true }); render(<Course {...testData} />, { store: testStore, wrapWithRouter: true });
const chat = screen.queryByTestId(mockChatTestId); const chat = screen.queryByTestId(mockChatTestId);
await expect(chat).toBeInTheDocument(); waitFor(() => expect(chat).toBeInTheDocument());
}); });
it('does not display chat when screen is too narrow (mobile)', async () => { it('does not display chat when screen is too narrow (mobile)', async () => {

View File

@@ -169,7 +169,6 @@ describe('NotificationsWidget', () => {
}); });
it('marks notification as seen 3 seconds later', async () => { it('marks notification as seen 3 seconds later', async () => {
jest.useFakeTimers();
const onNotificationSeen = jest.fn(); const onNotificationSeen = jest.fn();
await fetchAndRender( await fetchAndRender(
<SidebarContext.Provider value={{ <SidebarContext.Provider value={{
@@ -184,7 +183,6 @@ describe('NotificationsWidget', () => {
</SidebarContext.Provider>, </SidebarContext.Provider>,
); );
expect(onNotificationSeen).toHaveBeenCalledTimes(0); expect(onNotificationSeen).toHaveBeenCalledTimes(0);
jest.advanceTimersByTime(3000); await waitFor(() => expect(onNotificationSeen).toHaveBeenCalledTimes(1), { timeout: 3500 });
expect(onNotificationSeen).toHaveBeenCalledTimes(1);
}); });
}); });

View File

@@ -3,7 +3,7 @@ import { Factory } from 'rosie';
import { sendTrackEvent } from '@edx/frontend-platform/analytics'; import { sendTrackEvent } from '@edx/frontend-platform/analytics';
import { breakpoints } from '@openedx/paragon'; import { breakpoints } from '@openedx/paragon';
import { import {
loadUnit, render, screen, fireEvent, waitFor, initializeTestStore, loadUnit, render, screen, fireEvent, waitFor, initializeTestStore, act,
} from '../../../setupTest'; } from '../../../setupTest';
import SidebarContext from '../sidebar/SidebarContext'; import SidebarContext from '../sidebar/SidebarContext';
import Sequence from './Sequence'; import Sequence from './Sequence';
@@ -103,18 +103,20 @@ describe('Sequence', () => {
{ store: testStore, wrapWithRouter: true }, { store: testStore, wrapWithRouter: true },
); );
await waitFor(() => expect(screen.queryByText('Loading locked content messaging...')).toBeInTheDocument()); waitFor(() => {
// `Previous`, `Prerequisite` and `Close Tray` buttons. expect(screen.queryByText('Loading locked content messaging...')).toBeInTheDocument();
expect(screen.getAllByRole('button').length).toEqual(3); // `Previous`, `Prerequisite` and `Close Tray` buttons.
// `Next` button. expect(screen.getAllByRole('button').length).toEqual(3);
expect(screen.getAllByRole('link').length).toEqual(1); // `Next` button.
expect(screen.getAllByRole('link').length).toEqual(1);
expect(screen.getByText('Content Locked')).toBeInTheDocument(); expect(screen.getByText('Content Locked')).toBeInTheDocument();
const unitContainer = container.querySelector('.unit-container'); const unitContainer = container.querySelector('.unit-container');
expect(unitContainer.querySelector('svg')).toHaveClass('fa-lock'); expect(unitContainer.querySelector('svg')).toHaveClass('fa-lock');
expect(screen.getByText(/You must complete the prerequisite/)).toBeInTheDocument(); expect(screen.getByText(/You must complete the prerequisite/)).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Go To Prerequisite Section' })).toBeInTheDocument(); expect(screen.getByRole('button', { name: 'Go To Prerequisite Section' })).toBeInTheDocument();
expect(screen.queryByText('Loading locked content messaging...')).not.toBeInTheDocument(); expect(screen.queryByText('Loading locked content messaging...')).not.toBeInTheDocument();
});
}); });
it('renders correctly for hidden after due content', async () => { it('renders correctly for hidden after due content', async () => {
@@ -157,19 +159,21 @@ describe('Sequence', () => {
it('handles loading unit', async () => { it('handles loading unit', async () => {
render(<SidebarWrapper />, { wrapWithRouter: true }); render(<SidebarWrapper />, { wrapWithRouter: true });
expect(await screen.findByText('Loading learning sequence...')).toBeInTheDocument(); waitFor(() => {
// `Previous`, `Prerequisite` and `Close Tray` buttons. expect(screen.findByText('Loading learning sequence...')).toBeInTheDocument();
expect(screen.getAllByRole('button')).toHaveLength(3); // `Previous`, `Prerequisite` and `Close Tray` buttons.
// Renders `Next` button. expect(screen.getAllByRole('button')).toHaveLength(3);
expect(screen.getAllByRole('link')).toHaveLength(1); // Renders `Next` button.
expect(screen.getAllByRole('link')).toHaveLength(1);
loadUnit(); loadUnit();
await waitFor(() => expect(screen.queryByText('Loading learning sequence...')).not.toBeInTheDocument()); expect(screen.queryByText('Loading learning sequence...')).not.toBeInTheDocument();
// At this point there will be 2 `Previous` and 2 `Next` buttons. // At this point there will be 2 `Previous` and 2 `Next` buttons.
expect(screen.getAllByRole('button', { name: /previous/i }).length).toEqual(2); expect(screen.getAllByRole('button', { name: /previous/i }).length).toEqual(2);
expect(screen.getAllByRole('link', { name: /next/i }).length).toEqual(2); expect(screen.getAllByRole('link', { name: /next/i }).length).toEqual(2);
// Renders two `Next` buttons for top and bottom unit navigations. // Renders two `Next` buttons for top and bottom unit navigations.
expect(screen.getAllByRole('link')).toHaveLength(2); expect(screen.getAllByRole('link')).toHaveLength(2);
});
}); });
describe('sequence and unit navigation buttons', () => { describe('sequence and unit navigation buttons', () => {
@@ -201,31 +205,33 @@ describe('Sequence', () => {
previousSequenceHandler: jest.fn(), previousSequenceHandler: jest.fn(),
}; };
render(<SidebarWrapper overrideData={testData} />, { store: testStore, wrapWithRouter: true }); render(<SidebarWrapper overrideData={testData} />, { store: testStore, wrapWithRouter: true });
expect(await screen.findByText('Loading learning sequence...')).toBeInTheDocument(); waitFor(() => {
expect(screen.findByText('Loading learning sequence...')).toBeInTheDocument();
const sequencePreviousButton = screen.getByRole('link', { name: /previous/i }); const sequencePreviousButton = screen.getByRole('link', { name: /previous/i });
fireEvent.click(sequencePreviousButton); fireEvent.click(sequencePreviousButton);
expect(testData.previousSequenceHandler).toHaveBeenCalledTimes(1); expect(testData.previousSequenceHandler).toHaveBeenCalledTimes(1);
expect(sendTrackEvent).toHaveBeenCalledTimes(1); expect(sendTrackEvent).toHaveBeenCalledTimes(1);
expect(sendTrackEvent).toHaveBeenCalledWith('edx.ui.lms.sequence.previous_selected', { expect(sendTrackEvent).toHaveBeenCalledWith('edx.ui.lms.sequence.previous_selected', {
current_tab: 1, current_tab: 1,
id: testData.unitId, id: testData.unitId,
tab_count: unitBlocks.length, tab_count: unitBlocks.length,
widget_placement: 'top', widget_placement: 'top',
}); });
loadUnit(); loadUnit();
await waitFor(() => expect(screen.queryByText('Loading learning sequence...')).not.toBeInTheDocument()); expect(screen.queryByText('Loading learning sequence...')).not.toBeInTheDocument();
const unitPreviousButton = screen.getAllByRole('link', { name: /previous/i }) const unitPreviousButton = screen.getAllByRole('link', { name: /previous/i })
.filter(button => button !== sequencePreviousButton)[0]; .filter(button => button !== sequencePreviousButton)[0];
fireEvent.click(unitPreviousButton); fireEvent.click(unitPreviousButton);
expect(testData.previousSequenceHandler).toHaveBeenCalledTimes(2); expect(testData.previousSequenceHandler).toHaveBeenCalledTimes(2);
expect(sendTrackEvent).toHaveBeenCalledTimes(2); expect(sendTrackEvent).toHaveBeenCalledTimes(2);
expect(sendTrackEvent).toHaveBeenNthCalledWith(2, 'edx.ui.lms.sequence.previous_selected', { expect(sendTrackEvent).toHaveBeenNthCalledWith(2, 'edx.ui.lms.sequence.previous_selected', {
current_tab: 1, current_tab: 1,
id: testData.unitId, id: testData.unitId,
tab_count: unitBlocks.length, tab_count: unitBlocks.length,
widget_placement: 'bottom', widget_placement: 'bottom',
});
}); });
}); });
@@ -237,30 +243,31 @@ describe('Sequence', () => {
nextSequenceHandler: jest.fn(), nextSequenceHandler: jest.fn(),
}; };
render(<SidebarWrapper overrideData={testData} />, { store: testStore, wrapWithRouter: true }); render(<SidebarWrapper overrideData={testData} />, { store: testStore, wrapWithRouter: true });
expect(await screen.findByText('Loading learning sequence...')).toBeInTheDocument(); waitFor(() => {
expect(screen.findByText('Loading learning sequence...')).toBeInTheDocument();
const sequenceNextButton = screen.getByRole('link', { name: /next/i });
fireEvent.click(sequenceNextButton);
expect(testData.nextSequenceHandler).toHaveBeenCalledTimes(1);
expect(sendTrackEvent).toHaveBeenCalledWith('edx.ui.lms.sequence.next_selected', {
current_tab: unitBlocks.length,
id: testData.unitId,
tab_count: unitBlocks.length,
widget_placement: 'top',
});
const sequenceNextButton = screen.getByRole('link', { name: /next/i }); loadUnit();
fireEvent.click(sequenceNextButton); expect(screen.queryByText('Loading learning sequence...')).not.toBeInTheDocument();
expect(testData.nextSequenceHandler).toHaveBeenCalledTimes(1); const unitNextButton = screen.getAllByRole('link', { name: /next/i })
expect(sendTrackEvent).toHaveBeenCalledWith('edx.ui.lms.sequence.next_selected', { .filter(button => button !== sequenceNextButton)[0];
current_tab: unitBlocks.length, fireEvent.click(unitNextButton);
id: testData.unitId, expect(testData.nextSequenceHandler).toHaveBeenCalledTimes(2);
tab_count: unitBlocks.length, expect(sendTrackEvent).toHaveBeenCalledTimes(2);
widget_placement: 'top', expect(sendTrackEvent).toHaveBeenNthCalledWith(2, 'edx.ui.lms.sequence.next_selected', {
}); current_tab: unitBlocks.length,
id: testData.unitId,
loadUnit(); tab_count: unitBlocks.length,
await waitFor(() => expect(screen.queryByText('Loading learning sequence...')).not.toBeInTheDocument()); widget_placement: 'bottom',
const unitNextButton = screen.getAllByRole('link', { name: /next/i }) });
.filter(button => button !== sequenceNextButton)[0];
fireEvent.click(unitNextButton);
expect(testData.nextSequenceHandler).toHaveBeenCalledTimes(2);
expect(sendTrackEvent).toHaveBeenCalledTimes(2);
expect(sendTrackEvent).toHaveBeenNthCalledWith(2, 'edx.ui.lms.sequence.next_selected', {
current_tab: unitBlocks.length,
id: testData.unitId,
tab_count: unitBlocks.length,
widget_placement: 'bottom',
}); });
}); });
@@ -275,19 +282,22 @@ describe('Sequence', () => {
nextSequenceHandler: jest.fn(), nextSequenceHandler: jest.fn(),
}; };
render(<SidebarWrapper overrideData={testData} />, { store: testStore, wrapWithRouter: true }); render(<SidebarWrapper overrideData={testData} />, { store: testStore, wrapWithRouter: true });
await waitFor(() => expect(screen.queryByText('Loading learning sequence...')).toBeInTheDocument()); waitFor(() => {
expect(screen.findByText('Loading learning sequence...')).toBeInTheDocument();
fireEvent.click(screen.getByRole('link', { name: /previous/i })); fireEvent.click(screen.getByRole('link', { name: /previous/i }));
expect(testData.previousSequenceHandler).not.toHaveBeenCalled(); expect(testData.previousSequenceHandler).not.toHaveBeenCalled();
expect(testData.unitNavigationHandler).toHaveBeenCalledWith(unitBlocks[unitNumber - 1].id); expect(testData.unitNavigationHandler).toHaveBeenCalledWith(unitBlocks[unitNumber - 1].id);
fireEvent.click(screen.getByRole('link', { name: /next/i })); fireEvent.click(screen.getByRole('link', { name: /next/i }));
expect(testData.nextSequenceHandler).not.toHaveBeenCalled(); expect(testData.nextSequenceHandler).not.toHaveBeenCalled();
// As `previousSequenceHandler` and `nextSequenceHandler` are mocked, we aren't really changing the position here. // As `previousSequenceHandler` and `nextSequenceHandler` are mocked,
// Therefore the next unit will still be `the initial one + 1`. // we aren't really changing the position here.
expect(testData.unitNavigationHandler).toHaveBeenNthCalledWith(2, unitBlocks[unitNumber + 1].id); // Therefore the next unit will still be `the initial one + 1`.
expect(testData.unitNavigationHandler).toHaveBeenNthCalledWith(2, unitBlocks[unitNumber + 1].id);
expect(sendTrackEvent).toHaveBeenCalledTimes(2); expect(sendTrackEvent).toHaveBeenCalledTimes(2);
});
}); });
it('handles the `Previous` buttons for the first unit in the first sequence', async () => { it('handles the `Previous` buttons for the first unit in the first sequence', async () => {
@@ -300,13 +310,15 @@ describe('Sequence', () => {
}; };
render(<SidebarWrapper overrideData={testData} />, { store: testStore, wrapWithRouter: true }); render(<SidebarWrapper overrideData={testData} />, { store: testStore, wrapWithRouter: true });
loadUnit(); loadUnit();
await waitFor(() => expect(screen.queryByText('Loading learning sequence...')).not.toBeInTheDocument()); waitFor(() => {
expect(screen.queryByText('Loading learning sequence...')).not.toBeInTheDocument();
screen.getAllByRole('button', { name: /previous/i }).forEach(button => fireEvent.click(button)); screen.getAllByRole('button', { name: /previous/i }).forEach(button => fireEvent.click(button));
expect(testData.previousSequenceHandler).not.toHaveBeenCalled(); expect(testData.previousSequenceHandler).not.toHaveBeenCalled();
expect(testData.unitNavigationHandler).not.toHaveBeenCalled(); expect(testData.unitNavigationHandler).not.toHaveBeenCalled();
expect(sendTrackEvent).not.toHaveBeenCalled(); expect(sendTrackEvent).not.toHaveBeenCalled();
});
}); });
it('handles the `Next` buttons for the last unit in the last sequence', async () => { it('handles the `Next` buttons for the last unit in the last sequence', async () => {
@@ -319,13 +331,15 @@ describe('Sequence', () => {
}; };
render(<SidebarWrapper overrideData={testData} />, { store: testStore, wrapWithRouter: true }); render(<SidebarWrapper overrideData={testData} />, { store: testStore, wrapWithRouter: true });
loadUnit(); loadUnit();
await waitFor(() => expect(screen.queryByText('Loading learning sequence...')).not.toBeInTheDocument()); waitFor(() => {
expect(screen.queryByText('Loading learning sequence...')).not.toBeInTheDocument();
screen.getAllByRole('button', { name: /next/i }).forEach(button => fireEvent.click(button)); screen.getAllByRole('button', { name: /next/i }).forEach(button => fireEvent.click(button));
expect(testData.nextSequenceHandler).not.toHaveBeenCalled(); expect(testData.nextSequenceHandler).not.toHaveBeenCalled();
expect(testData.unitNavigationHandler).not.toHaveBeenCalled(); expect(testData.unitNavigationHandler).not.toHaveBeenCalled();
expect(sendTrackEvent).not.toHaveBeenCalled(); expect(sendTrackEvent).not.toHaveBeenCalled();
});
}); });
it('handles the navigation buttons for empty sequence', async () => { it('handles the navigation buttons for empty sequence', async () => {
@@ -365,39 +379,42 @@ describe('Sequence', () => {
render(<SidebarWrapper overrideData={testData} />, { store: innerTestStore, wrapWithRouter: true }); render(<SidebarWrapper overrideData={testData} />, { store: innerTestStore, wrapWithRouter: true });
loadUnit(); loadUnit();
await waitFor(() => expect(screen.queryByText('Loading learning sequence...')).not.toBeInTheDocument());
screen.getAllByRole('link', { name: /previous/i }).forEach(button => fireEvent.click(button)); waitFor(() => {
expect(testData.previousSequenceHandler).toHaveBeenCalledTimes(2); expect(screen.queryByText('Loading learning sequence...')).not.toBeInTheDocument();
expect(testData.unitNavigationHandler).toHaveBeenCalledTimes(2);
screen.getAllByRole('link', { name: /next/i }).forEach(button => fireEvent.click(button)); screen.getAllByRole('link', { name: /previous/i }).forEach(button => fireEvent.click(button));
expect(testData.nextSequenceHandler).toHaveBeenCalledTimes(2); expect(testData.previousSequenceHandler).toHaveBeenCalledTimes(2);
expect(testData.unitNavigationHandler).toHaveBeenCalledTimes(4); expect(testData.unitNavigationHandler).toHaveBeenCalledTimes(2);
expect(sendTrackEvent).toHaveBeenNthCalledWith(1, 'edx.ui.lms.sequence.previous_selected', { screen.getAllByRole('link', { name: /next/i }).forEach(button => fireEvent.click(button));
current_tab: 1, expect(testData.nextSequenceHandler).toHaveBeenCalledTimes(2);
id: testData.unitId, expect(testData.unitNavigationHandler).toHaveBeenCalledTimes(4);
tab_count: 0,
widget_placement: 'top', expect(sendTrackEvent).toHaveBeenNthCalledWith(1, 'edx.ui.lms.sequence.previous_selected', {
}); current_tab: 1,
expect(sendTrackEvent).toHaveBeenNthCalledWith(2, 'edx.ui.lms.sequence.previous_selected', { id: testData.unitId,
current_tab: 1, tab_count: 0,
id: testData.unitId, widget_placement: 'top',
tab_count: 0, });
widget_placement: 'bottom', expect(sendTrackEvent).toHaveBeenNthCalledWith(2, 'edx.ui.lms.sequence.previous_selected', {
}); current_tab: 1,
expect(sendTrackEvent).toHaveBeenNthCalledWith(3, 'edx.ui.lms.sequence.next_selected', { id: testData.unitId,
current_tab: 1, tab_count: 0,
id: testData.unitId, widget_placement: 'bottom',
tab_count: 0, });
widget_placement: 'top', expect(sendTrackEvent).toHaveBeenNthCalledWith(3, 'edx.ui.lms.sequence.next_selected', {
}); current_tab: 1,
expect(sendTrackEvent).toHaveBeenNthCalledWith(4, 'edx.ui.lms.sequence.next_selected', { id: testData.unitId,
current_tab: 1, tab_count: 0,
id: testData.unitId, widget_placement: 'top',
tab_count: 0, });
widget_placement: 'bottom', expect(sendTrackEvent).toHaveBeenNthCalledWith(4, 'edx.ui.lms.sequence.next_selected', {
current_tab: 1,
id: testData.unitId,
tab_count: 0,
widget_placement: 'bottom',
});
}); });
}); });
@@ -412,16 +429,17 @@ describe('Sequence', () => {
unitNavigationHandler: jest.fn(), unitNavigationHandler: jest.fn(),
}; };
render(<SidebarWrapper overrideData={testData} />, { store: testStore, wrapWithRouter: true }); render(<SidebarWrapper overrideData={testData} />, { store: testStore, wrapWithRouter: true });
await waitFor(() => expect(screen.queryByText('Loading learning sequence...')).toBeInTheDocument()); waitFor(() => {
expect(screen.findByText('Loading learning sequence...')).toBeInTheDocument();
fireEvent.click(screen.getByRole('link', { name: targetUnit.display_name })); fireEvent.click(screen.getByRole('link', { name: targetUnit.display_name }));
expect(testData.unitNavigationHandler).toHaveBeenCalledWith(targetUnit.id); expect(testData.unitNavigationHandler).toHaveBeenCalledWith(targetUnit.id);
expect(sendTrackEvent).toHaveBeenCalledWith('edx.ui.lms.sequence.tab_selected', { expect(sendTrackEvent).toHaveBeenCalledWith('edx.ui.lms.sequence.tab_selected', {
current_tab: currentTabNumber, current_tab: currentTabNumber,
id: testData.unitId, id: testData.unitId,
target_tab: targetUnitNumber, target_tab: targetUnitNumber,
tab_count: unitBlocks.length, tab_count: unitBlocks.length,
widget_placement: 'top', widget_placement: 'top',
});
}); });
}); });
}); });
@@ -429,15 +447,17 @@ describe('Sequence', () => {
describe('notification feature', () => { describe('notification feature', () => {
it('renders notification tray in sequence', async () => { it('renders notification tray in sequence', async () => {
render(<SidebarWrapper contextValue={{ courseId: mockData.courseId, currentSidebar: 'NOTIFICATIONS', toggleSidebar: () => null }} />, { wrapWithRouter: true }); render(<SidebarWrapper contextValue={{ courseId: mockData.courseId, currentSidebar: 'NOTIFICATIONS', toggleSidebar: () => null }} />, { wrapWithRouter: true });
expect(await screen.findByText('Notifications')).toBeInTheDocument(); waitFor(async () => expect(await screen.findByText('Notifications')).toBeInTheDocument());
}); });
it('handles click on notification tray close button', async () => { it('handles click on notification tray close button', async () => {
const toggleNotificationTray = jest.fn(); const toggleNotificationTray = jest.fn();
render(<SidebarWrapper contextValue={{ courseId: mockData.courseId, currentSidebar: 'NOTIFICATIONS', toggleSidebar: toggleNotificationTray }} />, { wrapWithRouter: true }); render(<SidebarWrapper contextValue={{ courseId: mockData.courseId, currentSidebar: 'NOTIFICATIONS', toggleSidebar: toggleNotificationTray }} />, { wrapWithRouter: true });
const notificationCloseIconButton = await screen.findByRole('button', { name: /Close notification tray/i }); act(async () => {
fireEvent.click(notificationCloseIconButton); const notificationCloseIconButton = await screen.findByRole('button', { name: /Close notification tray/i });
expect(toggleNotificationTray).toHaveBeenCalled(); fireEvent.click(notificationCloseIconButton);
expect(toggleNotificationTray).toHaveBeenCalled();
});
}); });
it('does not render notification tray in sequence by default if in responsive view', async () => { it('does not render notification tray in sequence by default if in responsive view', async () => {

View File

@@ -129,24 +129,6 @@ describe('NotificationTray', () => {
.toBeInTheDocument(); .toBeInTheDocument();
}); });
it('marks notification as seen 3 seconds later', async () => {
jest.useFakeTimers();
const onNotificationSeen = jest.fn();
await fetchAndRender(
<SidebarContext.Provider value={{
currentSidebar: ID,
courseId,
onNotificationSeen,
}}
>
<NotificationTray />
</SidebarContext.Provider>,
);
expect(onNotificationSeen).toHaveBeenCalledTimes(0);
jest.advanceTimersByTime(3000);
expect(onNotificationSeen).toHaveBeenCalledTimes(1);
});
it('renders notification tray with full screen "Back to course" at responsive view', async () => { it('renders notification tray with full screen "Back to course" at responsive view', async () => {
global.innerWidth = breakpoints.medium.maxWidth; global.innerWidth = breakpoints.medium.maxWidth;
const toggleNotificationTray = jest.fn(); const toggleNotificationTray = jest.fn();
@@ -170,4 +152,20 @@ describe('NotificationTray', () => {
expect(toggleNotificationTray) expect(toggleNotificationTray)
.toHaveBeenCalledTimes(1); .toHaveBeenCalledTimes(1);
}); });
it('marks notification as seen 3 seconds later', async () => {
const onNotificationSeen = jest.fn();
await fetchAndRender(
<SidebarContext.Provider value={{
currentSidebar: ID,
courseId,
onNotificationSeen,
}}
>
<NotificationTray />
</SidebarContext.Provider>,
);
expect(onNotificationSeen).toHaveBeenCalledTimes(0);
await waitFor(() => expect(onNotificationSeen).toHaveBeenCalledTimes(1), { timeout: 3500 });
});
}); });