This repository has been archived by the owner on Dec 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
/
message.test.js
132 lines (117 loc) · 6.03 KB
/
message.test.js
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
const expect = require('expect-puppeteer');
const lib = require('../../lib/browser');
require('dotenv').config();
beforeAll(async () => {
await lib.getBrowser('E-Mail');
page.waitForSelector('div.x-tree-selected a span',{text: "Posteingang"});
});
describe('message', () => {
let popupWindow;
test('compose message with uploaded attachment', async () => {
popupWindow = await lib.getEditDialog('Verfassen');
let currentUser = await lib.getCurrentUser(popupWindow);
// add recipient
let inputFields = await popupWindow.$$('input');
await inputFields[2].type(currentUser.accountEmailAddress);
await popupWindow.waitForSelector('.search-item.x-combo-selected');
await popupWindow.click('.search-item.x-combo-selected');
await popupWindow.waitFor(500); //wait for new mail line!
await popupWindow.click('input[name=subject]');
await popupWindow.waitFor(500); //musst wait for input!
await expect(popupWindow).toFill('input[name=subject]', 'message with attachment');
const fileToUpload = 'src/test/Felamimail/attachment.txt';
await expect(popupWindow).toClick('.x-btn-text', {text: 'Datei hinzufügen'});
const filePickerWindow = await lib.getNewWindow();
await expect(filePickerWindow).toClick('span',{text: 'Mein Gerät'});
await filePickerWindow.waitForSelector('input[type=file]');
const inputUploadHandle = await filePickerWindow.$('input[type=file]');
await inputUploadHandle.uploadFile(fileToUpload);
await expect(popupWindow).toMatchElement('.x-grid3-cell-inner.x-grid3-col-name', {text:'attachment.txt'});
await popupWindow.waitFor(500); //musst wait for upload complete!
// send message
await expect(popupWindow).toClick('button', {text: 'Senden'});
});
// test('compose message with filemanager attachment', async () => {
// await expect(page).toClick('span', {text: process.env.TEST_BRANDING_TITLE});
// await expect(page).toClick('.x-menu-item-text', {text: 'Dateimanager'});
//
// // @TODO
// });
let newMail;
test('fetch messages', async () => {
await page.click('.t-app-felamimail .x-btn-image.x-tbar-loading');
try{
await page.waitForSelector('.flag_unread',{timeout: 10000});
} catch(e){
await page.click('.t-app-felamimail .x-btn-image.x-tbar-loading');
await page.waitForSelector('.flag_unread',{timeout: 10000});
}
newMail = await expect(page).toMatchElement('.x-grid3-cell-inner.x-grid3-col-subject', {text: 'message with attachment'});
await newMail.click();
});
test('details panel', async () => {
await page.waitForSelector('.preview-panel-felamimail');
});
let attachement;
test('download attachments', async () => {
newMail.click({clickCount: 2});
popupWindow = await lib.getNewWindow();
//await popupWindow.waitForSelector('.ext-el-mask');
await popupWindow.waitFor(() => !document.querySelector('.ext-el-mask'));
await popupWindow.waitForSelector('.tinebase-download-link');
attachement = await popupWindow.$$('.tinebase-download-link');
await attachement[1].hover();
await attachement[1].click('tinebase-download-link-wait');
let file = await lib.download(popupWindow, '.x-menu-item-text', {text:'Herunterladen'});
if(!file.includes('attachment')) {
throw new Error('download of attachments failed!');
}
});
test('file attachment', async () => {
await popupWindow.waitForSelector('.tinebase-download-link');
attachement = await popupWindow.$$('.tinebase-download-link');
await attachement[1].hover();
await attachement[1].click('tinebase-download-link-wait');
await expect(popupWindow).toClick('.x-menu-item-text',
{text: new RegExp('Datei.*'), visible: true});
await popupWindow.waitForSelector('.x-grid3-row.x-grid3-row-first');
await popupWindow.click('.x-grid3-row.x-grid3-row-first');
await expect(popupWindow).toClick('button', {text: 'Ok'});
await popupWindow.close();
});
test('attachment file in filemanager', async () => {
await expect(page).toClick('span', {text: process.env.TEST_BRANDING_TITLE});
await expect(page).toClick('.x-menu-item-text', {text: 'Dateimanager'});
await page.waitForSelector('.x-grid3-cell-inner.x-grid3-col-name', {text: 'Tine 2.0 Admin Account\'s personal files'});
await expect(page).toClick('.x-grid3-cell-inner.x-grid3-col-name', {text: 'Tine 2.0 Admin Account\'s personal files', clickCount: 2});
await page.waitForSelector('.x-grid3-cell-inner.x-grid3-col-name', {text: 'attachment.txt'});
});
});
// skip... is to unstable
describe('email note preference', () => {
test('open Felamimail settings and set note=yes', async () => {
await expect(page).toClick('span', {text: process.env.TEST_BRANDING_TITLE});
await expect(page).toClick('.x-menu-item-text', {text: 'E-Mail'});
await page.waitFor(2000);
await lib.setPreference(page,'E-Mail', 'autoAttachNote', 'ja');
});
test('open compose dialog and check button pressed', async () => {
await page.waitFor(3000);
let popupWindow = await lib.getEditDialog('Verfassen');
await popupWindow.waitForSelector('.x-btn.x-btn-text-icon.x-btn-pressed');
await popupWindow.close();
});
test('open Felamimail settings and set note=no', async () => {
await page.waitFor(2000);
await lib.setPreference(page,'E-Mail', 'autoAttachNote', 'nein');
});
test('open editDialog and check button unpressed', async () => {
await page.waitFor(2000);
let popupWindow = await lib.getEditDialog('Verfassen');
if (await popupWindow.$('.x-btn.x-btn-text-icon.x-btn-pressed') !== null) return Promise.reject('Error: The button is pressed');
await popupWindow.close();
});
});
afterAll(async () => {
browser.close();
});