summaryrefslogtreecommitdiffstats
path: root/cypress_test/integration_tests/mobile/calc/bottom_toolbar_spec.js
blob: 916ba01f8c02b660cb68f49d974b26cc3ee1cf36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
/* global describe it cy require afterEach */

var helper = require('../../common/helper');
var calcHelper = require('../../common/calc_helper');
var mobileHelper = require('../../common/mobile_helper');
var calcMobileHelper = require('./calc_mobile_helper');

require('cypress-wait-until');

describe('Interact with bottom toolbar.', function() {
	var testFileName;

	function before(fileName) {
		testFileName = fileName;
		helper.beforeAll(testFileName, 'calc');

		// Click on edit button
		mobileHelper.enableEditingMobile();

		helper.waitUntilIdle('#toolbar-down');

		calcHelper.clickOnFirstCell();
	}

	afterEach(function() {
		helper.afterAll(testFileName);
	});

	function getTextPosForFirstCell() {
		calcHelper.dblClickOnFirstCell();

		// Select text content
		helper.typeIntoDocument('{ctrl}a');

		helper.initAliasToNegative('currentTextPos');

		cy.get('.leaflet-selection-marker-end')
			.invoke('offset')
			.its('left')
			.as('currentTextPos');

		cy.get('@currentTextPos')
			.should('be.greaterThan', 0);

		calcHelper.removeTextSelection();
	}

	it('Apply bold.', function() {
		before('bottom_toolbar.ods');

		cy.get('.w2ui-tb-image.w2ui-icon.bold')
			.click();

		calcHelper.selectAllMobile();

		cy.get('#copy-paste-container table td b')
			.should('exist');
	});

	it('Apply italic.', function() {
		before('bottom_toolbar.ods');

		cy.get('.w2ui-tb-image.w2ui-icon.italic')
			.click();

		calcHelper.selectAllMobile();

		cy.get('#copy-paste-container table td i')
			.should('exist');
	});

	it('Apply underline.', function() {
		before('bottom_toolbar.ods');

		cy.get('.w2ui-tb-image.w2ui-icon.underline')
			.click();

		calcHelper.selectAllMobile();

		cy.get('#copy-paste-container table td u')
			.should('exist');
	});

	it('Apply strikeout.', function() {
		before('bottom_toolbar.ods');

		cy.get('.w2ui-tb-image.w2ui-icon.strikeout')
			.click();

		calcHelper.selectAllMobile();

		cy.get('#copy-paste-container table td s')
			.should('exist');
	});

	it('Apply font color.', function() {
		before('bottom_toolbar.ods');

		cy.get('.w2ui-tb-image.w2ui-icon.textcolor')
			.click();

		mobileHelper.selectFromColorPalette(0, 5);

		calcHelper.selectAllMobile();

		cy.get('#copy-paste-container table td font')
			.should('have.attr', 'color', '#00FF00');
	});

	it('Apply highlight color.', function() {
		before('bottom_toolbar.ods');

		cy.get('.w2ui-tb-image.w2ui-icon.backcolor')
			.click();

		mobileHelper.selectFromColorPalette(0, 5);

		calcHelper.selectAllMobile();

		cy.get('#copy-paste-container table td')
			.should('have.attr', 'bgcolor', '#00FF00');
	});

	it('Merge cells', function() {
		before('bottom_toolbar.ods');

		// Select the full row
		calcMobileHelper.selectFirstRow();

		// Despite the selection is there, merge cells needs more time here.
		cy.wait(1000);

		cy.get('.w2ui-tb-image.w2ui-icon.togglemergecells')
			.click();

		calcHelper.selectAllMobile(false);

		cy.get('#copy-paste-container table td')
			.should('have.attr', 'colspan', '1024');
	});

	it('Apply left/right alignment', function() {
		before('bottom_toolbar.ods');

		// Set right aligment first
		cy.get('.w2ui-tb-image.w2ui-icon.alignright')
			.click();

		calcHelper.selectAllMobile();

		cy.get('#copy-paste-container table td')
			.should('have.attr', 'align', 'right');

		// Change alignment back
		calcHelper.clickOnFirstCell();

		cy.get('.w2ui-tb-image.w2ui-icon.alignleft')
			.click();

		calcHelper.selectAllMobile();

		cy.get('#copy-paste-container table td')
			.should('have.attr', 'align', 'left');
	});

	it('Align to center.', function() {
		before('bottom_toolbar.ods');

		cy.get('.w2ui-tb-image.w2ui-icon.alignhorizontal')
			.click();

		calcHelper.selectAllMobile();

		cy.get('#copy-paste-container table td')
			.should('have.attr', 'align', 'center');
	});

	it('Change to block alignment.', function() {
		before('bottom_toolbar.ods');

		cy.get('.w2ui-tb-image.w2ui-icon.alignblock')
			.click();

		calcHelper.selectAllMobile();

		cy.get('#copy-paste-container table td')
			.should('have.attr', 'align', 'justify');
	});

	it('Enable text wrapping.', function() {
		before('bottom_toolbar.ods');

		helper.initAliasToNegative('originalTextPos');

		getTextPosForFirstCell();
		cy.get('@currentTextPos')
			.as('originalTextPos');

		cy.get('@currentTextPos')
			.should('be.greaterThan', 0);

		calcHelper.clickOnFirstCell();

		cy.get('.w2ui-tb-image.w2ui-icon.wraptext')
			.click();

		// We use the text position as indicator
		cy.waitUntil(function() {
			getTextPosForFirstCell();

			return cy.get('@currentTextPos')
				.then(function(currentTextPos) {
					return cy.get('@originalTextPos')
						.then(function(originalTextPos) {
							return originalTextPos > currentTextPos;
						});
				});
		});
	});

	it('Insert row after.', function() {
		before('bottom_toolbar2.ods');

		cy.get('.w2ui-tb-image.w2ui-icon.insertrowsafter')
			.click();

		calcHelper.selectAllMobile();

		cy.get('#copy-paste-container table tr')
			.should('have.length', 3);

		cy.get('#copy-paste-container table tr:nth-of-type(1)')
			.should('contain.text', 'long line long line long line');

		cy.get('#copy-paste-container table tr:nth-of-type(2)')
			.should('not.contain.text', 'long line long line long line');

		cy.get('#copy-paste-container table tr:nth-of-type(2)')
			.should('not.contain.text', '2');

		cy.get('#copy-paste-container table tr:nth-of-type(3)')
			.should('contain.text', '2');
	});

	it('Insert column after.', function() {
		before('bottom_toolbar2.ods');

		cy.get('.w2ui-tb-image.w2ui-icon.insertcolumnsafter')
			.click();

		calcHelper.selectAllMobile();

		cy.get('#copy-paste-container table tr')
			.should('have.length', 2);

		cy.get('#copy-paste-container table tr:nth-of-type(1) td')
			.should('have.length', 3);

		cy.get('#copy-paste-container table tr:nth-of-type(1) td:nth-of-type(1)')
			.should('contain.text', 'long line long line long line');

		cy.get('#copy-paste-container table tr:nth-of-type(1) td:nth-of-type(2)')
			.should('not.contain.text', 'long line long line long line');

		cy.get('#copy-paste-container table tr:nth-of-type(1) td:nth-of-type(2)')
			.should('not.contain.text', '1');

		cy.get('#copy-paste-container table tr:nth-of-type(1) td:nth-of-type(3)')
			.should('contain.text', '1');
	});
});