-
Notifications
You must be signed in to change notification settings - Fork 167
Expand file tree
/
Copy pathchannelSelector.steps.ts
More file actions
65 lines (56 loc) · 2.17 KB
/
channelSelector.steps.ts
File metadata and controls
65 lines (56 loc) · 2.17 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
import { Given, When } from '@cucumber/cucumber';
import { SimpleIntentResolver } from '@finos/testing';
import { CustomWorld } from '../world/index';
import { CHANNEL_STATE } from '@finos/testing';
import {
DefaultChannelSupport,
DefaultHeartbeatSupport,
DefaultIntentSupport,
DefaultAppSupport,
DesktopAgentProxy,
} from '../../src';
import { TestChannelSelector } from '../support/TestChannelSelector';
import { TestMessaging } from '../support/TestMessaging';
Given(
'A Channel Selector in {string} and a Desktop Agent in {string}',
async function (this: CustomWorld, selectorField: string, daField: string) {
if (!this.messaging) {
this.messaging = new TestMessaging(this.props[CHANNEL_STATE]);
}
const ts = new TestChannelSelector();
this.props[selectorField] = ts;
const cs = new DefaultChannelSupport(this.messaging, ts);
const hs = new DefaultHeartbeatSupport(this.messaging);
const is = new DefaultIntentSupport(this.messaging, new SimpleIntentResolver(this));
const as = new DefaultAppSupport(this.messaging);
const da = new DesktopAgentProxy(hs, cs, is, as, [hs], { debug: true, heartbeat: false });
await da.connect();
this.props[daField] = da;
this.props['result'] = null;
//populate the channel selector
const channel = await cs.getUserChannel();
const userChannels = await cs.getUserChannels();
ts.updateChannel(channel?.id ?? null, userChannels);
}
);
When(
'The first channel is selected via the channel selector in {string}',
async function (this: CustomWorld, selectorField: string) {
const selector = this.props[selectorField] as TestChannelSelector;
selector.selectFirstChannel();
}
);
When(
'The second channel is selected via the channel selector in {string}',
async function (this: CustomWorld, selectorField: string) {
const selector = this.props[selectorField] as TestChannelSelector;
selector.selectSecondChannel();
}
);
When(
'The channel is deselected via the channel selector in {string}',
async function (this: CustomWorld, selectorField: string) {
const selector = this.props[selectorField] as TestChannelSelector;
selector.deselectChannel();
}
);