ECOM-4906 Add the program editor fix to allow creation of Micromasters programs (#13064)
This commit is contained in:
@@ -26,12 +26,7 @@ define([
|
||||
}],
|
||||
next: null
|
||||
},
|
||||
sampleInput = {
|
||||
organizations: 'test-org-key',
|
||||
name: 'Test Course Name',
|
||||
subtitle: 'Test Course Subtitle',
|
||||
marketing_slug: 'test-management'
|
||||
},
|
||||
sampleInput,
|
||||
completeForm = function( data ) {
|
||||
view.$el.find('#program-name').val( data.name );
|
||||
view.$el.find('#program-subtitle').val( data.subtitle );
|
||||
@@ -63,6 +58,13 @@ define([
|
||||
expect( $errorMsg.find('.field-message-content').html() ).toEqual( inputErrorMsg );
|
||||
};
|
||||
|
||||
var validateFormSubmitted = function(view, programId){
|
||||
expect( $.ajax ).toHaveBeenCalled();
|
||||
expect( view.saveSuccess ).toHaveBeenCalled();
|
||||
expect( view.goToView ).toHaveBeenCalledWith( String( programId ) );
|
||||
expect( view.saveError ).not.toHaveBeenCalled();
|
||||
};
|
||||
|
||||
beforeEach( function() {
|
||||
// Set the DOM
|
||||
setFixtures( '<div class="js-program-admin"></div>' );
|
||||
@@ -74,6 +76,14 @@ define([
|
||||
spyOn( ProgramCreatorView.prototype, 'saveError' ).and.callThrough();
|
||||
spyOn( Router.prototype, 'goHome' );
|
||||
|
||||
sampleInput = {
|
||||
category: 'xseries',
|
||||
organizations: 'test-org-key',
|
||||
name: 'Test Course Name',
|
||||
subtitle: 'Test Course Subtitle',
|
||||
marketing_slug: 'test-management'
|
||||
};
|
||||
|
||||
view = new ProgramCreatorView({
|
||||
router: new Router({
|
||||
homeUrl: '/author/home'
|
||||
@@ -116,10 +126,22 @@ define([
|
||||
|
||||
view.$el.find('.js-create-program').click();
|
||||
|
||||
expect( $.ajax ).toHaveBeenCalled();
|
||||
expect( view.saveSuccess ).toHaveBeenCalled();
|
||||
expect( view.goToView ).toHaveBeenCalledWith( String( programId ) );
|
||||
expect( view.saveError ).not.toHaveBeenCalled();
|
||||
validateFormSubmitted(view, programId);
|
||||
});
|
||||
|
||||
it( 'should submit the form correctly when creating micromasters program ', function(){
|
||||
var programId = 221;
|
||||
sampleInput.category = 'micromasters';
|
||||
|
||||
completeForm( sampleInput );
|
||||
|
||||
spyOn( $, 'ajax' ).and.callFake( function( event ) {
|
||||
event.success({ id: programId });
|
||||
});
|
||||
|
||||
view.$el.find('.js-create-program').click();
|
||||
|
||||
validateFormSubmitted(view, programId);
|
||||
});
|
||||
|
||||
it( 'should run the saveError when model save failures occur', function() {
|
||||
@@ -152,6 +174,19 @@ define([
|
||||
expect( view.model.get('marketing_slug') ).toEqual( sampleInput.marketing_slug );
|
||||
});
|
||||
|
||||
it( 'should not set the model when bad program type selected', function() {
|
||||
var invalidInput = $.extend({}, sampleInput);
|
||||
spyOn( view.model, 'save' );
|
||||
|
||||
// No name provided.
|
||||
invalidInput.category = '';
|
||||
verifyValidation( invalidInput, 'category' );
|
||||
|
||||
// bad program type name
|
||||
invalidInput.name = 'badprogramtype';
|
||||
verifyValidation( invalidInput, 'category' );
|
||||
});
|
||||
|
||||
it( 'should not set the model when an invalid program name is submitted', function() {
|
||||
var invalidInput = $.extend({}, sampleInput);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user