Handle planner notes api call in AgendaViewSpec

fixes VICE-639
flag=none

In the removal of the student planner feature flag
This check was added to keep tests from failing and
should be removed

test plan:
  - specs should pass

qa risk: low

Change-Id: I9de70183296f811d81fbf3814f82f6e8fd17f41e
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/243367
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Tested-by: Jeffrey Johnson <jeffrey.johnson@instructure.com>
Reviewed-by: Jeffrey Johnson <jeffrey.johnson@instructure.com>
QA-Review: Jeffrey Johnson <jeffrey.johnson@instructure.com>
Product-Review: Jeffrey Johnson <jeffrey.johnson@instructure.com>
This commit is contained in:
Drake Harper 2020-07-24 10:18:20 -06:00
parent 3387f88283
commit 14efb60bb6
3 changed files with 54 additions and 24 deletions

View File

@ -495,23 +495,21 @@ export default class EventDataSource {
if (ENV.STUDENT_PLANNER_ENABLED) {
eventDataSources.push(['/api/v1/planner_notes', params])
}
if (ENV.CALENDAR && ENV.CALENDAR.MANAGE_CONTEXTS) {
const [admin_contexts, student_contexts] = _.partition(
params.context_codes,
cc => ENV.CALENDAR.MANAGE_CONTEXTS.indexOf(cc) >= 0
)
if (student_contexts.length) {
const pparams = {filter: 'ungraded_todo_items', ...params, context_codes: student_contexts}
eventDataSources.push(['/api/v1/planner/items', pparams])
}
if (admin_contexts.length) {
const pparams = {
filter: 'all_ungraded_todo_items',
...params,
context_codes: admin_contexts
}
eventDataSources.push(['/api/v1/planner/items', pparams])
const [admin_contexts, student_contexts] = _.partition(
params.context_codes,
cc => ENV.CALENDAR?.MANAGE_CONTEXTS?.indexOf(cc) >= 0
)
if (student_contexts.length) {
const pparams = {filter: 'ungraded_todo_items', ...params, context_codes: student_contexts}
eventDataSources.push(['/api/v1/planner/items', pparams])
}
if (admin_contexts.length) {
const pparams = {
filter: 'all_ungraded_todo_items',
...params,
context_codes: admin_contexts
}
eventDataSources.push(['/api/v1/planner/items', pparams])
}
return this.startFetch(eventDataSources, dataCB, doneCB, options)
}

View File

@ -24,18 +24,19 @@ import denver from 'timezone/America/Denver'
import juneau from 'timezone/America/Juneau'
import french from 'timezone/fr_FR'
import AgendaView from 'compiled/views/calendar/AgendaView'
import Calendar from 'compiled/calendar/Calendar'
import EventDataSource from 'compiled/calendar/EventDataSource'
import eventResponse from 'helpers/ajax_mocks/api/v1/calendarEvents'
import plannerItemsResponse from 'helpers/ajax_mocks/api/planner/items'
import assignmentResponse from 'helpers/ajax_mocks/api/v1/calendarAssignments'
import I18nStubber from 'helpers/I18nStubber'
import fakeENV from 'helpers/fakeENV'
const loadEventPage = (server, includeNext = false) =>
sendCustomEvents(server, eventResponse, assignmentResponse, includeNext)
var sendCustomEvents = function(server, events, assignments, includeNext = false) {
const requestIndex = server.requests.length - 2
server.requests[requestIndex].respond(
sendCustomEvents(server, eventResponse, assignmentResponse, plannerItemsResponse, includeNext)
const sendCustomEvents = function(server, events, assignments, plannerItems, includeNext = false) {
const requestIndex = server.requests.length - 3
server.requests[requestIndex].respond(200, {'Content-Type': 'application/json'}, plannerItems)
server.requests[requestIndex + 1].respond(
200,
{
'Content-Type': 'application/json',
@ -43,7 +44,7 @@ var sendCustomEvents = function(server, events, assignments, includeNext = false
},
events
)
return server.requests[requestIndex + 1].respond(
return server.requests[requestIndex + 2].respond(
200,
{'Content-Type': 'application/json'},
assignments
@ -151,7 +152,13 @@ test('should only include days on page breaks once', function() {
date.setFullYear(date.getFullYear() + 1)
addEvents(events, date)
}
sendCustomEvents(this.server, JSON.stringify(events), JSON.stringify([]), true)
sendCustomEvents(
this.server,
JSON.stringify(events),
JSON.stringify([]),
JSON.stringify([]),
true
)
ok(
this.container.find('.agenda-event__item-container').length,
40,
@ -164,7 +171,13 @@ test('should only include days on page breaks once', function() {
addEvents(events, date)
date.setFullYear(date.getFullYear() + 1)
}
sendCustomEvents(this.server, JSON.stringify(events), JSON.stringify([]), false)
sendCustomEvents(
this.server,
JSON.stringify(events),
JSON.stringify([]),
JSON.stringify([]),
false
)
equal(
this.container.find('.agenda-event__item-container').length,
70,

View File

@ -0,0 +1,19 @@
/*
* Copyright (C) 2013 - 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/>.
*/
export default `[]`