import { Selector } from 'testcafe';

//  testcafe "chrome:headless" engine/web/templates/x/static/js/tests/test.wpj.watchdog.js

fixture`Product page`.page`https://www.kupshop.local/columbia-lay-d-down-jacket_z14/`;

test('Watchdog elements exist', async t => {
   const formExists = await Selector('form[data-watchdog="form"]').exists;

   if (formExists) {
      await t
         .expect(Selector('[data-watchdog="info"]').exists)
         .ok()
         .expect(Selector('[data-watchdog="loggedout"]').exists)
         .ok()
         .expect(Selector('[data-watchdog="opener"]').exists)
         .ok()
         .expect(Selector('[data-watchdog="success"]').exists)
         .ok();
   } else {
      console.log('No watchdog form');
   }
});

test('Product elements exist', async t => {
   await t
      .expect(Selector('[data-buy-form]').exists)
      .ok()
      .expect(Selector('.submit-block').exists)
      .ok()
      .expect(Selector('.submit-block [name="No"]').exists)
      .ok();
});

// todo dopsat, neni to cely
test('Product sets elements exist', async t => {
   const formExists = await Selector('[data-sets="wrapper"]').exists;

   if (formExists) {
      await t
         .expect(Selector('[data-sets="selected-wrapper"]').exists)
         .ok()
         .expect(Selector('[data-sets="selected-item"]').exists)
         .ok()
         .expect(Selector('[data-submit-btn]').exists)
         .ok()
         .expect(Selector('.product-set-focus .inner').exists)
         .ok();
   } else {
      console.log('No sets');
   }
});
