Compare commits

...

74 Commits

Author SHA1 Message Date
Brian Smith
4825c3d68c feat: import FooterSlot from component package instead of slot package (#414) 2025-04-24 12:33:01 -04:00
renovate[bot]
4e27a35e10 fix(deps): update dependency @edx/frontend-component-header to v6.4.0 (#415)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-23 20:17:57 +00:00
Stanislav Lunyachek
ad0e2af8c8 feat: ORA visual improvements 2025-04-16 16:10:15 +03:30
Brian Smith
d03e7c40d8 feat: upgrade to react 18 (#406) 2025-04-09 15:22:36 -04:00
Régis Behmo
5a7063c123 chore: remove husky 🪓🐶 (#405) 2025-04-09 13:56:30 +00:00
Régis Behmo
9348c4bb4c feat: lighter build by avoiding full lodash import
Incorrect lodash imports are causing MFEs to import the entire lodash
library.
2025-04-03 12:42:31 +03:30
Brian Smith
5c5ff1190b chore(deps): update @openedx dependencies to versions that support React 18 (#399) 2025-03-27 16:17:00 -04:00
Jansen Kantor
7aee8562a8 Merge pull request #390 from openedx/jkantor/conflictError
fix: error code expecting wrong data shape
2025-03-05 14:49:36 -05:00
Jansen Kantor
ebca59a38f Merge branch 'master' into jkantor/conflictError 2025-03-05 14:42:07 -05:00
salman2013
f87d521bc0 chore: update catalog-info file for release data 2025-02-20 19:07:39 +03:30
Stanislav Lunyachek
5280cef554 feat: Add header styles inclusion 2025-02-20 18:19:39 +03:30
Stanislav Lunyachek
08430571ed fix: Fix for the Paragon modal shadow, which prevents clicking on an element on the grading page 2025-02-19 18:45:39 +03:30
Jansen Kantor
3de6821c5d Merge branch 'master' into jkantor/conflictError 2025-01-14 10:45:33 -05:00
Paulo Viadanna
fb06133a27 fix: enable scroll in grading modal 2025-01-14 19:00:42 +03:30
Jansen Kantor
12f1c72b7e Merge branch 'master' into jkantor/conflictError 2025-01-10 14:11:49 -05:00
Jansen Kantor
ca8d08c8a0 fixup! fix: error code expecting wrong data shape 2025-01-10 14:08:32 -05:00
Jansen Kantor
30a4ca17ac fix: error code expecting wrong data shape 2025-01-10 14:07:01 -05:00
Awais Ansari
25d76c0e59 fix: updated notifications preferences url (#389)
* fix: updated notifiations preferences url

* fix: updated test cases
2025-01-10 17:09:14 +05:00
Emad Rad
6527f505f1 chore: npm publish action removed (#366)
We don't push MFEs to the npm registry.
Achieves part of https://github.com/openedx/public-engineering/issues/284
2024-12-18 13:48:18 -05:00
milad-emami
400950cff8 feat: update react-pdf to v7 and fix worker configuration 2024-12-18 13:25:38 +03:30
Adolfo R. Brandes
0219f5cd25 chore: remove extraneous file
Remove a file that was previously added by mistake.
2024-12-06 10:54:46 -03:00
Adolfo R. Brandes
fdcab456e8 fix: broken download tests
Declaring `browserslist` in package.json exposed a bug in the
download.js tests that wasn't causing failures before (but arguably,
should): one can't use arrow functions to mock constructors because
calling `new` on them doesn't work.  See the NOTE under:

https://jestjs.io/docs/es6-class-mocks#-module-factory-function-must-return-a-function
2024-12-06 10:54:46 -03:00
Adolfo R. Brandes
5283e7c7c6 fix: Use browserslist-config
We were installing browserslist-config but not declaring it.  This had
the effect that webpack - and likely others - were not using it.
2024-12-06 10:54:46 -03:00
Dima Alipov
e39533c56a fix: incorrect message for locking 2024-11-30 15:22:18 +03:30
milad-emami
212014fed9 chore: update redux-devtools-extension to @redux-devtools/extension@3.0.0 2024-11-25 12:14:34 +03:30
milad-emami
9600301a62 chore(deps): update dependency redux-mock-store to 1.5.5
Updates redux-mock-store to version 1.5.5 in both package.json and package-lock.json to ensure dependency consistency
2024-11-25 12:08:07 +03:30
Feanil Patel
1d5f64e1db docs: Update catalog-info.yaml
Correct the owner.
2024-11-20 13:14:08 -05:00
milad-emami
f5208c58aa fix: remove fixed height from review modal body
Remove height:100% property from modal body content to prevent content from sticking to bottom of page and allow proper spacing
2024-11-20 17:38:01 +03:30
milad-emami
c15680cb8c fix: prevent radio criterion shrinking and improve alignment
- Add flexShrink: 0 style to prevent radio button compression
- Add align-items-center class for better vertical alignment
2024-11-20 17:36:46 +03:30
Diana Catalina Olarte
76f41439e9 fix: apply getPath to PUBLIC_PATH to allow use with CDN 2024-11-19 16:19:19 +03:30
Feanil Patel
4581cf8698 Merge pull request #371 from CodeWithEmad/chore/catalog-info
chore: owner changed
2024-11-12 09:01:55 -05:00
Emad Rad
95fa32eaaa chore: owner changed 2024-11-09 11:25:09 +03:30
Asad Ali
1f729becbe feat: remove CTA (#347) 2024-11-05 12:00:31 -05:00
Arslan Ashraf
7ad1df8bd0 test: Remove support for Node 18 (#365)
Co-authored-by: Muhammad Anas <muhammad.anas@arbisoft.com>
2024-11-04 13:46:17 -05:00
Asad Ali
c9d0abe968 fix: convert notification banner to text if accounts url is not set (#362)
* fix: convert banner to text if ACCOUNT_SETTINGS_URL is not set

* refactor: refactoring

* refactor: rename notificationsBannerLinkMessage to notificationsBannerPreferencesCenterMessage

* refactor: remove lodash usage

* refactor: remove lodash usage
2024-11-04 12:22:50 -05:00
Brian Smith
91e33748ab feat(deps): update header to 5.6.0 (#363) 2024-10-22 19:19:55 -04:00
Feanil Patel
8809f4cf16 Merge pull request #353 from openedx/feanil/ubuntu_upgrade
build: Switch to ubuntu-latest for builds
2024-09-20 10:28:36 -04:00
Feanil Patel
7482765aa4 build: Switch to ubuntu-latest for builds
This code does not have any dependencies that are specific to any specific
version of ubuntu.  So instead of testing on a specific version and then needing
to do work to keep the versions up-to-date, we switch to the ubuntu-latest
target which should be sufficient for testing purposes.

This work is being done as a part of https://github.com/openedx/platform-roadmap/issues/377

closes https://github.com/openedx/frontend-app-ora-grading/issues/345
2024-09-20 10:28:31 -04:00
Kristin Aoki
7003b6102d Merge pull request #354 from openedx/jkantor/headingMessage
fix: incorrect key breaks page
2024-09-13 09:19:34 -04:00
Jansen Kantor
d608daccb1 Merge branch 'master' into jkantor/headingMessage 2024-09-12 16:03:50 -04:00
Jansen Kantor
2208737a69 fix: incorrect key crashes page 2024-09-12 16:01:02 -04:00
Muhammad Anas
567a020061 build: Upgrade to Node 20 (#349)
* build: Upgrade to Node 20

* refactor: updated package-lock

* refactor: updated the lockfile version workflow
2024-09-06 12:23:49 -04:00
Muhammad Anas
c5d9bfb2f6 test: Add Node 20 to CI matrix (#348)
* test: Add Node 20 to CI matrix

* fix: pinning node 18 verson
2024-09-03 14:30:54 -04:00
Feanil Patel
f433d33f9d Merge pull request #328 from openedx/bilalqamar95/jest-v29-upgrade
feat: updated frontend-build & frontend-platform major versions
2024-08-07 10:01:12 -04:00
Bilal Qamar
c0816e0818 Merge branch 'master' into bilalqamar95/jest-v29-upgrade 2024-07-30 14:12:20 +05:00
Feanil Patel
c83e86bf06 Merge pull request #343 from openedx/feanil/update_maintainer
docs: Make it clear that this is unmaintained.
2024-07-24 10:52:01 -04:00
Feanil Patel
b6f1a9739e docs: Make it clear that this is unmaintained. 2024-07-19 16:06:30 -04:00
Bilal Qamar
f2b6cd4cac Merge branch 'master' into bilalqamar95/jest-v29-upgrade 2024-07-04 16:02:16 +05:00
Adolfo R. Brandes
3092bd3980 build: Update codecov and use token (#342)
Update codecov to the latest version and start using the org-wide token for uploads.

See https://github.com/openedx/wg-frontend/issues/179
2024-06-17 12:14:02 -03:00
Bilal Qamar
20dc736278 refactor: installed jest-environment-jsdom package, updated package-lock 2024-06-03 16:08:02 +05:00
Bilal Qamar
d72beeb2d4 Merge branch 'master' of github.com:openedx/frontend-app-ora-grading into bilalqamar95/jest-v29-upgrade 2024-06-03 16:06:23 +05:00
Brian Smith
64b57df976 feat: use frontend-plugin-framework to provide a FooterSlot 2024-05-23 11:28:25 -03:00
Bilal Qamar
346b371ba2 Merge branch 'master' of github.com:openedx/frontend-app-ora-grading into bilalqamar95/jest-v29-upgrade 2024-05-16 16:04:53 +05:00
Bilal Qamar
650d708a1c refactor: major version upgrade for react-unit-test-utils 2024-05-16 16:04:13 +05:00
Awais Ansari
1d924b4812 Merge pull request #329 from openedx/aansari/INF-1375
feat: added info banner for ORA notifications
2024-04-30 21:09:29 +05:00
Awais Ansari
31ed9410a4 test: added test cases for NotificationsBanner 2024-04-30 20:07:23 +05:00
Awais Ansari
0ba3cac532 feat: added info banner for ORA notifications 2024-04-30 19:59:26 +05:00
Bilal Qamar
b23effdb7f feat: updated frontend-build & frontend-platform major versions 2024-04-24 13:54:40 +05:00
Bilal Qamar
5bcb6fe6f3 refactor: updated snapshots for failing tests 2024-04-15 15:44:02 +05:00
Bilal Qamar
a67f201f4d feat: updated frontend-build major version, bumps jest to v29 2024-04-15 15:43:48 +05:00
alipov_d
9cfab58663 fix: request error for empty user list responses 2024-04-03 15:25:01 -03:00
Samir Sabri
59a7d0751b feat!: remove Transifex calls for OEP-58 2024-03-18 15:01:30 -04:00
Jeremy Ristau
9d673e803e Merge pull request #320 from openedx/ownership-update
chore: update catalog-info owner
2024-03-15 12:54:11 -04:00
Jeremy Ristau
8438915f72 fix: use correct yaml 2024-03-15 09:25:01 -04:00
Jeremy Ristau
cc6dd20f12 chore: update catalog-info owner
Continuing maintainership updates for 2U 2024.
2024-03-11 21:34:25 -04:00
Mashal Malik
f67ffdd480 refactor: replace @edx/paragon and @edx/frontend-build (#294)
* refactor: replace @edx/paragon and @edx/frontend-build

* refactor: updated edx packages

* fix: fixed failing test cases by remmoving paragon mock

* fix: updated lock file to fix build issues

---------

Co-authored-by: mashal-m <mashal.malik@arbisoft.com>
Co-authored-by: Bilal Qamar <59555732+BilalQamar95@users.noreply.github.com>
Co-authored-by: Muhammad Abdullah Waheed <abdullah.waheed@arbisoft.com>
2024-02-28 13:04:23 -03:00
renovate[bot]
836df49829 fix(deps): update dependency axios to ^0.28.0 [security] 2024-02-21 22:18:09 -05:00
Syed Ali Abbas Zaidi
5bed90b659 feat: migrate enzyme to edx/react-unit-test-utils (#295)
* feat: migrate enzyme to edx/react-unit-test-utils

* refactor: remove shallowWrapper usage

* refactor: remove unnecessary _instance usage
2024-02-10 00:35:02 +05:00
Feanil Patel
3b39c79fbf Merge pull request #262 from openedx/abdullahwaheed/react-intl-to-formatjs
feat: babel-plugin-react-intl to babel-plugin-formatjs migration
2024-02-08 14:58:54 -05:00
Abdullah Waheed
df7a189bcd fix: upgraded frontend-build to fix security issue 2024-02-08 14:43:21 -05:00
Abdullah Waheed
08c51b6492 fix: reverted install package functionality 2024-02-08 14:43:21 -05:00
Abdullah Waheed
3bb3d90f3a feat: babel-plugin-react-intl to babel-plugin-formatjs migration 2024-02-08 14:43:19 -05:00
Feanil Patel
2f48cc5767 Merge pull request #247 from openedx/mashal-m/update_lockfile
refactor: updated lock file version check to use new workflow
2024-02-08 14:19:55 -05:00
mashal-m
ea43ebb031 refactor: update lock file version 2024-02-08 14:10:50 -05:00
190 changed files with 10272 additions and 17442 deletions

1
.env
View File

@@ -32,3 +32,4 @@ ENTERPRISE_MARKETING_UTM_CAMPAIGN=''
ENTERPRISE_MARKETING_FOOTER_UTM_MEDIUM=''
APP_ID=''
MFE_CONFIG_API_URL=''
ACCOUNT_SETTINGS_URL=''

View File

@@ -7,7 +7,6 @@ LOGOUT_URL='http://localhost:18000/logout'
LOGO_URL=https://edx-cdn.org/v3/default/logo.svg
LOGO_TRADEMARK_URL=https://edx-cdn.org/v3/default/logo-trademark.svg
LOGO_WHITE_URL=https://edx-cdn.org/v3/default/logo-white.svg
LOGO_POWERED_BY_OPEN_EDX_URL_SVG=https://edx-cdn.org/v3/stage/open-edx-tag.svg
FAVICON_URL=https://edx-cdn.org/v3/default/favicon.ico
CSRF_TOKEN_API_PATH='/csrf/api/v1/token'
REFRESH_ACCESS_TOKEN_ENDPOINT='http://localhost:18000/login_refresh'
@@ -38,3 +37,4 @@ ENTERPRISE_MARKETING_UTM_CAMPAIGN='example.com Referral'
ENTERPRISE_MARKETING_FOOTER_UTM_MEDIUM='Footer'
APP_ID=''
MFE_CONFIG_API_URL=''
ACCOUNT_SETTINGS_URL=http://localhost:1997

View File

@@ -7,7 +7,6 @@ LOGOUT_URL='http://localhost:18000/logout'
LOGO_URL=https://edx-cdn.org/v3/default/logo.svg
LOGO_TRADEMARK_URL=https://edx-cdn.org/v3/default/logo-trademark.svg
LOGO_WHITE_URL=https://edx-cdn.org/v3/default/logo-white.svg
LOGO_POWERED_BY_OPEN_EDX_URL_SVG=https://edx-cdn.org/v3/stage/open-edx-tag.svg
FAVICON_URL=https://edx-cdn.org/v3/default/favicon.ico
CSRF_TOKEN_API_PATH='/csrf/api/v1/token'
REFRESH_ACCESS_TOKEN_ENDPOINT='http://localhost:18000/login_refresh'
@@ -36,3 +35,4 @@ ENTERPRISE_MARKETING_URL='http://example.com'
ENTERPRISE_MARKETING_UTM_SOURCE='example.com'
ENTERPRISE_MARKETING_UTM_CAMPAIGN='example.com Referral'
ENTERPRISE_MARKETING_FOOTER_UTM_MEDIUM='Footer'
ACCOUNT_SETTINGS_URL=http://localhost:1997

View File

@@ -1,4 +1,5 @@
const { createConfig } = require('@edx/frontend-build');
// eslint-disable-next-line import/no-extraneous-dependencies
const { createConfig } = require('@openedx/frontend-build');
const config = createConfig('eslint', {
rules: {

View File

@@ -10,17 +10,18 @@ on:
jobs:
tests:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Nodejs Env
run: echo "NODE_VER=`cat .nvmrc`" >> $GITHUB_ENV
- name: Setup Nodejs
uses: actions/setup-node@v3
uses: actions/setup-node@v4
# Because of node 18 bug (https://github.com/nodejs/node/issues/47563), Pinning node version 18.15 until the next release of node
with:
node-version: 18.15
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm ci
@@ -38,7 +39,10 @@ jobs:
run: npm run build
- name: Run Coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
- name: Send failure notification
if: ${{ failure() }}

View File

@@ -1,32 +0,0 @@
name: Release CI
on:
push:
tags:
- "*"
jobs:
release:
name: Release
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 12
- name: Install dependencies
run: npm ci
- name: Create Build
run: npm run build
- name: Release Package
env:
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }}
run: npm semantic-release

2
.gitignore vendored
View File

@@ -25,3 +25,5 @@ module.config.js
### transifex ###
src/i18n/transifex_input.json
temp
src/i18n/messages

View File

@@ -1,4 +0,0 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npm run lint

2
.nvmrc
View File

@@ -1 +1 @@
18.19
20

View File

@@ -1,27 +0,0 @@
{
"branch": "master",
"tagFormat": "v${version}",
"verifyConditions": [
"@semantic-release/npm",
{
"path": "@semantic-release/github",
"assets": {
"path": "dist/*"
}
}
],
"analyzeCommits": "@semantic-release/commit-analyzer",
"generateNotes": "@semantic-release/release-notes-generator",
"prepare": "@semantic-release/npm",
"publish": [
"@semantic-release/npm",
{
"path": "@semantic-release/github",
"assets": {
"path": "dist/*"
}
}
],
"success": [],
"fail": []
}

View File

@@ -1,9 +0,0 @@
[main]
host = https://www.transifex.com
[o:open-edx:p:edx-platform:r:frontend-app-ora-grading]
file_filter = src/i18n/messages/<lang>.json
source_file = src/i18n/transifex_input.json
source_lang = en
type = KEYVALUEJSON

View File

@@ -2,16 +2,13 @@ npm-install-%: ## install specified % npm package
npm install $* --save-dev
git add package.json
transifex_resource = frontend-app-ora-grading
transifex_langs = "ar,de_DE,es_419,fa_IR,fr,fr_CA,hi,it_IT,pt_PT,uk,ru,zh_CN"
intl_imports = ./node_modules/.bin/intl-imports.js
transifex_utils = ./node_modules/.bin/transifex-utils.js
i18n = ./src/i18n
transifex_input = $(i18n)/transifex_input.json
# This directory must match .babelrc .
transifex_temp = ./temp/babel-plugin-react-intl
transifex_temp = ./temp/babel-plugin-formatjs
NPM_TESTS=build i18n_extract lint test
@@ -43,23 +40,6 @@ detect_changed_source_translations:
# Checking for changed translations...
git diff --exit-code $(i18n)
# Pushes translations to Transifex. You must run make extract_translations first.
push_translations:
# Pushing strings to Transifex...
tx push -s
# Fetching hashes from Transifex...
./node_modules/@edx/reactifex/bash_scripts/get_hashed_strings_v3.sh
# Writing out comments to file...
$(transifex_utils) $(transifex_temp) --comments --v3-scripts-path
# Pushing comments to Transifex...
./node_modules/@edx/reactifex/bash_scripts/put_comments_v3.sh
ifeq ($(OPENEDX_ATLAS_PULL),)
# Pulls translations from Transifex.
pull_translations:
tx pull -t -f --mode reviewed --languages=$(transifex_langs)
else
# Experimental: OEP-58 Pulls translations using atlas
pull_translations:
rm -rf src/i18n/messages
mkdir src/i18n/messages
@@ -72,7 +52,6 @@ pull_translations:
translations/frontend-app-ora-grading/src/i18n/messages:frontend-app-ora-grading
$(intl_imports) frontend-component-footer frontend-component-header frontend-platform paragon frontend-app-ora-grading
endif
# This target is used by CI.
validate-no-uncommitted-package-lock-changes:

View File

@@ -39,6 +39,12 @@ to the `relevant tutor-mfe documentation`_ to get started using it.
.. _relevant tutor-mfe documentation: https://github.com/overhangio/tutor-mfe#mfe-development
Plugins
=======
This MFE can be customized using `Frontend Plugin Framework <https://github.com/openedx/frontend-plugin-framework>`_.
The parts of this MFE that can be customized in that manner are documented `here </src/plugin-slots>`_.
Developing
==========

View File

@@ -13,7 +13,9 @@ metadata:
- url: "https://ora-grading.stage.edx.org"
title: "Stage Site"
icon: "Web"
annotations:
openedx.org/release: "master"
spec:
owner: group:content-aurora
owner: "user:codewithemad"
type: 'website'
lifecycle: 'production'

View File

@@ -1,4 +1,4 @@
const { createConfig } = require('@edx/frontend-build');
const { createConfig } = require('@openedx/frontend-build');
module.exports = createConfig('jest', {
setupFilesAfterEnv: [
@@ -6,9 +6,6 @@ module.exports = createConfig('jest', {
'<rootDir>/src/setupTest.js',
],
modulePaths: ['<rootDir>/src/'],
snapshotSerializers: [
'enzyme-to-json/serializer',
],
coveragePathIgnorePatterns: [
'src/segment.js',
'src/postcss.config.js',
@@ -18,8 +15,4 @@ module.exports = createConfig('jest', {
],
testTimeout: 120000,
testEnvironment: 'jsdom',
moduleNameMapper: {
'^@openedx/paragon$': '<rootDir>/mockParagon.js',
'^@openedx/paragon/(.*)$': '<rootDir>/mockParagon.js',
},
});

View File

@@ -1 +0,0 @@
module.exports = {};

View File

@@ -1,9 +0,0 @@
# This file describes this Open edX repo, as described in OEP-2:
# http://open-edx-proposals.readthedocs.io/en/latest/oeps/oep-0002.html#specification
tags:
- frontend-app
- masters
oeps:
oep-2: true # Repository metadata
openedx-release: {ref: master}

23946
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,16 +6,19 @@
"type": "git",
"url": "git+https://github.com/edx/frontend-app-ora-grading.git"
},
"browserslist": [
"extends @edx/browserslist-config"
],
"scripts": {
"build": "fedx-scripts webpack",
"i18n_extract": "BABEL_ENV=i18n fedx-scripts babel src --quiet > /dev/null",
"i18n_extract": "fedx-scripts formatjs extract",
"lint": "fedx-scripts eslint --ext .jsx,.js src/",
"lint-fix": "fedx-scripts eslint --fix --ext .jsx,.js src/",
"semantic-release": "semantic-release",
"start": "fedx-scripts webpack-dev-server --progress",
"dev": "PUBLIC_PATH=/ora-grading/ MFE_CONFIG_API_URL='http://localhost:8000/api/mfe_config/v1' fedx-scripts webpack-dev-server --progress --host apps.local.openedx.io",
"test": "TZ=GMT fedx-scripts jest --coverage --passWithNoTests",
"watch-tests": "jest --watch",
"prepare": "husky install"
"watch-tests": "jest --watch"
},
"author": "edX",
"license": "AGPL-3.0",
@@ -25,26 +28,25 @@
},
"dependencies": {
"@edx/brand": "npm:@openedx/brand-openedx@^1.2.2",
"@edx/frontend-component-footer": "12.7.1",
"@edx/frontend-component-header": "4.11.1",
"@edx/frontend-platform": "5.6.1",
"@edx/frontend-component-footer": "^14.6.0",
"@edx/frontend-component-header": "^6.2.0",
"@edx/frontend-platform": "^8.3.1",
"@edx/openedx-atlas": "^0.6.0",
"@edx/paragon": "^20.44.0",
"@fortawesome/fontawesome-svg-core": "^1.2.36",
"@fortawesome/free-brands-svg-icons": "^5.15.4",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/react-fontawesome": "^0.2.0",
"@openedx/paragon": "^22.16.0",
"@redux-beacon/segment": "^1.1.0",
"@redux-devtools/extension": "3.0.0",
"@reduxjs/toolkit": "^1.6.1",
"@testing-library/user-event": "^14.0.0",
"@zip.js/zip.js": "^2.4.6",
"axios": "^0.27.0",
"axios": "^0.28.0",
"classnames": "^2.3.1",
"core-js": "3.35.1",
"dompurify": "^2.3.1",
"email-prop-type": "^3.0.1",
"enzyme": "^3.11.0",
"enzyme-to-json": "^3.6.2",
"file-saver": "^2.0.5",
"filesize": "^8.0.6",
"font-awesome": "4.7.0",
@@ -54,18 +56,17 @@
"moment": "^2.29.3",
"prop-types": "15.8.1",
"query-string": "7.1.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-helmet": "^6.1.0",
"react-intl": "^5.20.9",
"react-pdf": "^5.5.0",
"react-intl": "6.4.7",
"react-pdf": "^7.0.0",
"react-redux": "^7.2.9",
"react-router": "6.21.3",
"react-router-dom": "6.21.3",
"react-router-redux": "^5.0.0-alpha.9",
"redux": "4.2.1",
"redux-beacon": "^2.1.0",
"redux-devtools-extension": "2.13.9",
"redux-logger": "3.0.6",
"redux-thunk": "2.4.2",
"regenerator-runtime": "^0.14.0",
@@ -74,22 +75,21 @@
"whatwg-fetch": "^3.6.2"
},
"devDependencies": {
"@edx/browserslist-config": "^1.2.0",
"@edx/frontend-build": "^12.7.0",
"@edx/browserslist-config": "^1.3.0",
"@edx/react-unit-test-utils": "^4.0.0",
"@edx/reactifex": "^2.1.1",
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "12.1.5",
"@wojtekmaj/enzyme-adapter-react-17": "0.8.0",
"@openedx/frontend-build": "^14.3.3",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.2.0",
"axios-mock-adapter": "^1.20.0",
"fetch-mock": "^9.11.0",
"husky": "^7.0.0",
"identity-obj-proxy": "^3.0.0",
"jest": "29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-expect-message": "^1.0.2",
"react-dev-utils": "^12.0.1",
"react-test-renderer": "^17.0.2",
"react-test-renderer": "^18.3.1",
"reactifex": "1.1.1",
"redux-mock-store": "^1.5.4",
"semantic-release": "^19.0.3"
"redux-mock-store": "^1.5.5"
}
}

View File

@@ -3,13 +3,13 @@ import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { BrowserRouter as Router } from 'react-router-dom';
import Footer from '@edx/frontend-component-footer';
import { FooterSlot } from '@edx/frontend-component-footer';
import { LearningHeader as Header } from '@edx/frontend-component-header';
import { selectors } from 'data/redux';
import DemoWarning from 'containers/DemoWarning';
import CTA from 'containers/CTA';
import NotificationsBanner from 'containers/NotificationsBanner';
import ListView from 'containers/ListView';
import './App.scss';
@@ -23,13 +23,14 @@ export const App = ({ courseMetadata, isEnabled }) => (
courseTitle={courseMetadata.title}
courseNumber={courseMetadata.number}
courseOrg={courseMetadata.org}
data-testid="header"
/>
{!isEnabled && <DemoWarning />}
<CTA />
<main>
<NotificationsBanner />
<main data-testid="main">
<ListView />
</main>
<Footer logo={process.env.LOGO_POWERED_BY_OPEN_EDX_URL_SVG} />
<FooterSlot />
</div>
</Router>
);

View File

@@ -1,7 +1,7 @@
// frontend-app-*/src/index.scss
@import "~@edx/brand/paragon/fonts";
@import "~@edx/brand/paragon/variables";
@import "~@edx/paragon/scss/core/core";
@import "~@openedx/paragon/scss/core/core";
@import "~@edx/brand/paragon/overrides";
$fa-font-path: "~font-awesome/fonts";
@@ -10,6 +10,7 @@ $fa-font-path: "~font-awesome/fonts";
$input-focus-box-shadow: $input-box-shadow; // hack to get upgrade to paragon 4.0.0 to work
@import "~@edx/frontend-component-footer/dist/_footer";
@import "~@edx/frontend-component-header/dist/index";
#root {
display: flex;

View File

@@ -1,10 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import Footer from '@edx/frontend-component-footer';
import { LearningHeader as Header } from '@edx/frontend-component-header';
import ListView from 'containers/ListView';
import { shallow } from '@edx/react-unit-test-utils';
import { App } from './App';
@@ -20,16 +15,13 @@ jest.mock('data/redux', () => ({
jest.mock('@edx/frontend-component-header', () => ({
LearningHeader: 'Header',
}));
jest.mock('@edx/frontend-component-footer', () => 'Footer');
jest.mock('@edx/frontend-component-footer', () => ({ FooterSlot: 'FooterSlot' }));
jest.mock('containers/DemoWarning', () => 'DemoWarning');
jest.mock('containers/CTA', () => 'CTA');
jest.mock('containers/ListView', () => 'ListView');
jest.mock('components/Head', () => 'Head');
const logo = 'fakeLogo.png';
let el;
let router;
describe('App router component', () => {
const props = {
@@ -41,34 +33,28 @@ describe('App router component', () => {
isEnabled: true,
};
test('snapshot: enabled', () => {
expect(shallow(<App {...props} />)).toMatchSnapshot();
expect(shallow(<App {...props} />).snapshot).toMatchSnapshot();
});
test('snapshot: disabled (show demo warning)', () => {
expect(shallow(<App {...props} isEnabled={false} />)).toMatchSnapshot();
expect(shallow(<App {...props} isEnabled={false} />).snapshot).toMatchSnapshot();
});
describe('component', () => {
beforeEach(() => {
process.env.LOGO_POWERED_BY_OPEN_EDX_URL_SVG = logo;
el = shallow(<App {...props} />);
router = el.childAt(0);
});
describe('Router', () => {
test('Routing - ListView is only route', () => {
expect(router.find('main')).toEqual(shallow(
<main><ListView /></main>,
));
expect(el.instance.findByTestId('main')[0].children).toHaveLength(1);
expect(el.instance.findByTestId('main')[0].children[0].type).toBe('ListView');
});
});
test('Footer logo drawn from env variable', () => {
expect(router.find(Footer).props().logo).toEqual(logo);
});
test('Header to use courseMetadata props', () => {
const {
courseTitle,
courseNumber,
courseOrg,
} = router.find(Header).props();
} = el.instance.findByTestId('header')[0].props;
expect(courseTitle).toEqual(props.courseMetadata.title);
expect(courseNumber).toEqual(props.courseMetadata.number);
expect(courseOrg).toEqual(props.courseMetadata.org);

View File

@@ -8,15 +8,16 @@ exports[`App router component snapshot: disabled (show demo warning) 1`] = `
courseNumber="course-number"
courseOrg="course-org"
courseTitle="course-title"
data-testid="header"
/>
<DemoWarning />
<CTA />
<main>
<NotificationsBanner />
<main
data-testid="main"
>
<ListView />
</main>
<Footer
logo="https://edx-cdn.org/v3/stage/open-edx-tag.svg"
/>
<FooterSlot />
</div>
</BrowserRouter>
`;
@@ -29,14 +30,15 @@ exports[`App router component snapshot: enabled 1`] = `
courseNumber="course-number"
courseOrg="course-org"
courseTitle="course-title"
data-testid="header"
/>
<CTA />
<main>
<NotificationsBanner />
<main
data-testid="main"
>
<ListView />
</main>
<Footer
logo="https://edx-cdn.org/v3/stage/open-edx-tag.svg"
/>
<FooterSlot />
</div>
</BrowserRouter>
`;

View File

@@ -1,24 +1,28 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`app registry subscribe: APP_INIT_ERROR. snapshot: displays an ErrorPage to root element 1`] = `
<ErrorPage
message="test-error-message"
/>
<React Strict Mode>
<ErrorPage
message="test-error-message"
/>
</React Strict Mode>
`;
exports[`app registry subscribe: APP_READY. links App to root element 1`] = `
<AppProvider
store={
Object {
"dispatch": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
Symbol(Symbol.observable): [Function],
<React Strict Mode>
<AppProvider
store={
{
"dispatch": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
Symbol(Symbol.observable): [Function],
}
}
}
wrapWithRouter={false}
>
<App />
</AppProvider>
wrapWithRouter={false}
>
<App />
</AppProvider>
</React Strict Mode>
`;

View File

@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { AlertModal, ActionRow, Button } from '@edx/paragon';
import { AlertModal, ActionRow, Button } from '@openedx/paragon';
import { nullMethod } from 'hooks';
export const ConfirmModal = ({

View File

@@ -1,4 +1,4 @@
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { ConfirmModal } from './ConfirmModal';
@@ -13,9 +13,9 @@ describe('ConfirmModal', () => {
onConfirm: jest.fn().mockName('this.props.onConfirm'),
};
test('snapshot: closed', () => {
expect(shallow(<ConfirmModal {...props} />)).toMatchSnapshot();
expect(shallow(<ConfirmModal {...props} />).snapshot).toMatchSnapshot();
});
test('snapshot: open', () => {
expect(shallow(<ConfirmModal {...props} isOpen />)).toMatchSnapshot();
expect(shallow(<ConfirmModal {...props} isOpen />).snapshot).toMatchSnapshot();
});
});

View File

@@ -6,7 +6,7 @@ import {
ActionRow,
AlertModal,
Button,
} from '@edx/paragon';
} from '@openedx/paragon';
import messages from './messages';

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { formatMessage } from 'testUtils';
import { DemoAlert } from '.';
@@ -11,6 +11,6 @@ describe('DemoAlert component', () => {
isOpen: true,
onClose: jest.fn().mockName('props.onClose'),
};
expect(shallow(<DemoAlert {...props} />)).toMatchSnapshot();
expect(shallow(<DemoAlert {...props} />).snapshot).toMatchSnapshot();
});
});

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import filesize from 'filesize';
import FilePopoverContent from '.';
@@ -19,20 +19,19 @@ describe('FilePopoverContent', () => {
el = shallow(<FilePopoverContent {...props} />);
});
describe('snapshot', () => {
test('default', () => expect(el).toMatchSnapshot());
test('default', () => expect(el.snapshot).toMatchSnapshot());
test('invalid size', () => {
el.setProps({
size: null,
});
expect(el).toMatchSnapshot();
el = shallow(<FilePopoverContent {...props} size={null} />);
expect(el.snapshot).toMatchSnapshot();
});
});
describe('behavior', () => {
test('content', () => {
expect(el.text()).toContain(props.name);
expect(el.text()).toContain(props.description);
expect(el.text()).toContain(filesize(props.size));
const childElements = el.instance.children;
expect(childElements[0].children[2].el).toContain(props.name);
expect(childElements[1].children[2].el).toContain(props.description);
expect(childElements[2].children[2].el).toContain(filesize(props.size));
});
});
});

View File

@@ -1,8 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Alert, Button } from '@edx/paragon';
import { Info } from '@edx/paragon/icons';
import { Alert, Button } from '@openedx/paragon';
import { Info } from '@openedx/paragon/icons';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
const messageShape = PropTypes.shape({

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import ErrorBanner from './ErrorBanner';
@@ -31,16 +31,20 @@ describe('Error Banner component', () => {
});
test('snapshot', () => {
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
describe('component', () => {
test('children node', () => {
expect(el.containsMatchingElement(children)).toEqual(true);
const childElement = el.instance.children[1];
const child = shallow(children);
expect(childElement.type).toEqual(child.type);
expect(childElement.children[0].el).toEqual(child.children[0].el);
});
test('verify actions', () => {
const actions = el.find('Alert').prop('actions');
const { actions } = el.instance.findByType('Alert')[0].props;
expect(actions).toHaveLength(props.actions.length);
actions.forEach((action, index) => {
@@ -52,8 +56,8 @@ describe('Error Banner component', () => {
});
test('verify heading', () => {
const heading = el.find('FormattedMessage');
expect(heading.props()).toEqual(props.headingMessage);
const heading = el.instance.findByType('FormattedMessage')[0];
expect(heading.props).toEqual(props.headingMessage);
});
});
});

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { Alert, Spinner } from '@edx/paragon';
import { Alert, Spinner } from '@openedx/paragon';
export const LoadingBanner = () => (
<Alert variant="info">

View File

@@ -1,11 +1,11 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import LoadingBanner from './LoadingBanner';
describe('Loading Banner component', () => {
test('snapshot', () => {
const el = shallow(<LoadingBanner />);
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
});

View File

@@ -3,7 +3,7 @@
exports[`Error Banner component snapshot 1`] = `
<Alert
actions={
Array [
[
<Button
onClick={[MockFunction action1.onClick]}
variant="outline-primary"

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import ImageRenderer from './ImageRenderer';
@@ -16,6 +16,6 @@ describe('Image Renderer Component', () => {
el = shallow(<ImageRenderer {...props} />);
});
test('snapshot', () => {
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
});

View File

@@ -1,17 +1,15 @@
import React from 'react';
import PropTypes from 'prop-types';
import { pdfjs, Document, Page } from 'react-pdf';
import { Document, Page, pdfjs } from 'react-pdf';
import {
Icon, Form, ActionRow, IconButton,
} from '@edx/paragon';
import { ChevronLeft, ChevronRight } from '@edx/paragon/icons';
import pdfjsWorker from 'react-pdf/dist/esm/pdf.worker.entry';
} from '@openedx/paragon';
import { ChevronLeft, ChevronRight } from '@openedx/paragon/icons';
import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
import { rendererHooks } from './pdfHooks';
pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.js`;
/**
* <PDFRenderer />

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import PDFRenderer from './PDFRenderer';
@@ -42,7 +42,7 @@ describe('PDF Renderer Component', () => {
describe('snapshots', () => {
test('first page, prev is disabled', () => {
hooks.rendererHooks.mockReturnValue(hookProps);
expect(shallow(<PDFRenderer {...props} />)).toMatchSnapshot();
expect(shallow(<PDFRenderer {...props} />).snapshot).toMatchSnapshot();
});
test('on last page, next is disabled', () => {
hooks.rendererHooks.mockReturnValue({
@@ -51,7 +51,7 @@ describe('PDF Renderer Component', () => {
hasNext: false,
hasPrev: true,
});
expect(shallow(<PDFRenderer {...props} />)).toMatchSnapshot();
expect(shallow(<PDFRenderer {...props} />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import TXTRenderer from './TXTRenderer';
@@ -18,6 +18,6 @@ describe('TXT Renderer Component', () => {
onSuccess: jest.fn().mockName('this.props.onSuccess'),
};
test('snapshot', () => {
expect(shallow(<TXTRenderer {...props} />)).toMatchSnapshot();
expect(shallow(<TXTRenderer {...props} />).snapshot).toMatchSnapshot();
});
});

View File

@@ -12,7 +12,7 @@ exports[`PDF Renderer Component snapshots first page, prev is disabled 1`] = `
<div
className="page-wrapper"
style={
Object {
{
"height": 200,
}
}
@@ -80,7 +80,7 @@ exports[`PDF Renderer Component snapshots on last page, next is disabled 1`] = `
<div
className="page-wrapper"
style={
Object {
{
"height": 200,
}
}

View File

@@ -1,16 +1,11 @@
import { useState, useRef } from 'react';
import { pdfjs } from 'react-pdf';
import pdfjsWorker from 'react-pdf/dist/esm/pdf.worker.entry';
import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
import { ErrorStatuses } from 'data/constants/requests';
import { StrictDict } from 'utils';
import * as module from './pdfHooks';
pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
export const errors = StrictDict({
missingPDF: 'MissingPDFException',
});

View File

@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Card, Collapsible } from '@edx/paragon';
import { Card, Collapsible } from '@openedx/paragon';
import FilePopoverContent from 'components/FilePopoverContent';
import FileInfo from './FileInfo';
@@ -17,7 +17,7 @@ export const FileCard = ({ file, children }) => (
defaultOpen
title={<h3 className="file-card-title">{file.name}</h3>}
>
<div className="preview-panel">
<div className="preview-panel" data-testid="preview-panel">
<FileInfo><FilePopoverContent {...file} /></FileInfo>
{children}
</div>

View File

@@ -1,4 +1,4 @@
@import "@edx/paragon/scss/core/core";
@import "@openedx/paragon/scss/core/core";
.file-card {
margin: map-get($spacers, 1) 0;

View File

@@ -1,7 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { Collapsible } from '@edx/paragon';
import { Collapsible } from '@openedx/paragon';
import FilePopoverContent from 'components/FilePopoverContent';
import FileInfo from './FileInfo';
@@ -24,19 +24,19 @@ describe('File Preview Card component', () => {
el = shallow(<FileCard {...props}>{children}</FileCard>);
});
test('snapshot', () => {
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
describe('Component', () => {
test('collapsible title is name header', () => {
const title = el.find(Collapsible).prop('title');
const { title } = el.instance.findByType(Collapsible)[0].props;
expect(title).toEqual(<h3 className="file-card-title">{props.file.name}</h3>);
});
test('forwards children into preview-panel', () => {
const previewPanelChildren = el.find('.preview-panel').children();
expect(previewPanelChildren.at(0).equals(
const previewPanelChildren = el.instance.findByTestId('preview-panel')[0].children;
expect(previewPanelChildren[0].matches(
<FileInfo><FilePopoverContent file={props.file} /></FileInfo>,
));
expect(previewPanelChildren.at(1).equals(children)).toEqual(true);
expect(previewPanelChildren[1].matches(shallow(children))).toEqual(true);
});
});
});

View File

@@ -5,8 +5,8 @@ import {
Button,
OverlayTrigger,
Popover,
} from '@edx/paragon';
import { InfoOutline } from '@edx/paragon/icons';
} from '@openedx/paragon';
import { InfoOutline } from '@openedx/paragon/icons';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import { nullMethod } from 'hooks';
import messages from './messages';

View File

@@ -1,7 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { Popover } from '@edx/paragon';
import { Popover } from '@openedx/paragon';
import FileInfo from './FileInfo';
@@ -13,11 +13,11 @@ describe('File Preview Card component', () => {
el = shallow(<FileInfo {...props}>{children}</FileInfo>);
});
test('snapshot', () => {
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
describe('Component', () => {
test('overlay with passed children', () => {
const { overlay } = el.at(0).props();
const { overlay } = el.instance.props;
expect(overlay.type).toEqual(Popover);
expect(overlay.props.children).toEqual(<Popover.Content>{children}</Popover.Content>);
});

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { formatMessage } from 'testUtils';
import { keyStore } from 'utils';
@@ -35,7 +35,7 @@ describe('FileRenderer', () => {
rendererProps: { prop: 'hooks.rendererProps' },
};
jest.spyOn(hooks, hookKeys.renderHooks).mockReturnValueOnce(hookProps);
expect(shallow(<FileRenderer {...props} />)).toMatchSnapshot();
expect(shallow(<FileRenderer {...props} />).snapshot).toMatchSnapshot();
});
test('is not loading, with error', () => {
const hookProps = {
@@ -46,7 +46,7 @@ describe('FileRenderer', () => {
rendererProps: { prop: 'hooks.rendererProps' },
};
jest.spyOn(hooks, hookKeys.renderHooks).mockReturnValueOnce(hookProps);
expect(shallow(<FileRenderer {...props} />)).toMatchSnapshot();
expect(shallow(<FileRenderer {...props} />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -18,6 +18,7 @@ exports[`File Preview Card component snapshot 1`] = `
>
<div
className="preview-panel"
data-testid="preview-panel"
>
<FileInfo>
<FilePopoverContent

View File

@@ -3,7 +3,7 @@
exports[`FileRenderer component snapshot is not loading, with error 1`] = `
<FileCard
file={
Object {
{
"downloadUrl": "file download url",
"name": "filename.txt",
}
@@ -19,7 +19,7 @@ exports[`FileRenderer component snapshot is not loading, with error 1`] = `
exports[`FileRenderer component snapshot isLoading, no Error 1`] = `
<FileCard
file={
Object {
{
"downloadUrl": "file download url",
"name": "filename.txt",
}

View File

@@ -79,7 +79,7 @@ export const renderHooks = ({
message: messages.retryButton,
};
const error = {
headerMessage: errorMessage,
headingMessage: errorMessage,
children: intl.formatMessage(errorMessage),
actions: [errorAction],
};

View File

@@ -55,7 +55,7 @@ describe('FilePreview hooks', () => {
});
describe('error', () => {
it('loads message from current error status, if valid, else from serverError', () => {
expect(hook.error.headerMessage).toEqual(
expect(hook.error.headingMessage).toEqual(
hooks.ERROR_STATUSES[ErrorStatuses.serverError],
);
expect(hook.error.children).toEqual(
@@ -63,7 +63,7 @@ describe('FilePreview hooks', () => {
);
state.mockVal(state.keys.errorStatus, ErrorStatuses.notFound);
hook = hooks.renderHooks({ intl: { formatMessage }, file });
expect(hook.error.headerMessage).toEqual(
expect(hook.error.headingMessage).toEqual(
hooks.ERROR_STATUSES[ErrorStatuses.notFound],
);
expect(hook.error.children).toEqual(

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { getConfig } from '@edx/frontend-platform';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import Head from '.';
jest.mock('react-helmet', () => ({
@@ -17,9 +17,9 @@ jest.mock('@edx/frontend-platform', () => ({
describe('Head', () => {
it('snapshot', () => {
const el = shallow(<Head />);
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
expect(el.find('title').text()).toContain(getConfig().SITE_NAME);
expect(el.find('link').prop('href')).toEqual(getConfig().FAVICON_URL);
expect(el.instance.findByType('title')[0].el.children[0]).toContain(getConfig().SITE_NAME);
expect(el.instance.findByType('link')[0].props.href).toEqual(getConfig().FAVICON_URL);
});
});

View File

@@ -21,6 +21,7 @@ exports[`Info Popover Component snapshot 1`] = `
<IconButton
alt="Display more info"
className="esg-help-icon"
data-testid="esg-help-icon"
iconAs="Icon"
onClick={[MockFunction this.props.onClick]}
src={[MockFunction icons.InfoOutline]}

View File

@@ -6,8 +6,8 @@ import {
Popover,
Icon,
IconButton,
} from '@edx/paragon';
import { InfoOutline } from '@edx/paragon/icons';
} from '@openedx/paragon';
import { InfoOutline } from '@openedx/paragon/icons';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { nullMethod } from 'hooks';
@@ -30,6 +30,7 @@ export const InfoPopover = ({ onClick, children, intl }) => (
>
<IconButton
className="esg-help-icon"
data-testid="esg-help-icon"
src={InfoOutline}
alt={intl.formatMessage(messages.altText)}
iconAs={Icon}

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { formatMessage } from 'testUtils';
import { InfoPopover } from '.';
@@ -12,12 +12,12 @@ describe('Info Popover Component', () => {
el = shallow(<InfoPopover onClick={onClick} intl={{ formatMessage }}>{child}</InfoPopover>);
});
test('snapshot', () => {
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
describe('Component', () => {
test('Test component render', () => {
expect(el.length).toEqual(1);
expect(el.find('.esg-help-icon').length).toEqual(1);
expect(el.instance.children.length).toEqual(1);
expect(el.instance.findByTestId('esg-help-icon').length).toEqual(1);
});
});
});

View File

@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Spinner } from '@edx/paragon';
import { Spinner } from '@openedx/paragon';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
/**

View File

@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Badge } from '@edx/paragon';
import { Badge } from '@openedx/paragon';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import { StrictDict } from 'utils';

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { gradingStatuses } from 'data/services/lms/constants';
import { StatusBadge } from './StatusBadge';
@@ -10,25 +10,25 @@ describe('StatusBadge component', () => {
describe('behavior', () => {
it('does not render if status does not have configured variant', () => {
const el = render('arbitrary');
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
expect(el.isEmptyRender()).toEqual(true);
});
describe('status snapshots: loads badge with configured variant and message.', () => {
test('`ungraded` shows primary button variant and message', () => {
const el = render(gradingStatuses.ungraded);
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
test('`locked` shows light button variant and message', () => {
const el = render(gradingStatuses.locked);
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
test('`graded` shows success button variant and message', () => {
const el = render(gradingStatuses.graded);
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
test('`inProgress` shows warning button variant and message', () => {
const el = render(gradingStatuses.inProgress);
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
});
});

View File

@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`StatusBadge component behavior does not render if status does not have configured variant 1`] = `""`;
exports[`StatusBadge component behavior does not render if status does not have configured variant 1`] = `null`;
exports[`StatusBadge component behavior status snapshots: loads badge with configured variant and message. \`graded\` shows success button variant and message 1`] = `
<Badge

View File

@@ -1,11 +0,0 @@
import React from 'react';
import { shallow } from 'enzyme';
import { CTA } from '.';
describe('CTA component', () => {
test('snapshots', () => {
const el = shallow(<CTA hide />);
expect(el).toMatchSnapshot();
});
});

View File

@@ -1,31 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`CTA component snapshots 1`] = `
<PageBanner>
<span>
<FormattedMessage
defaultMessage="Thanks for using the new ORA staff grading experience. "
description="Thank user for using ora and ask for feed back"
id="ora-grading.CTA.feedbackMessage"
/>
<Hyperlink
destination="https://docs.google.com/forms/d/1Hu1rgJcCHl5_EtDb5Up3hiZ40sSUtkZQfRHJ3fWOvfQ/edit"
isInline={true}
showLaunchIcon={false}
target="_blank"
variant="muted"
>
<FormattedMessage
defaultMessage="Provide some feedback"
description="placeholder for the feedback anchor link"
id="ora-grading.CTA.linkMessage"
/>
</Hyperlink>
<FormattedMessage
defaultMessage=" and let us know what you think!"
description="inform user to provide feedback"
id="ora-grading.CTA.letUsKnowMessage"
/>
</span>
</PageBanner>
`;

View File

@@ -1,29 +0,0 @@
import React from 'react';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import { PageBanner, Hyperlink } from '@edx/paragon';
import messages from './messages';
/**
* <CTA />
*/
export const CTA = () => (
<PageBanner>
<span>
<FormattedMessage {...messages.ctaFeedbackMessage} />
<Hyperlink
isInline
variant="muted"
destination="https://docs.google.com/forms/d/1Hu1rgJcCHl5_EtDb5Up3hiZ40sSUtkZQfRHJ3fWOvfQ/edit"
target="_blank"
showLaunchIcon={false}
>
<FormattedMessage {...messages.ctaLinkMessage} />
</Hyperlink>
<FormattedMessage {...messages.ctaLetUsKnowMessage} />
</span>
</PageBanner>
);
export default CTA;

View File

@@ -1,23 +0,0 @@
/* eslint-disable quotes */
import { defineMessages } from '@edx/frontend-platform/i18n';
import { StrictDict } from 'utils';
const messages = defineMessages({
ctaFeedbackMessage: {
id: 'ora-grading.CTA.feedbackMessage',
defaultMessage: 'Thanks for using the new ORA staff grading experience. ',
description: 'Thank user for using ora and ask for feed back',
},
ctaLinkMessage: {
id: 'ora-grading.CTA.linkMessage',
defaultMessage: 'Provide some feedback',
description: 'placeholder for the feedback anchor link',
},
ctaLetUsKnowMessage: {
id: 'ora-grading.CTA.letUsKnowMessage',
defaultMessage: ' and let us know what you think!',
description: 'inform user to provide feedback',
},
});
export default StrictDict(messages);

View File

@@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Form } from '@edx/paragon';
import { Form } from '@openedx/paragon';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { feedbackRequirement } from 'data/services/lms/constants';
@@ -51,13 +51,14 @@ export class CriterionFeedback extends React.Component {
<Form.Control
as="textarea"
className="criterion-feedback feedback-input"
data-testid="criterion-feedback-input"
floatingLabel={this.commentMessage}
value={value}
onChange={this.onChange}
disabled={!isGrading}
/>
{isInvalid && (
<Form.Control.Feedback type="invalid" className="feedback-error-msg">
<Form.Control.Feedback type="invalid" className="feedback-error-msg" data-testid="criterion-feedback-error-msg">
{this.translate(messages.criterionFeedbackError)}
</Form.Control.Feedback>
)}

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { actions, selectors } from 'data/redux';
import {
@@ -48,34 +48,27 @@ describe('Criterion Feedback', () => {
let el;
beforeEach(() => {
el = shallow(<CriterionFeedback {...props} />);
el.instance().onChange = jest.fn().mockName('this.onChange');
el.instance.onChange = jest.fn().mockName('this.onChange');
});
describe('snapshot', () => {
test('is grading', () => {
expect(el.instance().render()).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
test('is graded', () => {
el.setProps({
isGrading: false,
gradeStatus: gradeStatuses.graded,
});
expect(el.instance().render()).toMatchSnapshot();
el = shallow(<CriterionFeedback {...props} isGrading={false} gradeStatus={gradeStatuses.graded} />);
expect(el.snapshot).toMatchSnapshot();
});
test('feedback value is invalid', () => {
el.setProps({
isInvalid: true,
});
expect(el.instance().render()).toMatchSnapshot();
el = shallow(<CriterionFeedback {...props} isInvalid />);
expect(el.snapshot).toMatchSnapshot();
});
Object.values(feedbackRequirement).forEach((requirement) => {
test(`feedback is configured to ${requirement}`, () => {
el.setProps({
config: requirement,
});
expect(el.instance().render()).toMatchSnapshot();
el = shallow(<CriterionFeedback {...props} config={requirement} />);
expect(el.snapshot).toMatchSnapshot();
});
});
});
@@ -84,33 +77,23 @@ describe('Criterion Feedback', () => {
describe('render', () => {
test('is grading (the feedback input is not disabled)', () => {
expect(el.isEmptyRender()).toEqual(false);
expect(el.instance().props.value).toEqual(props.value);
const controlEl = el.find('.feedback-input');
expect(controlEl.prop('disabled')).toEqual(false);
expect(controlEl.prop('value')).toEqual(props.value);
const controlEl = el.instance.findByTestId('criterion-feedback-input')[0];
expect(controlEl.props.disabled).toEqual(false);
expect(controlEl.props.value).toEqual(props.value);
});
test('is graded (the input is disabled)', () => {
el.setProps({
isGrading: false,
gradeStatus: gradeStatuses.graded,
});
expect(el.instance().props.value).toEqual(props.value);
const controlEl = el.find('.feedback-input');
expect(controlEl.prop('disabled')).toEqual(true);
expect(controlEl.prop('value')).toEqual(props.value);
el = shallow(<CriterionFeedback {...props} isGrading={false} gradeStatus={gradeStatuses.graded} />);
const controlEl = el.instance.findByTestId('criterion-feedback-input')[0];
expect(controlEl.props.disabled).toEqual(true);
expect(controlEl.props.value).toEqual(props.value);
});
test('is having invalid feedback (feedback get render)', () => {
el.setProps({
isInvalid: true,
});
const feedbackErrorEl = el.find('.feedback-error-msg');
expect(el.instance().props.isInvalid).toEqual(true);
el = shallow(<CriterionFeedback {...props} isInvalid />);
const feedbackErrorEl = el.instance.findByTestId('criterion-feedback-error-msg');
expect(feedbackErrorEl).toBeDefined();
});
test('is configure to disabled (the input does not get render)', () => {
el.setProps({
config: feedbackRequirement.disabled,
});
el = shallow(<CriterionFeedback {...props} config={feedbackRequirement.disabled} />);
expect(el.isEmptyRender()).toEqual(true);
});
});
@@ -118,7 +101,7 @@ describe('Criterion Feedback', () => {
describe('behavior', () => {
test('onChange call set value', () => {
el = shallow(<CriterionFeedback {...props} />);
el.instance().onChange({
el.instance.findByTestId('criterion-feedback-input')[0].props.onChange({
target: {
value: 'some value',
},
@@ -129,33 +112,41 @@ describe('Criterion Feedback', () => {
describe('getter commentMessage', () => {
test('is grading', () => {
el.setProps({ config: feedbackRequirement.optional, isGrading: true });
expect(el.instance().commentMessage).toContain(
let commentMessage;
el = shallow(<CriterionFeedback {...props} isGrading config={feedbackRequirement.optional} />);
commentMessage = el.instance.findByTestId('criterion-feedback-input')[0].props.floatingLabel;
expect(commentMessage).toContain(
messages.optional.defaultMessage,
);
el.setProps({ config: feedbackRequirement.required });
expect(el.instance().commentMessage).not.toContain(
el = shallow(<CriterionFeedback {...props} config={feedbackRequirement.required} />);
commentMessage = el.instance.findByTestId('criterion-feedback-input')[0].props.floatingLabel;
expect(commentMessage).not.toContain(
messages.optional.defaultMessage,
);
expect(el.instance().commentMessage).toContain(
expect(commentMessage).toContain(
messages.addComments.defaultMessage,
);
});
test('is not grading', () => {
el.setProps({ config: feedbackRequirement.optional, isGrading: false });
expect(el.instance().commentMessage).toContain(
let commentMessage;
el = shallow(<CriterionFeedback {...props} isGrading={false} config={feedbackRequirement.optional} />);
commentMessage = el.instance.findByTestId('criterion-feedback-input')[0].props.floatingLabel;
expect(commentMessage).toContain(
messages.optional.defaultMessage,
);
el.setProps({ config: feedbackRequirement.required });
expect(el.instance().commentMessage).not.toContain(
el = shallow(<CriterionFeedback {...props} isGrading={false} config={feedbackRequirement.required} />);
commentMessage = el.instance.findByTestId('criterion-feedback-input')[0].props.floatingLabel;
expect(commentMessage).not.toContain(
messages.optional.defaultMessage,
);
expect(el.instance().commentMessage).toContain(
expect(commentMessage).toContain(
messages.comments.defaultMessage,
);
});

View File

@@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Form } from '@edx/paragon';
import { Form } from '@openedx/paragon';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { actions, selectors } from 'data/redux';
@@ -36,12 +36,13 @@ export class RadioCriterion extends React.Component {
<Form.RadioSet name={config.name} value={data}>
{config.options.map((option) => (
<Form.Radio
className="criteria-option"
className="criteria-option align-items-center"
key={option.name}
value={option.name}
description={intl.formatMessage(messages.optionPoints, { points: option.points })}
onChange={this.onChange}
disabled={!isGrading}
style={{ flexShrink: 0 }}
>
{option.label}
</Form.Radio>

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { actions, selectors } from 'data/redux';
import { formatMessage } from 'testUtils';
@@ -63,25 +63,21 @@ describe('Radio Criterion Container', () => {
let el;
beforeEach(() => {
el = shallow(<RadioCriterion {...props} />);
el.instance().onChange = jest.fn().mockName('this.onChange');
el.instance.onChange = jest.fn().mockName('this.onChange');
});
describe('snapshot', () => {
test('is grading', () => {
expect(el.instance().render()).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
test('is not grading', () => {
el.setProps({
isGrading: false,
});
expect(el.instance().render()).toMatchSnapshot();
el = shallow(<RadioCriterion {...props} isGrading={false} />);
expect(el.snapshot).toMatchSnapshot();
});
test('radio contain invalid response', () => {
el.setProps({
isInvalid: true,
});
expect(el.instance().render()).toMatchSnapshot();
el = shallow(<RadioCriterion {...props} isInvalid />);
expect(el.snapshot).toMatchSnapshot();
});
});
@@ -89,36 +85,33 @@ describe('Radio Criterion Container', () => {
describe('rendering', () => {
test('is grading (all options are not disabled)', () => {
expect(el.isEmptyRender()).toEqual(false);
const optionsEl = el.find('.criteria-option');
const optionsEl = el.instance.children;
expect(optionsEl.length).toEqual(props.config.options.length);
optionsEl.forEach((optionEl) => expect(optionEl.prop('disabled')).toEqual(false));
optionsEl.forEach((optionEl) => expect(optionEl.props.disabled).toEqual(false));
});
test('is not grading (all options are disabled)', () => {
el.setProps({
isGrading: false,
});
el = shallow(<RadioCriterion {...props} isGrading={false} />);
expect(el.isEmptyRender()).toEqual(false);
const optionsEl = el.find('.criteria-option');
const optionsEl = el.instance.children;
expect(optionsEl.length).toEqual(props.config.options.length);
optionsEl.forEach((optionEl) => expect(optionEl.prop('disabled')).toEqual(true));
optionsEl.forEach((optionEl) => expect(optionEl.props.disabled).toEqual(true));
});
test('radio contain invalid response (error response get render)', () => {
el.setProps({
isInvalid: true,
});
el = shallow(<RadioCriterion {...props} isInvalid />);
expect(el.isEmptyRender()).toEqual(false);
const radioErrorEl = el.find('.feedback-error-msg');
expect(el.instance().props.isInvalid).toEqual(true);
expect(radioErrorEl).toBeDefined();
const radioErrorEl = el.instance.children[2];
expect(radioErrorEl.props.type).toBe('invalid');
expect(radioErrorEl.props.className).toBe('feedback-error-msg');
expect(radioErrorEl).toBeTruthy();
});
});
describe('behavior', () => {
test('onChange call set crition option', () => {
el = shallow(<RadioCriterion {...props} />);
el.instance().onChange({
el.instance.children[0].props.onChange({
target: {
value: 'some value',
},

View File

@@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Form, FormControlFeedback } from '@edx/paragon';
import { Form, FormControlFeedback } from '@openedx/paragon';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import { selectors } from 'data/redux';
@@ -14,10 +14,10 @@ import messages from './messages';
export const ReviewCriterion = ({ config }) => (
<div className="review-criterion">
{config.options.map((option) => (
<div key={option.name} className="criteria-option">
<div key={option.name} className="criteria-option" data-testid="criteria-option">
<div>
<Form.Label className="option-label">{option.label}</Form.Label>
<FormControlFeedback className="option-points">
<Form.Label className="option-label" data-testid="option-label">{option.label}</Form.Label>
<FormControlFeedback className="option-points" data-testid="option-points">
<FormattedMessage {...messages.optionPoints} values={{ points: option.points }} />
</FormControlFeedback>
</div>

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { selectors } from 'data/redux';
import { ReviewCriterion, mapStateToProps } from './ReviewCriterion';
@@ -55,21 +55,21 @@ describe('Review Crition Container', () => {
el = shallow(<ReviewCriterion {...props} />);
});
test('snapshot', () => {
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
describe('component', () => {
test('rendering (everything show up)', () => {
expect(el.isEmptyRender()).toEqual(false);
const optionsEl = el.find('.criteria-option');
const optionsEl = el.instance.findByTestId('criteria-option');
expect(optionsEl.length).toEqual(props.config.options.length);
optionsEl.forEach((optionEl, i) => {
const option = props.config.options[i];
expect(optionEl.key()).toEqual(option.name);
expect(optionEl.find('.option-label').childAt(0).text()).toEqual(
expect(optionEl.props.key).toEqual(option.name);
expect(optionEl.findByTestId('option-label')[0].children[0].el).toEqual(
option.label,
);
expect(optionEl.find('.option-points').childAt(0).props()).toEqual({
expect(optionEl.findByTestId('option-points')[0].children[0].props).toEqual({
...messages.optionPoints,
values: { points: option.points },
});

View File

@@ -7,9 +7,10 @@ exports[`Criterion Feedback snapshot feedback is configured to optional 1`] = `
<Form.Control
as="textarea"
className="criterion-feedback feedback-input"
data-testid="criterion-feedback-input"
disabled={false}
floatingLabel="Add comments (Optional)"
onChange={[MockFunction this.onChange]}
onChange={[Function]}
value="criterion value"
/>
</Form.Group>
@@ -20,9 +21,10 @@ exports[`Criterion Feedback snapshot feedback is configured to required 1`] = `
<Form.Control
as="textarea"
className="criterion-feedback feedback-input"
data-testid="criterion-feedback-input"
disabled={false}
floatingLabel="Add comments"
onChange={[MockFunction this.onChange]}
onChange={[Function]}
value="criterion value"
/>
</Form.Group>
@@ -33,13 +35,15 @@ exports[`Criterion Feedback snapshot feedback value is invalid 1`] = `
<Form.Control
as="textarea"
className="criterion-feedback feedback-input"
data-testid="criterion-feedback-input"
disabled={false}
floatingLabel="Add comments"
onChange={[MockFunction this.onChange]}
onChange={[Function]}
value="criterion value"
/>
<Form.Control.Feedback
className="feedback-error-msg"
data-testid="criterion-feedback-error-msg"
type="invalid"
>
The feedback is required
@@ -52,9 +56,10 @@ exports[`Criterion Feedback snapshot is graded 1`] = `
<Form.Control
as="textarea"
className="criterion-feedback feedback-input"
data-testid="criterion-feedback-input"
disabled={true}
floatingLabel="Comments"
onChange={[MockFunction this.onChange]}
onChange={[Function]}
value="criterion value"
/>
</Form.Group>
@@ -65,9 +70,10 @@ exports[`Criterion Feedback snapshot is grading 1`] = `
<Form.Control
as="textarea"
className="criterion-feedback feedback-input"
data-testid="criterion-feedback-input"
disabled={false}
floatingLabel="Add comments"
onChange={[MockFunction this.onChange]}
onChange={[Function]}
value="criterion value"
/>
</Form.Group>

View File

@@ -6,19 +6,31 @@ exports[`Radio Criterion Container snapshot is grading 1`] = `
value="selected radio option"
>
<Form.Radio
className="criteria-option"
className="criteria-option align-items-center"
description="1 points"
disabled={false}
onChange={[MockFunction this.onChange]}
key="option name"
onChange={[Function]}
style={
{
"flexShrink": 0,
}
}
value="option name"
>
this label
</Form.Radio>
<Form.Radio
className="criteria-option"
className="criteria-option align-items-center"
description="2 points"
disabled={false}
onChange={[MockFunction this.onChange]}
key="option name 2"
onChange={[Function]}
style={
{
"flexShrink": 0,
}
}
value="option name 2"
>
this label 2
@@ -32,19 +44,31 @@ exports[`Radio Criterion Container snapshot is not grading 1`] = `
value="selected radio option"
>
<Form.Radio
className="criteria-option"
className="criteria-option align-items-center"
description="1 points"
disabled={true}
onChange={[MockFunction this.onChange]}
key="option name"
onChange={[Function]}
style={
{
"flexShrink": 0,
}
}
value="option name"
>
this label
</Form.Radio>
<Form.Radio
className="criteria-option"
className="criteria-option align-items-center"
description="2 points"
disabled={true}
onChange={[MockFunction this.onChange]}
key="option name 2"
onChange={[Function]}
style={
{
"flexShrink": 0,
}
}
value="option name 2"
>
this label 2
@@ -58,19 +82,31 @@ exports[`Radio Criterion Container snapshot radio contain invalid response 1`] =
value="selected radio option"
>
<Form.Radio
className="criteria-option"
className="criteria-option align-items-center"
description="1 points"
disabled={false}
onChange={[MockFunction this.onChange]}
key="option name"
onChange={[Function]}
style={
{
"flexShrink": 0,
}
}
value="option name"
>
this label
</Form.Radio>
<Form.Radio
className="criteria-option"
className="criteria-option align-items-center"
description="2 points"
disabled={false}
onChange={[MockFunction this.onChange]}
key="option name 2"
onChange={[Function]}
style={
{
"flexShrink": 0,
}
}
value="option name 2"
>
this label 2

View File

@@ -6,23 +6,26 @@ exports[`Review Crition Container snapshot 1`] = `
>
<div
className="criteria-option"
data-testid="criteria-option"
key="option name"
>
<div>
<Form.Label
className="option-label"
data-testid="option-label"
>
this label
</Form.Label>
<FormControlFeedback
className="option-points"
data-testid="option-points"
>
<FormattedMessage
defaultMessage="{points} points"
description="criterion option point value display"
id="ora-grading.RadioCriterion.optionPoints"
values={
Object {
{
"points": 1,
}
}
@@ -32,23 +35,26 @@ exports[`Review Crition Container snapshot 1`] = `
</div>
<div
className="criteria-option"
data-testid="criteria-option"
key="option name 2"
>
<div>
<Form.Label
className="option-label"
data-testid="option-label"
>
this label 2
</Form.Label>
<FormControlFeedback
className="option-points"
data-testid="option-points"
>
<FormattedMessage
defaultMessage="{points} points"
description="criterion option point value display"
id="ora-grading.RadioCriterion.optionPoints"
values={
Object {
{
"points": 2,
}
}

View File

@@ -13,6 +13,7 @@ exports[`Criterion Container snapshot is graded and is not grading 1`] = `
<InfoPopover>
<div
className="help-popover-option"
data-testid="help-popover-option"
key="option name"
>
<strong>
@@ -23,6 +24,7 @@ exports[`Criterion Container snapshot is graded and is not grading 1`] = `
</div>
<div
className="help-popover-option"
data-testid="help-popover-option"
key="option name 2"
>
<strong>
@@ -35,6 +37,7 @@ exports[`Criterion Container snapshot is graded and is not grading 1`] = `
</Form.Label>
<div
className="rubric-criteria"
data-testid="rubric-criteria"
>
<RadioCriterion
isGrading={false}
@@ -61,6 +64,7 @@ exports[`Criterion Container snapshot is ungraded and is grading 1`] = `
<InfoPopover>
<div
className="help-popover-option"
data-testid="help-popover-option"
key="option name"
>
<strong>
@@ -71,6 +75,7 @@ exports[`Criterion Container snapshot is ungraded and is grading 1`] = `
</div>
<div
className="help-popover-option"
data-testid="help-popover-option"
key="option name 2"
>
<strong>
@@ -83,6 +88,7 @@ exports[`Criterion Container snapshot is ungraded and is grading 1`] = `
</Form.Label>
<div
className="rubric-criteria"
data-testid="rubric-criteria"
>
<RadioCriterion
isGrading={true}
@@ -109,6 +115,7 @@ exports[`Criterion Container snapshot is ungraded and is not grading 1`] = `
<InfoPopover>
<div
className="help-popover-option"
data-testid="help-popover-option"
key="option name"
>
<strong>
@@ -119,6 +126,7 @@ exports[`Criterion Container snapshot is ungraded and is not grading 1`] = `
</div>
<div
className="help-popover-option"
data-testid="help-popover-option"
key="option name 2"
>
<strong>
@@ -131,6 +139,7 @@ exports[`Criterion Container snapshot is ungraded and is not grading 1`] = `
</Form.Label>
<div
className="rubric-criteria"
data-testid="rubric-criteria"
>
<ReviewCriterion
orderNum={1}

View File

@@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Form } from '@edx/paragon';
import { Form } from '@openedx/paragon';
import { selectors } from 'data/redux';
import { gradeStatuses } from 'data/services/lms/constants';
@@ -25,7 +25,7 @@ export const CriterionContainer = (props) => {
<span className="criteria-title">{config.prompt}</span>
<InfoPopover>
{config.options.map((option) => (
<div key={option.name} className="help-popover-option">
<div key={option.name} className="help-popover-option" data-testid="help-popover-option">
<strong>{option.label}</strong>
<br />
{option.explanation}
@@ -33,7 +33,7 @@ export const CriterionContainer = (props) => {
))}
</InfoPopover>
</Form.Label>
<div className="rubric-criteria">
<div className="rubric-criteria" data-testid="rubric-criteria">
{isGrading || gradeStatus === gradeStatuses.graded ? (
<RadioCriterion orderNum={orderNum} isGrading={isGrading} />
) : (

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { selectors } from 'data/redux';
import { gradeStatuses } from 'data/services/lms/constants';
@@ -58,56 +58,46 @@ describe('Criterion Container', () => {
describe('snapshot', () => {
test('is ungraded and is grading', () => {
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
test('is ungraded and is not grading', () => {
el.setProps({
isGrading: false,
});
expect(el).toMatchSnapshot();
el = shallow(<CriterionContainer {...props} isGrading={false} />);
expect(el.snapshot).toMatchSnapshot();
});
test('is graded and is not grading', () => {
el.setProps({
isGrading: false,
gradeStatus: gradeStatuses.graded,
});
expect(el).toMatchSnapshot();
el = shallow(<CriterionContainer {...props} isGrading={false} gradeStatus={gradeStatuses.graded} />);
expect(el.snapshot).toMatchSnapshot();
});
});
describe('component', () => {
test('rendering and all of the option show up', () => {
expect(el.isEmptyRender()).toEqual(false);
const optionsEl = el.find('.help-popover-option');
const optionsEl = el.instance.findByTestId('help-popover-option');
expect(optionsEl.length).toEqual(props.config.options.length);
optionsEl.forEach((optionEl, i) => {
expect(optionEl.key()).toEqual(props.config.options[i].name);
expect(optionEl.text()).toContain(props.config.options[i].explanation);
expect(optionEl.props.key).toEqual(props.config.options[i].name);
expect(optionEl.children[2].el).toContain(props.config.options[i].explanation);
});
});
test('is ungraded and is grading (Radio criterion get render)', () => {
const rubricCriteria = el.find('.rubric-criteria');
expect(rubricCriteria.children(0).name()).toEqual('RadioCriterion');
const rubricCriteria = el.instance.findByTestId('rubric-criteria')[0];
expect(rubricCriteria.children[0].el.type).toEqual('RadioCriterion');
});
test('is ungraded and is not grading (Review criterion get render)', () => {
el.setProps({
isGrading: false,
});
const rubricCriteria = el.find('.rubric-criteria');
expect(rubricCriteria.children(0).name()).toEqual('ReviewCriterion');
el = shallow(<CriterionContainer {...props} isGrading={false} />);
const rubricCriteria = el.instance.findByTestId('rubric-criteria')[0];
expect(rubricCriteria.children[0].el.type).toEqual('ReviewCriterion');
});
test('is graded and is not grading (Radio criterion get render)', () => {
el.setProps({
isGrading: false,
gradeStatus: gradeStatuses.graded,
});
const rubricCriteria = el.find('.rubric-criteria');
expect(rubricCriteria.children(0).name()).toEqual('RadioCriterion');
el = shallow(<CriterionContainer {...props} isGrading={false} gradeStatus={gradeStatuses.graded} />);
const rubricCriteria = el.instance.findByTestId('rubric-criteria')[0];
expect(rubricCriteria.children[0].el.type).toEqual('RadioCriterion');
});
});

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { selectors } from 'data/redux';
import { DemoWarning, mapStateToProps } from '.';
@@ -16,12 +16,12 @@ describe('DemoWarning component', () => {
describe('snapshots', () => {
test('does not render if disabled flag is missing', () => {
el = shallow(<DemoWarning hide />);
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
expect(el.isEmptyRender()).toEqual(true);
});
test('snapshot: disabled flag is present', () => {
el = shallow(<DemoWarning hide={false} />);
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
expect(el.isEmptyRender()).toEqual(false);
});
});

View File

@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`DemoWarning component snapshots does not render if disabled flag is missing 1`] = `""`;
exports[`DemoWarning component snapshots does not render if disabled flag is missing 1`] = `null`;
exports[`DemoWarning component snapshots snapshot: disabled flag is present 1`] = `
<Alert

View File

@@ -3,8 +3,8 @@ import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import { Alert } from '@edx/paragon';
import { Info } from '@edx/paragon/icons';
import { Alert } from '@openedx/paragon';
import { Info } from '@openedx/paragon/icons';
import { selectors } from 'data/redux';
import messages from './messages';

View File

@@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import { Hyperlink, Button } from '@edx/paragon';
import { Hyperlink, Button } from '@openedx/paragon';
import urls from 'data/services/lms/urls';
import emptyStateSVG from './assets/empty-state.svg';

View File

@@ -1,7 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { Hyperlink } from '@edx/paragon';
import { Hyperlink } from '@openedx/paragon';
import urls from 'data/services/lms/urls';
@@ -22,11 +22,11 @@ describe('EmptySubmission component', () => {
el = shallow(<EmptySubmission {...props} />);
});
test('snapshot', () => {
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
test('openResponse destination', () => {
expect(
el.find(Hyperlink).at(0).props().destination,
el.instance.findByType(Hyperlink)[0].props.destination,
).toEqual(urls.openResponse(props.courseId));
});
});

View File

@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Button, DataTableContext } from '@edx/paragon';
import { Button, DataTableContext } from '@openedx/paragon';
import * as module from './FilterStatusComponent';

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import * as module from './FilterStatusComponent';
@@ -71,20 +71,20 @@ describe('FilterStatusComponent component', () => {
test('showFilteredFields', () => {
mockHooks(hookProps);
const el = shallow(<FilterStatusComponent {...props} />);
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
test('showFilteredFields=false - hide filterTexts', () => {
mockHooks(hookProps);
const el = shallow(
<FilterStatusComponent {...props} showFilteredFields={false} />,
);
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
});
test('without filters', () => {
mockHooks({});
const el = shallow(<FilterStatusComponent {...props} />);
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
expect(el.isEmptyRender()).toEqual(true);
});
});

View File

@@ -6,8 +6,8 @@ import {
Alert,
Button,
Hyperlink,
} from '@edx/paragon';
import { Info } from '@edx/paragon/icons';
} from '@openedx/paragon';
import { Info } from '@openedx/paragon/icons';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import urls from 'data/services/lms/urls';

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { selectors, thunkActions } from 'data/redux';
@@ -45,7 +45,7 @@ describe('ListError component', () => {
el = shallow(<ListError {...props} />);
});
test('snapshot', () => {
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
});
});

View File

@@ -1,4 +1,4 @@
@import "@edx/paragon/scss/core/core";
@import "@openedx/paragon/scss/core/core";
span.pgn__icon.breadcrumb-arrow {
width: 16px !important;

View File

@@ -2,8 +2,8 @@ import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { ArrowBack, Launch } from '@edx/paragon/icons';
import { Hyperlink, Icon } from '@edx/paragon';
import { ArrowBack, Launch } from '@openedx/paragon/icons';
import { Hyperlink, Icon } from '@openedx/paragon';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import { selectors } from 'data/redux';

View File

@@ -1,7 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { Hyperlink } from '@edx/paragon';
import { Hyperlink } from '@openedx/paragon';
import * as constants from 'data/constants/app';
import urls from 'data/services/lms/urls';
@@ -40,16 +40,16 @@ describe('ListViewBreadcrumb component', () => {
el = shallow(<ListViewBreadcrumb {...props} />);
});
test('snapshot: empty (no list data)', () => {
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
test('openResponse destination', () => {
expect(
el.find(Hyperlink).at(0).props().destination,
el.instance.findByType(Hyperlink)[0].props.destination,
).toEqual(urls.openResponse(props.courseId));
});
test('ora destination', () => {
expect(
el.find(Hyperlink).at(1).props().destination,
el.instance.findByType(Hyperlink)[1].props.destination,
).toEqual(urls.ora(props.courseId, constants.locationId()));
});
});

View File

@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Button } from '@edx/paragon';
import { Button } from '@openedx/paragon';
import { FormattedMessage } from '@edx/frontend-platform/i18n';

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { SelectedBulkAction } from './SelectedBulkAction';
@@ -10,7 +10,7 @@ describe('SelectedBulkAction component', () => {
};
test('snapshots', () => {
const el = shallow(<SelectedBulkAction {...props} handleClick={() => jest.fn()} />);
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
test('handleClick', () => {

View File

@@ -7,7 +7,7 @@ import {
DataTable,
TextFilter,
MultiSelectDropdownFilter,
} from '@edx/paragon';
} from '@openedx/paragon';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { gradingStatuses, submissionFields } from 'data/services/lms/constants';
@@ -74,6 +74,7 @@ export class SubmissionsTable extends React.Component {
return (
<div className="submissions-table">
<DataTable
data-testid="data-table"
isFilterable
FilterStatusComponent={FilterStatusComponent}
numBreakoutFilters={2}

View File

@@ -1,11 +1,10 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import {
DataTable,
MultiSelectDropdownFilter,
TextFilter,
} from '@edx/paragon';
} from '@openedx/paragon';
import { selectors, thunkActions } from 'data/redux';
import { gradingStatuses as statuses, submissionFields } from 'data/services/lms/constants';
@@ -122,7 +121,7 @@ describe('SubmissionsTable component', () => {
});
describe('render tests', () => {
const mockMethod = (methodName) => {
el.instance()[methodName] = jest.fn().mockName(`this.${methodName}`);
el.instance[methodName] = jest.fn().mockName(`this.${methodName}`);
};
beforeEach(() => {
el = shallow(<SubmissionsTable {...props} />);
@@ -136,23 +135,21 @@ describe('SubmissionsTable component', () => {
});
test('snapshot: empty (no list data)', () => {
el = shallow(<SubmissionsTable {...props} listData={[]} />);
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
expect(el.isEmptyRender()).toEqual(true);
});
test('snapshot: happy path', () => {
expect(el.instance().render()).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
test('snapshot: team happy path', () => {
el.setProps({ isIndividual: false, listData: [...teamData] });
expect(el.instance().render()).toMatchSnapshot();
el = shallow(<SubmissionsTable {...props} isIndividual={false} listData={[...teamData]} />);
expect(el.snapshot).toMatchSnapshot();
});
});
describe('DataTable', () => {
let table;
let tableProps;
beforeEach(() => {
table = el.find(DataTable);
tableProps = table.props();
tableProps = el.instance.findByTestId('data-table')[0].props;
});
test.each([
'isFilterable',
@@ -181,7 +178,7 @@ describe('SubmissionsTable component', () => {
expect(columns[1]).toEqual({
Header: messages.learnerSubmissionDate.defaultMessage,
accessor: submissionFields.dateSubmitted,
Cell: el.instance().formatDate,
Cell: el.instance.children[0].props.columns[1].Cell,
disableFilters: true,
});
});
@@ -189,7 +186,7 @@ describe('SubmissionsTable component', () => {
expect(columns[2]).toEqual({
Header: messages.grade.defaultMessage,
accessor: submissionFields.score,
Cell: el.instance().formatGrade,
Cell: el.instance.children[0].props.columns[2].Cell,
disableFilters: true,
});
});
@@ -197,18 +194,18 @@ describe('SubmissionsTable component', () => {
expect(columns[3]).toEqual({
Header: messages.gradingStatus.defaultMessage,
accessor: submissionFields.gradingStatus,
Cell: el.instance().formatStatus,
Cell: el.instance.children[0].props.columns[3].Cell,
Filter: MultiSelectDropdownFilter,
filter: 'includesValue',
filterChoices: el.instance().gradeStatusOptions,
filterChoices: el.instance.children[0].props.columns[3].filterChoices,
});
});
});
describe('team columns', () => {
let columns;
beforeEach(() => {
el.setProps({ isIndividual: false, listData: [...teamData] });
columns = el.find(DataTable).props().columns;
el = shallow(<SubmissionsTable {...props} isIndividual={false} listData={[...teamData]} />);
columns = el.instance.findByTestId('data-table')[0].props.columns;
});
test('teamName column', () => {
expect(columns[0]).toEqual({
@@ -220,7 +217,7 @@ describe('SubmissionsTable component', () => {
expect(columns[1]).toEqual({
Header: messages.teamSubmissionDate.defaultMessage,
accessor: submissionFields.dateSubmitted,
Cell: el.instance().formatDate,
Cell: el.instance.children[0].props.columns[1].Cell,
disableFilters: true,
});
});
@@ -228,7 +225,7 @@ describe('SubmissionsTable component', () => {
expect(columns[2]).toEqual({
Header: messages.grade.defaultMessage,
accessor: submissionFields.score,
Cell: el.instance().formatGrade,
Cell: el.instance.children[0].props.columns[2].Cell,
disableFilters: true,
});
});
@@ -236,10 +233,10 @@ describe('SubmissionsTable component', () => {
expect(columns[3]).toEqual({
Header: messages.gradingStatus.defaultMessage,
accessor: submissionFields.gradingStatus,
Cell: el.instance().formatStatus,
Cell: el.instance.children[0].props.columns[3].Cell,
Filter: MultiSelectDropdownFilter,
filter: 'includesValue',
filterChoices: el.instance().gradeStatusOptions,
filterChoices: el.instance.children[0].props.columns[3].filterChoices,
});
});
});
@@ -251,24 +248,24 @@ describe('SubmissionsTable component', () => {
const fakeDate = 16131215154955;
const fakeDateString = 'test-date-string';
const mock = jest.spyOn(Date.prototype, 'toLocaleString').mockReturnValue(fakeDateString);
expect(el.instance().formatDate({ value: fakeDate })).toEqual(fakeDateString);
expect(el.instance.children[0].props.columns[1].Cell({ value: fakeDate })).toEqual(fakeDateString);
mock.mockRestore();
});
});
describe('formatGrade method', () => {
it('returns "-" if grade is null', () => {
expect(el.instance().formatGrade({ value: null })).toEqual('-');
expect(el.instance.children[0].props.columns[2].Cell({ value: null })).toEqual('-');
});
it('returns <pointsEarned>/<pointsPossible> if grade exists', () => {
expect(
el.instance().formatGrade({ value: { pointsEarned: 1, pointsPossible: 10 } }),
el.instance.children[0].props.columns[2].Cell({ value: { pointsEarned: 1, pointsPossible: 10 } }),
).toEqual('1/10');
});
});
describe('formatStatus method', () => {
it('returns a StatusBadge with the given status', () => {
const status = 'graded';
expect(el.instance().formatStatus({ value: 'graded' })).toEqual(
expect(el.instance.children[0].props.columns[3].Cell({ value: 'graded' })).toEqual(
<StatusBadge status={status} />,
);
});
@@ -280,8 +277,8 @@ describe('SubmissionsTable component', () => {
{ original: { submissionUUID: '456' } },
{ original: { submissionUUID: '789' } },
];
el.instance().handleViewAllResponsesClick(data)();
expect(el.instance().props.loadSelectionForReview).toHaveBeenCalledWith(['123', '456', '789']);
el.instance.children[0].props.tableActions[0].props.handleClick(data)();
expect(el.shallowRenderer._instance.props.loadSelectionForReview).toHaveBeenCalledWith(['123', '456', '789']); // eslint-disable-line no-underscore-dangle
});
});
});

View File

@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Button } from '@edx/paragon';
import { Button } from '@openedx/paragon';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
@@ -11,6 +11,7 @@ export const TableAction = ({ tableInstance, handleClick }) => (
onClick={handleClick(tableInstance.rows)}
variant="primary"
className="view-all-responses-btn"
disabled={tableInstance.rows.length === 0}
>
<FormattedMessage {...messages.viewAllResponses} />
</Button>

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { TableAction } from './TableAction';
@@ -10,7 +10,16 @@ describe('TableAction component', () => {
};
test('snapshots', () => {
const el = shallow(<TableAction {...props} handleClick={() => jest.fn()} />);
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
test('Inactive Button "View All Responses"', () => {
const emptyProps = {
tableInstance: { rows: [] },
handleClick: jest.fn(),
};
const el = shallow(<TableAction {...emptyProps} />);
expect(el.snapshot).toMatchSnapshot();
});
test('handleClick', () => {

View File

@@ -34,4 +34,4 @@ exports[`FilterStatusComponent component snapshot with filters showFilteredField
</div>
`;
exports[`FilterStatusComponent component snapshot without filters 1`] = `""`;
exports[`FilterStatusComponent component snapshot without filters 1`] = `null`;

View File

@@ -3,7 +3,7 @@
exports[`ListError component component render tests snapshot 1`] = `
<Alert
actions={
Array [
[
<Button
onClick={[MockFunction]}
>
@@ -30,7 +30,7 @@ exports[`ListError component component render tests snapshot 1`] = `
description="Initialization failure alert message line 2"
id="ora-grading.ListView.loadErrorMessage1"
values={
Object {
{
"backToResponses": <Hyperlink
destination="api/openResponse/test-course-id"
>

View File

@@ -11,7 +11,7 @@ exports[`SelectedBulkAction component snapshots 1`] = `
description="Button text to load selected responses for review/grading"
id="ora-grading.ListView.viewSelectedResponses"
values={
Object {
{
"value": 2,
}
}

View File

@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`SubmissionsTable component component render tests snapshots snapshot: empty (no list data) 1`] = `""`;
exports[`SubmissionsTable component component render tests snapshots snapshot: empty (no list data) 1`] = `null`;
exports[`SubmissionsTable component component render tests snapshots snapshot: happy path 1`] = `
<div
@@ -9,50 +9,50 @@ exports[`SubmissionsTable component component render tests snapshots snapshot: h
<DataTable
FilterStatusComponent={[MockFunction FilterStatusComponent]}
bulkActions={
Array [
[
<mockConstructor
handleClick={[MockFunction this.handleViewAllResponsesClick]}
handleClick={[Function]}
/>,
]
}
columns={
Array [
Object {
[
{
"Header": "Username",
"accessor": "username",
},
Object {
"Cell": [MockFunction this.formatDate],
{
"Cell": [Function],
"Header": "Learner submission date",
"accessor": "dateSubmitted",
"disableFilters": true,
},
Object {
"Cell": [MockFunction this.formatGrade],
{
"Cell": [Function],
"Header": "Grade",
"accessor": "score",
"disableFilters": true,
},
Object {
"Cell": [MockFunction this.formatStatus],
{
"Cell": [Function],
"Filter": "MultiSelectDropdownFilter",
"Header": "Grading status",
"accessor": "gradingStatus",
"filter": "includesValue",
"filterChoices": Array [
Object {
"filterChoices": [
{
"name": "Ungraded",
"value": "ungraded",
},
Object {
{
"name": "Grading Completed",
"value": "graded",
},
Object {
{
"name": "Currently being graded by someone else",
"value": "locked",
},
Object {
{
"name": "You are currently grading this response",
"value": "in-progress",
},
@@ -61,29 +61,29 @@ exports[`SubmissionsTable component component render tests snapshots snapshot: h
]
}
data={
Array [
Object {
[
{
"dateSubmitted": "2021-12-08 09:06:15.319213+00:00",
"gradingStatus": "ungraded",
"score": Object {
"score": {
"pointsEarned": 1,
"pointsPossible": 10,
},
"username": "username-1",
},
Object {
{
"dateSubmitted": "2021-12-10 18:06:15.319213+00:00",
"gradingStatus": "graded",
"score": Object {
"score": {
"pointsEarned": 2,
"pointsPossible": 10,
},
"username": "username-2",
},
Object {
{
"dateSubmitted": "2021-12-11 07:06:15.319213+00:00",
"gradingStatus": "in-progress",
"score": Object {
"score": {
"pointsEarned": 3,
"pointsPossible": 10,
},
@@ -91,13 +91,14 @@ exports[`SubmissionsTable component component render tests snapshots snapshot: h
},
]
}
data-testid="data-table"
defaultColumnValues={
Object {
{
"Filter": "TextFilter",
}
}
initialState={
Object {
{
"pageIndex": 0,
"pageSize": 10,
}
@@ -109,9 +110,9 @@ exports[`SubmissionsTable component component render tests snapshots snapshot: h
itemCount={3}
numBreakoutFilters={2}
tableActions={
Array [
[
<mockConstructor
handleClick={[MockFunction this.handleViewAllResponsesClick]}
handleClick={[Function]}
/>,
]
}
@@ -130,50 +131,50 @@ exports[`SubmissionsTable component component render tests snapshots snapshot: t
<DataTable
FilterStatusComponent={[MockFunction FilterStatusComponent]}
bulkActions={
Array [
[
<mockConstructor
handleClick={[MockFunction this.handleViewAllResponsesClick]}
handleClick={[Function]}
/>,
]
}
columns={
Array [
Object {
[
{
"Header": "Team name",
"accessor": "teamName",
},
Object {
"Cell": [MockFunction this.formatDate],
{
"Cell": [Function],
"Header": "Team submission date",
"accessor": "dateSubmitted",
"disableFilters": true,
},
Object {
"Cell": [MockFunction this.formatGrade],
{
"Cell": [Function],
"Header": "Grade",
"accessor": "score",
"disableFilters": true,
},
Object {
"Cell": [MockFunction this.formatStatus],
{
"Cell": [Function],
"Filter": "MultiSelectDropdownFilter",
"Header": "Grading status",
"accessor": "gradingStatus",
"filter": "includesValue",
"filterChoices": Array [
Object {
"filterChoices": [
{
"name": "Ungraded",
"value": "ungraded",
},
Object {
{
"name": "Grading Completed",
"value": "graded",
},
Object {
{
"name": "Currently being graded by someone else",
"value": "locked",
},
Object {
{
"name": "You are currently grading this response",
"value": "in-progress",
},
@@ -182,29 +183,29 @@ exports[`SubmissionsTable component component render tests snapshots snapshot: t
]
}
data={
Array [
Object {
[
{
"dateSubmitted": "2021-12-08 09:06:15.319213+00:00",
"gradingStatus": "ungraded",
"score": Object {
"score": {
"pointsEarned": 1,
"pointsPossible": 10,
},
"teamName": "teamName-1",
},
Object {
{
"dateSubmitted": "2021-12-10 18:06:15.319213+00:00",
"gradingStatus": "graded",
"score": Object {
"score": {
"pointsEarned": 2,
"pointsPossible": 10,
},
"teamName": "teamName-2",
},
Object {
{
"dateSubmitted": "2021-12-11 07:06:15.319213+00:00",
"gradingStatus": "in-progress",
"score": Object {
"score": {
"pointsEarned": 3,
"pointsPossible": 10,
},
@@ -212,13 +213,14 @@ exports[`SubmissionsTable component component render tests snapshots snapshot: t
},
]
}
data-testid="data-table"
defaultColumnValues={
Object {
{
"Filter": "TextFilter",
}
}
initialState={
Object {
{
"pageIndex": 0,
"pageSize": 10,
}
@@ -230,9 +232,9 @@ exports[`SubmissionsTable component component render tests snapshots snapshot: t
itemCount={3}
numBreakoutFilters={2}
tableActions={
Array [
[
<mockConstructor
handleClick={[MockFunction this.handleViewAllResponsesClick]}
handleClick={[Function]}
/>,
]
}

View File

@@ -1,8 +1,23 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`TableAction component Inactive Button "View All Responses" 1`] = `
<Button
className="view-all-responses-btn"
disabled={true}
variant="primary"
>
<FormattedMessage
defaultMessage="View all responses"
description="Button text to load all responses for review/grading"
id="ora-grading.ListView.viewAllResponses"
/>
</Button>
`;
exports[`TableAction component snapshots 1`] = `
<Button
className="view-all-responses-btn"
disabled={false}
onClick={[MockFunction]}
variant="primary"
>

View File

@@ -13,10 +13,10 @@ exports[`ListView component component snapshots loaded has data 1`] = `
<Container
className="py-4"
>
<React.Fragment>
<Fragment>
<ListViewBreadcrumb />
<SubmissionsTable />
</React.Fragment>
</Fragment>
<ReviewModal />
</Container>
`;

View File

@@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Container, Spinner } from '@edx/paragon';
import { Container, Spinner } from '@openedx/paragon';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import { selectors, thunkActions } from 'data/redux';

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { selectors, thunkActions } from 'data/redux';
import { RequestKeys } from 'data/constants/requests';
@@ -34,7 +34,7 @@ jest.mock('data/redux', () => ({
},
}));
jest.mock('@edx/paragon', () => ({
jest.mock('@openedx/paragon', () => ({
Container: 'Container',
Spinner: 'Spinner',
}));
@@ -59,20 +59,20 @@ describe('ListView component', () => {
el = shallow(<ListView {...props} />);
});
test('loading', () => {
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
test('loaded has data', () => {
el.setProps({ isLoaded: true });
expect(el.instance().render()).toMatchSnapshot();
el = shallow(<ListView {...props} isLoaded />);
expect(el.snapshot).toMatchSnapshot();
});
test('loaded with no data', () => {
el.setProps({ isLoaded: true, isEmptySubmissionData: true });
expect(el.instance().render()).toMatchSnapshot();
el = shallow(<ListView {...props} isLoaded isEmptySubmissionData />);
expect(el.snapshot).toMatchSnapshot();
});
test('error', () => {
el.setProps({ hasError: true });
expect(el.instance().render()).toMatchSnapshot();
el = shallow(<ListView {...props} hasError />);
expect(el.snapshot).toMatchSnapshot();
});
});
describe('behavior', () => {

Some files were not shown because too many files have changed in this diff Show More