canvas-lms/jest.config.js

72 lines
2.8 KiB
JavaScript
Raw Normal View History

/*
* Copyright (C) 2018 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const {defaults} = require('jest-config')
module.exports = {
moduleNameMapper: {
'^i18n!(.*$)': '<rootDir>/jest/i18nTransformer.js',
'\\.svg$': '<rootDir>/jest/imageMock.js',
add conference ui to calendar details page refs CAL-4 flag=calendar_conferences Test plan: - enable FF "Add Conferences from Calendar" and "Allow Conference Selection..." - enable BigBlueButton with dummy settings at /plugins/big_blue_button - create two courses, one with multiple sections - add LTI tool for conference selection to one course - open add calendar event dialog at /calendar - switch context to one of the courses - verify that conferencing options appear (two options if in course with LTI; one option otherwise) - click more options to open detailed edit page - verify that conferencing options appear the same way - add a conference - save the conference - verify that conference appears on the calendar - repeat in the other context to verify other select UI - add a conference before clicking "more options" and verify that it is included in the more options page - verfy that updating the conference and then cancelling on the more options page does not save the update - in the course with multiple sections, select "use a different date for each section" - verify that the conference for the parent event is shown for each of the child events in the calendar - verify that the conference can't be edited from the child events - verify that updating the parent event conference from the More Details page also updates the child events (as seen in the calendar) Change-Id: I9a7dccc9962d3c056f6a6a5fdb8a501ce8960c18 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/235298 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Ken McGrady <kmcgrady@instructure.com> QA-Review: Steve Shepherd <sshepherd@instructure.com> Product-Review: Michael Brewer-Davis <mbd@instructure.com>
2020-04-25 00:55:53 +08:00
'node_modules-version-of-backbone': require.resolve('backbone'),
'node_modules-version-of-react-modal': require.resolve('react-modal'),
'^Backbone$': '<rootDir>/public/javascripts/Backbone.js',
// jest can't import the icons
'@instructure/ui-icons/es/svg': '<rootDir>/packages/canvas-rce/src/rce/__tests__/_mockIcons.js',
// redirect imports from es/rce to lib
'@instructure/canvas-rce/es/rce/tinyRCE': '<rootDir>/packages/canvas-rce/lib/rce/tinyRCE.js',
'@instructure/canvas-rce/es/rce/RCE': '<rootDir>/packages/canvas-rce/lib/rce/RCE.js',
// mock the tinymce-react Editor react component
'@tinymce/tinymce-react': '<rootDir>/packages/canvas-rce/src/rce/__mocks__/tinymceReact.js'
},
roots: ['<rootDir>/ui', 'gems/plugins', 'public/javascripts'],
moduleDirectories: ['ui/shims', 'public/javascripts', 'node_modules'],
reporters: [
'default',
[
'jest-junit',
{
suiteName: 'Jest Tests',
outputDirectory: process.env.TEST_RESULT_OUTPUT_DIR || './coverage-js/junit-reports',
outputName: 'jest.xml'
}
]
],
snapshotSerializers: ['enzyme-to-json/serializer'],
setupFiles: ['jest-localstorage-mock', 'jest-canvas-mock', '<rootDir>/jest/jest-setup.js'],
Upgrade to babel 7 & allow any js file to be themeable closes: CORE-2699 CORE-2700 UIDEV-99 This commit gets canvas-lms itself upgraded to babel 7. To do that we also had to upgrade jest to v24. We had already got canvas-rce and canvas-planner on jest24/babel7 but now this gets everything to babel 7. so you will see a lot of things removed from yarn.lock since we don’t don’t have to have different versions of everything for babel and jest The other major thing this does is make it so any JS file in canvas can become an @instructure/ui-themeable themeable component. This means you no longer should have to put your css in app/stylesheets for any new react components that you are writing. Test plan: 1. Make sure that the perf of `yarn build:js` is on-par with what it was before. We pass everything through the themeable babel transform now so there is a chance it is slower. If it is majorly slower, we’ll have to figure something out. 2. run a production weback build. The common (or any bundle for that matter should get output exactly the same as it did before) things to manually qa check: * in a NODE_ENV=production enviornment, go to /accounts/site_admin/developer_keys * click the "+ Developer Key" button, it should open the modal. (there are selenium tests that do this, but it was one thing that had to be fixed to get jenkins to pass) * on a course that is set up as a master course, click on the thing that opens the blueprint courses tray. * verify that when you click "Associations" and "Sync History" links in that tray, that they dynamically load the webpack chunk for the modal contents for that thing and then the modal is shown (again, there are selenium specs that test that exact thing but it is always good to manually test it too) Change-Id: I802584228962b54480a500f8fe422f45c2dcac4c Reviewed-on: https://gerrit.instructure.com/183965 Tested-by: Jenkins Reviewed-by: Clay Diffrient <cdiffrient@instructure.com> QA-Review: Ryan Shaw <ryan@instructure.com> Product-Review: Ryan Shaw <ryan@instructure.com>
2019-03-06 05:20:27 +08:00
setupFilesAfterEnv: [
'@testing-library/jest-dom/extend-expect',
'./packages/validated-apollo/src/ValidatedApolloCleanup.js'
Upgrade to babel 7 & allow any js file to be themeable closes: CORE-2699 CORE-2700 UIDEV-99 This commit gets canvas-lms itself upgraded to babel 7. To do that we also had to upgrade jest to v24. We had already got canvas-rce and canvas-planner on jest24/babel7 but now this gets everything to babel 7. so you will see a lot of things removed from yarn.lock since we don’t don’t have to have different versions of everything for babel and jest The other major thing this does is make it so any JS file in canvas can become an @instructure/ui-themeable themeable component. This means you no longer should have to put your css in app/stylesheets for any new react components that you are writing. Test plan: 1. Make sure that the perf of `yarn build:js` is on-par with what it was before. We pass everything through the themeable babel transform now so there is a chance it is slower. If it is majorly slower, we’ll have to figure something out. 2. run a production weback build. The common (or any bundle for that matter should get output exactly the same as it did before) things to manually qa check: * in a NODE_ENV=production enviornment, go to /accounts/site_admin/developer_keys * click the "+ Developer Key" button, it should open the modal. (there are selenium tests that do this, but it was one thing that had to be fixed to get jenkins to pass) * on a course that is set up as a master course, click on the thing that opens the blueprint courses tray. * verify that when you click "Associations" and "Sync History" links in that tray, that they dynamically load the webpack chunk for the modal contents for that thing and then the modal is shown (again, there are selenium specs that test that exact thing but it is always good to manually test it too) Change-Id: I802584228962b54480a500f8fe422f45c2dcac4c Reviewed-on: https://gerrit.instructure.com/183965 Tested-by: Jenkins Reviewed-by: Clay Diffrient <cdiffrient@instructure.com> QA-Review: Ryan Shaw <ryan@instructure.com> Product-Review: Ryan Shaw <ryan@instructure.com>
2019-03-06 05:20:27 +08:00
],
Initial pace plans import This change brings in the basic pace plans frontend with styled-components and several other smaller libraries replaced with InstUI 7 components. It also adds the 'reselect' library as a direct dependency (which we already had through @instructure/outcomes-ui) and 'tsc-files' for type-checking of staged TS files on commit. There were also some tweaks to typescript and eslint configs, mostly to get both up to speed with the typescript code. Finally, this also adds a `pace_plans` endpoint to `courses_controller` to bootstrap the frontend-- this will get moved to `pace_plans_controller` once it has been merged. It's also worth noting that no frontend tests are included with this change-- the existing tests were written with enzyme and are heavily snapshot-based, so we will be replacing those with @testing-library/react tests in later updates (in keeping with current testing best practices at Instructure). closes LS-2431, LS-2432, LS-2433, LS-2434, LS-2452 flag = pace_plans Test plan: - Set up a course with at least one module and several module items - Turn on the pace_plans feature flag in the account associated with that course - Turn on the "Enable pace plans" setting in course settings - Create a pace plan for the course via the Rails console: c = Course.find<id> pp = c.pace_plans.create! workflow_state: 'active' c.context_module_tags.each_with_index do |t, i| pp.pace_plan_module_items.create! module_item: t, duration: i*2 end - Go to the course as a teacher or admin - Expect to see a "Pace Plans" link in the course navigation - Click it, expect the pace plan you created earlier to load and render - Expect to be able to pick dates, change durations, and toggle checkboxes (although saves will fail, since there is no API yet). - Expect to not see the "Pace Plans" course nav link when the feature flag or course setting is off - Expect /courses/<id>/pace_plans to return a 404 when the feature flag or course setting is off - Expect to not see the "Pace Plans" course nav link as a student - Expect /courses/<id>/pace_plans to display an "Unauthorized" page as a student Change-Id: If4dc5d17f2c6a2109d4b4cb652c9e9ef00d7cc33 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/271650 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Ed Schiebel <eschiebel@instructure.com> QA-Review: Ed Schiebel <eschiebel@instructure.com> Product-Review: Jeff Largent <jeff.largent@instructure.com>
2021-08-18 05:14:24 +08:00
testMatch: ['**/__tests__/**/?(*.)(spec|test).[jt]s?(x)'],
coverageDirectory: '<rootDir>/coverage-jest/',
moduleFileExtensions: [...defaults.moduleFileExtensions, 'coffee', 'handlebars'],
restoreMocks: true,
testEnvironment: 'jest-environment-jsdom-fourteen',
transform: {
'^i18n': '<rootDir>/jest/i18nTransformer.js',
'^.+\\.coffee': '<rootDir>/jest/coffeeTransformer.js',
'^.+\\.handlebars': '<rootDir>/jest/handlebarsTransformer.js',
'^.+\\.[jt]sx?$': 'babel-jest',
'\\.graphql$': 'jest-raw-loader'
}
}