import { Button } from '@contour/fet/lib/elements'; import { P2P_MESSAGE_BUTTONS, P2P_SPECIAL_VALUE } from '../../../enum/p2p'; import P2PMessageView from '../../../pages/p2p/p2pMessageView.page'; import * as stepVariableMap from '../../../util/stepVariableMap'; const assert = require('assert').strict; export async function clickButtonAtMessageInP2PThread(buttonType, message) { await browser.pause(1000); const p2pMessageView = new P2PMessageView(); const replacedMessage = stepVariableMap.replaceWithSpecialKeyValue(message); let button: Button; switch (buttonType) { case P2P_MESSAGE_BUTTONS.VERRIFY: button = p2pMessageView.getBubbleVerifyButtonByMessage(P2P_SPECIAL_VALUE.MY_BUBBLE, replacedMessage); break; case P2P_MESSAGE_BUTTONS.REJECT: button = p2pMessageView.getBubbleRejectButtonByMessage(P2P_SPECIAL_VALUE.MY_BUBBLE, replacedMessage); break; case P2P_MESSAGE_BUTTONS.APPROVE: button = p2pMessageView.getBubbleApproveButtonByMessage(P2P_SPECIAL_VALUE.MY_BUBBLE, replacedMessage); break; case P2P_MESSAGE_BUTTONS.EDIT: button = p2pMessageView.getBubbleEditButtonByMessage(P2P_SPECIAL_VALUE.MY_BUBBLE, replacedMessage); break; case P2P_MESSAGE_BUTTONS.DISCARD: button = p2pMessageView.getBubbleDiscardButtonByMessage(P2P_SPECIAL_VALUE.MY_BUBBLE, replacedMessage); break; default: assert.fail('Unknown Button:' + buttonType); break; } await button.clickElement(); }