Advertisement
Guest User

by_price+add_prod

a guest
Feb 6th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.01 KB | None | 0 0
  1. app_product.po.js
  2.  
  3. var commonHelper = require('./../../helpers/common.helper');
  4.  
  5. var AddProductPage = function () {
  6.  
  7. //--------------------------------------------------------------------------
  8. //--------------------------------------------------------------------------
  9. // Selectors
  10. //--------------------------------------------------------------------------
  11. //--------------------------------------------------------------------------
  12.  
  13. var image = '[data-ng-repeat="item in vm.images"]';
  14.  
  15. //--------------------------------------------------------------------------
  16. //--------------------------------------------------------------------------
  17. // Elements
  18. //--------------------------------------------------------------------------
  19. //--------------------------------------------------------------------------
  20.  
  21. // Main section ------------------------------------------------------------
  22.  
  23. this.selType = element(by.model('vm.product.type'));
  24.  
  25. this.selVendor = element(by.model('vm.product.vendor'));
  26.  
  27. this.selCollections = element(by.model('vm.product.collections'));
  28.  
  29. this.txtTitle = element(by.model('vm.product.title'));
  30.  
  31. this.txtPrice = element(by.model('vm.product.price'));
  32.  
  33. this.txtSku = element(by.model('vm.product.sku'));
  34.  
  35. this.txtTags = $('input[placeholder="Enter tags"]');
  36.  
  37. this.txtComparePrice = element(by.model('vm.product.compare_price'));
  38.  
  39. this.txtShippingWeight = element(by.model('vm.product.shipping_weight'));
  40.  
  41. this.select2FirstResult = element.all(by.repeater('item in $select.items')).first();
  42.  
  43. this.select2Choice = element(by.binding('$item.title'));
  44.  
  45. this.radMulti = $('[for="variant-multi"]');
  46.  
  47. this.radSingle = $('[for="variant-single"]');
  48.  
  49. // Variants section --------------------------------------------------------
  50.  
  51. this.btnAddOption = $('[ng-click="vm.optionsControl.add()"]');
  52.  
  53. this.eleAddEditThumbnailsForm = $('[name="ThumbnailForm"]');
  54.  
  55. this.btnSubmitThumbnail = this.eleAddEditThumbnailsForm.$('[type="submit"]');
  56.  
  57. // Images section ----------------------------------------------------------
  58.  
  59. this.images = $$(image);
  60.  
  61. // SEO section -------------------------------------------------------------
  62.  
  63. this.txtSeoTitle = element(by.model('vm.product.seo_title'));
  64.  
  65. this.txtMetaDescription = element(by.model('vm.product.seo_meta'));
  66.  
  67. this.txtUrl = element(by.model('vm.product.seo_url'));
  68.  
  69. // Other elements ----------------------------------------------------------
  70.  
  71. this.imgLoader = $('[loading="!vm.queriesAreReady"] .chq-loader-image');
  72.  
  73. this.btnPublish = $('[ng-click="vm.product.is_draft = false"]');
  74.  
  75. this.btnDraft = $('[ng-click="vm.product.is_draft = true"]');
  76.  
  77. this.btnSave = $('button[ng-if="vm.product.id"]');
  78.  
  79. this.btnSaveAsTemplate = $('[ng-click="vm.submitControl.open()"]');
  80.  
  81. this.chkAnother = $('[ng-model="vm.createAnother"]+label');
  82.  
  83. this.btnDeleteProduct = $('[ng-click="vm.delete()"]');
  84.  
  85. this.btnConfirm = $('[data-ng-click="confirm()"]');
  86.  
  87. // Template section --------------------------------------------------------
  88.  
  89. this.txtTemplateTitle = element(by.model('vm.product.template_name'));
  90.  
  91. this.btnSaveTemplate = $('[ng-click="vm.templateSave = true;"]');
  92.  
  93. this.selTemplate = $('[placeholder="Use template"]');
  94.  
  95. this.imgTemplateLoader = $('.bottom-buttons [src*="loader"]');
  96.  
  97. //--------------------------------------------------------------------------
  98. //--------------------------------------------------------------------------
  99. // Functions
  100. //--------------------------------------------------------------------------
  101. //--------------------------------------------------------------------------
  102.  
  103. // Main section ------------------------------------------------------------
  104.  
  105. this.selectType = function(name) {
  106. this.selType.click();
  107. var txtSelect2 = $('[style="opacity: 1;"] .select2-input');
  108. commonHelper.waitUntilElementVisible(txtSelect2);
  109. txtSelect2.sendKeys(name);
  110. var el = $$('.ui-select-choices-row-inner span').first();
  111. browser.sleep(1000);
  112. el.click();
  113. };
  114.  
  115. this.fillType = function(value) {
  116. this.selType.clear();
  117. this.selType.sendKeys(value);
  118. };
  119.  
  120. this.selectedType = function() {
  121. return this.selType.getText();
  122. };
  123.  
  124. this.selectFirstCollection = function() {
  125. this.selCollections.click();
  126. commonHelper.waitUntilElementVisible(this.select2FirstResult);
  127. this.select2FirstResult.click();
  128. };
  129.  
  130. this.selectCollection = function(name) {
  131. commonHelper.waitUntilElementVisible(this.selCollections);
  132. this.selCollections.click();
  133. var txtSelect2 = this.selCollections.$('.select2-input');
  134. commonHelper.waitUntilElementVisible(txtSelect2);
  135. txtSelect2.sendKeys(name);
  136. var el = $$('.ui-select-choices-row-inner>span').first();
  137. browser.sleep(500);
  138. el.click();
  139. };
  140.  
  141. this.fillDescription = function(value) {
  142. var driver = browser.driver;
  143. var iframe = by.css('.cke_wysiwyg_frame');
  144. var el = driver.findElement(iframe);
  145. browser.switchTo().frame(el);
  146. var body = driver.findElement(by.tagName('body'));
  147. body.clear();
  148. body.sendKeys(value);
  149. browser.switchTo().defaultContent();
  150. };
  151.  
  152. this.btnDeleteCollection = function(name) {
  153. return this.eleSelectedCollection(name).$('[ng-click="$selectMultiple.removeChoice($index)"]');
  154. };
  155.  
  156. this.clickDeleteCollection = function(name) {
  157. this.btnDeleteCollection(name).click();
  158. commonHelper.waitUntilElementIsNotPresent(this.eleSelectedCollection(name));
  159. };
  160.  
  161. this.deleteTab = function () {
  162. element(by.css('a[class^="ui-select-match-close"]')).click()
  163. };
  164.  
  165. this.fillTitle = function(name) {
  166. commonHelper.waitUntilElementVisible(this.txtTitle);
  167. this.txtTitle.clear();
  168. this.txtTitle.sendKeys(name);
  169. };
  170.  
  171. this.fillPrice = function(value) {
  172. this.txtPrice.clear();
  173. this.txtPrice.sendKeys(value);
  174. };
  175.  
  176. this.fillComparePrice = function(value) {
  177. this.txtComparePrice.clear();
  178. this.txtComparePrice.sendKeys(value);
  179. };
  180.  
  181. this.fillShippingWeight = function(value) {
  182. this.txtShippingWeight.clear();
  183. this.txtShippingWeight.sendKeys(value);
  184. };
  185.  
  186. this.fillSku = function(value) {
  187. this.txtSku.clear();
  188. this.txtSku.sendKeys(value);
  189. };
  190.  
  191. this.fillVendor = function(value) {
  192. this.selVendor.clear();
  193. this.selVendor.sendKeys(value);
  194. };
  195.  
  196. this.selectVendor = function(name) {
  197. this.selVendor.click();
  198. var txtSelect2 = $('[style="opacity: 1;"] .select2-input');
  199. commonHelper.waitUntilElementVisible(txtSelect2);
  200. txtSelect2.sendKeys(name);
  201. var el = $$('.ui-select-choices-row-inner span').first();
  202. browser.sleep(1000);
  203. el.click();
  204. };
  205.  
  206. this.eleSelectedCollection = function(name) {
  207. return element(by.cssContainingText('[ng-repeat*="$item in $select.selected"]', name))
  208. };
  209.  
  210. this.clickMulti = function() {
  211. commonHelper.waitUntilElementVisible(this.radMulti);
  212. this.radMulti.click();
  213. };
  214.  
  215. this.clickSingle = function() {
  216. this.radSingle.click();
  217. };
  218.  
  219. this.addTag = function(value) {
  220. var tagsField = this.txtTags;
  221. var option = element(by.cssContainingText('.ui-select-highlight', value));
  222. tagsField.sendKeys(value);
  223. option.isPresent().then(function(result) {
  224. if(result) {
  225. option.click();
  226. } else {
  227. tagsField.sendKeys(protractor.Key.ENTER);
  228. }
  229. });
  230. commonHelper.waitUntilElementVisible(this.eleSelectedCollection(value));
  231. };
  232.  
  233. // Variants section --------------------------------------------------------
  234.  
  235. this.eleOptionSection = function(index) {
  236. return element.all(by.repeater('item in vm.product.options')).get(index);
  237. };
  238.  
  239. this.variantEntry = function(name) {
  240. return element(by.cssContainingText('[ng-repeat="item in vm.product.variants"]', name))
  241. };
  242.  
  243. this.txtOptionTitle = function(index) {
  244. return this.eleOptionSection(index).element(by.model('item.title'));
  245. };
  246.  
  247. this.fillOptionTitle = function(index, value) {
  248. this.txtOptionTitle(index).clear();
  249. this.txtOptionTitle(index).sendKeys(value);
  250. };
  251.  
  252. this.chkProductLook = function(index) {
  253. return this.eleOptionSection(index).$('[ng-model="item.changes_look"]+label');
  254. };
  255.  
  256. this.chkDefaultVariant = function(name) {
  257. return this.variantEntry(name).$('[ng-model="item.default"]+label');
  258. };
  259.  
  260. this.radSwitchOff = function(name) {
  261. return this.variantEntry(name).$('.bootstrap-switch-label');
  262. };
  263.  
  264. this.clickProductLookCheckbox = function(index) {
  265. this.chkProductLook(index).click();
  266. };
  267.  
  268. this.clickDefaultVariantCheckbox = function(name) {
  269. this.chkDefaultVariant(name).click();
  270. };
  271.  
  272. this.clickSwitchOff = function(name) {
  273. this.radSwitchOff(name).click();
  274. };
  275.  
  276. this.txtOptionValue = function(index) {
  277. return this.eleOptionSection(index).$('[ng-model="item.values"] input');
  278. };
  279.  
  280. this.fillOptionValue = function(index, value) {
  281. this.txtOptionValue(index).sendKeys(value);
  282. this.txtOptionValue(index).sendKeys(protractor.Key.ENTER);
  283. };
  284.  
  285. this.btnDeleteOption = function(index) {
  286. return this.eleOptionSection(index).$('.btn-delete');
  287. };
  288.  
  289. this.clickDeleteOption = function(index) {
  290. this.btnDeleteOption(index).click();
  291. };
  292.  
  293. this.clickAddOption = function() {
  294. this.btnAddOption.click();
  295. };
  296.  
  297. this.txtVariantPrice = function(name) {
  298. return this.variantEntry(name).element(by.model('item.price'));
  299. };
  300.  
  301. this.fillVariantPrice = function(name, value) {
  302. commonHelper.waitUntilElementPresent(this.variantEntry(name));
  303. this.txtVariantPrice(name).clear();
  304. this.txtVariantPrice(name).sendKeys(value);
  305. };
  306.  
  307. this.btnVariantPriceAutofill = function(name) {
  308. return this.variantEntry(name).$('[ng-click="vm.variantControl.priceFill(\'price\', item.price)"]');
  309. };
  310.  
  311. this.clickVariantPriceAutofill = function(name) {
  312. this.btnVariantPriceAutofill(name).click()
  313. };
  314.  
  315. this.btnVariantComparePriceAutofill = function(name) {
  316. return this.variantEntry(name).$('[ng-click="vm.variantControl.priceFill(\'compare_price\', item.compare_price)"]');
  317. };
  318.  
  319. this.clickVariantComparePriceAutofill = function(name) {
  320. this.btnVariantComparePriceAutofill(name).click()
  321. };
  322.  
  323. this.txtVariantComparePrice = function(name) {
  324. return this.variantEntry(name).element(by.model('item.compare_price'));
  325. };
  326.  
  327. this.fillVariantComparePrice = function(name, value) {
  328. commonHelper.waitUntilElementPresent(this.variantEntry(name));
  329. this.txtVariantComparePrice(name).clear();
  330. this.txtVariantComparePrice(name).sendKeys(value);
  331. };
  332.  
  333. this.txtVariantSku = function(name) {
  334. return this.variantEntry(name).element(by.model('item.sku'));
  335. };
  336.  
  337. this.fillVariantSku = function(name, value) {
  338. this.txtVariantSku(name).clear();
  339. this.txtVariantSku(name).sendKeys(value);
  340. };
  341.  
  342. this.eleSelectedOptionValue = function(index, name) {
  343. return this.eleOptionSection(index).element(by.cssContainingText('[ng-repeat*="$item in $select.selected"]', name))
  344. };
  345.  
  346. // Add / Edit thumbnails subsection ----------------------------------------
  347.  
  348. this.radThumbnailSelector = function(index) {
  349. return this.eleOptionSection(index).$('[ng-class="{\'active\': item._isThumbOption}"] span');
  350. };
  351.  
  352. this.clickThumbnailSelectorRadio = function(index) {
  353. this.radThumbnailSelector(index).click();
  354. };
  355.  
  356. this.radTextDropdown = function(index) {
  357. return this.eleOptionSection(index).$('[ng-class="{\'active\': !item._isThumbOption}"] span');
  358. };
  359.  
  360. this.clickTextDropdownRadio = function(index) {
  361. this.radTextDropdown(index).click();
  362. };
  363.  
  364. this.btnAddThumbnails = function(index) {
  365. return this.eleOptionSection(index).$('[ng-click="vm.optionsControl.editThumbnails( item )"]');
  366. };
  367.  
  368. this.clickAddThumbnails = function(index) {
  369. this.btnAddThumbnails(index).click();
  370. commonHelper.waitUntilElementVisible(this.btnSubmitThumbnail);
  371. };
  372.  
  373. this.clickSubmitThumbnail = function() {
  374. this.btnSubmitThumbnail.click();
  375. };
  376.  
  377. this.thumbnailCard = function(name) {
  378. var items = element.all(by.repeater('item in vm.thumbnails')).filter(function(item) {
  379. return item.element(by.binding('item.value')).getText().then(function(_name) {
  380. return _name === name;
  381. });
  382. });
  383. return items.first();
  384. };
  385.  
  386. this.txtColorCode = function(name) {
  387. return this.thumbnailCard(name).element(by.model('ngModel'));
  388. };
  389.  
  390. this.fillColorCode = function(name, value) {
  391. this.txtColorCode(name).clear();
  392. this.txtColorCode(name).sendKeys(value);
  393. };
  394.  
  395. this.radSwatchImage = function(name) {
  396. return this.thumbnailCard(name).$('[ng-click="item._isColor = false"]');
  397. };
  398.  
  399. this.radColorCode = function(name) {
  400. return this.thumbnailCard(name).$('[ng-click="item._isColor = true"]');
  401. };
  402.  
  403. this.clickSwatchImage = function(name) {
  404. this.radSwatchImage(name).click();
  405. };
  406.  
  407. this.clickColorCode = function(name) {
  408. this.radColorCode(name).click();
  409. };
  410.  
  411. this.eleSwatchImage = function(name) {
  412. return this.thumbnailCard(name).$('.image-container_image');
  413. };
  414.  
  415. // Images section ----------------------------------------------------------
  416.  
  417. this.attachmentInputField = function(index) {
  418. return $$('[type="file"]').get(index);
  419. };
  420.  
  421. this.uploadImage = function(index, name) {
  422. var path = require('path');
  423. var fileToUpload = '../../../data/admin/testfiles/' + name,
  424. absolutePath = path.resolve(__dirname, fileToUpload);
  425. this.attachmentInputField(index - 1).sendKeys(absolutePath);
  426. };
  427.  
  428. this.imageSectionName = function(name) {
  429. var items = element.all(by.repeater('item in vm.product._imagesVariants')).filter(function(item) {
  430. return item.element(by.binding('vm.variantControl.getName(item)')).getText().then(function(_name) {
  431. return _name === name;
  432. });
  433. });
  434. return items.first();
  435. };
  436.  
  437. this.eleImages = function(name) {
  438. return this.imageSectionName(name).$$(image);
  439. };
  440.  
  441. this.dragAndDropImage = function(from, to) {
  442. browser.actions().mouseDown($$(image + ' .dragger').get(from - 1)).perform();
  443. commonHelper.moveMouse();
  444. browser.actions().mouseUp($$(image + ' ._number').get(to - 1)).perform();
  445. };
  446.  
  447. this.deleteImage = function(index) {
  448. commonHelper.moveMouseOver($$(image).get(index - 1));
  449. $$(image + ' .image-delete').get(index - 1).click();
  450. };
  451.  
  452. // SEO section -------------------------------------------------------------
  453.  
  454. this.fillSeoTitle = function(value) {
  455. this.txtSeoTitle.clear();
  456. this.txtSeoTitle.sendKeys(value);
  457. };
  458.  
  459. this.fillMetaDescription = function(value) {
  460. this.txtMetaDescription.clear();
  461. this.txtMetaDescription.sendKeys(value);
  462. };
  463.  
  464. this.fillUrl = function(value) {
  465. this.txtUrl.clear();
  466. this.txtUrl.sendKeys(value);
  467. };
  468.  
  469. // Other functions ---------------------------------------------------------
  470.  
  471. this.clickPublish = function() {
  472. commonHelper.moveMouseOver(this.btnPublish);
  473. commonHelper.waitUntilElementVisible(this.btnPublish);
  474. this.btnPublish.click();
  475. };
  476.  
  477. this.clickDraft = function() {
  478. commonHelper.moveMouseOver(this.btnDraft);
  479. this.btnDraft.click();
  480. };
  481.  
  482. this.clickSave = function() {
  483. commonHelper.moveMouseOver(this.btnSave);
  484. commonHelper.waitUntilElementVisible(this.btnSave);
  485. this.btnSave.click();
  486. };
  487.  
  488. this.clickSaveAsTemplate = function() {
  489. commonHelper.moveMouseOver(this.btnSaveAsTemplate);
  490. commonHelper.waitUntilElementVisible(this.btnSaveAsTemplate);
  491. this.btnSaveAsTemplate.click();
  492. };
  493.  
  494. this.waitForPublishButton = function() {
  495. commonHelper.waitUntilElementPresent(this.btnPublish);
  496. browser.sleep(1000);
  497. this.waitForPageLoading();
  498. };
  499.  
  500. this.waitForSaveButton = function() {
  501. commonHelper.waitUntilElementPresent(this.btnSave);
  502. browser.sleep(1000);
  503. this.waitForPageLoading();
  504. };
  505.  
  506. this.waitForPageLoading = function() {
  507. commonHelper.waitUntilElementInvisible(this.imgLoader);
  508. };
  509.  
  510. this.checkAnother = function() {
  511. this.chkAnother.click();
  512. };
  513.  
  514. this.clickDeleteProduct = function() {
  515. this.btnDeleteProduct.click();
  516. };
  517.  
  518. this.clickConfirm = function() {
  519. commonHelper.waitUntilElementVisible(this.btnConfirm);
  520. this.btnConfirm.click();
  521. };
  522.  
  523. // Template section --------------------------------------------------------
  524.  
  525. this.fillTemplateTitle = function(value) {
  526. this.txtTemplateTitle.clear();
  527. this.txtTemplateTitle.sendKeys(value);
  528. };
  529.  
  530. this.clickSaveTemplate = function() {
  531. commonHelper.moveMouseOver(this.btnSaveTemplate);
  532. commonHelper.waitUntilElementVisible(this.btnSaveTemplate);
  533. this.btnSaveTemplate.click();
  534. };
  535.  
  536. this.selectTemplate = function(name) {
  537. commonHelper.waitUntilElementVisible(this.selTemplate);
  538. this.selTemplate.click();
  539. var el = element(by.cssContainingText('[repeat="item.id as item in vm.templateSelect"]', name));
  540. commonHelper.waitUntilElementVisible(el);
  541. el.click();
  542. };
  543. };
  544.  
  545. module.exports = AddProductPage;
  546.  
  547.  
  548. ________________________________________________________
  549. by_price.spec.js
  550.  
  551.  
  552. var pageObject = require('./../../../../../../services/pages').container.PageObject;
  553. var signInPage = pageObject.getSignInPage();
  554. var dashboardPage = pageObject.getDashboardPage();
  555. var addCollectionPage = pageObject.getAddCollectionPage();
  556. var collectionListPage = pageObject.getCollectionListPage();
  557. var collectionsPage = pageObject.getCollectionsPage();
  558. var addProductPage = pageObject.getAddProductPage();
  559. var productListPage = pageObject.getProductListPage();
  560. var signInData = require('./../../../../../../data/admin/sign_in/index');
  561. var collectionData = require('./../../../../../../data/admin/collection/index');
  562. var productData = require('./../../../../../../data/admin/product/index');
  563. var commonHelper = require('./../../../../../../services/helpers/common.helper.js');
  564.  
  565. describe('Add Collection - Auto Adding - By Price', function () {
  566.  
  567. var username = signInData.adminAccount.username;
  568. var password = signInData.adminAccount.password;
  569. var firstCollectionTitle = commonHelper.uniqueProductName('price1');
  570. var firstCollectionDescription = collectionData.collection.description.first;
  571.  
  572. var product = {
  573. firstTitle: commonHelper.uniqueProductName('price2'),
  574. type: productData.product.type,
  575. firstPrice: productData.product.price
  576. };
  577.  
  578. describe('auto-add product by product price is equal', function () {
  579.  
  580. var unique_value = commonHelper.uniqueValue();
  581. var collectionTitle = firstCollectionTitle + unique_value;
  582. var productTitle = product.firstTitle + unique_value;
  583.  
  584. beforeAll(function () {
  585. commonHelper.acceptAlert();
  586. browser.get(signInData.link);
  587. });
  588.  
  589. afterAll(function () {
  590. commonHelper.clearAllData();
  591. });
  592.  
  593. it('should redirect on dashboard page after login', function () {
  594. signInPage.login(username, password);
  595. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  596. });
  597.  
  598. it('should open products list page', function () {
  599. dashboardPage.openProductListPage();
  600. });
  601.  
  602. it('should open new product page', function () {
  603. productListPage.clickAddProduct();
  604. addProductPage.waitForPublishButton();
  605. });
  606.  
  607. it('should add new product', function () {
  608. addProductPage.selectType(product.type);
  609. addProductPage.selectFirstCollection();
  610. addProductPage.fillTitle(productTitle);
  611. addProductPage.fillPrice(product.firstPrice);
  612. addProductPage.clickPublish();
  613. commonHelper.waitUntilElementVisible(productListPage.productEntry(productTitle));
  614. });
  615.  
  616. it('should open new collection page', function () {
  617. dashboardPage.openAddCollectionPage();
  618. });
  619.  
  620. it('should fill title and description fields', function () {
  621. addCollectionPage.fillTitle(collectionTitle);
  622. addCollectionPage.fillDescription(firstCollectionDescription);
  623. });
  624.  
  625. it('should click auto add product radio button', function () {
  626. addCollectionPage.clickAddAuto();
  627. commonHelper.waitUntilElementVisible(addCollectionPage.sel2Type);
  628. });
  629.  
  630. it('should add condition', function () {
  631. addCollectionPage.selectConditionVariant(0, 'Product price');
  632. addCollectionPage.selectConditionRule(0, 'is equal to');
  633. addCollectionPage.fillConditionValue(0, '$25.00');
  634. });
  635.  
  636. it('should add new collection', function () {
  637. addCollectionPage.clickPublish();
  638. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(collectionTitle));
  639. });
  640.  
  641. it('should show collection page after click on collection link', function () {
  642. collectionListPage.clickCollection(collectionTitle);
  643. commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
  644.  
  645. expect(collectionsPage.productTitle(productTitle).isDisplayed()).toBeTruthy();
  646. commonHelper.switchToPreviousTab();
  647. });
  648. });
  649.  
  650.  
  651. describe('auto-add product by product price is not equal', function () {
  652.  
  653. var unique_value = commonHelper.uniqueValue();
  654. var collectionTitle = firstCollectionTitle + unique_value;
  655. var productTitle = product.firstTitle + unique_value;
  656.  
  657. beforeAll(function () {
  658. commonHelper.acceptAlert();
  659. browser.get(signInData.link);
  660. });
  661.  
  662. afterAll(function () {
  663. commonHelper.clearAllData();
  664. });
  665.  
  666. it('should redirect on dashboard page after login', function () {
  667. signInPage.login(username, password);
  668. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  669. });
  670.  
  671. it('should open products list page', function () {
  672. dashboardPage.openProductListPage();
  673. });
  674.  
  675. it('should open new product page', function () {
  676. productListPage.clickAddProduct();
  677. addProductPage.waitForPublishButton();
  678. });
  679.  
  680. it('should add new product', function () {
  681. addProductPage.selectType(product.type);
  682. addProductPage.selectFirstCollection();
  683. addProductPage.fillTitle(productTitle);
  684. addProductPage.fillPrice(product.firstPrice);
  685. addProductPage.clickPublish();
  686. commonHelper.waitUntilElementVisible(productListPage.productEntry(productTitle));
  687. });
  688.  
  689. it('should open new collection page', function () {
  690. dashboardPage.openAddCollectionPage();
  691. });
  692.  
  693. it('should fill title and description fields', function () {
  694. addCollectionPage.fillTitle(collectionTitle);
  695. addCollectionPage.fillDescription(firstCollectionDescription);
  696. });
  697.  
  698. it('should click auto add product radio button', function () {
  699. addCollectionPage.clickAddAuto();
  700. commonHelper.waitUntilElementVisible(addCollectionPage.sel2Type);
  701. });
  702.  
  703. it('should add condition', function () {
  704. addCollectionPage.selectConditionVariant(0, 'Product price');
  705. addCollectionPage.selectConditionRule(0, 'is not equal to');
  706. addCollectionPage.fillConditionValue(0, '$35.00');
  707. });
  708.  
  709. it('should add new collection', function () {
  710. addCollectionPage.clickPublish();
  711. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(collectionTitle));
  712. });
  713.  
  714. it('should show collection page after click on collection link', function () {
  715. collectionListPage.clickCollection(collectionTitle);
  716. commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
  717.  
  718. expect(collectionsPage.productTitle(productTitle).isDisplayed()).toBeTruthy();
  719. commonHelper.switchToPreviousTab();
  720. });
  721. });
  722.  
  723.  
  724. describe('auto-add product by product price is greater then', function () {
  725.  
  726. var unique_value = commonHelper.uniqueValue();
  727. var collectionTitle = firstCollectionTitle + unique_value;
  728. var productTitle = product.firstTitle + unique_value;
  729.  
  730. beforeAll(function () {
  731. commonHelper.acceptAlert();
  732. browser.get(signInData.link);
  733. });
  734.  
  735. afterAll(function () {
  736. commonHelper.clearAllData();
  737. });
  738.  
  739. it('should redirect on dashboard page after login', function () {
  740. signInPage.login(username, password);
  741. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  742. });
  743.  
  744. it('should open products list page', function () {
  745. dashboardPage.openProductListPage();
  746. });
  747.  
  748. it('should open new product page', function () {
  749. productListPage.clickAddProduct();
  750. addProductPage.waitForPublishButton();
  751. });
  752.  
  753. it('should add new product', function () {
  754. addProductPage.selectType(product.type);
  755. addProductPage.selectFirstCollection();
  756. addProductPage.fillTitle(productTitle);
  757. addProductPage.fillPrice(product.firstPrice);
  758. addProductPage.clickPublish();
  759. commonHelper.waitUntilElementVisible(productListPage.productEntry(productTitle));
  760. });
  761.  
  762. it('should open new collection page', function () {
  763. dashboardPage.openAddCollectionPage();
  764. });
  765.  
  766. it('should fill title and description fields', function () {
  767. addCollectionPage.fillTitle(collectionTitle);
  768. addCollectionPage.fillDescription(firstCollectionDescription);
  769. });
  770.  
  771. it('should click auto add product radio button', function () {
  772. addCollectionPage.clickAddAuto();
  773. commonHelper.waitUntilElementVisible(addCollectionPage.sel2Type);
  774. });
  775.  
  776. it('should add condition', function () {
  777. addCollectionPage.selectConditionVariant(0, 'Product price');
  778. addCollectionPage.selectConditionRule(0, 'is greater then');
  779. addCollectionPage.fillConditionValue(0, '$15.00');
  780. });
  781.  
  782. it('should add new collection', function () {
  783. addCollectionPage.clickPublish();
  784. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(collectionTitle));
  785. });
  786.  
  787. it('should show collection page after click on collection link', function () {
  788. collectionListPage.clickCollection(collectionTitle);
  789. commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
  790.  
  791. expect(collectionsPage.productTitle(productTitle).isDisplayed()).toBeTruthy();
  792. commonHelper.switchToPreviousTab();
  793. });
  794. });
  795.  
  796. describe('auto-add product by product price is less then', function () {
  797.  
  798. var unique_value = commonHelper.uniqueValue();
  799. var collectionTitle = firstCollectionTitle + unique_value;
  800. var productTitle = product.firstTitle + unique_value;
  801.  
  802. beforeAll(function () {
  803. commonHelper.acceptAlert();
  804. browser.get(signInData.link);
  805. });
  806.  
  807. afterAll(function () {
  808. commonHelper.clearAllData();
  809. });
  810.  
  811. it('should redirect on dashboard page after login', function () {
  812. signInPage.login(username, password);
  813. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  814. });
  815.  
  816. it('should open products list page', function () {
  817. dashboardPage.openProductListPage();
  818. });
  819.  
  820. it('should open new product page', function () {
  821. productListPage.clickAddProduct();
  822. addProductPage.waitForPublishButton();
  823. });
  824.  
  825. it('should add new product', function () {
  826. addProductPage.selectType(product.type);
  827. addProductPage.selectFirstCollection();
  828. addProductPage.fillTitle(productTitle);
  829. addProductPage.fillPrice(product.firstPrice);
  830. addProductPage.clickPublish();
  831. commonHelper.waitUntilElementVisible(productListPage.productEntry(productTitle));
  832. });
  833.  
  834. it('should open new collection page', function () {
  835. dashboardPage.openAddCollectionPage();
  836. });
  837.  
  838. it('should fill title and description fields', function () {
  839. addCollectionPage.fillTitle(collectionTitle);
  840. addCollectionPage.fillDescription(firstCollectionDescription);
  841. });
  842.  
  843. it('should click auto add product radio button', function () {
  844. addCollectionPage.clickAddAuto();
  845. commonHelper.waitUntilElementVisible(addCollectionPage.sel2Type);
  846. });
  847.  
  848. it('should add condition', function () {
  849. addCollectionPage.selectConditionVariant(0, 'Product price');
  850. addCollectionPage.selectConditionRule(0, 'is less then');
  851. addCollectionPage.fillConditionValue(0, '$35.00');
  852. });
  853.  
  854. it('should add new collection', function () {
  855. addCollectionPage.clickPublish();
  856. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(collectionTitle));
  857. });
  858.  
  859. it('should show collection page after click on collection link', function () {
  860. collectionListPage.clickCollection(collectionTitle);
  861. commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
  862.  
  863. expect(collectionsPage.productTitle(productTitle).isDisplayed()).toBeTruthy();
  864. commonHelper.switchToPreviousTab();
  865. });
  866. });
  867. });
  868.  
  869. __________________________________________________________________________
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement