summaryrefslogtreecommitdiff
path: root/cypress_test/integration_tests/common/nextcloud_helper.js
blob: 304c814e9504da2c24e25c35d154e310da01c339 (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
/* global cy Cypress require */

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

function checkAndCloseRevisionHistory() {
	mobileHelper.openHamburgerMenu();

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

	cy.contains('.menu-entry-with-icon', 'See revision history')
		.then(function(item) {
			Cypress.env('IFRAME_LEVEL', '');
			cy.wrap(item)
				.click();
		});
	cy.get('#app-sidebar')
		.should('be.visible');

	cy.get('section#tab-versionsTabView')
		.should('be.visible');

	cy.get('.app-sidebar__close.icon-close')
		.then(function(item) {
			Cypress.env('IFRAME_LEVEL', '1');
			cy.wrap(item)
				.click();
		});

	cy.get('#revViewerContainer .icon-close')
		.then(function(item) {
			Cypress.env('IFRAME_LEVEL', '2');
			cy.wrap(item)
				.click();
		});
}

function checkAndCloseSharing() {
	mobileHelper.openHamburgerMenu();

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

	cy.contains('.menu-entry-with-icon', 'Share...')
		.then(function(item) {
			Cypress.env('IFRAME_LEVEL', '');
			cy.wrap(item)
				.click();
		});

	cy.get('#app-sidebar')
		.should('be.visible');

	// issue here
	//cy.get('section#sharing')
	//	.should('be.visible');

	cy.get('.app-sidebar__close.icon-close')
		.then(function(item) {
			Cypress.env('IFRAME_LEVEL', '2');
			cy.wrap(item)
				.click();
		});
}

function insertImageFromStorage(fileName) {
	mobileHelper.openInsertionWizard();

	cy.get('.insertgraphicremote')
		.then(function(item) {
			Cypress.env('IFRAME_LEVEL', '');
			cy.wrap(item)
				.click();
		});

	cy.get('.oc-dialog')
		.should('be.visible');

	cy.get('tr[data-entryname=\'' + fileName + '\']')
		.click();

	cy.get('.oc-dialog-buttonrow .primary')
		.then(function(item) {
			Cypress.env('IFRAME_LEVEL', '2');
			cy.wrap(item)
				.click();
		});
}

function saveFileAs(fileName) {
	mobileHelper.enableEditingMobile();

	mobileHelper.openHamburgerMenu();

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

	cy.contains('.menu-entry-with-icon', 'Save As...')
		.then(function(item) {
			Cypress.env('IFRAME_LEVEL', '1');
			cy.wrap(item)
				.click();
		});

	cy.get('.oc-dialog')
		.should('be.visible');

	cy.get('.oc-dialog input')
		.clear()
		.type(fileName);

	cy.get('.oc-dialog-buttonrow .primary')
		.then(function(item) {
			Cypress.env('IFRAME_LEVEL', '2');
			cy.wrap(item)
				.click();
		});
}

module.exports.checkAndCloseRevisionHistory = checkAndCloseRevisionHistory;
module.exports.checkAndCloseSharing = checkAndCloseSharing;
module.exports.insertImageFromStorage = insertImageFromStorage;
module.exports.saveFileAs = saveFileAs;