|
| 1 | +describe('Upgrade Tests', function () { |
| 2 | + |
| 3 | + // Protractor doesn't support the UpgradeAdapter's asynchronous |
| 4 | + // bootstrap with Angular 1 at the moment. Get around it by |
| 5 | + // waiting for an element to get `ng-scope` class. |
| 6 | + function waitForNg1AsyncBootstrap() { |
| 7 | + browser.ignoreSynchronization = true; |
| 8 | + browser.driver.wait(function() { |
| 9 | + return element(by.css('.ng-scope')).isPresent(); |
| 10 | + }, 5000); |
| 11 | + } |
| 12 | + |
| 13 | + describe('NG1 Auto-bootstrap', function() { |
| 14 | + |
| 15 | + beforeAll(function () { |
| 16 | + browser.get('/index-ng-app.html'); |
| 17 | + setProtractorToNg1Mode(); |
| 18 | + }); |
| 19 | + |
| 20 | + it('bootstraps as expected', function () { |
| 21 | + expect(element(by.css('#message')).getText()).toEqual('Hello world'); |
| 22 | + }); |
| 23 | + |
| 24 | + }); |
| 25 | + |
| 26 | + describe('NG1 JavaScript Bootstrap', function() { |
| 27 | + |
| 28 | + beforeAll(function () { |
| 29 | + browser.get('/index-bootstrap.html'); |
| 30 | + setProtractorToNg1Mode(); |
| 31 | + }); |
| 32 | + |
| 33 | + it('bootstraps as expected', function () { |
| 34 | + expect(element(by.css('#message')).getText()).toEqual('Hello world'); |
| 35 | + }); |
| 36 | + |
| 37 | + }); |
| 38 | + |
| 39 | + describe('NG1-2 Hybrid Bootstrap', function() { |
| 40 | + |
| 41 | + beforeAll(function () { |
| 42 | + browser.get('/index-1-2-hybrid-bootstrap.html'); |
| 43 | + setProtractorToNg1Mode(); |
| 44 | + }); |
| 45 | + |
| 46 | + it('bootstraps as expected', function () { |
| 47 | + expect(element(by.css('#message')).getText()).toEqual('Hello world'); |
| 48 | + }); |
| 49 | + |
| 50 | + }); |
| 51 | + |
| 52 | + describe('NG1-2 Hybrid Bootstrap with Shared UpgradeAdapter', function() { |
| 53 | + |
| 54 | + beforeAll(function () { |
| 55 | + browser.get('/index-1-2-hybrid-shared-adapter-bootstrap.html'); |
| 56 | + setProtractorToNg1Mode(); |
| 57 | + }); |
| 58 | + |
| 59 | + it('bootstraps as expected', function () { |
| 60 | + expect(element(by.css('#message')).getText()).toEqual('Hello world'); |
| 61 | + }); |
| 62 | + |
| 63 | + }); |
| 64 | + |
| 65 | + describe('Upgraded static component', function() { |
| 66 | + |
| 67 | + beforeAll(function () { |
| 68 | + browser.get('/index-upgrade-static.html'); |
| 69 | + setProtractorToNg1Mode(); |
| 70 | + waitForNg1AsyncBootstrap(); |
| 71 | + }); |
| 72 | + |
| 73 | + it('renders', function () { |
| 74 | + expect(element(by.css('h2')).getText()).toEqual('Windstorm details!'); |
| 75 | + }); |
| 76 | + |
| 77 | + }); |
| 78 | + |
| 79 | + |
| 80 | + describe('Upgraded component with IO', function() { |
| 81 | + |
| 82 | + beforeAll(function () { |
| 83 | + browser.get('/index-upgrade-io.html'); |
| 84 | + setProtractorToNg1Mode(); |
| 85 | + waitForNg1AsyncBootstrap(); |
| 86 | + }); |
| 87 | + |
| 88 | + it('has inputs', function () { |
| 89 | + expect(element(by.css('h2')).getText()).toEqual('Windstorm details!'); |
| 90 | + }); |
| 91 | + |
| 92 | + it('has outputs', function () { |
| 93 | + element(by.buttonText('Delete')).click(); |
| 94 | + expect(element(by.css('h2')).getText()).toEqual('Ex-Windstorm details!'); |
| 95 | + }); |
| 96 | + |
| 97 | + }); |
| 98 | + |
| 99 | + |
| 100 | + describe('Downgraded static component', function() { |
| 101 | + |
| 102 | + beforeAll(function () { |
| 103 | + browser.get('/index-downgrade-static.html'); |
| 104 | + setProtractorToNg1Mode(); |
| 105 | + waitForNg1AsyncBootstrap(); |
| 106 | + }); |
| 107 | + |
| 108 | + it('renders', function () { |
| 109 | + expect(element(by.css('h2')).getText()).toEqual('Windstorm details!'); |
| 110 | + }); |
| 111 | + |
| 112 | + }); |
| 113 | + |
| 114 | + describe('Downgraded component with IO', function() { |
| 115 | + |
| 116 | + beforeAll(function () { |
| 117 | + browser.get('/index-downgrade-io.html'); |
| 118 | + setProtractorToNg1Mode(); |
| 119 | + waitForNg1AsyncBootstrap(); |
| 120 | + }); |
| 121 | + |
| 122 | + it('has inputs', function () { |
| 123 | + expect(element.all(by.css('h2')).first().getText()).toEqual('Windstorm details!'); |
| 124 | + }); |
| 125 | + |
| 126 | + it('has outputs', function () { |
| 127 | + element.all(by.buttonText('Delete')).first().click(); |
| 128 | + expect(element.all(by.css('h2')).first().getText()).toEqual('Ex-Windstorm details!'); |
| 129 | + }); |
| 130 | + |
| 131 | + it('supports ng-repeat', function () { |
| 132 | + expect(element.all(by.css('hero-detail')).count()).toBe(3); |
| 133 | + }); |
| 134 | + |
| 135 | + }); |
| 136 | + |
| 137 | + |
| 138 | + describe('Downgraded component with content projection', function() { |
| 139 | + |
| 140 | + beforeAll(function () { |
| 141 | + browser.get('/index-1-to-2-projection.html'); |
| 142 | + setProtractorToNg1Mode(); |
| 143 | + waitForNg1AsyncBootstrap(); |
| 144 | + }); |
| 145 | + |
| 146 | + it('can be transcluded into', function () { |
| 147 | + expect(element(by.css('hero-detail')).getText()).toContain('Specific powers of controlling winds'); |
| 148 | + }); |
| 149 | + |
| 150 | + }); |
| 151 | + |
| 152 | + |
| 153 | + describe('Upgraded component with transclusion', function() { |
| 154 | + |
| 155 | + beforeAll(function () { |
| 156 | + browser.get('/index-2-to-1-transclusion.html'); |
| 157 | + setProtractorToNg1Mode(); |
| 158 | + waitForNg1AsyncBootstrap(); |
| 159 | + }); |
| 160 | + |
| 161 | + it('can be projected into', function () { |
| 162 | + expect(element(by.css('hero-detail')).getText()).toContain('Specific powers of controlling winds'); |
| 163 | + }); |
| 164 | + |
| 165 | + }); |
| 166 | + |
| 167 | + |
| 168 | + describe('Upgrading NG1 Providers', function() { |
| 169 | + |
| 170 | + beforeAll(function () { |
| 171 | + browser.get('/index-1-to-2-providers.html'); |
| 172 | + setProtractorToNg1Mode(); |
| 173 | + waitForNg1AsyncBootstrap(); |
| 174 | + }); |
| 175 | + |
| 176 | + it('works', function () { |
| 177 | + expect(element(by.css('h2')).getText()).toBe('1: Windstorm'); |
| 178 | + }); |
| 179 | + |
| 180 | + }); |
| 181 | + |
| 182 | + |
| 183 | + describe('Downgrading NG2 Providers', function() { |
| 184 | + |
| 185 | + beforeAll(function () { |
| 186 | + browser.get('/index-2-to-1-providers.html'); |
| 187 | + setProtractorToNg1Mode(); |
| 188 | + waitForNg1AsyncBootstrap(); |
| 189 | + }); |
| 190 | + |
| 191 | + it('works', function () { |
| 192 | + expect(element(by.css('h2')).getText()).toBe('1: Windstorm'); |
| 193 | + }); |
| 194 | + |
| 195 | + }); |
| 196 | + |
| 197 | +}); |
0 commit comments