import getBrowser from '../../helpers/puppeteer';

const $ = {
    company: 'vn-client-balance-index vn-autocomplete[ng-model="$ctrl.companyId"]',
    compensationButton: 'vn-client-balance-index vn-icon-button[vn-dialog="send_compensation"]',
    saveButton: '.vn-dialog.shown [response="accept"]'
};

describe('Client Send balance compensation', () => {
    let browser;
    let page;
    beforeAll(async() => {
        browser = await getBrowser();
        page = browser.page;
        await page.loginAndModule('employee', 'client');
        await page.accessToSearchResult('Clark Kent');
        await page.accessToSection('client.card.balance.index');
    });

    afterAll(async() => {
        await browser.close();
    });

    it(`should click on send compensation button`, async() => {
        await page.autocompleteSearch($.company, 'VNL');
        await page.waitToClick($.compensationButton);
        await page.waitToClick($.saveButton);
        const message = await page.waitForSnackbar();

        expect(message.text).toContain('Notification sent!');
    });
});