Skip to content

Commit cd12905

Browse files
committed
OO wip
1 parent d057d92 commit cd12905

File tree

7 files changed

+1803
-11
lines changed

7 files changed

+1803
-11
lines changed

browserstack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const caps = {
1414
build: 'localhost-5',
1515
'browserstack.username': process.env.BROWSERSTACK_USERNAME,
1616
'browserstack.accessKey': process.env.BROWSERSTACK_ACCESS_KEY,
17-
'browserstack.local': !!process.env.PW_URL.includes('localhost'),
17+
// 'browserstack.local': !!process.env.PW_URL.includes('localhost'),
1818
// "browserstack.idleTimeout" : "300",
1919
'browserstack.playwrightVersion': clientPlaywrightVersion,
2020
'bstack:options': {

ctrf/ctrf.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@
1010
"pending": 0,
1111
"skipped": 0,
1212
"other": 0,
13-
"start": 1760520499675,
14-
"stop": 1760520516109,
13+
"start": 1761758485425,
14+
"stop": 1761758493378,
1515
"suites": 0
1616
},
1717
"tests": [
1818
{
19-
"name": "loggedin - add and remove other user as contact",
19+
"name": "anon - presentation - export (pdf)",
2020
"status": "passed",
21-
"duration": 15675,
22-
"start": 1760520499,
23-
"stop": 1760520515,
21+
"duration": 7455,
22+
"start": 1761758485,
23+
"stop": 1761758493,
2424
"rawStatus": "passed",
2525
"tags": [],
2626
"type": "e2e",
27-
"filePath": "/home/zuzanna/e2e-test-suite/e2e-tests/z_user_loggedin.spec.js",
27+
"filePath": "/home/zuzanna/e2e-test-suite/e2e-tests/presentation_anon.spec.js",
2828
"retries": 0,
2929
"flaky": false,
3030
"steps": [],
31-
"suite": "chrome@Galaxy S9+ > z_user_loggedin.spec.js",
31+
"suite": "chrome > presentation_anon.spec.js",
3232
"attachments": [],
3333
"stdout": [],
3434
"stderr": [],

e2e-tests/doc_anon.spec.js

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
2+
const { test, url } = require('../fixture.js');
3+
const { expect } = require('@playwright/test');
4+
const { FileActions } = require('./fileactions.js');
5+
const fs = require('fs');
6+
require('dotenv').config();
7+
const os = require('os');
8+
const mammoth = require('mammoth');
9+
// const PDFParse = require('pdf-parse');
10+
const PDFParser = require('pdf2json');
11+
// import PDFParser from "pdf2json";
12+
13+
// const local = !!process.env.PW_URL.includes('localhost');
14+
15+
let mobile;
16+
let browserName;
17+
let browserstackMobile;
18+
let fileActions;
19+
let fileActions1
20+
21+
test.beforeEach(async ({ page }, testInfo) => {
22+
test.setTimeout(90000);
23+
24+
mobile = testInfo.project.use.mobile;
25+
browserName = testInfo.project.name.split(/@/)[0];
26+
browserstackMobile = testInfo.project.name.match(/browserstack-mobile/);
27+
fileActions = new FileActions(page);
28+
await fileActions.loadFileType("doc")
29+
});
30+
31+
test('anon - doc - input text', async ({ page, context }) => {
32+
try {
33+
34+
await fileActions.docEditor.click({force: true});
35+
await fileActions.docEditor.dispatchEvent('focus');
36+
await fileActions.docEditor.dispatchEvent('select');
37+
38+
await fileActions.typeTestTextCode(mobile, 'test text');
39+
await page.keyboard.press('Control+A');
40+
await page.keyboard.press('Control+C');
41+
42+
const clipboardText = await page.evaluate(() => navigator.clipboard.readText());
43+
expect(clipboardText.trim()).toContain('test text');
44+
await fileActions.toSuccess( 'Can input text into Document');
45+
} catch (e) {
46+
await fileActions.toFailure(e,'Can\'t input text into Document');
47+
}
48+
});
49+
50+
test('anon - doc - make a copy', async ({ page, context }) => {
51+
try {
52+
53+
await fileActions.docEditor.click({force: true});
54+
await fileActions.docEditor.dispatchEvent('focus');
55+
await fileActions.docEditor.dispatchEvent('select');
56+
57+
await fileActions.typeTestTextCode(mobile, 'test text');
58+
await page.keyboard.press('Control+A');
59+
await page.keyboard.press('Control+C');
60+
61+
const clipboardText = await page.evaluate(() => navigator.clipboard.readText());
62+
expect(clipboardText.trim()).toContain('test text');
63+
64+
await fileActions.filemenuClick(mobile);
65+
const [page1] = await Promise.all([
66+
page.waitForEvent('popup'),
67+
await fileActions.filecopy.click()
68+
]);
69+
70+
await expect(page1).toHaveURL(new RegExp(`^${url}/doc`), { timeout: 100000 });
71+
fileActions1 = new FileActions(page1);
72+
73+
await fileActions1.fileSaved.waitFor()
74+
await fileActions1.docEditor.click({force: true});
75+
76+
await page1.keyboard.press('Control+A');
77+
await page1.keyboard.press('Control+C');
78+
79+
const clipboardText2 = await page.evaluate(() => navigator.clipboard.readText());
80+
expect(clipboardText2.trim()).toContain('test text');
81+
82+
await fileActions.toSuccess( 'Can make a copy of Document');
83+
} catch (e) {
84+
await fileActions.toFailure(e,'Can\'t make a copy of Document');
85+
}
86+
});
87+
88+
89+
test('anon - doc - insert image', async ({ page, context }) => {
90+
try {
91+
92+
await fileActions.docEditor.click({force: true});
93+
94+
95+
await fileActions.insertTab.click({force: true});
96+
await fileActions.insertImg.click();
97+
await fileActions.imgFromFile.click();
98+
99+
100+
101+
102+
await fileActions.toSuccess( 'Can input text into Document');
103+
} catch (e) {
104+
await fileActions.toFailure(e,'Can\'t input text into Document');
105+
}
106+
});
107+
108+
test('anon - doc - history (previous version)', async ({ page, context }) => {
109+
try {
110+
111+
await fileActions.docEditor.click({force: true});
112+
await fileActions.docEditor.dispatchEvent('focus');
113+
await fileActions.docEditor.dispatchEvent('select');
114+
115+
await fileActions.typeTestTextCode(mobile, 'test text');
116+
117+
await fileActions.history(mobile);
118+
await fileActions.historyFastPrev.click()
119+
await fileActions.fileSaved.waitFor()
120+
await page.locator('#sbox-iframe').contentFrame().getByRole('paragraph').filter({ hasText: 'syncing changes, please wait' }).waitFor({state: 'hidden'})
121+
122+
123+
await fileActions.docEditor.click({force: true});
124+
125+
await page.keyboard.press('Control+A');
126+
await page.keyboard.press('Control+C');
127+
128+
const clipboardText = await page.evaluate(() => navigator.clipboard.readText());
129+
130+
expect(clipboardText.trim()).toEqual('');
131+
132+
await fileActions.toSuccess( 'Can input text into Document');
133+
134+
} catch (e) {
135+
await fileActions.toFailure(e,'Can\'t input text into Document');
136+
}
137+
});
138+
139+
test('anon - doc - export (doc)', async ({ page, context }) => {
140+
try {
141+
142+
await fileActions.docEditor.click({force: true});
143+
await fileActions.docEditor.dispatchEvent('focus');
144+
await fileActions.docEditor.dispatchEvent('select');
145+
146+
await fileActions.typeTestTextCode(mobile, 'test text');
147+
148+
await fileActions.export(mobile);
149+
await fileActions.textbox.fill('test doc');
150+
151+
const [download] = await Promise.all([
152+
page.waitForEvent('download'),
153+
await fileActions.okButton.click()
154+
]);
155+
156+
await download.saveAs('/tmp/test doc');
157+
158+
mammoth.extractRawText({path: "/tmp/test doc"})
159+
.then(result => {
160+
expect(result.value.trim()).toEqual('test text');
161+
})
162+
await fileActions.toSuccess( 'Can export Document as .doc');
163+
164+
} catch (e) {
165+
await fileActions.toFailure(e,'Can\'t input text into Document');
166+
}
167+
});
168+
169+
test('anon - doc - export (pdf)', async ({ page, context }) => {
170+
try {
171+
172+
173+
await fileActions.docEditor.click({force: true});
174+
await fileActions.docEditor.dispatchEvent('focus');
175+
await fileActions.docEditor.dispatchEvent('select');
176+
177+
await fileActions.typeTestTextCode(mobile, 'test text');
178+
179+
await fileActions.export(mobile);
180+
await fileActions.textbox.fill('test doc');
181+
await page.locator('#sbox-iframe').contentFrame().getByRole('button', { name: '.docx' }).click();
182+
await page.locator('#sbox-iframe').contentFrame().getByText('.pdf').click();
183+
184+
const [download] = await Promise.all([
185+
page.waitForEvent('download'),
186+
await fileActions.okButton.click()
187+
]);
188+
189+
await download.saveAs('/tmp/test doc');
190+
const { PDFParse } = require('pdf-parse');
191+
192+
const buffer = fs.readFileSync('/tmp/test doc');
193+
const parser = new PDFParse({ data: buffer });
194+
195+
const result = await parser.getText();
196+
await parser.destroy();
197+
expect(result.text).toEqual('test text\n\n-- 1 of 1 --\n\n')
198+
await fileActions.toSuccess( 'Can export Document as .pdf');
199+
200+
} catch (e) {
201+
await fileActions.toFailure(e,'Can\'t export Document as .pdf');
202+
}
203+
});
204+
205+
test('anon - doc - history (previous version 1)', async ({ page, context }) => {
206+
try {
207+
208+
await fileActions.docEditor.click({force: true});
209+
await fileActions.docEditor.dispatchEvent('focus');
210+
await fileActions.docEditor.dispatchEvent('select');
211+
212+
await fileActions.typeTestTextCode(mobile, 'test \n text');
213+
214+
await fileActions.history(mobile);
215+
await fileActions.historyFastPrev.click()
216+
await fileActions.fileSaved.waitFor()
217+
await page.locator('#sbox-iframe').contentFrame().getByRole('paragraph').filter({ hasText: 'syncing changes, please wait' }).waitFor({state: 'hidden'})
218+
219+
await fileActions.docEditor.click({force: true});
220+
221+
await page.keyboard.press('Control+A');
222+
await page.keyboard.press('Control+C');
223+
224+
const clipboardText = await page.evaluate(() => navigator.clipboard.readText());
225+
226+
expect(clipboardText.trim()).toEqual('');
227+
228+
} catch (e) {
229+
await fileActions.toFailure(e,'Can\'t input text into Document');
230+
}
231+
});
232+

e2e-tests/fileactions.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export class FileActions {
3434
// file actions
3535
this.fileimport = this.mainFrame.getByRole('menuitem', { name: 'Import' }).locator('a');
3636
this.filecopy = this.mainFrame.getByRole('menuitem', { name: 'Make a copy' }).locator('a');
37-
this.historyPrev = this.mainFrame.locator('.cp-toolbar-history-previous').last();
37+
this.historyPrev = this.mainFrame.locator('.cp-toolbar-history-previous').first();
38+
this.historyFastPrev = this.mainFrame.locator('.cp-toolbar-history-previous').last();
3839
this.toolbar = this.mainFrame.getByRole('button', { name: 'Tools' });
3940
this.shareLink = this.mainFrame.getByRole('button', { name: 'Share' });
4041
this.shareSecureLink = this.mainFrame.getByRole('button', { name: 'Share' });
@@ -242,6 +243,12 @@ export class FileActions {
242243
this.clearFilter = this.mainFrame.getByRole('button', { name: 'Clear filter' })
243244
this.kanbanControls = this.mainFrame.locator('#cp-kanban-controls')
244245

246+
this.docEditor = this.mainFrame.locator('iframe[name="frameEditor"]')
247+
this.docEditorInput = this.mainFrame.frameLocator('iframe[name="frameEditor"]').locator('#area_id')
248+
this.insertTab = this.mainFrame.frameLocator('iframe[name="frameEditor"]').getByRole('tab', { name: 'Insert' })
249+
this.insertImg = this.mainFrame.frameLocator('iframe[name="frameEditor"]').getByRole('button', { name: 'Image', exact: true })
250+
this.imgFromFile = this.mainFrame.frameLocator('iframe[name="frameEditor"]').getByText('Image from file')
251+
245252
// teams
246253
this.typeMessage = this.mainFrame.getByRole('textbox', { name: 'Type a message here...' }).first()
247254
this.teamAddNotif = this.mainFrame.getByText('test-user has invited you to join their team: test team')
@@ -841,7 +848,8 @@ export class FileActions {
841848
async typeTestTextCode (mobile, string) {
842849
await this.fileSaved.waitFor();
843850
for (let i = 0; i < string.length; i++) {
844-
await this.page.keyboard.press(`${string.charAt(i)}`);
851+
852+
await this.page.keyboard.press(`${string.charAt(i)}`, {delay: 100});
845853
}
846854
}
847855

0 commit comments

Comments
 (0)