Added front-end test
This commit is contained in:
		
							parent
							
								
									27a363952b
								
							
						
					
					
						commit
						af7fa15060
					
				
					 2 changed files with 146 additions and 6 deletions
				
			
		|  | @ -123,7 +123,9 @@ exports.handleClientMessage_emailNotificationMissingParams = function (hook, con | |||
|       // (string | mandatory) the text inside the notification
 | ||||
|       text: window._('ep_email_notifications.msgParamsMissing'), | ||||
|       // (bool | optional) if you want it to fade out on its own or just sit there
 | ||||
|       sticky: true | ||||
|       sticky: true, | ||||
|       // (string | optional) add a class name to the gritter msg
 | ||||
|       class_name: "emailNotificationsParamsMissing" | ||||
|     }); | ||||
| 
 | ||||
|     // Hide the notification menu in mysettings
 | ||||
|  | @ -179,6 +181,8 @@ function askClientToEnterEmail(){ | |||
|     sticky: true, | ||||
|     // (int | optional) the time you want it to be alive for before fading out
 | ||||
|     time: 2000, | ||||
|     // (string | optional) add a class name to the gritter msg
 | ||||
|     class_name: "emailNotificationsPopupForm", | ||||
|     // the function to bind to the form
 | ||||
|     after_open: function(e){ | ||||
|       $('#ep_email_form_popup').submit(function(){ | ||||
|  | @ -219,7 +223,9 @@ function checkAndSend(e) { | |||
|       // (string | mandatory) the heading of the notification
 | ||||
|       title: window._('ep_email_notifications.titleGritterError'), | ||||
|       // (string | mandatory) the text inside the notification
 | ||||
|       text: window._('ep_email_notifications.msgOptionsNotChecked') | ||||
|       text: window._('ep_email_notifications.msgOptionsNotChecked'), | ||||
|       // (string | optional) add a class name to the gritter msg
 | ||||
|       class_name: "emailNotificationsSubscrOptionsMissing" | ||||
|     }); | ||||
|   } else if (email) { | ||||
|     $('#' + formName).submit(); | ||||
|  | @ -278,7 +284,9 @@ function showRegistrationSuccess(){ | |||
|     // (string | mandatory) the text inside the notification
 | ||||
|     text: window._('ep_email_notifications.msgSubscrSuccess'), | ||||
|     // (int | optional) the time you want it to be alive for before fading out
 | ||||
|     time: 10000 | ||||
|     time: 10000, | ||||
|     // (string | optional) add a class name to the gritter msg
 | ||||
|     class_name: "emailNotificationsSubscrResponseGood" | ||||
|   }); | ||||
| } | ||||
| 
 | ||||
|  | @ -299,7 +307,9 @@ function showAlreadyRegistered(type){ | |||
|     // (string | mandatory) the text inside the notification
 | ||||
|     text: msg, | ||||
|     // (int | optional) the time you want it to be alive for before fading out
 | ||||
|     time: 7000 | ||||
|     time: 7000, | ||||
|     // (string | optional) add a class name to the gritter msg
 | ||||
|     class_name: "emailNotificationsSubscrResponseBad" | ||||
|   }); | ||||
| 
 | ||||
| } | ||||
|  | @ -314,7 +324,9 @@ function showUnregistrationSuccess(){ | |||
|     // (string | mandatory) the text inside the notification
 | ||||
|     text: window._('ep_email_notifications.msgUnsubscrSuccess'), | ||||
|     // (int | optional) the time you want it to be alive for before fading out
 | ||||
|     time: 10000 | ||||
|     time: 10000, | ||||
|     // (string | optional) add a class name to the gritter msg
 | ||||
|     class_name: "emailNotificationsUnsubscrResponseGood" | ||||
|   }); | ||||
| } | ||||
| 
 | ||||
|  | @ -328,7 +340,9 @@ function showWasNotRegistered(){ | |||
|     // (string | mandatory) the text inside the notification
 | ||||
|     text: window._('ep_email_notifications.msgUnsubscrNotExisting'), | ||||
|     // (int | optional) the time you want it to be alive for before fading out
 | ||||
|     time: 7000 | ||||
|     time: 7000, | ||||
|     // (string | optional) add a class name to the gritter msg
 | ||||
|     class_name: "emailNotificationsUnsubscrResponseBad" | ||||
|   }); | ||||
| 
 | ||||
| } | ||||
|  |  | |||
							
								
								
									
										126
									
								
								static/tests/frontend/specs/email_notifications.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										126
									
								
								static/tests/frontend/specs/email_notifications.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,126 @@ | |||
