summaryrefslogtreecommitdiffstats
path: root/cypress_test/integration_tests/mobile/writer/spellchecking_spec.js
blob: 4068df911e3966e92e5a749c6381c52b9b6f4853 (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
/* global describe it cy beforeEach require afterEach expect*/

var helper = require('../../common/helper');
var mobileHelper = require('../../common/mobile_helper');
var writerHelper = require('../../common/writer_helper');

describe('Spell checking menu.', function() {
	var testFileName = 'spellchecking.odt';

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

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

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

	function openContextMenu() {
		// Do a new selection
		writerHelper.selectAllTextOfDoc();

		// Open context menu
		cy.get('.leaflet-marker-icon')
			.then(function(markers) {
				expect(markers.length).to.have.greaterThan(1);
				for (var i = 0; i < markers.length; i++) {
					if (markers[i].classList.contains('leaflet-selection-marker-start')) {
						var startPos = markers[i].getBoundingClientRect();
					} else if (markers[i].classList.contains('leaflet-selection-marker-end')) {
						var endPos = markers[i].getBoundingClientRect();
					}
				}

				// Remove selection
				helper.typeIntoDocument('{downarrow}');
				cy.get('.leaflet-marker-icon')
					.should('not.exist');

				var XPos = startPos.right + 10;
				var YPos = endPos.top - 10;
				mobileHelper.longPressOnDocument(XPos, YPos);
			});

		cy.get('#mobile-wizard-content')
			.should('be.visible');
	}

	it('Apply suggestion.', function() {
		openContextMenu();

		cy.contains('.context-menu-link', 'hello')
			.click();

		writerHelper.selectAllTextOfDoc();

		helper.expectTextForClipboard('hello');
	});

	it('Ignore one.', function() {
		openContextMenu();

		cy.contains('.context-menu-link', 'Ignore')
			.click();

		openContextMenu();

		// We don't get the spell check context menu any more
		cy.contains('.context-menu-link', 'Paste');
	});

	it('Ignore all.', function() {
		openContextMenu();

		cy.contains('.context-menu-link', 'Ignore All')
			.click();

		openContextMenu();

		// We don't get the spell check context menu any more
		cy.contains('.context-menu-link', 'Paste')
			.should('be.visible');
	});

	it('Check language status for selection.', function() {
		openContextMenu();

		cy.contains('.menu-entry-with-icon', 'Set Language for Selection')
			.click();

		// English is selected
		cy.contains('.ui-content[title="Set Language for Selection"] .menu-entry-checked', 'English (USA)')
			.should('be.visible');
	});

	it('Set None Language for selection.', function() {
		openContextMenu();

		cy.contains('.menu-entry-with-icon', 'Set Language for Selection')
			.click();

		cy.contains('.ui-content[title="Set Language for Selection"] .menu-entry-with-icon', 'None (Do not check spelling)')
			.click();

		openContextMenu();

		// We don't get the spell check context menu any more
		cy.contains('.context-menu-link', 'Paste')
			.should('be.visible');
	});

	it('Check language status for paragraph.', function() {
		openContextMenu();

		cy.contains('.menu-entry-with-icon', 'Set Language for Paragraph')
			.click();

		// English is selected
		cy.contains('.ui-content[title="Set Language for Paragraph"] .menu-entry-checked', 'English (USA)')
			.should('be.visible');
	});

	it('Set None Language for paragraph.', function() {
		openContextMenu();

		cy.contains('.menu-entry-with-icon', 'Set Language for Paragraph')
			.click();

		cy.contains('.ui-content[title="Set Language for Paragraph"] .menu-entry-with-icon', 'None (Do not check spelling)')
			.click();

		openContextMenu();

		// We don't get the spell check context menu any more
		cy.contains('.context-menu-link', 'Paste')
			.should('be.visible');
	});
});