import testUsers from '@webex/test-helper-test-users';
import {expect} from 'chai';

describe('samples', () => {
  describe('browser-single-party-call', () => {
    describe('normal dialing', () => {
      let mccoy, spock;

      const browserSpock = browser.select('browserSpock');
      const browserMccoy = browser.select('browserMccoy');

      before('create test users', () => testUsers.create({count: 2})
        .then((users) => {
          [spock, mccoy] = users;
        }));

      before('reload browser', () => {
        browser.refresh();
      });

      it('loads the app', () => {
        browser.url('/browser-single-party-call');
      });
        browserMccoy.click('[title="connect"]');
        browserMccoy.waitForExist('.listening');
      });

      it('connects spock\'s browser', () => {
        expect(browserSpock.getTitle()).to.equal('Sample: Single Party Calling');
        browserSpock.setValue('[placeholder="Your access token"]', spock.token.access_token);
        browserSpock.click('[title="connect"]');
        browserSpock.waitForExist('.listening');
      });

      it('places call from spock to mccoy', () => {
        browserSpock.setValue('[placeholder="Person ID or Email Address or SIP URI or Room ID"]', mccoy.emailAddress);
        browserSpock.click('[title="dial"]');

        browserMccoy.pause(2500);
        browserMccoy.alertAccept();
      });

      it('ends the call', () => {
        browser.pause(5000);
        // TODO add assertions around streams

        browserSpock.click('[title="hangup"]');
      });
    });
  });
});

      it('connects mccoy\'s browser', () => {
        expect(browserMccoy.getTitle()).to.equal('Sample: Single Party Calling');
        browserMccoy.setValue('[placeholder="Your access token"]', mccoy.token.access_token);