UNPKG

@textback/notification-widget

Version:

TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.

62 lines (49 loc) 2.07 kB
const {Selector} = require('testcafe'); const querystring = require('querystring'); const query = querystring.stringify({ widgetPath: '/build/index.js', apiPath: '/api', widgetId: 'a' }); fixture `Notification widget base tests` .page `http://localhost:3000/examples?${query}`; test('Telegram button', async t => { const button = Selector('tb-notification-button[channel="tg"]'); const link = button.find('a'); const text = await button.innerText; const href = await link.getAttribute('href'); await t.expect(text).contains('Telegram'); await t.expect(href).contains('https://telegram.me/rb_dev_3_bot?start=subscribe_'); }); test('VK button', async t => { const button = Selector('tb-notification-button[channel="vk"]'); const text = await button.innerText; await t.expect(text).contains('VKontakte'); }); test('Facebook button', async t => { const button = Selector('tb-notification-button[channel="facebook"]'); const link = button.find('a'); const text = await button.innerText; const href = await link.getAttribute('href'); await t.expect(text).contains('Facebook'); await t.expect(href).contains('https://m.me/323049074708312?ref=subscribe_'); }); test('Viber button', async t => { const button = Selector('tb-notification-button[channel="viber"]'); const link = button.find('a'); const text = await button.innerText; const href = await link.getAttribute('href'); await t.expect(text).contains('Viber'); await t.expect(href).contains('viber://pa?chatURI=dev_&context=subscribe_'); }); test('deeplink request', async t => { const requests = await t.eval(() => window.fetch.calls); const deeplinkRequests = requests.filter(call => { return call.url === '/api/endUserNotifications/deepLinks' }); await t.expect(JSON.parse(deeplinkRequests[0].options.body)).eql({ "accountId": "99bffda5-5bd1-49b1-b4f2-658854797c01", "insecureContext": {"orderId": "insecureOrderID"}, "secureContextToken": null }); });