Advertisement
Guest User

by_variant.spec.js

a guest
Feb 7th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.29 KB | None | 0 0
  1. by_variant.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 Variant', function () {
  17.  
  18. var username = signInData.adminAccount.username;
  19. var password = signInData.adminAccount.password;
  20. var firstCollectionTitle = commonHelper.uniqueProductName('variant1');
  21. var firstCollectionDescription = collectionData.collection.description.first;
  22.  
  23. var product = {
  24. firstTitle: commonHelper.uniqueProductName('variant2'),
  25. type: productData.product.type,
  26. price: productData.product.price,
  27. firstColor: productData.product.color.first,
  28. secondColor: productData.product.color.second,
  29. firstSize: productData.product.size.first,
  30. secondSize: productData.product.size.second,
  31. firstVariant: productData.product.color.first + ' / ' + productData.product.size.first
  32. };
  33.  
  34. describe('auto-add product by product variant does not contain', function () {
  35.  
  36. var unique_value = commonHelper.uniqueValue();
  37. var collectionTitle = firstCollectionTitle + unique_value;
  38. var productTitle = product.firstTitle + unique_value;
  39. var productVariant = product.firstColor + '1';
  40.  
  41. beforeAll(function () {
  42. commonHelper.acceptAlert();
  43. browser.get(signInData.link);
  44. });
  45.  
  46. afterAll(function () {
  47. commonHelper.clearAllData();
  48. });
  49.  
  50. it('should redirect on dashboard page after login', function () {
  51. signInPage.login(username, password);
  52. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  53. });
  54.  
  55. it('should open products list page', function () {
  56. dashboardPage.openProductListPage();
  57. });
  58.  
  59. it('should open new product page', function () {
  60. productListPage.clickAddProduct();
  61. addProductPage.waitForPublishButton();
  62. });
  63.  
  64. it('should add new product', function () {
  65. addProductPage.clickMulti();
  66. addProductPage.selectType(product.type);
  67. addProductPage.selectFirstCollection();
  68. addProductPage.fillTitle(productTitle);
  69. addProductPage.fillOptionTitle(0, 'Color');
  70. addProductPage.fillOptionValue(0, product.firstColor);
  71. addProductPage.fillOptionValue(0, product.secondColor);
  72. addProductPage.fillOptionTitle(1, 'Size');
  73. addProductPage.fillOptionValue(1, product.firstSize);
  74. addProductPage.fillOptionValue(1, product.secondSize);
  75.  
  76. addProductPage.fillVariantPrice(product.firstVariant ,product.price);
  77. addProductPage.clickVariantPriceAutofill(product.firstVariant);
  78.  
  79. addProductPage.clickPublish();
  80. commonHelper.waitUntilElementVisible(productListPage.productEntry(productTitle));
  81. });
  82.  
  83. it('should open new collection page', function () {
  84. dashboardPage.openAddCollectionPage();
  85. });
  86.  
  87. it('should fill title and description fields', function () {
  88. addCollectionPage.fillTitle(collectionTitle);
  89. addCollectionPage.fillDescription(firstCollectionDescription);
  90. });
  91.  
  92. it('should click auto add product radio button', function () {
  93. addCollectionPage.clickAddAuto();
  94. commonHelper.waitUntilElementVisible(addCollectionPage.sel2Type);
  95. });
  96.  
  97. it('should add condition', function () {
  98. addCollectionPage.selectConditionVariant(0, 'Variant option value');
  99. addCollectionPage.selectConditionRule(0, 'does not contain');
  100. addCollectionPage.fillConditionValue(0, productVariant);
  101. });
  102.  
  103. it('should add new collection', function () {
  104. addCollectionPage.clickPublish();
  105. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(collectionTitle));
  106. });
  107.  
  108. it('should show collection page after click on collection link', function () {
  109. collectionListPage.clickCollection(collectionTitle);
  110. commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
  111. });
  112.  
  113. it('should see product', function check(done) {
  114. collectionsPage.allProducts(productTitle).count().then(function(result){
  115. if(result == 1){
  116. done();
  117. }else {
  118. collectionsPage.clickPaginationButton('Next');
  119. check(done);
  120. }
  121. })
  122. });
  123.  
  124. it('should switch to previous tab', function () {
  125. commonHelper.switchToPreviousTab();
  126. });
  127. });
  128.  
  129. describe('auto-add product by product variant is exactly', function () {
  130.  
  131. var unique_value = commonHelper.uniqueValue();
  132. var collectionTitle = firstCollectionTitle + unique_value;
  133. var productTitle = product.firstTitle + unique_value;
  134.  
  135. beforeAll(function () {
  136. commonHelper.acceptAlert();
  137. browser.get(signInData.link);
  138. });
  139.  
  140. afterAll(function () {
  141. commonHelper.clearAllData();
  142. });
  143.  
  144. it('should redirect on dashboard page after login', function () {
  145. signInPage.login(username, password);
  146. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  147. });
  148.  
  149. it('should open products list page', function () {
  150. dashboardPage.openProductListPage();
  151. });
  152.  
  153. it('should open new product page', function () {
  154. productListPage.clickAddProduct();
  155. addProductPage.waitForPublishButton();
  156. });
  157.  
  158. it('should add new product', function () {
  159. addProductPage.clickMulti();
  160. addProductPage.selectType(product.type);
  161. addProductPage.selectFirstCollection();
  162. addProductPage.fillTitle(productTitle);
  163. addProductPage.fillOptionTitle(0, 'Color');
  164. addProductPage.fillOptionValue(0, product.firstColor);
  165. addProductPage.fillOptionValue(0, product.secondColor);
  166. addProductPage.fillOptionTitle(1, 'Size');
  167. addProductPage.fillOptionValue(1, product.firstSize);
  168. addProductPage.fillOptionValue(1, product.secondSize);
  169.  
  170. addProductPage.fillVariantPrice(product.firstVariant ,product.price);
  171. addProductPage.clickVariantPriceAutofill(product.firstVariant);
  172.  
  173. addProductPage.clickPublish();
  174. commonHelper.waitUntilElementVisible(productListPage.productEntry(productTitle));
  175. });
  176.  
  177. it('should open new collection page', function () {
  178. dashboardPage.openAddCollectionPage();
  179. });
  180.  
  181. it('should fill title and description fields', function () {
  182. addCollectionPage.fillTitle(collectionTitle);
  183. addCollectionPage.fillDescription(firstCollectionDescription);
  184. });
  185.  
  186. it('should click auto add product radio button', function () {
  187. addCollectionPage.clickAddAuto();
  188. commonHelper.waitUntilElementVisible(addCollectionPage.sel2Type);
  189. });
  190.  
  191. it('should add condition', function () {
  192. addCollectionPage.selectConditionVariant(0, 'Variant option value');
  193. addCollectionPage.selectConditionRule(0, 'is exactly');
  194. addCollectionPage.fillConditionValue(0, product.firstSize);
  195. });
  196.  
  197. it('should add new collection', function () {
  198. addCollectionPage.clickPublish();
  199. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(collectionTitle));
  200. });
  201.  
  202. it('should show collection page after click on collection link', function () {
  203. collectionListPage.clickCollection(collectionTitle);
  204. commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
  205. });
  206.  
  207. it('should see product', function check(done) {
  208. collectionsPage.allProducts(productTitle).count().then(function(result){
  209. if(result == 1){
  210. done();
  211. }else {
  212. collectionsPage.clickPaginationButton('Next');
  213. check(done);
  214. }
  215. })
  216. });
  217.  
  218. it('should switch to previous tab', function () {
  219. commonHelper.switchToPreviousTab();
  220. });
  221. });
  222.  
  223. describe('auto-add product by product variant starts with', function () {
  224.  
  225. var unique_value = commonHelper.uniqueValue();
  226. var collectionTitle = firstCollectionTitle + unique_value;
  227. var productTitle = product.firstTitle + unique_value;
  228. var productVariant = 'Re';
  229.  
  230. beforeAll(function () {
  231. commonHelper.acceptAlert();
  232. browser.get(signInData.link);
  233. });
  234.  
  235. afterAll(function () {
  236. commonHelper.clearAllData();
  237. });
  238.  
  239. it('should redirect on dashboard page after login', function () {
  240. signInPage.login(username, password);
  241. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  242. });
  243.  
  244. it('should open products list page', function () {
  245. dashboardPage.openProductListPage();
  246. });
  247.  
  248. it('should open new product page', function () {
  249. productListPage.clickAddProduct();
  250. addProductPage.waitForPublishButton();
  251. });
  252.  
  253. it('should add new product', function () {
  254. addProductPage.clickMulti();
  255. addProductPage.selectType(product.type);
  256. addProductPage.selectFirstCollection();
  257. addProductPage.fillTitle(productTitle);
  258. addProductPage.fillOptionTitle(0, 'Color');
  259. addProductPage.fillOptionValue(0, product.firstColor);
  260. addProductPage.fillOptionValue(0, product.secondColor);
  261. addProductPage.fillOptionTitle(1, 'Size');
  262. addProductPage.fillOptionValue(1, product.firstSize);
  263. addProductPage.fillOptionValue(1, product.secondSize);
  264.  
  265. addProductPage.fillVariantPrice(product.firstVariant ,product.price);
  266. addProductPage.clickVariantPriceAutofill(product.firstVariant);
  267.  
  268. addProductPage.clickPublish();
  269. commonHelper.waitUntilElementVisible(productListPage.productEntry(productTitle));
  270. });
  271.  
  272. it('should open new collection page', function () {
  273. dashboardPage.openAddCollectionPage();
  274. });
  275.  
  276. it('should fill title and description fields', function () {
  277. addCollectionPage.fillTitle(collectionTitle);
  278. addCollectionPage.fillDescription(firstCollectionDescription);
  279. });
  280.  
  281. it('should click auto add product radio button', function () {
  282. addCollectionPage.clickAddAuto();
  283. commonHelper.waitUntilElementVisible(addCollectionPage.sel2Type);
  284. });
  285.  
  286. it('should add condition', function () {
  287. addCollectionPage.selectConditionVariant(0, 'Variant option value');
  288. addCollectionPage.selectConditionRule(0, 'starts with');
  289. addCollectionPage.fillConditionValue(0, productVariant);
  290. });
  291.  
  292. it('should add new collection', function () {
  293. addCollectionPage.clickPublish();
  294. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(collectionTitle));
  295. });
  296.  
  297. it('should show collection page after click on collection link', function () {
  298. collectionListPage.clickCollection(collectionTitle);
  299. commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
  300.  
  301. expect(collectionsPage.productTitle(productTitle).isDisplayed()).toBeTruthy();
  302. commonHelper.switchToPreviousTab();
  303. });
  304. });
  305.  
  306. describe('auto-add product by product variant ends with', function () {
  307.  
  308. var unique_value = commonHelper.uniqueValue();
  309. var collectionTitle = firstCollectionTitle + unique_value;
  310. var productTitle = product.firstTitle + unique_value;
  311. var productVariant = 'all';
  312.  
  313. beforeAll(function () {
  314. commonHelper.acceptAlert();
  315. browser.get(signInData.link);
  316. });
  317.  
  318. afterAll(function () {
  319. commonHelper.clearAllData();
  320. });
  321.  
  322. it('should redirect on dashboard page after login', function () {
  323. signInPage.login(username, password);
  324. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  325. });
  326.  
  327. it('should open products list page', function () {
  328. dashboardPage.openProductListPage();
  329. });
  330.  
  331. it('should open new product page', function () {
  332. productListPage.clickAddProduct();
  333. addProductPage.waitForPublishButton();
  334. });
  335.  
  336. it('should add new product', function () {
  337. addProductPage.clickMulti();
  338. addProductPage.selectType(product.type);
  339. addProductPage.selectFirstCollection();
  340. addProductPage.fillTitle(productTitle);
  341. addProductPage.fillOptionTitle(0, 'Color');
  342. addProductPage.fillOptionValue(0, product.firstColor);
  343. addProductPage.fillOptionValue(0, product.secondColor);
  344. addProductPage.fillOptionTitle(1, 'Size');
  345. addProductPage.fillOptionValue(1, product.firstSize);
  346. addProductPage.fillOptionValue(1, product.secondSize);
  347.  
  348. addProductPage.fillVariantPrice(product.firstVariant ,product.price);
  349. addProductPage.clickVariantPriceAutofill(product.firstVariant);
  350.  
  351. addProductPage.clickPublish();
  352. commonHelper.waitUntilElementVisible(productListPage.productEntry(productTitle));
  353. });
  354.  
  355. it('should open new collection page', function () {
  356. dashboardPage.openAddCollectionPage();
  357. });
  358.  
  359. it('should fill title and description fields', function () {
  360. addCollectionPage.fillTitle(collectionTitle);
  361. addCollectionPage.fillDescription(firstCollectionDescription);
  362. });
  363.  
  364. it('should click auto add product radio button', function () {
  365. addCollectionPage.clickAddAuto();
  366. commonHelper.waitUntilElementVisible(addCollectionPage.sel2Type);
  367. });
  368.  
  369. it('should add condition', function () {
  370. addCollectionPage.selectConditionVariant(0, 'Variant option value');
  371. addCollectionPage.selectConditionRule(0, 'ends with');
  372. addCollectionPage.fillConditionValue(0, productVariant);
  373. });
  374.  
  375. it('should add new collection', function () {
  376. addCollectionPage.clickPublish();
  377. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(collectionTitle));
  378. });
  379.  
  380. it('should show collection page after click on collection link', function () {
  381. collectionListPage.clickCollection(collectionTitle);
  382. commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
  383.  
  384. expect(collectionsPage.productTitle(productTitle).isDisplayed()).toBeTruthy();
  385. commonHelper.switchToPreviousTab();
  386. });
  387. });
  388.  
  389. describe('auto-add product by product variant contains', function () {
  390.  
  391. var unique_value = commonHelper.uniqueValue();
  392. var collectionTitle = firstCollectionTitle + unique_value;
  393. var productTitle = product.firstTitle + unique_value;
  394.  
  395. beforeAll(function () {
  396. commonHelper.acceptAlert();
  397. browser.get(signInData.link);
  398. });
  399.  
  400. afterAll(function () {
  401. commonHelper.clearAllData();
  402. });
  403.  
  404. it('should redirect on dashboard page after login', function () {
  405. signInPage.login(username, password);
  406. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  407. });
  408.  
  409. it('should open products list page', function () {
  410. dashboardPage.openProductListPage();
  411. });
  412.  
  413. it('should open new product page', function () {
  414. productListPage.clickAddProduct();
  415. addProductPage.waitForPublishButton();
  416. });
  417.  
  418. it('should add new product', function () {
  419. addProductPage.clickMulti();
  420. addProductPage.selectType(product.type);
  421. addProductPage.selectFirstCollection();
  422. addProductPage.fillTitle(productTitle);
  423. addProductPage.fillOptionTitle(0, 'Color');
  424. addProductPage.fillOptionValue(0, product.firstColor);
  425. addProductPage.fillOptionValue(0, product.secondColor);
  426. addProductPage.fillOptionTitle(1, 'Size');
  427. addProductPage.fillOptionValue(1, product.firstSize);
  428. addProductPage.fillOptionValue(1, product.secondSize);
  429.  
  430. addProductPage.fillVariantPrice(product.firstVariant ,product.price);
  431. addProductPage.clickVariantPriceAutofill(product.firstVariant);
  432.  
  433. addProductPage.clickPublish();
  434. commonHelper.waitUntilElementVisible(productListPage.productEntry(productTitle));
  435. });
  436.  
  437. it('should open new collection page', function () {
  438. dashboardPage.openAddCollectionPage();
  439. });
  440.  
  441. it('should fill title and description fields', function () {
  442. addCollectionPage.fillTitle(collectionTitle);
  443. addCollectionPage.fillDescription(firstCollectionDescription);
  444. });
  445.  
  446. it('should click auto add product radio button', function () {
  447. addCollectionPage.clickAddAuto();
  448. commonHelper.waitUntilElementVisible(addCollectionPage.sel2Type);
  449. });
  450.  
  451. it('should add condition', function () {
  452. addCollectionPage.selectConditionVariant(0, 'Variant option value');
  453. addCollectionPage.selectConditionRule(0, 'contains');
  454. addCollectionPage.fillConditionValue(0, product.secondColor);
  455. });
  456.  
  457. it('should add new collection', function () {
  458. addCollectionPage.clickPublish();
  459. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(collectionTitle));
  460. });
  461.  
  462. it('should show collection page after click on collection link', function () {
  463. collectionListPage.clickCollection(collectionTitle);
  464. commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
  465.  
  466. expect(collectionsPage.productTitle(productTitle).isDisplayed()).toBeTruthy();
  467. commonHelper.switchToPreviousTab();
  468. });
  469. });
  470. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement