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

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

describe('Track Changes', function() {
	var origTestFileName = 'track_changes.odt';
	var testFileName;

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

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

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

	function confirmChange(action) {
		cy.get('#toolbar-hamburger')
			.click()
			.get('.menu-entry-icon.changesmenu').parent()
			.click();
		if (action === 'Accept All') {
			cy.get('.menu-entry-icon.acceptalltrackedchanges')
				.click();
		} else if (action === 'Reject All') {
			cy.get('.menu-entry-icon.rejectalltrackedchanges')
				.click();
		}
	}
	//enable record for track changes
	function enableRecord() {
		cy.get('#toolbar-hamburger')
			.click()
			.get('.menu-entry-icon.changesmenu').parent()
			.click()
			.get('.menu-entry-icon.trackchanges').parent()
			.click();

		//if we don't wait , the test will fail in CLI
		cy.wait(200);

		cy.get('#toolbar-hamburger')
			.click()
			.get('.menu-entry-icon.changesmenu').parent()
			.click()
			.get('.menu-entry-icon.trackchanges').parent()
			.should('have.class', 'menu-entry-checked');

		//to close
		cy.get('#toolbar-hamburger')
			.click();
	}

	it('Accept All', function() {
		helper.typeIntoDocument('Hello World');

		cy.wait(1000);

		enableRecord();

		helper.selectAllText();

		helper.typeIntoDocument('{del}');

		//if we don't wait , the test will fail in CLI
		cy.wait(200);

		helper.selectAllText();

		confirmChange('Accept All');

		helper.typeIntoDocument('{ctrl}a');

		helper.textSelectionShouldNotExist();
	});

	it('Reject All',function() {
		helper.typeIntoDocument('Hello World');

		cy.wait(1000);

		enableRecord();

		helper.selectAllText();

		helper.typeIntoDocument('{del}');

		//if we don't wait , the test will fail in CLI
		cy.wait(400);

		confirmChange('Reject All');

		cy.get('.leaflet-layer').click();

		helper.selectAllText();

		helper.expectTextForClipboard('\nHello World');
	});
});