Skip to content

Commit

Permalink
fix(test): adjust duplication test
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 Apr 30, 2024
1 parent 496feb1 commit d518438
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const translations = defineMessages({
});

interface CourseDropdownMenuProps {
additionalClassName: string;
prompt: string;
currentHost: string;
selectedCourseId: number;
Expand All @@ -33,8 +34,14 @@ interface CourseDropdownMenuProps {
}

const CourseDropdownMenu: FC<CourseDropdownMenuProps> = (props) => {
const { prompt, currentHost, courses, currentCourseId, selectedCourseId } =
props;
const {
additionalClassName,
prompt,
currentHost,
courses,
currentCourseId,
selectedCourseId,
} = props;

const { t } = useTranslation();
const dispatch = useAppDispatch();
Expand All @@ -44,7 +51,7 @@ const CourseDropdownMenu: FC<CourseDropdownMenuProps> = (props) => {
<Typography className="mt-6">{prompt}</Typography>
<div className="flex flex-row">
<Select
className="w-full shadow-md m-1 rounded-md"
className={`w-full shadow-md m-1 rounded-md ${additionalClassName}`}
onChange={(event) => {
dispatch(
actions.setDestinationCourseId(event.target.value as number),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const DestinationCourseSelector: FC = () => {
const ExistingCourseDestinationForm = (): JSX.Element => {
return (
<CourseDropdownMenu
additionalClassName="destination-course-dropdown"
courses={destinationCourses}
currentCourseId={currentCourseId}
currentHost={currentHost}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ const {
} = duplicableItemTypes;

interface SidebarItemsProps {
className: string;
panelKey: string;
titleKey: string;
count: number;
}

const SidebarItem: FC<SidebarItemsProps> = (props) => {
const { panelKey, titleKey, count } = props;
const { className, panelKey, titleKey, count } = props;
const { t } = useTranslation();
const dispatch = useAppDispatch();
const duplication = useAppSelector(selectDuplicationStore);
Expand All @@ -57,6 +58,7 @@ const SidebarItem: FC<SidebarItemsProps> = (props) => {
return (
<ListItem
button
className={className}
onClick={() => dispatch(actions.setItemSelectorPanel(panelKey))}
>
<ListItemAvatar className="h-[50px] flex items-center">
Expand Down Expand Up @@ -97,34 +99,39 @@ const ItemsSelectorMenu: FC = () => {
<List className="items-selector-menu">
{!unduplicableObjectTypes.includes('ASSESSMENT') && (
<SidebarItem
className="items-selector-menu-assessment"
count={assessmentsComponentCount}
panelKey={panels.ASSESSMENTS}
titleKey="course_assessments_component"
/>
)}
{!unduplicableObjectTypes.includes('SURVEY') && (
<SidebarItem
className="items-selector-menu-survey"
count={counts[SURVEY]}
panelKey={panels.SURVEYS}
titleKey="course_survey_component"
/>
)}
{!unduplicableObjectTypes.includes('ACHIEVEMENT') && (
<SidebarItem
className="items-selector-menu-achievement"
count={counts[ACHIEVEMENT]}
panelKey={panels.ACHIEVEMENTS}
titleKey="course_achievements_component"
/>
)}
{!unduplicableObjectTypes.includes('MATERIAL') && (
<SidebarItem
className="items-selector-menu-material"
count={counts[FOLDER] + counts[MATERIAL]}
panelKey={panels.MATERIALS}
titleKey="course_materials_component"
/>
)}
{!unduplicableObjectTypes.includes('VIDEO') && (
<SidebarItem
className="items-selector-menu-video"
count={videosComponentCount}
panelKey={panels.VIDEOS}
titleKey="course_videos_component"
Expand Down
17 changes: 5 additions & 12 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("[class*='destination-course-dropdown']").click
find("[role='option']", text: course.title).click

find('.items-selector-menu span span', text: 'Assessments').click
find("div[class*='items-selector-menu-assessment']", 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 d518438

Please sign in to comment.