summaryrefslogtreecommitdiffstats
path: root/cypress_test/integration_tests/desktop/writer/copy_paste_spec.js
blob: 32d1d9b180343bb0dfa0f92835a9744d7fbe815c (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
/* global describe it cy beforeEach require expect afterEach*/

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

describe('Clipboard operations.', function() {
	var origTestFileName = 'copy_paste.odt';
	var testFileName;

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

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

	it('Copy and Paste text.', function() {
		// Select some text
		helper.selectAllText();

		cy.get('.leaflet-marker-icon')
			.then(function(marker) {
				expect(marker).to.have.lengthOf(2);
				var XPos =  (marker[0].getBoundingClientRect().right + marker[1].getBoundingClientRect().left) / 2;
				var YPos = marker[0].getBoundingClientRect().top - 5;

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

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

		// COOL code can not execute document.execCommand() when executed by cypress
		// https://github.com/cypress-io/cypress/issues/2851
		cy.get('.vex-dialog-message p')
			.should('have.text', 'Your browser has very limited access to the clipboard, so use these keyboard shortcuts:');

		cy.get('.vex-dialog-form button[type=\'submit\']')
			.click();

		cy.get('.vex-dialog-form')
			.should('not.exist');
	});
});