Advertisement
Guest User

by_title.spec.js

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