-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest.js
More file actions
89 lines (69 loc) · 2.95 KB
/
test.js
File metadata and controls
89 lines (69 loc) · 2.95 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
89
import { Selector } from 'testcafe';
import {
checkLiquidErrors,
getResultElement,
getResultText,
getBtAlertElement,
getBtAlertText,
getPerformanceMetrics
} from './index';
const url = 'https://examples.staging.oregon.platform-os.com/multilanguage';
const forceAlertsQuery =
'flash[notice]=Flash%20notice&flash[error]=Flash%20error&flash[alert]=Flash%20alert&flash[info]=Flash%20info';
fixture('Test helpers').page(url);
test('checkLiquidErrors', async t => {
await checkLiquidErrors({ t, Selector });
});
test('getResultElement', async t => {
const resultElement = await getResultElement({ name: 1, Selector });
const attr = resultElement.getAttribute('data-result');
await t.expect(attr).eql('1');
});
test('getResultText', async t => {
const resultText = await getResultText({ name: 1, Selector });
await t.expect(resultText).contains('Hello world');
});
test('getBtAlertElement', async t => {
await t.navigateTo(`${url}?${forceAlertsQuery}`);
const dangerElement = await getBtAlertElement({ type: 'danger', Selector });
const warningElement = await getBtAlertElement({ type: 'warning', Selector });
const successElement = await getBtAlertElement({ type: 'success', Selector });
const infoElement = await getBtAlertElement({ type: 'info', Selector });
const noTypeElement = await getBtAlertElement({ type: 'success', Selector });
const dangerText = await dangerElement.innerText;
const warningText = await warningElement.innerText;
const successText = await successElement.innerText;
const infoText = await infoElement.innerText;
const noTypeText = await noTypeElement.innerText;
await t.expect(dangerText).contains('Flash error');
await t.expect(warningText).contains('Flash alert');
await t.expect(successText).contains('Flash notice');
await t.expect(infoText).contains('Flash info');
await t.expect(noTypeText).contains('Flash notice');
});
test('getBtAlertText', async t => {
await t.navigateTo(`${url}?${forceAlertsQuery}`);
const danger = await getBtAlertText({ type: 'danger', Selector });
const warning = await getBtAlertText({ type: 'warning', Selector });
const success = await getBtAlertText({ type: 'success', Selector });
const info = await getBtAlertText({ type: 'info', Selector });
const noType = await getBtAlertText({ type: 'success', Selector });
await t.expect(danger).contains('Flash error');
await t.expect(warning).contains('Flash alert');
await t.expect(success).contains('Flash notice');
await t.expect(info).contains('Flash info');
await t.expect(noType).contains('Flash notice');
});
test('getPerformanceMetrics', async t => {
await t.navigateTo(`${url}`);
const perf = await getPerformanceMetrics({ t });
const { raw, computed } = perf;
await t.expect(raw).typeOf('object');
await t.expect(computed).typeOf('object');
for (let r in raw) {
await t.expect(raw[r]).typeOf('number');
}
for (let c in computed) {
await t.expect(computed[c]).typeOf('number');
}
});