summaryrefslogtreecommitdiffstats
path: root/cypress_test/integration_tests/desktop/calc/cell_appearance_spec.js
blob: 39b515c060ce221184a6c62d0cb3aa5c82b765ec (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
/* global describe it cy beforeEach require afterEach expect*/

var helper = require('../../common/helper');
var calcHelper = require('../../common/calc_helper');
var desktopHelper = require('../../common/desktop_helper');

describe('Change cell appearance.', function() {
	var origTestFileName = 'cell_appearance.ods';
	var testFileName;

	beforeEach(function() {
		testFileName = helper.beforeAll(origTestFileName, 'calc');
	});

	afterEach(function() {
		helper.afterAll(testFileName, this.currentTest.state);
	});

	it('Apply background color', function() {
		calcHelper.clickOnFirstCell();

		desktopHelper.actionOnSelector('backgroundColor', (selector) => { helper.clickOnIdle(selector); });

		desktopHelper.selectColorFromPalette('006CE7');

		calcHelper.selectEntireSheet();

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

	it('Apply left border', function() {
		calcHelper.clickOnFirstCell();

		desktopHelper.actionOnSelector('borderStyle', (selector) => { helper.clickOnIdle(selector); });

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

		calcHelper.selectEntireSheet();

		cy.get('#copy-paste-container table td')
			.should('have.attr', 'style', 'border-left: 1px solid #000000');
	});

	it('Remove cell border', function() {
		calcHelper.clickOnFirstCell();

		// First add left border
		desktopHelper.actionOnSelector('borderStyle', (selector) => { helper.clickOnIdle(selector); });

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

		calcHelper.selectEntireSheet();

		cy.get('#copy-paste-container table td')
			.should('have.attr', 'style', 'border-left: 1px solid #000000');

		// Then remove it
		calcHelper.clickOnFirstCell();

		desktopHelper.actionOnSelector('borderStyle', (selector) => { helper.clickOnIdle(selector); });

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

		calcHelper.selectEntireSheet();

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

	it('Apply right border', function() {
		calcHelper.clickOnFirstCell();

		desktopHelper.actionOnSelector('borderStyle', (selector) => { helper.clickOnIdle(selector); });

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

		calcHelper.selectEntireSheet();

		cy.get('#copy-paste-container table td')
			.should('have.attr', 'style', 'border-right: 1px solid #000000');
	});

	it('Apply left and right border', function() {
		calcHelper.clickOnFirstCell();

		desktopHelper.actionOnSelector('borderStyle', (selector) => { helper.clickOnIdle(selector); });

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

		calcHelper.selectEntireSheet();

		cy.get('#copy-paste-container table td')
			.should('have.attr', 'style', 'border-left: 1px solid #000000; border-right: 1px solid #000000');
	});

	it('Apply top border', function() {
		calcHelper.clickOnFirstCell();

		desktopHelper.actionOnSelector('borderStyle', (selector) => { helper.clickOnIdle(selector); });

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

		calcHelper.selectEntireSheet();

		cy.get('#copy-paste-container table td')
			.should('have.attr', 'style', 'border-top: 1px solid #000000');
	});

	it('Apply bottom border', function() {
		calcHelper.clickOnFirstCell();

		desktopHelper.actionOnSelector('borderStyle', (selector) => { helper.clickOnIdle(selector); });

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

		calcHelper.selectEntireSheet();

		cy.get('#copy-paste-container table td')
			.should('have.attr', 'style', 'border-bottom: 1px solid #000000');
	});

	it('Apply top and bottom border', function() {
		calcHelper.clickOnFirstCell();

		desktopHelper.actionOnSelector('borderStyle', (selector) => { helper.clickOnIdle(selector); });

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

		calcHelper.selectEntireSheet();

		cy.get('#copy-paste-container table td')
			.should('have.attr', 'style', 'border-top: 1px solid #000000; border-bottom: 1px solid #000000');
	});

	it('Apply border for all sides', function() {
		calcHelper.clickOnFirstCell();

		desktopHelper.actionOnSelector('borderStyle', (selector) => { helper.clickOnIdle(selector); });

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

		calcHelper.selectEntireSheet();

		cy.get('#copy-paste-container table td')
			.should('have.attr', 'style', 'border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000');
	});

	it('Apply horizontal borders for multiple cells', function() {
		calcHelper.selectEntireSheet();

		desktopHelper.actionOnSelector('borderStyle', (selector) => { helper.clickOnIdle(selector); });

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

		calcHelper.selectEntireSheet();

		cy.get('#copy-paste-container table td')
			.should(function(cells) {
				expect(cells).to.have.lengthOf(4);
				for (var i = 0; i < cells.length; i++) {
					expect(cells[i]).to.have.attr('style', 'border-top: 1px solid #000000; border-bottom: 1px solid #000000');
				}
			});
	});

	it('Apply horizontal inner borders and vertical outer borders', function() {
		calcHelper.selectEntireSheet();

		desktopHelper.actionOnSelector('borderStyle', (selector) => { helper.clickOnIdle(selector); });

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

		calcHelper.selectEntireSheet();

		cy.get('#copy-paste-container table td')
			.should(function(cells) {
				expect(cells).to.have.lengthOf(4);
				for (var i = 0; i < cells.length; i++) {
					if (i == 0 || i == 2)
						expect(cells[i]).to.have.attr('style', 'border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000');
					else
						expect(cells[i]).to.have.attr('style', 'border-top: 1px solid #000000; border-bottom: 1px solid #000000');
				}
			});
	});

	it('Apply vertical inner borders and horizontal outer borders', function() {
		calcHelper.selectEntireSheet();

		desktopHelper.actionOnSelector('borderStyle', (selector) => { helper.clickOnIdle(selector); });

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

		calcHelper.selectEntireSheet();

		cy.get('#copy-paste-container table td')
			.should(function(cells) {
				expect(cells).to.have.lengthOf(4);
				for (var i = 0; i < cells.length; i++) {
					if (i == 0 || i == 1)
						expect(cells[i]).to.have.attr('style', 'border-top: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000');
					else
						expect(cells[i]).to.have.attr('style', 'border-left: 1px solid #000000; border-right: 1px solid #000000');
				}
			});
	});

	it('Apply all inner and outer borders', function() {
		calcHelper.selectEntireSheet();

		desktopHelper.actionOnSelector('borderStyle', (selector) => { helper.clickOnIdle(selector); });

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

		calcHelper.selectEntireSheet();

		cy.get('#copy-paste-container table td')
			.should(function(cells) {
				expect(cells).to.have.lengthOf(4);
				for (var i = 0; i < cells.length; i++) {
					expect(cells[i]).to.have.attr('style', 'border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000');
				}
			});
	});

	it('Apply border color', function() {
		calcHelper.clickOnFirstCell();

		// Apply left border first
		desktopHelper.actionOnSelector('borderStyle', (selector) => { helper.clickOnIdle(selector); });

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

		// Then apply border color
		helper.clickOnIdle('#FrameLineColor');

		desktopHelper.selectColorFromPalette('006CE7');

		calcHelper.selectEntireSheet();

		cy.get('#copy-paste-container table td')
			.should('have.attr', 'style', 'border-left: 1px solid #006ce7');
	});

});