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

var helper = require('../../common/helper');
var searchHelper = require('../../common/search_helper');
var mobileHelper = require('../../common/mobile_helper');
var writerMobileHelper = require('./writer_mobile_helper');

describe('Searching via search bar.', function() {
	var testFileName = 'search_bar.odt';

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

		mobileHelper.enableEditingMobile();

		searchHelper.showSearchBar();
	});

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

	it('Search existing word.', function() {
		searchHelper.tpyeIntoSearchField('a');

		// Part of the text should be selected
		cy.get('.leaflet-marker-icon')
			.should('exist');

		cy.get('#copy-paste-container p')
			.should('have.text', '\na');
	});

	it('Search not existing word.', function() {
		writerMobileHelper.selectAllMobile();

		cy.get('.leaflet-marker-icon')
			.should('exist');

		searchHelper.tpyeIntoSearchField('q');

		// Should be no selection
		cy.get('.leaflet-marker-icon')
			.should('not.exist');
	});

	it('Search next / prev instance.', function() {
		searchHelper.tpyeIntoSearchField('a');

		cy.get('.leaflet-marker-icon')
			.should('exist');

		cy.get('#copy-paste-container p')
			.should('have.text', '\na');

		cy.get('#copy-paste-container p b')
			.should('not.exist');

		// Search next instance
		searchHelper.searchNext();

		cy.get('#copy-paste-container p b')
			.should('exist');

		cy.get('.leaflet-marker-icon')
			.should('exist');

		cy.get('#copy-paste-container p')
			.should('have.text', '\na');

		// Search prev instance
		searchHelper.searchPrev();

		cy.get('#copy-paste-container p b')
			.should('not.exist');

		cy.get('.leaflet-marker-icon')
			.should('exist');

		cy.get('#copy-paste-container p')
			.should('have.text', '\na');
	});

	it('Search at the document end.', function() {
		searchHelper.tpyeIntoSearchField('a');

		cy.get('.leaflet-marker-icon')
			.should('exist');

		cy.get('#copy-paste-container p')
			.should('have.text', '\na');

		cy.get('#copy-paste-container p b')
			.should('not.exist');

		// Search next instance
		searchHelper.searchNext();

		cy.get('#copy-paste-container p b')
			.should('exist');

		cy.get('.leaflet-marker-icon')
			.should('exist');

		cy.get('#copy-paste-container p')
			.should('have.text', '\na');

		// Search next instance, which is in the beginning of the document.
		searchHelper.searchNext();

		cy.get('#copy-paste-container p b')
			.should('not.exist');

		cy.get('.leaflet-marker-icon')
			.should('exist');

		cy.get('#copy-paste-container p')
			.should('have.text', '\na');
	});

	it('Cancel search.', function() {
		searchHelper.tpyeIntoSearchField('a');

		// Part of the text should be selected
		cy.get('.leaflet-marker-icon')
			.should('exist');

		cy.get('#copy-paste-container p')
			.should('have.text', '\na');

		// Cancel search -> selection removed
		searchHelper.cancelSearch();

		cy.get('.leaflet-marker-icon')
			.should('not.exist');

		cy.get('input#search-input')
			.should('be.visible');
	});

	it('Close search.', function() {
		searchHelper.tpyeIntoSearchField('a');

		// Part of the text should be selected
		cy.get('.leaflet-marker-icon')
			.should('exist');

		cy.get('#copy-paste-container p')
			.should('have.text', '\na');

		// Close search -> search bar is closed
		searchHelper.closeSearchBar();
	});
});