(title: string)
| 67 | } |
| 68 | |
| 69 | function tests(title: string) { |
| 70 | it('should display correct title', async () => { |
| 71 | expect(await page.title.getText()).toContain(title); |
| 72 | }); |
| 73 | |
| 74 | it('should not display submitted message before submit', async () => { |
| 75 | expect(await page.actorSubmitted.isElementPresent(by.css('p'))).toBe(false); |
| 76 | }); |
| 77 | |
| 78 | it('should have form buttons', async () => { |
| 79 | expect(await page.actorFormButtons.count()).toEqual(2); |
| 80 | }); |
| 81 | |
| 82 | it('should have error at start', async () => { |
| 83 | await expectFormIsInvalid(); |
| 84 | }); |
| 85 | |
| 86 | // it('showForm', () => { |
| 87 | // page.form.getInnerHtml().then(html => console.log(html)); |
| 88 | // }); |
| 89 | |
| 90 | it('should have disabled submit button', async () => { |
| 91 | expect(await page.actorFormButtons.get(0).isEnabled()).toBe(false); |
| 92 | }); |
| 93 | |
| 94 | it('resetting name to valid name should clear errors', async () => { |
| 95 | const ele = page.nameInput; |
| 96 | expect(await ele.isPresent()).toBe(true, 'nameInput should exist'); |
| 97 | await ele.clear(); |
| 98 | await ele.sendKeys(testName); |
| 99 | await expectFormIsValid(); |
| 100 | }); |
| 101 | |
| 102 | it('should produce "required" error after clearing name', async () => { |
| 103 | await page.nameInput.clear(); |
| 104 | // await page.roleInput.click(); // to blur ... didn't work |
| 105 | await page.nameInput.sendKeys('x', protractor.Key.BACK_SPACE); // ugh! |
| 106 | expect(await page.form.getAttribute('class')).toMatch('ng-invalid'); |
| 107 | expect(await page.errorMessages.get(0).getText()).toContain('required'); |
| 108 | }); |
| 109 | |
| 110 | it('should produce "at least 4 characters" error when name="x"', async () => { |
| 111 | await page.nameInput.clear(); |
| 112 | await page.nameInput.sendKeys('x'); // too short |
| 113 | await expectFormIsInvalid(); |
| 114 | expect(await page.errorMessages.get(0).getText()).toContain('at least 4 characters'); |
| 115 | }); |
| 116 | |
| 117 | it('resetting name to valid name again should clear errors', async () => { |
| 118 | await page.nameInput.sendKeys(testName); |
| 119 | await expectFormIsValid(); |
| 120 | }); |
| 121 | |
| 122 | it('should have enabled submit button', async () => { |
| 123 | const submitBtn = page.actorFormButtons.get(0); |
| 124 | expect(await submitBtn.isEnabled()).toBe(true); |
| 125 | }); |
| 126 |
no test coverage detected