Skip to content

Commit

Permalink
fix(test): adjust duplication test and remove source courses list
Browse files Browse the repository at this point in the history
- due to change in the UI for duplication page
- source course button needs to be removed
  • Loading branch information
bivanalhar committed Aug 7, 2024
1 parent 3f2d1f8 commit 27b1e5b
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 38 deletions.
13 changes: 0 additions & 13 deletions app/controllers/course/object_duplications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ class Course::ObjectDuplicationsController < Course::ComponentController
helper Course::Achievement::AchievementsHelper

def new
load_source_courses_data
load_destination_courses_data
load_items_data
load_destination_instances_data
Expand All @@ -25,18 +24,6 @@ def authorize_duplication

private

def load_source_courses_data
ActsAsTenant.without_tenant do
# Workaround to get Courses where current user is allowed to duplicate contents from
# without having to use accessible_by, which can take up to 5 minutes with includes
course_copiers = CourseUser.where(user: current_user).
where(role: CourseUser::MANAGER_ROLES.to_a) +
CourseUser.where(user: current_user).
where(role: :observer)
@source_courses = Course.includes(:instance).find(course_copiers.map(&:course_id))
end
end

def load_destination_courses_data
ActsAsTenant.without_tenant do
# Workaround to get Courses where current user plays one of manager roles
Expand Down
2 changes: 0 additions & 2 deletions app/views/course/object_duplications/data.json.jbuilder

This file was deleted.

5 changes: 0 additions & 5 deletions app/views/course/object_duplications/new.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# frozen_string_literal: true
json.currentHost current_tenant.host

json.sourceCourses @source_courses do |course|
json.(course, :id, :title)
json.host course.instance.host
end

json.destinationCourses @destination_courses do |course|
json.(course, :id, :title)
json.path course_path(course)
Expand Down
1 change: 0 additions & 1 deletion client/app/api/course/Duplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default class DuplicationAPI extends BaseCourseAPI {
* currentHost: string,
* destinationCourses: Array.<courseShape>,
* destinationInstances: Array.<instanceShape>,
* sourceCourses: courseListingShape,
* sourceCourse: sourceCourseShape,
* assessmentComponent: Array.<categoryShape>,
* surveyComponent: Array.<surveyShape>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ import PropTypes from 'prop-types';

import { duplicationModes } from 'course/duplication/constants';
import { fetchObjectsList } from 'course/duplication/operations';
import {
courseListingShape,
sourceCourseShape,
} from 'course/duplication/propTypes';
import { sourceCourseShape } from 'course/duplication/propTypes';
import { actions } from 'course/duplication/store';
import Page from 'lib/components/core/layouts/Page';
import LoadingIndicator from 'lib/components/core/LoadingIndicator';
Expand Down Expand Up @@ -241,7 +238,6 @@ Duplication.propTypes = {
currentHost: PropTypes.string.isRequired,
currentCourseId: PropTypes.number,
sourceCourse: sourceCourseShape.isRequired,
sourceCourses: courseListingShape,

dispatch: PropTypes.func.isRequired,
intl: PropTypes.object,
Expand All @@ -260,7 +256,6 @@ export default Object.assign(
currentHost: duplication.currentHost,
currentCourseId: duplication.currentCourseId,
sourceCourse: duplication.sourceCourse,
sourceCourses: duplication.sourceCourses,
}))(injectIntl(Duplication)),
{ handle },
);
15 changes: 4 additions & 11 deletions spec/features/course/duplication_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
expect(find_sidebar).to have_text(I18n.t('layouts.duplication.title'))
end

context 'when I am a manager in another course' do
context 'when I am a manager in one specific course' do
let(:source_course) { create(:course) }
let!(:course_user) { create(:course_manager, course: source_course, user: user) }
let(:assessment_title1) { SecureRandom.hex }
Expand All @@ -58,17 +58,14 @@
end

scenario 'I can duplicate objects from that course' do
visit course_duplication_path(course)

find('.source-course-dropdown').click
find("[role='option']", text: source_course.title).click
visit course_duplication_path(source_course)

find("input[value='OBJECT']", visible: false).click

find('.destination-course-dropdown').click
find("[role='option']", text: course.title).click

find('.items-selector-menu span span', text: 'Assessments').click
find('.items-selector-menu span', text: 'Assessments').click
find('label', text: assessment_title1).click
click_on 'Duplicate Items'
click_on 'Duplicate'
Expand All @@ -78,18 +75,14 @@
end

scenario 'I can duplicate the whole course' do
visit course_duplication_path(course)

find('.source-course-dropdown').click
find("[role='option']", text: source_course.title).click
visit course_duplication_path(source_course)

fill_in 'new_title', with: ''
fill_in 'new_title', with: new_course_title

click_on 'Duplicate Course'
click_on 'Continue'

expect(page).not_to have_css('.source-course-dropdown')
wait_for_job
duplicated_course = Course.find_by(title: new_course_title)
expect(duplicated_course).to be_present
Expand Down

0 comments on commit 27b1e5b

Please sign in to comment.