| describe("email notifications plugin", function(){ | ||||
|   //create a new pad before each test run
 | ||||
|   beforeEach(function(cb){ | ||||
|     helper.newPad(cb); | ||||
|     this.timeout(60000); | ||||
|   }); | ||||
| 
 | ||||
|   // Subscribe malformed email
 | ||||
|   var malformedEmail = "tutti@bad-email"; | ||||
| 
 | ||||
|   // Subscribe good email
 | ||||
|   var goodEmail = "tutti@non-existing-domain.org"; | ||||
| 
 | ||||
|   // Test the form in mysetting menu
 | ||||
| 
 | ||||
|   // Launch the tests
 | ||||
|   // First test without options selected
 | ||||
|   it("makes test without options selected", function(done) { | ||||
|     var chrome$ = helper.padChrome$; | ||||
| 
 | ||||
|     //click on the settings button to make settings visible
 | ||||
|     var $settingsButton = chrome$(".buttonicon-settings"); | ||||
|     $settingsButton.click(); | ||||
| 
 | ||||
|     // Show the notification form
 | ||||
|     chrome$('.ep_email_settings').slideDown(function() { | ||||
| 
 | ||||
|       chrome$('#ep_email_form_mysettings [name=ep_email]').val(goodEmail); | ||||
|       chrome$('#ep_email_form_mysettings [name=ep_email_onStart]').prop('checked', false); | ||||
|       chrome$('#ep_email_form_mysettings [name=ep_email_onEnd]').prop('checked', false); | ||||
| 
 | ||||
|       chrome$('#ep_email_form_mysettings [name=ep_email_subscribe]').click(); //function() {
 | ||||
| 
 | ||||
|       // Is the correct gritter msg there
 | ||||
|       helper.waitFor(function() { | ||||
|         return chrome$(".gritter-item").is(':visible') == true; | ||||
|       }) | ||||
|       .done(function(){ | ||||
|         expect(chrome$(".emailNotificationsSubscrOptionsMissing").is(':visible')).to.be(true); | ||||
|         done(); | ||||
|       }); | ||||
|     }); | ||||
|   }); | ||||
| 
 | ||||
|   // Second, test with a malformed email
 | ||||
|   it("makes test subscription with malformed email address", function(done) { | ||||
|     var chrome$ = helper.padChrome$; | ||||
| 
 | ||||
|     //click on the settings button to make settings visible
 | ||||
|     var $settingsButton = chrome$(".buttonicon-settings"); | ||||
|     $settingsButton.click(); | ||||
| 
 | ||||
|     // Show the notification form
 | ||||
|     chrome$('.ep_email_settings').slideDown(function() { | ||||
| 
 | ||||
|       chrome$('#ep_email_form_mysettings [name=ep_email]').val(malformedEmail); | ||||
|       chrome$('#ep_email_form_mysettings [name=ep_email_onStart]').prop('checked', true); | ||||
| 
 | ||||
|       chrome$('#ep_email_form_mysettings [name=ep_email_subscribe]').click(); | ||||
| 
 | ||||
|       // Is the correct gritter msg there
 | ||||
|       helper.waitFor(function() { | ||||
|         return chrome$(".gritter-item").is(':visible') == true; | ||||
|       }) | ||||
|       .done(function(){ | ||||
|         expect(chrome$(".emailNotificationsSubscrResponseBad").is(':visible')).to.be(true); | ||||
|         done(); | ||||
|       }); | ||||
|     }); | ||||
|   }); | ||||
| 
 | ||||
|   // Third, test unsubscription with an email not registered
 | ||||
|   it("makes test unsubscription with an unregistered email address", function(done) { | ||||
|     var chrome$ = helper.padChrome$; | ||||
| 
 | ||||
|     //click on the settings button to make settings visible
 | ||||
|     var $settingsButton = chrome$(".buttonicon-settings"); | ||||
|     $settingsButton.click(); | ||||
| 
 | ||||
|     // Show the notification form
 | ||||
|     chrome$('.ep_email_settings').slideDown(function() { | ||||
| 
 | ||||
|       chrome$('#ep_email_form_mysettings [name=ep_email]').val(goodEmail); | ||||
| 
 | ||||
|       chrome$('#ep_email_form_mysettings [name=ep_email_unsubscribe]').click(); | ||||
| 
 | ||||
|       // Is the correct gritter msg there
 | ||||
|       helper.waitFor(function() { | ||||
|         return chrome$(".gritter-item").is(':visible') == true; | ||||
|       }) | ||||
|       .done(function(){ | ||||
|         expect(chrome$(".emailNotificationsUnsubscrResponseBad").is(':visible')).to.be(true); | ||||
| 
 | ||||
|         done(); | ||||
|       }); | ||||
|     }); | ||||
|   }); | ||||
| 
 | ||||
|   // Fourth, test subscription with a good email
 | ||||
|   it("makes test subscription with an unregistered email address", function(done) { | ||||
|     var chrome$ = helper.padChrome$; | ||||
| 
 | ||||
|     //click on the settings button to make settings visible
 | ||||
|     var $settingsButton = chrome$(".buttonicon-settings"); | ||||
|     $settingsButton.click(); | ||||
| 
 | ||||
|     // Show the notification form
 | ||||
|     chrome$('.ep_email_settings').slideDown(function() { | ||||
| 
 | ||||
|       chrome$('#ep_email_form_mysettings [name=ep_email]').val(goodEmail); | ||||
|       chrome$('#ep_email_form_mysettings [name=ep_email_onStart]').prop('checked', true); | ||||
| 
 | ||||
|       chrome$('#ep_email_form_mysettings [name=ep_email_subscribe]').click(); | ||||
| 
 | ||||
|       // Is the correct gritter msg there
 | ||||
|       helper.waitFor(function() { | ||||
|         return chrome$(".gritter-item").is(':visible') == true; | ||||
|       }) | ||||
|       .done(function(){ | ||||
|         expect(chrome$(".emailNotificationsSubscrResponseGood").is(':visible')).to.be(true); | ||||
| 
 | ||||
|         done(); | ||||
|       }); | ||||
|     }); | ||||
|   }); | ||||
| }); | ||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 quenenni
						quenenni