|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +/** |
| 4 | + * This scenario checks the presence of the table of contents for a sample of pages - API and guide. |
| 5 | + * The expectations are kept vague so that they can be easily adjusted when the docs change. |
| 6 | + */ |
| 7 | + |
| 8 | +describe('table of contents', function() { |
| 9 | + |
| 10 | + it('on provider pages', function() { |
| 11 | + browser.get('build/docs/index.html#!/api/ng/provider/$controllerProvider'); |
| 12 | + |
| 13 | + var toc = element.all(by.css('toc-container > div > toc-tree')); |
| 14 | + toc.getText().then(function(text) { |
| 15 | + expect(text.join('')).toContain('Overview'); |
| 16 | + expect(text.join('')).toContain('Methods'); |
| 17 | + }); |
| 18 | + |
| 19 | + var tocFirstLevel = element.all(by.css('toc-container > div > toc-tree > ul > li')); |
| 20 | + |
| 21 | + tocFirstLevel.then(function(match) { |
| 22 | + expect(match.length).toBe(2); |
| 23 | + |
| 24 | + expect(match[1].all(by.css('li')).count()).toBe(2); |
| 25 | + }); |
| 26 | + |
| 27 | + }); |
| 28 | + |
| 29 | + it('on service pages', function() { |
| 30 | + browser.get('build/docs/index.html#!/api/ng/service/$controller'); |
| 31 | + |
| 32 | + var toc = element.all(by.css('toc-container > div > toc-tree')); |
| 33 | + toc.getText().then(function(text) { |
| 34 | + expect(text.join('')).toContain('Overview'); |
| 35 | + expect(text.join('')).toContain('Usage'); |
| 36 | + }); |
| 37 | + |
| 38 | + var tocFirstLevel = element.all(by.css('toc-container > div > toc-tree > ul > li')); |
| 39 | + |
| 40 | + tocFirstLevel.then(function(match) { |
| 41 | + expect(match.length).toBe(3); |
| 42 | + |
| 43 | + expect(match[2].all(by.css('li')).count()).toBe(2); |
| 44 | + }); |
| 45 | + }); |
| 46 | + |
| 47 | + it('on directive pages', function() { |
| 48 | + browser.get('build/docs/index.html#!/api/ng/directive/input'); |
| 49 | + |
| 50 | + var toc = element.all(by.css('toc-container > div > toc-tree')); |
| 51 | + toc.getText().then(function(text) { |
| 52 | + expect(text.join('')).toContain('Overview'); |
| 53 | + expect(text.join('')).toContain('Usage'); |
| 54 | + expect(text.join('')).toContain('Directive Info'); |
| 55 | + }); |
| 56 | + |
| 57 | + var tocFirstLevel = element.all(by.css('toc-container > div > toc-tree > ul > li')); |
| 58 | + |
| 59 | + tocFirstLevel.then(function(match) { |
| 60 | + expect(match.length).toBe(4); |
| 61 | + |
| 62 | + expect(match[2].all(by.css('li')).count()).toBe(1); |
| 63 | + }); |
| 64 | + }); |
| 65 | + |
| 66 | + it('on function pages', function() { |
| 67 | + browser.get('build/docs/index.html#!/api/ng/function/angular.bind'); |
| 68 | + |
| 69 | + var toc = element.all(by.css('toc-container > div > toc-tree')); |
| 70 | + toc.getText().then(function(text) { |
| 71 | + expect(text.join('')).toContain('Overview'); |
| 72 | + expect(text.join('')).toContain('Usage'); |
| 73 | + }); |
| 74 | + |
| 75 | + var tocFirstLevel = element.all(by.css('toc-container > div > toc-tree > ul > li')); |
| 76 | + |
| 77 | + tocFirstLevel.then(function(match) { |
| 78 | + expect(match.length).toBe(2); |
| 79 | + |
| 80 | + expect(match[1].all(by.css('li')).count()).toBe(2); |
| 81 | + }); |
| 82 | + }); |
| 83 | + |
| 84 | + it('on type pages', function() { |
| 85 | + browser.get('build/docs/index.html#!/api/ng/type/ModelOptions'); |
| 86 | + |
| 87 | + var toc = element.all(by.css('toc-container > div > toc-tree')); |
| 88 | + toc.getText().then(function(text) { |
| 89 | + expect(text.join('')).toContain('Overview'); |
| 90 | + expect(text.join('')).toContain('Methods'); |
| 91 | + }); |
| 92 | + |
| 93 | + var tocFirstLevel = element.all(by.css('toc-container > div > toc-tree > ul > li')); |
| 94 | + |
| 95 | + tocFirstLevel.then(function(match) { |
| 96 | + expect(match.length).toBe(2); |
| 97 | + |
| 98 | + expect(match[1].all(by.css('li')).count()).toBe(2); |
| 99 | + }); |
| 100 | + }); |
| 101 | + |
| 102 | + it('on filter pages', function() { |
| 103 | + browser.get('build/docs/index.html#!/api/ng/filter/date'); |
| 104 | + |
| 105 | + var toc = element.all(by.css('toc-container > div > toc-tree')); |
| 106 | + toc.getText().then(function(text) { |
| 107 | + expect(text.join('')).toContain('Overview'); |
| 108 | + expect(text.join('')).toContain('Usage'); |
| 109 | + }); |
| 110 | + |
| 111 | + var tocFirstLevel = element.all(by.css('toc-container > div > toc-tree > ul > li')); |
| 112 | + |
| 113 | + tocFirstLevel.then(function(match) { |
| 114 | + expect(match.length).toBe(3); |
| 115 | + |
| 116 | + expect(match[1].all(by.css('li')).count()).toBe(2); |
| 117 | + }); |
| 118 | + }); |
| 119 | + |
| 120 | + it('on guide pages', function() { |
| 121 | + browser.get('build/docs/index.html#!/guide/services'); |
| 122 | + var tocFirstLevel = element.all(by.css('toc-container > div > toc-tree > ul > li')); |
| 123 | + |
| 124 | + tocFirstLevel.then(function(match) { |
| 125 | + expect(match.length).toBe(5); |
| 126 | + |
| 127 | + expect(match[1].all(by.css('li')).count()).toBe(3); |
| 128 | + }); |
| 129 | + }); |
| 130 | +}); |
0 commit comments