Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 939abee

Browse files
committed
Update e2e
1 parent bb94ec4 commit 939abee

File tree

1 file changed

+60
-79
lines changed

1 file changed

+60
-79
lines changed

Diff for: public/docs/_examples/cb-a11y/e2e-spec.ts

+60-79
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
1+
///<reference path="e2e-spec.d.ts" />
2+
13
'use strict';
24

35
import { browser, element, by } from 'protractor';
46

5-
declare module jasmine {
6-
7-
interface Matchers {
8-
toHaveTextByCss(expected: any): boolean;
9-
toHaveText(expected: any): boolean;
10-
toBeDisplayed(expectationFailOutput?: any): boolean;
11-
toBePresent(expectationFailOutput?: any): boolean;
12-
toHaveValue(expected: any): boolean;
13-
toContainText(expected: any): boolean;
14-
toBeSelected(expectationFailOutput?: any): boolean;
15-
}
16-
17-
interface ProtractorCustomMatcherResult {
18-
pass: webdriver.promise.Promise<boolean>;
19-
message?: string;
20-
}
21-
22-
}
23-
247
let matchers: any = {
258
toHaveTextByCss: toHaveTextByCss,
269
toHaveText: toHaveText,
@@ -224,72 +207,74 @@ function toHaveClass() {
224207

225208
}
226209

227-
describe('A11y Cookbook', () => {
210+
describe('A11y Cookbook', function() {
211+
212+
beforeEach(function() {
213+
jasmine.addMatchers(matchers);
214+
})
228215

229-
describe('A11y Cookbook main index', () => {
216+
describe('A11y Cookbook main index', function() {
230217

231-
beforeAll(() => {
232-
jasmine.addMatchers(matchers);
218+
beforeAll(function() {
233219
browser.get('');
234220
});
235221

236-
it('should display the main heading and links', () => {
222+
it('should display the main heading and links', function() {
237223
expect('h1').toHaveTextByCss('Angular 2 a11y cookbook');
238224
expect(element.all(by.tagName('a')).get(0)).toHaveText('Accessible form control labels');
239225
expect(element.all(by.tagName('a')).get(1)).toHaveText('Managing focus');
240226
expect(element.all(by.tagName('a')).get(2)).toHaveText('Roles for custom component widgets');
241227
expect(element.all(by.tagName('a')).get(3)).toHaveText('Developer tools');
242228
});
243229

244-
it('should display the dev tool deeplinks', () => {
230+
it('should display the dev tool deeplinks', function() {
245231
element.all(by.tagName('a')).get(3).click();
246232
expect(element.all(by.tagName('a')).get(0)).toHaveText('Demo with a11y errors');
247233
expect(element.all(by.tagName('a')).get(1)).toHaveText('Demo with full a11y features');
248234
});
249235

250236
});
251237

252-
describe('A11y Cookbook control labels', () => {
238+
describe('A11y Cookbook control labels', function() {
253239

254-
beforeAll(() => {
255-
jasmine.addMatchers(matchers);
240+
beforeAll(function() {
256241
browser.get('');
257242
element.all(by.tagName('a')).get(0).click();
258243
});
259244

260-
it('should have the correct page heading', () => {
245+
it('should have the correct page heading', function() {
261246
expect('h2').toHaveTextByCss('Accessible form control labels');
262247
});
263248

264-
it('should have the correct sections', () => {
249+
it('should have the correct sections', function() {
265250
let headings = element.all(by.tagName('h3'));
266251
expect(headings.get(0)).toHaveText('Implicit labeling');
267252
expect(headings.get(1)).toHaveText('Explicit labeling');
268253
expect(headings.get(2)).toHaveText('Hiding labels');
269254
expect(headings.get(3)).toHaveText('Labeling custom controls');
270255
});
271256

272-
it('should have a working implicitly labelled input', () => {
257+
it('should have a working implicitly labelled input', function() {
273258
let testVal = 'Some text';
274259
expect(element.all(by.tagName('label')).get(0)).toHaveText('Type something:');
275260
let input = element.all(by.css('label > input')).first();
276261
expect(input).toHaveValue('');
277-
sendKeys(input, testVal);
262+
input.sendKeys(testVal);
278263
expect(input).toHaveValue(testVal);
279264
testValueDecorator(0, testVal);
280265
});
281266

282-
it('should have a working implicitly labelled textarea', () => {
267+
it('should have a working implicitly labelled textarea', function() {
283268
let testVal = 'Some text';
284269
expect(element.all(by.tagName('label')).get(1)).toHaveText('Type some text:');
285270
let textarea = element.all(by.css('label > textarea')).first();
286271
expect(textarea).toHaveValue('');
287-
sendKeys(textarea, testVal);
272+
textarea.sendKeys(testVal);
288273
expect(textarea).toHaveValue(testVal);
289274
testValueDecorator(1, testVal);
290275
});
291276

292-
it('should have working implicitly labelled checkboxes', () => {
277+
it('should have working implicitly labelled checkboxes', function() {
293278
expect('fieldset legend').toHaveTextByCss('What do you like most about Angular 2?');
294279
let fieldSet = element.all(by.css('fieldset')).first();
295280
expect(fieldSet.all(by.css('label')).get(0)).toHaveText('Template syntax');
@@ -307,7 +292,7 @@ describe('A11y Cookbook', () => {
307292
testValueDecorator(2, '[ "Components", "Template syntax" ]');
308293
});
309294

310-
it('should have working implicitly labelled radiobuttons', () => {
295+
it('should have working implicitly labelled radiobuttons', function() {
311296
expect(element.all(by.css('fieldset legend')).get(1)).toHaveText('Choose your favourite Angular 2 language:');
312297
let fieldSet = element.all(by.css('fieldset')).get(1);
313298
expect(fieldSet.all(by.css('label')).get(0)).toHaveText('TypeScript');
@@ -323,87 +308,86 @@ describe('A11y Cookbook', () => {
323308
testValueDecorator(3, 'JavaScript');
324309
});
325310

326-
it('should have a working implicitly labelled select', () => {
311+
it('should have a working implicitly labelled select', function() {
327312
expect(element.all(by.tagName('label')).get(10)).toContainText('Why are you interested in a11y?');
328313
expect(element.all(by.tagName('select')).get(0)).toHaveValue('Curiosity');
329314
testValueDecorator(4, 'Curiosity');
330315
});
331316

332-
it('should have a working explicitly labelled input', () => {
317+
it('should have a working explicitly labelled input', function() {
333318
let testVal = 'Some text';
334319
expect(element.all(by.tagName('label[for="inputexplicit"]')).first()).toHaveText('Label for input:');
335320
let input = element.all(by.css('#inputexplicit')).get(0);
336321
expect(input).toHaveValue('');
337-
sendKeys(input, testVal);
322+
input.sendKeys(testVal);
338323
expect(input).toHaveValue(testVal);
339324
testValueDecorator(5, testVal);
340325
});
341326

342-
it('should have a working input with hidden label', () => {
327+
it('should have a working input with hidden label', function() {
343328
let testVal = 'Some text';
344329
expect(element.all(by.tagName('label.visually-hidden')).first()).toHaveText('Search:');
345330
let input = element.all(by.css('#inputsearch')).first();
346331
expect(input).toHaveValue('');
347-
sendKeys(input, testVal);
332+
input.sendKeys(testVal);
348333
expect(input).toHaveValue(testVal);
349334
testValueDecorator(6, testVal);
350335
});
351336

352-
it('should have a working input with aria-label', () => {
337+
it('should have a working input with aria-label', function() {
353338
let testVal = 'Some text';
354339
let input = element.all(by.css('input[aria-label="Filter:"')).first();
355340
expect(input).toHaveValue('');
356-
sendKeys(input, testVal);
341+
input.sendKeys(testVal);
357342
expect(input).toHaveValue(testVal);
358343
testValueDecorator(7, testVal);
359344
});
360345

361-
it('should have a working editable div with label', () => {
346+
it('should have a working editable div with label', function() {
362347
let testVal = 'Value';
363348
expect(element.all(by.tagName('div.col-xs-6 label')).first()).toHaveText('Write in this labeled div:');
364349
let input = element.all(by.css('div.col-xs-6 div.edit-box')).first();
365350
expect(input).toHaveText('');
366-
sendKeys(input, testVal);
351+
input.sendKeys(testVal);
367352
expect(input).toHaveText(testVal);
368353
});
369354

370-
it('should have a working wrapped input', () => {
355+
it('should have a working wrapped input', function() {
371356
let testVal = 'Test';
372357
expect(element.all(by.tagName('div.col-xs-6 label span')).first()).toHaveText('Write in this wrapped input:');
373358
let input = element.all(by.css('div.input-group input')).first();
374359
expect(input).toHaveValue('');
375-
sendKeys(input, testVal);
360+
input.sendKeys(testVal);
376361
expect(input).toHaveValue(testVal);
377362
});
378363

379364
});
380365

381-
describe('A11y Cookbook managing focus', () => {
366+
describe('A11y Cookbook managing focus', function() {
382367

383-
beforeAll(() => {
384-
jasmine.addMatchers(matchers);
368+
beforeAll(function() {
385369
browser.get('');
386370
element.all(by.tagName('a')).get(1).click();
387371
});
388372

389-
it('should have the correct page heading', () => {
373+
it('should have the correct page heading', function() {
390374
expect('h2').toHaveTextByCss('Managing focus');
391375
});
392376

393-
it('should have the correct sections', () => {
377+
it('should have the correct sections', function() {
394378
let headings = element.all(by.tagName('h3'));
395379
expect(headings.get(0)).toHaveText('The focus outline');
396380
expect(headings.get(1)).toHaveText('Focus flow');
397381
expect(headings.get(2)).toHaveText('Focusing custom controls');
398382
expect(headings.get(3)).toHaveText('Internal focus in a component');
399383
});
400384

401-
it('should have the focus outline elements', () => {
385+
it('should have the focus outline elements', function() {
402386
expect(element.all(by.cssContainingText('label', 'Focus me for the standard browser outline:')).first()).toBePresent();
403387
expect(element.all(by.cssContainingText('label', 'Focus me for a new and unusual outline:')).first()).toBePresent();
404388
});
405389

406-
it('should have the focus flow elements', () => {
390+
it('should have the focus flow elements', function() {
407391
expect(element.all(by.cssContainingText('label', 'Which city of The USA did you work in:')).first()).toBePresent();
408392
expect(element.all(by.cssContainingText('label', 'How many months did you work in The USA:')).first()).toBePresent();
409393
expect(element.all(by.cssContainingText('label', 'Which city of The Netherlands did you work in:')).first()).toBePresent();
@@ -416,12 +400,12 @@ describe('A11y Cookbook', () => {
416400
expect(element.all(by.cssContainingText('label', 'How many months did you work in The UK:')).first()).toBePresent();
417401
});
418402

419-
it('should have a clickable custom button component', () => {
403+
it('should have a clickable custom button component', function() {
420404
element.all(by.tagName('a11y-custom-button')).get(0).click();
421405
testValueDecorator(0, 'Button has been clicked 1 times');
422406
});
423407

424-
it('should have an error toggling component', () => {
408+
it('should have an error toggling component', function() {
425409
let showErrorButton = element(by.css('a11y-error-demo button.btn.btn-primary'));
426410
expect(showErrorButton).toHaveText('Show error');
427411
let errorBanner = element(by.css('a11y-error-demo div.alert'));
@@ -434,81 +418,78 @@ describe('A11y Cookbook', () => {
434418

435419
});
436420

437-
describe('A11y Cookbook roles for custom components', () => {
421+
describe('A11y Cookbook roles for custom components', function() {
438422

439-
beforeAll(() => {
440-
jasmine.addMatchers(matchers);
423+
beforeAll(function() {
441424
browser.get('');
442425
element.all(by.tagName('a')).get(2).click();
443426
});
444427

445-
it('should have the correct page heading', () => {
428+
it('should have the correct page heading', function() {
446429
expect('h2').toHaveTextByCss('Roles for custom component widgets');
447430
});
448431

449-
it('should have the correct sections', () => {
432+
it('should have the correct sections', function() {
450433
let headings = element.all(by.tagName('h3'));
451434
expect(headings.get(0)).toHaveText('Roles in the template');
452435
expect(headings.get(1)).toHaveText('Roles of the host element');
453436
});
454437

455-
it('should have a working editable div with label and internal role', () => {
438+
it('should have a working editable div with label and internal role', function() {
456439
let testVal = 'Test';
457440
expect(element.all(by.tagName('div.col-xs-6 label')).first()).toHaveText('I set the role in my template:');
458441
let input = element.all(by.css('div[role="textbox"]')).get(0);
459442
expect(input).toHaveText('');
460-
sendKeys(input, testVal);
443+
input.sendKeys(testVal);
461444
expect(input).toHaveText(testVal);
462445
});
463446

464-
it('should have a clickable custom button component with role', () => {
447+
it('should have a clickable custom button component with role', function() {
465448
element.all(by.css('a11y-custom-button[role="button"]')).get(0).click();
466449
testValueDecorator(1, 'Button has been clicked 1 times');
467450
});
468451

469452
});
470453

471-
describe('A11y Cookbook a11y errors page', () => {
454+
describe('A11y Cookbook a11y errors page', function() {
472455

473-
beforeAll(() => {
474-
jasmine.addMatchers(matchers);
456+
beforeAll(function() {
475457
browser.get('');
476458
element.all(by.tagName('a')).get(3).click();
477459
element.all(by.tagName('a')).first().click();
478460
});
479461

480-
it('should have the correct page heading', () => {
462+
it('should have the correct page heading', function() {
481463
expect('h3').toHaveTextByCss('Demo with a11y errors');
482464
});
483465

484-
it('should have the required form elements', () => {
466+
it('should have the required form elements', function() {
485467
testDemoPageLabels();
486468
});
487469

488-
it('should have basic form functionality', () => {
470+
it('should have basic form functionality', function() {
489471
testDemoPageFunction();
490472
});
491473

492474
});
493475

494-
describe('A11y Cookbook a11y features page', () => {
476+
describe('A11y Cookbook a11y features page', function() {
495477

496-
beforeAll(() => {
497-
jasmine.addMatchers(matchers);
478+
beforeAll(function() {
498479
browser.get('');
499480
element.all(by.tagName('a')).get(3).click();
500481
element.all(by.tagName('a')).get(1).click();
501482
});
502483

503-
it('should have the correct page heading', () => {
484+
it('should have the correct page heading', function() {
504485
expect('h2').toHaveTextByCss('Demo with full a11y features');
505486
});
506487

507-
it('should have the required form elements', () => {
488+
it('should have the required form elements', function() {
508489
testDemoPageLabels();
509490
});
510491

511-
it('should have basic form functionality', () => {
492+
it('should have basic form functionality', function() {
512493
testDemoPageFunction();
513494
});
514495

@@ -526,11 +507,11 @@ describe('A11y Cookbook', () => {
526507
let submitButton = element(by.css('button.btn.btn-primary'));
527508
expect(statusBanner).not.toBeDisplayed();
528509
let nameInput = element.all(by.css('input')).get(0);
529-
sendKeys(nameInput, 'John');
510+
nameInput.sendKeys('John');
530511
let surnameInput = element.all(by.css('input')).get(1);
531-
sendKeys(surnameInput, 'Smith');
512+
surnameInput.sendKeys('Smith');
532513
let reasonInput = element.all(by.css('input')).get(2);
533-
sendKeys(reasonInput, 'It is awesome!!');
514+
reasonInput.sendKeys('It is awesome!!');
534515
submitButton.click();
535516
expect(statusBanner).toBeDisplayed();
536517
expect(element.all(by.cssContainingText('div.alert.alert-success',

0 commit comments

Comments
 (0)