source: cats/SCHEMAcat/trunk/urn.org.isocat.schemacat.site/site/test/e2e/scenarios.js @ 4676

Last change on this file since 4676 was 4676, checked in by andre.moreira@mpi.nl, 10 years ago

Updated client side routing to use HTML5 history API.

File size: 13.3 KB
Line 
1'use strict';
2
3describe('SCHEMAcat', function() {
4        describe('Routing scenario', function() {
5
6                afterEach(function() {
7                                //load the default initial page
8                                browser().navigateTo('/schemacat/site/index.html/workspace/page/1/?schemaIndex=0');
9                });
10
11                // it('should jump to "index.html/workspace/page/1/?schemaIndex=0" when loading <serverURL>/schemacat/site/', function() {
12                //      browser().navigateTo('/schemacat/site/');
13                //      expect(browser().location().url()).toBe('index.html/workspace/page/1/?schemaIndex=0');
14                // });
15
16                it('should jump to "index.html/workspace/page/1/?schemaIndex=0" when location path and hash are empty', function() {
17                        browser().navigateTo('/schemacat/site/index.html');
18                        expect(browser().location().url()).toBe('/index.html/workspace/page/1/?schemaIndex=0');
19                });
20
21                it('should have a working /workspace.html/<page> route', function() {
22                        browser().navigateTo('/schemacat/site/index.html/workspace/page/1/');
23                        expect(browser().location().path()).toBe('/index.html/workspace/page/1/');
24                });
25
26                it('should have a working /about route', function() {
27                        browser().navigateTo('/schemacat/site/index.html/about');
28                        expect(browser().location().url()).toBe('/index.html/about');
29                });
30
31                it('should have a working /contact route', function() {
32                        browser().navigateTo('/schemacat/site/index.html/contact');
33                        expect(browser().location().url()).toBe('/index.html/contact');
34                });
35
36                it('should have a working /accountDetails route', function() {
37                        browser().navigateTo('/schemacat/site/index.html/accountDetails');
38                        expect(browser().location().url()).toBe('/index.html/accountDetails');
39                });
40
41                it('should jump to a different schema when schemaIndex changes', function() {
42                        browser().navigateTo('/schemacat/site/index.html/workspace/page/1/?schemaIndex=1');
43                        expect(browser().location().search()).toEqual({schemaIndex: '1'});
44                        browser().navigateTo('/schemacat/site/index.html/workspace/page/1/?schemaIndex=2');
45                        expect(browser().location().search()).toEqual({schemaIndex: '2'});
46                });
47
48                // it('Should login as administrator', function() {
49                //      element('li[title="userMenu"] a:has(span[data-ng-bind="displayName"])').click();
50                //      element('li[title="userMenu"] span:contains("Login as a different user...")').click();
51                //      input('loginNameInput.text').enter('Menzo.Windhouwer_mpi.nl@clarin.eu');
52                //      alertOK();
53                //      element('#login').click();
54                //      sleep(0.50);
55                //      expect(browser().location().url()).toBe('/index.html/workspace/page/1/?schemaIndex=0');
56                //      expect(element('li[title="userMenu"] span[data-ng-bind="displayName"]').text()).toBe('Menzo Windhouwer');
57                // });
58
59                // it('should jump to a different page when page path changes', function() {
60                //      browser().navigateTo('/schemacat/site/index.html/workspace/page/2/');
61                //      sleep(0.5);
62                //      expect(browser().location().path()).toBe('/index.html/workspace/page/2/');
63                // });
64
65                // it('Should login as guest', function() {
66                //      element('li[title="userMenu"] a:has(span[data-ng-bind="displayName"])').click();
67                //      element('li[title="userMenu"] span:contains("Login as a different user...")').click();
68                //      input('loginNameInput.text').enter('guest');
69                //      alertOK();
70                //      element('#login').click();
71                //      sleep(0.50);
72                //      expect(browser().location().url()).toBe('/index.html/workspace/page/1/?schemaIndex=0');
73                //      expect(element('li[title="userMenu"] span[data-ng-bind="displayName"]').text()).toBe('guest');
74                // });
75        });
76        describe('Workspace scenarios', function() {
77                describe('Routes scenario', function() {
78
79                        beforeEach(function() {
80                                //load the default initial page
81                                browser().navigateTo('/schemacat/site/index.html/workspace/page/1/?schemaIndex=0');
82                        });
83                        it('should redirect to "/index.html/workspace/page/1/?schemaIndex=0" when page is invalid (page="a")', function() {
84                                browser().navigateTo('/schemacat/site/index.html/workspace/page/a/?schemaIndex=0');
85                                expect(browser().location().url()).toBe('/index.html/workspace/page/1/?schemaIndex=0');
86                        });
87
88                        it('should redirect to "/index.html/workspace/page/1/?schemaIndex=0" when page is out of range (page=3)', function() {
89                                browser().navigateTo('/schemacat/site/index.html/workspace/page/3/?schemaIndex=0');
90                                expect(browser().location().url()).toBe('/index.html/workspace/page/1/?schemaIndex=0');
91                        });
92
93                        it('should redirect to "/index.html/workspace/page/1/?schemaIndex=0" when page is out of range (page<1)', function() {
94                                browser().navigateTo('/schemacat/site/index.html/workspace/page/0/?schemaIndex=0');
95                                expect(browser().location().url()).toBe('/index.html/workspace/page/1/?schemaIndex=0');
96                        });
97
98                        it('should redirect to "/index.html/workspace/page/1/?schemaIndex=0" when schemaIndex is invalid (schemaIndex="a")', function() {
99                                browser().navigateTo('/schemacat/site/index.html/workspace/page/1/?schemaIndex=a');
100                                expect(browser().location().url()).toBe('/index.html/workspace/page/1/?schemaIndex=0');
101                        });
102
103                        it('should redirect to "/index.html/workspace/page/1/?schemaIndex=0" when schemaIndex is out of range (schemaIndex>9)', function() {
104                                browser().navigateTo('/schemacat/site/index.html/workspace/page/1/?schemaIndex=10');
105                                sleep(0.3)
106                                expect(browser().location().url()).toBe('/index.html/workspace/page/1/?schemaIndex=0');
107                        });
108
109                        it('should redirect to "/index.html/workspace/page/1/?schemaIndex=0" when schemaIndex is out of range (schemaIndex=-1)', function() {
110                                browser().navigateTo('/schemacat/site/index.html/workspace/page/1/?schemaIndex=-1');
111                                expect(browser().location().url()).toBe('/index.html/workspace/page/1/?schemaIndex=0');
112                        });
113
114                        it('should show the schema with index=0 if schemaIndex is not supplied on the route', function() {
115                                browser().navigateTo('/schemacat/site/index.html/workspace/page/1/');
116                                sleep(0.30);
117                                expect(element('#schema-name').html()).not().toEqual('');
118                                expect(element('#schema-name').css('visibility')).toBe('visible');
119                        });
120
121                });
122                describe('Change schema scenario', function() {
123
124                        beforeEach(function() {
125                                //load the default initial page
126                                browser().navigateTo('/schemacat/site/index.html/workspace/page/1/?schemaIndex=0');
127                        });
128
129                        it('should show the clicked schema and update route (animated)', function() {
130                                element('#workspace-main-row table tbody tr:eq(1)').click();
131
132                                expect(browser().location().search()).toEqual({schemaIndex: '1'});
133                                expect(element('#schema-name').html()).not().toEqual('');
134                                expect(element('#schema-name').css('visibility')).toBe('visible');
135                                expect(element('#schema-div').attr('class')).toContain('animated fadeInUp');
136
137                                element('#workspace-main-row table tbody tr:eq(0)').click();
138
139                                expect(browser().location().search()).toEqual({schemaIndex: '0'});
140                                expect(element('#schema-name').html()).not().toEqual('');
141                                expect(element('#schema-name').css('visibility')).toBe('visible');
142                                expect(element('#schema-div').attr('class')).toContain('animated fadeInDown');
143                        });
144
145                        it('should show the clicked schema and update route (not animated)', function() {
146                                browser().navigateTo('/schemacat/site/index.html/workspace/page/1/?schemaIndex=0&animationsDisabled');
147                                element('#workspace-main-row table tbody tr:eq(1)').click();
148
149                                expect(browser().location().search()).toEqual({schemaIndex: '1', animationsDisabled: true});
150                                expect(element('#schema-name').html()).not().toEqual('');
151                                expect(element('#schema-name').css('visibility')).toBe('visible');
152                                expect(element('#schema-div').attr('class')).not().toContain('animated');
153
154                                element('#workspace-main-row table tbody tr:eq(0)').click();
155
156                                expect(browser().location().search()).toEqual({schemaIndex: '0', animationsDisabled: true});
157                                expect(element('#schema-name').html()).not().toEqual('');
158                                expect(element('#schema-name').css('visibility')).toBe('visible');
159                                expect(element('#schema-div').attr('class')).not().toContain('animated');
160                        });
161
162                });
163                describe('Open schema file scenario', function() {
164                        beforeEach(function() {
165                                //load the default initial page
166                                browser().navigateTo('/schemacat/site/index.html/workspace/page/1/?schemaIndex=0');
167                        });
168                        it('should navigate to the schema file url', function() {
169                                element('#files-list a:contains("Open"):eq(0)').click();
170                                expect(browser().window().href()).toContain('/schemacat/schemas/');
171                                expect(browser().window().href()).toContain('/files/');
172                        });
173                });
174        });
175        describe('Contact page scenarios', function() {
176                describe('Load page scenario (animated)', function() {
177                        beforeEach(function() {
178                                browser().navigateTo('/schemacat/site/index.html/workspace/page/1/?schemaIndex=0');
179                        });
180
181                        it('should load the contact page and fade it down when landing directly on the contact page', function() {
182                                browser().navigateTo('/schemacat/site/index.html/contact');
183                                expect(browser().location().url()).toBe('/index.html/contact');
184                                expect(element('#contact').html()).not().toEqual('');
185                                expect(element('#contact').attr('class')).toContain('animated fadeInDown');
186                        });
187
188                        it('should load the contact page and slide it from the right when url changes from the workspace page', function() {
189                                element('#contactTM').click();
190                                expect(browser().location().url()).toBe('/index.html/contact');
191                                expect(element('#contact').html()).not().toEqual('');
192                                expect(element('#contact').attr('class')).toContain('animated slideInRight');
193                        });
194
195                        it('should load the contact page and slide it from the right when url changes from the about page', function() {
196                                element('#aboutTM').click();
197                                element('#contactTM').click();
198                                expect(browser().location().url()).toBe('/index.html/contact');
199                                expect(element('#contact').html()).not().toEqual('');
200                                expect(element('#contact').attr('class')).toContain('animated slideInRight');
201                        });
202
203                        it('should load the contact page and fade it down when url changes from the accountDetails page', function() {
204                                browser().navigateTo('/schemacat/site/index.html/accountDetails');
205                                browser().navigateTo('/schemacat/site/index.html/contact');
206                                expect(browser().location().url()).toBe('/index.html/contact');
207                                expect(element('#contact').html()).not().toEqual('');
208                                expect(element('#contact').attr('class')).toContain('animated fadeInDown');
209                        });
210
211                        it('should load the contact page and fade it down when reload is clicked', function() {
212                                browser().navigateTo('/schemacat/site/index.html/contact');
213                                browser().reload();
214                                expect(browser().location().url()).toBe('/index.html/contact');
215                                expect(element('#contact').html()).not().toEqual('');
216                                expect(element('#contact').attr('class')).toContain('animated fadeInDown');
217                        });
218
219                        it('should load the contact page and fade it down when landing on this page from an external location', function() {
220                                browser().navigateTo('/');
221                                browser().navigateTo('/schemacat/site/index.html/contact');
222                                expect(browser().location().url()).toBe('/index.html/contact');
223                                expect(element('#contact').html()).not().toEqual('');
224                                expect(element('#contact').attr('class')).toContain('animated fadeInDown');
225                        });
226                });
227                describe('Load page scenario (not animated)', function() {
228                        beforeEach(function() {
229                                browser().navigateTo('/schemacat/site/index.html/workspace/page/1/?schemaIndex=0&animationsDisabled');
230                        });
231
232                        it('should load the contact page without animations when url changes from the workspace page', function() {
233                                browser().navigateTo('/schemacat/site/index.html/contact?animationsDisabled');
234                                expect(browser().location().url()).toBe('/index.html/contact?animationsDisabled');
235                                expect(element('#contact').html()).not().toEqual('');
236                                expect(element('#contact').attr('class')).not().toContain('animated');
237                        });
238
239                        it('should load the contact page without animations when url changes from the about page', function() {
240                                browser().navigateTo('/schemacat/site/index.html/about?animationsDisabled');
241                                browser().navigateTo('/schemacat/site/index.html/contact?animationsDisabled');
242                                expect(browser().location().url()).toBe('/index.html/contact?animationsDisabled');
243                                expect(element('#contact').html()).not().toEqual('');
244                                expect(element('#contact').attr('class')).not().toContain('animated');
245                        });
246
247                        it('should load the contact page without animations when url changes from the accountDetails page', function() {
248                                browser().navigateTo('/schemacat/site/index.html/accountDetails?animationsDisabled');
249                                browser().navigateTo('/schemacat/site/index.html/contact?animationsDisabled');
250                                expect(browser().location().url()).toBe('/index.html/contact?animationsDisabled');
251                                expect(element('#contact').html()).not().toEqual('');
252                                expect(element('#contact').attr('class')).not().toContain('animated');
253                        });
254
255                        it('should load the contact page without animations when reload is clicked', function() {
256                                browser().navigateTo('/schemacat/site/index.html/contact?animationsDisabled');
257                                browser().reload();
258                                expect(browser().location().url()).toBe('/index.html/contact?animationsDisabled');
259                                expect(element('#contact').html()).not().toEqual('');
260                                expect(element('#contact').attr('class')).not().toContain('animated');
261                        });
262
263                        it('should load the contact page without animations when landing on this page from an external location', function() {
264                                browser().navigateTo('/');
265                                browser().navigateTo('/schemacat/site/index.html/contact?animationsDisabled');
266                                expect(browser().location().url()).toBe('/index.html/contact?animationsDisabled');
267                                expect(element('#contact').html()).not().toEqual('');
268                                expect(element('#contact').attr('class')).not().toContain('animated');
269                        });
270                });
271        });
272});
Note: See TracBrowser for help on using the repository browser.