summaryrefslogtreecommitdiffstats
path: root/cypress_test/integration_tests/mobile/calc/chart_spec.js
blob: 96476fa379024797c7cfe0293ccaad7177349c7c (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
/* global describe it cy beforeEach require afterEach expect*/

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

describe('Chart tests.', function() {
	var testFileName = 'chart.ods';

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

		mobileHelper.enableEditingMobile();

		calcHelper.selectFirstColumn();

		insertChart();
	});

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

	function insertChart() {
		mobileHelper.openInsertionWizard();

		cy.contains('.menu-entry-with-icon', 'Chart...')
			.click();

		cy.get('.leaflet-drag-transform-marker')
			.should('have.length', 32);

		cy.get('svg .OLE2')
			.should('exist');

		cy.get('svg .OLE2 g g path')
			.should('have.length', 40);
	}

	function stepIntoChartEditing() {
		cy.get('.leaflet-drag-transform-marker')
			.should('exist');

		// Double click onto the chart shape
		cy.get('svg g svg')
			.then(function(items) {
				expect(items).to.have.length(1);
				var boundingRect = items[0].getBoundingClientRect();
				var XPos = boundingRect.left + 10;
				var YPos = (boundingRect.top + boundingRect.bottom) / 2;

				cy.get('body')
					.dblclick(XPos, YPos);
			});

		cy.get('.leaflet-drag-transform-marker')
			.should('not.exist');
	}

	function exitChartEditing() {
		calcHelper.typeIntoFormulabar('{enter}');
	}

	function selectChartOnCenter() {
		cy.get('#document-container')
			.then(function(items) {
				expect(items).to.have.length(1);
				var boundingRect = items[0].getBoundingClientRect();
				var XPos = (boundingRect.left + boundingRect.right) / 2;
				var YPos = (boundingRect.top + boundingRect.bottom) / 2;
				cy.get('body')
					.click(XPos, YPos);
			});

		cy.get('.leaflet-drag-transform-marker')
			.should('be.visible');
	}

	it.skip('Change chart type.', function() {
		stepIntoChartEditing();

		mobileHelper.openMobileWizard();

		helper.clickOnIdle('#ChartTypePanel');

		helper.clickOnIdle('#cmb_chartType');

		helper.clickOnIdle('.ui-combobox-text', 'Pie');

		// TODO: this leads to crash?
		//mobileHelper.closeMobileWizard();

		exitChartEditing();

		selectChartOnCenter();

		cy.get('svg .OLE2 g g path')
			.should('have.length', 7);
	});
});