|
22 | 22 | 'Alphanumeric + Exactly(3) + Required -- debounce(3sec)',
|
23 | 23 | 'Date ISO (yyyy-mm-dd) -- minimum condition >= 2001-01-01',
|
24 | 24 | 'Date US SHORT (mm/dd/yy) -- between the dates 12/01/99 and 12/31/15',
|
25 |
| - 'TextArea: Alphanumeric + Minimum(15) + Required' |
| 25 | + 'TextArea: Alphanumeric + Minimum(15) + Required', |
| 26 | + 'Input20 - ngDisabled =>' |
26 | 27 | ];
|
27 | 28 | var errorMessages = [
|
28 | 29 | 'Must be a positive or negative number. Field is required.',
|
|
71 | 72 | var types = ['Directive', 'Service'];
|
72 | 73 |
|
73 | 74 | // variables used on 2Forms web page
|
74 |
| - var formElement2FormsNames = ['input2', 'input3', 'select1', 'area1']; |
75 |
| - var formElement2FormsSummaryNames = ['First Name', 'Last Name', 'area1', 'select1']; |
| 75 | + var formElement2FormsNames = ['input2', 'input3', 'input4', 'select1', 'area1']; |
| 76 | + var formElement2FormsSummaryNames = ['First Name', 'Last Name', 'input4', 'area1', 'select1']; |
76 | 77 | var errorMessages2Forms = [
|
77 | 78 | 'May only contain letters, numbers and dashes. Must be at least 2 characters. Field is required.',
|
78 | 79 | 'May only contain letters, numbers and dashes. Must be at least 2 characters. Field is required.',
|
79 | 80 | 'Change language',
|
80 | 81 | 'May only contain letters, numbers, dashes and spaces. Must be at least 15 characters. Field is required.'
|
81 | 82 | ];
|
| 83 | + var errorMessages2FormsExtra = 'Field is required.'; |
82 | 84 | var validInput2FormsTexts = [
|
83 | 85 | 'John',
|
84 | 86 | 'Doe',
|
| 87 | + 'abc', |
85 | 88 | 'en',
|
86 | 89 | 'This is a great tool'
|
87 | 90 | ];
|
|
303 | 306 | var inputName;
|
304 | 307 |
|
305 | 308 | for (var i = 0, j = 0, ln = itemRows.length; i < ln; i++) {
|
306 |
| - // since field after input13 is part of errorMessages and is empty string, we need to skip that one |
307 |
| - if (formElement2FormsNames[i] === 'input13') { |
| 309 | + // since field after input4 is part of errorMessages and is empty string, we need to skip that one |
| 310 | + if (formElement2FormsNames[i] === 'input4') { |
308 | 311 | j++;
|
309 | 312 | }
|
310 | 313 | expect(itemRows.get(i).getText()).toEqual(formElement2FormsSummaryNames[i] + ': ' + errorMessages2Forms[j++]);
|
|
314 | 317 |
|
315 | 318 | it('Should enter valid text and make error go away', function () {
|
316 | 319 | for (var i = 0, ln = formElement2FormsNames.length; i < ln; i++) {
|
317 |
| - // some fields are not required or disabled so no error will show up, continue to next ones |
318 |
| - if (formElement2FormsNames[i] === 'input12' || formElement2FormsNames[i] === 'input14') { |
| 320 | + // since field after input4 is part of errorMessages and is empty string, we need to skip that one |
| 321 | + if (formElement2FormsNames[i] === 'input4') { |
319 | 322 | continue;
|
320 | 323 | }
|
| 324 | + |
321 | 325 | var elmInput = $('[name=' + formElement2FormsNames[i] + ']');
|
322 | 326 | elmInput.click();
|
323 | 327 | elmInput.sendKeys(validInput2FormsTexts[i]);
|
|
332 | 336 | }
|
333 | 337 | });
|
334 | 338 |
|
335 |
| - it('Should check that both submit button are now enabled', function() { |
| 339 | + it('Should check that both submit buttons are now enabled', function() { |
| 340 | + var elmSubmit1 = $('[name=save_btn1]'); |
| 341 | + expect(elmSubmit1.isEnabled()).toBe(true); |
| 342 | + |
| 343 | + var elmSubmit2 = $('[name=save_btn2]'); |
| 344 | + expect(elmSubmit2.isEnabled()).toBe(true); |
| 345 | + }); |
| 346 | + |
| 347 | + it('Should make input4 editable & error should show on input4', function() { |
| 348 | + // click on the radio button OFF, that will make the input editable |
| 349 | + element(by.id('radioDisableInput4_off')).click(); |
| 350 | + |
| 351 | + // error should appear |
| 352 | + var elmError = $('.validation-input4'); |
| 353 | + expect(elmError.getText()).toEqual(errorMessages2FormsExtra); |
| 354 | + |
| 355 | + // Save button should become disable |
| 356 | + var elmSubmit1 = $('[name=save_btn1]'); |
| 357 | + expect(elmSubmit1.isEnabled()).toBe(false); |
| 358 | + }); |
| 359 | + |
| 360 | + it('Should show input4 error in ValidationSummary', function () { |
| 361 | + var btnShowSummary = $('button[name=btn_showValidation]'); |
| 362 | + btnShowSummary.click(); |
| 363 | + browser.waitForAngular(); |
| 364 | + |
| 365 | + // showValidation checkbox should false at first but true after |
| 366 | + var elmCheckboxShowSummary = element(by.model('displayValidationSummary')); |
| 367 | + expect(elmCheckboxShowSummary.isSelected()).toBeTruthy(); |
| 368 | + |
| 369 | + // scroll back to top |
| 370 | + browser.executeScript('window.scrollTo(0,0);').then(function () { |
| 371 | + var itemRows = element.all(by.binding('message')); |
| 372 | + var inputName; |
| 373 | + |
| 374 | + for (var i = 0, j = 0, ln = itemRows.length; i < ln; i++) { |
| 375 | + expect(itemRows.get(i).getText()).toEqual('input4: Field is required.'); |
| 376 | + } |
| 377 | + }); |
| 378 | + }); |
| 379 | + |
| 380 | + it('Should disable input4, error go away from input & validation summary', function() { |
| 381 | + // click on the radio button OFF, that will make the input editable |
| 382 | + element(by.id('radioDisableInput4_on')).click(); |
| 383 | + |
| 384 | + // error should appear |
| 385 | + var elmError = $('.validation-input4'); |
| 386 | + expect(elmError.getText()).toEqual(''); |
| 387 | + |
| 388 | + // validation summary should become empty |
| 389 | + var itemRows = element.all(by.binding('message')); |
| 390 | + expect(itemRows.count()).toBe(0); |
| 391 | + }); |
| 392 | + |
| 393 | + it('Should check that both submit buttons are now enabled', function() { |
336 | 394 | var elmSubmit1 = $('[name=save_btn1]');
|
337 | 395 | expect(elmSubmit1.isEnabled()).toBe(true);
|
338 | 396 |
|
|
0 commit comments