Guest User

by_weight.spec.js

a guest
Feb 7th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.15 KB | None | 0 0
  1. by_weight.spec.js
  2.  
  3. var pageObject = require('./../../../../../../services/pages').container.PageObject;
  4. var signInPage = pageObject.getSignInPage();
  5. var dashboardPage = pageObject.getDashboardPage();
  6. var addCollectionPage = pageObject.getAddCollectionPage();
  7. var collectionListPage = pageObject.getCollectionListPage();
  8. var collectionsPage = pageObject.getCollectionsPage();
  9. var addProductPage = pageObject.getAddProductPage();
  10. var productListPage = pageObject.getProductListPage();
  11. var signInData = require('./../../../../../../data/admin/sign_in/index');
  12. var collectionData = require('./../../../../../../data/admin/collection/index');
  13. var productData = require('./../../../../../../data/admin/product/index');
  14. var commonHelper = require('./../../../../../../services/helpers/common.helper.js');
  15.  
  16. describe('Add Collection - Auto Adding - By Weight', function () {
  17.  
  18. var username = signInData.adminAccount.username;
  19. var password = signInData.adminAccount.password;
  20. var firstCollectionTitle = commonHelper.uniqueProductName('weight1');
  21. var firstCollectionDescription = collectionData.collection.description.first;
  22.  
  23. var product = {
  24. firstTitle: commonHelper.uniqueProductName('weight2'),
  25. type: productData.product.type,
  26. firstWeight: productData.product.weight,
  27. secondWeight: '1',
  28. thirdWeight: '3',
  29. firstPrice: productData.product.price
  30. };
  31.  
  32. describe('check weight metric', function () {
  33.  
  34. beforeAll(function () {
  35. commonHelper.acceptAlert();
  36. browser.get(signInData.link);
  37. });
  38.  
  39. afterAll(function () {
  40. commonHelper.clearAllData();
  41. });
  42.  
  43. it('should redirect on dashboard page after login', function () {
  44. signInPage.login(username, password);
  45. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  46. });
  47.  
  48. it('should open new collection page', function () {
  49. dashboardPage.openAddCollectionPage();
  50. });
  51.  
  52. it('should click auto add product radio button', function () {
  53. addCollectionPage.clickAddAuto();
  54. commonHelper.waitUntilElementVisible(addCollectionPage.sel2Type);
  55. });
  56.  
  57. it('should select condition', function () {
  58. addCollectionPage.selectConditionVariant(0, 'Weight');
  59. });
  60.  
  61. it('should show correct price placeholder', function () {
  62. expect(addCollectionPage.txtConditionWeightPlaceholder()).toEqual('kg');
  63. });
  64.  
  65. it('should select condition', function () {
  66. addCollectionPage.selectConditionVariant(0, 'Product title');
  67. });
  68.  
  69. it('should not show price placeholder', function () {
  70. expect(addCollectionPage.plhWeight('kg').isPresent()).toBeFalsy();
  71. });
  72. });
  73.  
  74. describe('auto-add product by weight is equal', function () {
  75.  
  76. var unique_value = commonHelper.uniqueValue();
  77. var collectionTitle = firstCollectionTitle + unique_value;
  78. var productTitle = product.firstTitle + unique_value;
  79.  
  80. beforeAll(function () {
  81. commonHelper.acceptAlert();
  82. browser.get(signInData.link);
  83. });
  84.  
  85. afterAll(function () {
  86. commonHelper.clearAllData();
  87. });
  88.  
  89. it('should redirect on dashboard page after login', function () {
  90. signInPage.login(username, password);
  91. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  92. });
  93.  
  94. it('should open products list page', function () {
  95. dashboardPage.openProductListPage();
  96. });
  97.  
  98. it('should open new product page', function () {
  99. productListPage.clickAddProduct();
  100. addProductPage.waitForPublishButton();
  101. });
  102.  
  103. it('should add new product', function () {
  104. addProductPage.selectType(product.type);
  105. addProductPage.selectFirstCollection();
  106. addProductPage.fillTitle(productTitle);
  107. addProductPage.fillPrice(product.firstPrice);
  108. addProductPage.fillShippingWeight(product.firstWeight);
  109. addProductPage.clickPublish();
  110. commonHelper.waitUntilElementVisible(productListPage.productEntry(productTitle));
  111. });
  112.  
  113. it('should open new collection page', function () {
  114. dashboardPage.openAddCollectionPage();
  115. });
  116.  
  117. it('should fill title and description fields', function () {
  118. addCollectionPage.fillTitle(collectionTitle);
  119. addCollectionPage.fillDescription(firstCollectionDescription);
  120. });
  121.  
  122. it('should click auto add product radio button', function () {
  123. addCollectionPage.clickAddAuto();
  124. commonHelper.waitUntilElementVisible(addCollectionPage.sel2Type);
  125. });
  126.  
  127. it('should add condition', function () {
  128. addCollectionPage.selectConditionVariant(0, 'Weight');
  129. addCollectionPage.selectConditionRule(0, 'is equal to');
  130. addCollectionPage.fillConditionValue(0, product.firstWeight);
  131. });
  132.  
  133. it('should add new collection', function () {
  134. addCollectionPage.clickPublish();
  135. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(collectionTitle));
  136. });
  137.  
  138. it('should show collection page after click on collection link', function () {
  139. collectionListPage.clickCollection(collectionTitle);
  140. commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
  141. });
  142.  
  143. it('should see product', function check(done) {
  144. collectionsPage.allProducts(productTitle).count().then(function(result){
  145. if(result == 1){
  146. done();
  147. }else {
  148. collectionsPage.clickPaginationButton('Next');
  149. check(done);
  150. }
  151. })
  152. });
  153.  
  154. it('should go to previous tab', function () {
  155. commonHelper.switchToPreviousTab();
  156. });
  157. });
  158.  
  159. describe('auto-add product by weight is not equal', function () {
  160.  
  161. var unique_value = commonHelper.uniqueValue();
  162. var collectionTitle = firstCollectionTitle + unique_value;
  163. var productTitle = product.firstTitle + unique_value;
  164.  
  165. beforeAll(function () {
  166. commonHelper.acceptAlert();
  167. browser.get(signInData.link);
  168. });
  169.  
  170. afterAll(function () {
  171. commonHelper.clearAllData();
  172. });
  173.  
  174. it('should redirect on dashboard page after login', function () {
  175. signInPage.login(username, password);
  176. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  177. });
  178.  
  179. it('should open products list page', function () {
  180. dashboardPage.openProductListPage();
  181. });
  182.  
  183. it('should open new product page', function () {
  184. productListPage.clickAddProduct();
  185. addProductPage.waitForPublishButton();
  186. });
  187.  
  188. it('should add new product', function () {
  189. addProductPage.selectType(product.type);
  190. addProductPage.selectFirstCollection();
  191. addProductPage.fillTitle(productTitle);
  192. addProductPage.fillPrice(product.firstPrice);
  193. addProductPage.fillShippingWeight(product.firstWeight);
  194. addProductPage.clickPublish();
  195. commonHelper.waitUntilElementVisible(productListPage.productEntry(productTitle));
  196. });
  197.  
  198. it('should open new collection page', function () {
  199. dashboardPage.openAddCollectionPage();
  200. });
  201.  
  202. it('should fill title and description fields', function () {
  203. addCollectionPage.fillTitle(collectionTitle);
  204. addCollectionPage.fillDescription(firstCollectionDescription);
  205. });
  206.  
  207. it('should click auto add product radio button', function () {
  208. addCollectionPage.clickAddAuto();
  209. commonHelper.waitUntilElementVisible(addCollectionPage.sel2Type);
  210. });
  211.  
  212. it('should add condition', function () {
  213. addCollectionPage.selectConditionVariant(0, 'Weight');
  214. addCollectionPage.selectConditionRule(0, 'is not equal to');
  215. addCollectionPage.fillConditionValue(0, product.secondWeight);
  216. });
  217.  
  218. it('should add new collection', function () {
  219. addCollectionPage.clickPublish();
  220. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(collectionTitle));
  221. });
  222.  
  223. it('should show collection page after click on collection link', function () {
  224. collectionListPage.clickCollection(collectionTitle);
  225. commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
  226.  
  227. expect(collectionsPage.productTitle(productTitle).isDisplayed()).toBeTruthy();
  228. commonHelper.switchToPreviousTab();
  229. });
  230. });
  231.  
  232. describe('auto-add product by weight is greater then', function () {
  233.  
  234. var unique_value = commonHelper.uniqueValue();
  235. var collectionTitle = firstCollectionTitle + unique_value;
  236. var productTitle = product.firstTitle + unique_value;
  237.  
  238. beforeAll(function () {
  239. commonHelper.acceptAlert();
  240. browser.get(signInData.link);
  241. });
  242.  
  243. afterAll(function () {
  244. commonHelper.clearAllData();
  245. });
  246.  
  247. it('should redirect on dashboard page after login', function () {
  248. signInPage.login(username, password);
  249. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  250. });
  251.  
  252. it('should open products list page', function () {
  253. dashboardPage.openProductListPage();
  254. });
  255.  
  256. it('should open new product page', function () {
  257. productListPage.clickAddProduct();
  258. addProductPage.waitForPublishButton();
  259. });
  260.  
  261. it('should add new product', function () {
  262. addProductPage.selectType(product.type);
  263. addProductPage.selectFirstCollection();
  264. addProductPage.fillTitle(productTitle);
  265. addProductPage.fillPrice(product.firstPrice);
  266. addProductPage.fillShippingWeight(product.firstWeight);
  267. addProductPage.clickPublish();
  268. commonHelper.waitUntilElementVisible(productListPage.productEntry(productTitle));
  269. });
  270.  
  271. it('should open new collection page', function () {
  272. dashboardPage.openAddCollectionPage();
  273. });
  274.  
  275. it('should fill title and description fields', function () {
  276. addCollectionPage.fillTitle(collectionTitle);
  277. addCollectionPage.fillDescription(firstCollectionDescription);
  278. });
  279.  
  280. it('should click auto add product radio button', function () {
  281. addCollectionPage.clickAddAuto();
  282. commonHelper.waitUntilElementVisible(addCollectionPage.sel2Type);
  283. });
  284.  
  285. it('should add condition', function () {
  286. addCollectionPage.selectConditionVariant(0, 'Weight');
  287. addCollectionPage.selectConditionRule(0, 'is greater then');
  288. addCollectionPage.fillConditionValue(0, product.secondWeight);
  289. });
  290.  
  291. it('should add new collection', function () {
  292. addCollectionPage.clickPublish();
  293. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(collectionTitle));
  294. });
  295.  
  296. it('should show collection page after click on collection link', function () {
  297. collectionListPage.clickCollection(collectionTitle);
  298. commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
  299.  
  300. expect(collectionsPage.productTitle(productTitle).isDisplayed()).toBeTruthy();
  301. commonHelper.switchToPreviousTab();
  302. });
  303. });
  304.  
  305. describe('auto-add product by weight is less then', function () {
  306.  
  307. var unique_value = commonHelper.uniqueValue();
  308. var collectionTitle = firstCollectionTitle + unique_value;
  309. var productTitle = product.firstTitle + unique_value;
  310.  
  311. beforeAll(function () {
  312. commonHelper.acceptAlert();
  313. browser.get(signInData.link);
  314. });
  315.  
  316. afterAll(function () {
  317. commonHelper.clearAllData();
  318. });
  319.  
  320. it('should redirect on dashboard page after login', function () {
  321. signInPage.login(username, password);
  322. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  323. });
  324.  
  325. it('should open products list page', function () {
  326. dashboardPage.openProductListPage();
  327. });
  328.  
  329. it('should open new product page', function () {
  330. productListPage.clickAddProduct();
  331. addProductPage.waitForPublishButton();
  332. });
  333.  
  334. it('should add new product', function () {
  335. addProductPage.selectType(product.type);
  336. addProductPage.selectFirstCollection();
  337. addProductPage.fillTitle(productTitle);
  338. addProductPage.fillPrice(product.firstPrice);
  339. addProductPage.fillShippingWeight(product.firstWeight);
  340. addProductPage.clickPublish();
  341. commonHelper.waitUntilElementVisible(productListPage.productEntry(productTitle));
  342. });
  343.  
  344. it('should open new collection page', function () {
  345. dashboardPage.openAddCollectionPage();
  346. });
  347.  
  348. it('should fill title and description fields', function () {
  349. addCollectionPage.fillTitle(collectionTitle);
  350. addCollectionPage.fillDescription(firstCollectionDescription);
  351. });
  352.  
  353. it('should click auto add product radio button', function () {
  354. addCollectionPage.clickAddAuto();
  355. commonHelper.waitUntilElementVisible(addCollectionPage.sel2Type);
  356. });
  357.  
  358. it('should add condition', function () {
  359. addCollectionPage.selectConditionVariant(0, 'Weight');
  360. addCollectionPage.selectConditionRule(0, 'is less then');
  361. addCollectionPage.fillConditionValue(0, product.thirdWeight);
  362. });
  363.  
  364. it('should add new collection', function () {
  365. addCollectionPage.clickPublish();
  366. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(collectionTitle));
  367. });
  368.  
  369. it('should show collection page after click on collection link', function () {
  370. collectionListPage.clickCollection(collectionTitle);
  371. commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
  372. });
  373.  
  374. it('should see product', function check(done) {
  375. collectionsPage.allProducts(productTitle).count().then(function(result){
  376. if(result == 1){
  377. done();
  378. }else {
  379. collectionsPage.clickPaginationButton('Next');
  380. check(done);
  381. }
  382. })
  383. });
  384.  
  385. it('should switch to previous tab', function () {
  386. commonHelper.switchToPreviousTab();
  387. });
  388. });
  389. });
Add Comment
Please, Sign In to add comment