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

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

describe('Insert fields via insertion wizard.', function() {
	var testFileName = 'insert_field.odt';

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

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

		mobileHelper.openInsertionWizard();

		// Open fields submenu
		cy.contains('.menu-entry-with-icon.flex-fullwidth', 'More Fields...')
			.click();

		cy.get('.ui-content.level-0.mobile-wizard')
			.should('be.visible');
	});

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

	it('Insert page number field.', function() {
		// Insert field
		cy.contains('.menu-entry-with-icon', 'Page Number')
			.click();

		writerHelper.selectAllTextOfDoc();

		cy.get('#copy-paste-container p sdfield')
			.should('have.attr', 'type', 'PAGE')
			.should('have.text', '1');
	});

	it('Insert page count field.', function() {
		// Insert field
		cy.contains('.menu-entry-with-icon', 'Page Count')
			.click();

		writerHelper.selectAllTextOfDoc();

		cy.get('#copy-paste-container p sdfield')
			.should('have.attr', 'type', 'DOCSTAT')
			.should('have.text', '1');
	});

	it('Insert date field.', function() {
		// Insert field
		cy.contains('.menu-entry-with-icon', 'Date')
			.click();

		writerHelper.selectAllTextOfDoc();

		cy.get('#copy-paste-container p sdfield')
			.should('have.attr', 'type', 'DATETIME');

		var regex = new RegExp(';MM/DD/YY$');
		cy.get('#copy-paste-container p sdfield')
			.should('have.attr', 'sdnum')
			.should('match', regex);
	});

	it('Insert time field.', function() {
		// Insert field
		cy.contains('.menu-entry-with-icon', 'Time')
			.click();

		writerHelper.selectAllTextOfDoc();

		cy.get('#copy-paste-container p sdfield')
			.should('have.attr', 'type', 'DATETIME');

		var regex = new RegExp(';HH:MM:SS AM/PM$');
		cy.get('#copy-paste-container p sdfield')
			.should('have.attr', 'sdnum')
			.should('match', regex);
	});

	it('Insert title field.', function() {
		// Insert field
		cy.contains('.menu-entry-with-icon', 'Title')
			.click();

		writerHelper.selectAllTextOfDoc();

		cy.get('#copy-paste-container p sdfield')
			.should('have.attr', 'type', 'DOCINFO')
			.should('have.attr', 'subtype', 'TITLE');
	});

	it('Insert author field.', function() {
		// Insert field
		cy.contains('.menu-entry-with-icon', 'First Author')
			.click();

		writerHelper.selectAllTextOfDoc();

		cy.get('#copy-paste-container p sdfield')
			.should('have.attr', 'type', 'DOCINFO')
			.should('have.attr', 'subtype', 'CREATE')
			.should('have.attr', 'format', 'AUTHOR');
	});

	it('Insert subject field.', function() {
		// Insert field
		cy.contains('.menu-entry-with-icon', 'Subject')
			.click();

		writerHelper.selectAllTextOfDoc();

		cy.get('#copy-paste-container p sdfield')
			.should('have.attr', 'type', 'DOCINFO')
			.should('have.attr', 'subtype', 'THEME');
	});
});