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

Last change on this file since 4191 was 4191, checked in by andmor, 10 years ago

Updated to AngularJS 1.2.5

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