Guest User

auto_manual/switch.spec.js

a guest
Feb 13th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.39 KB | None | 0 0
  1. var pageObject = require('./../../../../../../services/pages').container.PageObject;
  2. var signInPage = pageObject.getSignInPage();
  3. var dashboardPage = pageObject.getDashboardPage();
  4. var addCollectionPage = pageObject.getAddCollectionPage();
  5. var collectionListPage = pageObject.getCollectionListPage();
  6. var collectionsPage = pageObject.getCollectionsPage();
  7. var addProductPage = pageObject.getAddProductPage();
  8. var productListPage = pageObject.getProductListPage();
  9. var signInData = require('./../../../../../../data/admin/sign_in/index');
  10. var collectionData = require('./../../../../../../data/admin/collection/index');
  11. var productData = require('./../../../../../../data/admin/product/index');
  12. var commonHelper = require('./../../../../../../services/helpers/common.helper.js');
  13.  
  14. describe('Add Collection - Auto Manual - Switch Method Scenarios', function () {
  15.  
  16. var username = signInData.adminAccount.username;
  17. var password = signInData.adminAccount.password;
  18. var firstCollectionTitle = commonHelper.uniqueProductName('switch1');
  19. var firstCollectionDescription = collectionData.collection.description.first;
  20.  
  21. var addCollectionLink = signInData.link + '/collections/create';
  22.  
  23. var product = {
  24. firstTitle: commonHelper.uniqueProductName('switch2'),
  25. secondTitle: commonHelper.uniqueProductName('switch3'),
  26. type: productData.product.type,
  27. price: productData.product.price
  28. };
  29.  
  30. describe('switching from manually add products to auto add product based on conditions', function () {
  31.  
  32. var unique_value = commonHelper.uniqueValue();
  33. var collectionTitle = firstCollectionTitle + unique_value;
  34. var firstProductTitle = product.firstTitle + unique_value;
  35. var secondProductTitle = product.secondTitle + unique_value;
  36.  
  37. beforeAll(function () {
  38. commonHelper.acceptAlert();
  39. browser.get(signInData.link);
  40. });
  41.  
  42. afterAll(function () {
  43. commonHelper.clearAllData();
  44. });
  45.  
  46. it('should redirect on dashboard page after login', function () {
  47. signInPage.login(username, password);
  48. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  49. });
  50.  
  51. it('should redirect on add product page', function () {
  52. browser.get(productData.addLink);
  53. addProductPage.waitForPublishButton();
  54. });
  55.  
  56. it('should add first product', function () {
  57. addProductPage.selectType(product.type);
  58. addProductPage.selectFirstCollection();
  59. addProductPage.fillTitle(firstProductTitle);
  60. addProductPage.fillPrice(product.price);
  61. addProductPage.clickPublish();
  62. commonHelper.waitUntilElementVisible(productListPage.productEntry(firstProductTitle));
  63. });
  64.  
  65. it('should open new product page', function () {
  66. browser.get(productData.addLink);
  67. addProductPage.waitForPublishButton();
  68. });
  69.  
  70. it('should add second product', function () {
  71. addProductPage.selectType(product.type);
  72. addProductPage.selectFirstCollection();
  73. addProductPage.fillTitle(secondProductTitle);
  74. addProductPage.fillPrice(product.price);
  75. addProductPage.clickPublish();
  76. commonHelper.waitUntilElementVisible(productListPage.productEntry(secondProductTitle));
  77. });
  78.  
  79. it('should open new collection page', function () {
  80. browser.get(addCollectionLink);
  81. });
  82.  
  83. it('should fill title and description fields', function () {
  84. addCollectionPage.fillTitle(collectionTitle);
  85. addCollectionPage.fillDescription(firstCollectionDescription);
  86. });
  87.  
  88. it('should add manual product', function () {
  89. addCollectionPage.clickAddProducts();
  90. addCollectionPage.clickProduct(secondProductTitle);
  91. addCollectionPage.clickCloseProducts();
  92. });
  93.  
  94. it('should click auto add product radio button', function () {
  95. addCollectionPage.clickAddAuto();
  96. commonHelper.waitUntilElementClickable(addCollectionPage.btnConfirm);
  97. addCollectionPage.clickConfirm();
  98. commonHelper.waitUntilElementVisible(addCollectionPage.sel2Type);
  99. });
  100.  
  101. it('should add condition', function () {
  102. addCollectionPage.selectConditionVariant(0, 'Product title');
  103. addCollectionPage.selectConditionRule(0, 'is exactly');
  104. addCollectionPage.fillConditionValue(0, firstProductTitle);
  105. });
  106.  
  107. it('should add new collection', function () {
  108. addCollectionPage.clickPublish();
  109. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(collectionTitle));
  110. });
  111.  
  112. it('should show collection page after click on collection link', function () {
  113. collectionListPage.clickCollection(collectionTitle);
  114. commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
  115.  
  116. expect(collectionsPage.productTitle(firstProductTitle).isDisplayed()).toBeTruthy();
  117. expect(collectionsPage.productTitle(secondProductTitle).isPresent()).toBeFalsy();
  118. commonHelper.switchToPreviousTab();
  119. });
  120. });
  121.  
  122. describe('switching from auto add product based on conditions to manually add products', function () {
  123.  
  124. var unique_value = commonHelper.uniqueValue();
  125. var collectionTitle = firstCollectionTitle + unique_value;
  126. var firstProductTitle = product.firstTitle + unique_value;
  127. var secondProductTitle = product.secondTitle + unique_value;
  128.  
  129. beforeAll(function () {
  130. commonHelper.acceptAlert();
  131. browser.get(signInData.link);
  132. });
  133.  
  134. afterAll(function () {
  135. commonHelper.clearAllData();
  136. });
  137.  
  138. it('should redirect on dashboard page after login', function () {
  139. signInPage.login(username, password);
  140. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  141. });
  142.  
  143. it('should redirect on add product page', function () {
  144. browser.get(productData.addLink);
  145. addProductPage.waitForPublishButton();
  146. });
  147.  
  148. it('should add first product', function () {
  149. addProductPage.selectType(product.type);
  150. addProductPage.selectFirstCollection();
  151. addProductPage.fillTitle(firstProductTitle);
  152. addProductPage.fillPrice(product.price);
  153. addProductPage.clickPublish();
  154. commonHelper.waitUntilElementVisible(productListPage.productEntry(firstProductTitle));
  155. });
  156.  
  157. it('should open new product page', function () {
  158. browser.get(productData.addLink);
  159. addProductPage.waitForPublishButton();
  160. });
  161.  
  162. it('should add second product', function () {
  163. addProductPage.selectType(product.type);
  164. addProductPage.selectFirstCollection();
  165. addProductPage.fillTitle(secondProductTitle);
  166. addProductPage.fillPrice(product.price);
  167. addProductPage.clickPublish();
  168. commonHelper.waitUntilElementVisible(productListPage.productEntry(secondProductTitle));
  169. });
  170.  
  171. it('should open new collection page', function () {
  172. browser.get(addCollectionLink);
  173. });
  174.  
  175. it('should fill title and description fields', function () {
  176. addCollectionPage.fillTitle(collectionTitle);
  177. addCollectionPage.fillDescription(firstCollectionDescription);
  178. });
  179.  
  180. it('should click auto add product radio button', function () {
  181. addCollectionPage.clickAddAuto();
  182. commonHelper.waitUntilElementVisible(addCollectionPage.sel2Type);
  183. });
  184.  
  185. it('should add condition', function () {
  186. addCollectionPage.selectConditionVariant(0, 'Product title');
  187. addCollectionPage.selectConditionRule(0, 'is exactly');
  188. addCollectionPage.fillConditionValue(0, firstProductTitle);
  189. });
  190.  
  191. it('should click manual add product radio button', function () {
  192. addCollectionPage.clickAddManual();
  193. commonHelper.waitUntilElementClickable(addCollectionPage.btnConfirm);
  194. addCollectionPage.clickConfirm();
  195. });
  196.  
  197. it('should add manual product', function () {
  198. addCollectionPage.clickAddProducts();
  199. addCollectionPage.clickProduct(secondProductTitle);
  200. addCollectionPage.clickCloseProducts();
  201. });
  202.  
  203. it('should add new collection', function () {
  204. addCollectionPage.clickPublish();
  205. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(collectionTitle));
  206. });
  207.  
  208. it('should show collection page after click on collection link', function () {
  209. collectionListPage.clickCollection(collectionTitle);
  210. commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
  211.  
  212. expect(collectionsPage.productTitle(secondProductTitle).isDisplayed()).toBeTruthy();
  213. expect(collectionsPage.productTitle(firstCollectionDescription).isPresent()).toBeFalsy();
  214. commonHelper.switchToPreviousTab();
  215. });
  216. });
  217. });
Advertisement
Add Comment
Please, Sign In to add comment