-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmp_task_smoke.js
More file actions
executable file
·88 lines (79 loc) · 3.54 KB
/
tmp_task_smoke.js
File metadata and controls
executable file
·88 lines (79 loc) · 3.54 KB
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
const { chromium } = require('/Volumes/www/html/groupware/node_modules/playwright');
async function login(page, base, user, pass) {
await page.goto(base + '/login', { waitUntil: 'domcontentloaded' });
await page.fill('input[name="username"]', user);
await page.fill('input[name="password"]', pass);
await Promise.all([
page.waitForLoadState('networkidle'),
page.click('button[type="submit"]')
]);
}
async function run(base, user, pass, label) {
const browser = await chromium.launch({ headless: true });
const context = await browser.newContext({ ignoreHTTPSErrors: true, viewport: { width: 1440, height: 1200 } });
const page = await context.newPage();
page.setDefaultTimeout(15000);
page.on('console', msg => console.log(label, 'console', msg.type(), msg.text()));
page.on('response', async res => {
if (!res.url().includes('/api/task/')) return;
let body = '';
try { body = await res.text(); } catch (e) {}
console.log(label, 'api', res.status(), res.url(), body.slice(0, 250));
});
try {
await login(page, base, user, pass);
console.log(label, 'logged in', page.url());
const boardName = 'Board-' + Date.now();
await page.goto(base + '/task/create-board', { waitUntil: 'networkidle' });
await page.fill('#boardName', boardName);
await page.fill('#boardDescription', 'smoke');
await Promise.all([
page.waitForURL(/\/task\/board\/\d+/),
page.click('#submitBtn')
]);
const boardUrl = page.url();
const boardId = (boardUrl.match(/\/(\d+)$/) || [])[1];
console.log(label, 'board', boardUrl, boardId);
await page.click('#add-list-btn');
await page.waitForSelector('#addListModal.show');
await page.locator('#addListModal #listName').fill('ToDo');
await page.click('#saveListBtn');
await page.waitForTimeout(2000);
console.log(label, 'lists', await page.locator('.kanban-list-title').allTextContents());
const addCard = page.locator('.kanban-add-card .add-card').first();
await addCard.click();
await page.waitForSelector('#addCardModal.show');
await page.locator('#addCardModal #cardTitle').fill('Card1');
await page.locator('#addCardModal #cardDescription').fill('body');
await page.click('#saveCardBtn');
await page.waitForTimeout(2000);
console.log(label, 'cards', await page.locator('.kanban-card-title').allTextContents());
await page.goto(base + '/task/edit-board/' + boardId, { waitUntil: 'networkidle' });
await page.fill('#boardName', boardName + '-Edited');
await Promise.all([
page.waitForURL(new RegExp('/task/board/' + boardId + '$')),
page.locator('#boardForm button[type="submit"]').click()
]);
console.log(label, 'updated', await page.locator('h4').first().textContent());
page.on('dialog', d => d.accept().catch(() => {}));
await page.goto(base + '/task/edit-board/' + boardId, { waitUntil: 'networkidle' });
await page.click('#deleteBoard');
if (await page.locator('#confirmBoardDelete').count()) {
await page.locator('#confirmBoardDelete').check();
}
await Promise.all([
page.waitForLoadState('networkidle'),
page.click('#confirmDelete')
]);
console.log(label, 'after delete', page.url());
console.log(label, 'OK');
} catch (error) {
console.error(label, 'FAIL', error && error.stack ? error.stack : String(error));
} finally {
await browser.close();
}
}
(async () => {
await run('https://groupware.yuus-program.com', 'admin', 'demo1234', 'xserver');
await run('http://192.168.1.5/groupware', 'admin', 'admin123', 'local');
})();