Advertisement
Guest User

add_collection/manual_add/common

a guest
Feb 13th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.49 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 - Manual Adding', function () {
  15.  
  16. var username = signInData.adminAccount.username;
  17. var password = signInData.adminAccount.password;
  18. var firstCollectionTitle = commonHelper.uniqueProductName('common1');
  19. var firstCollectionDescription = collectionData.collection.description.first;
  20. var titleError = collectionData.collection.error.title;
  21. var urlError = collectionData.collection.error.url;
  22. var firstImage = 'car.jpg';
  23. var secondImage = 'bike.png';
  24.  
  25. var addCollectionLink = signInData.link + '/collections/create';
  26.  
  27. var product = {
  28. firstTitle: commonHelper.uniqueProductName('common2'),
  29. type: productData.product.type,
  30. price: productData.product.price
  31. };
  32.  
  33. describe('add collection without products', function () {
  34.  
  35. var unique_value = commonHelper.uniqueValue();
  36. var title = firstCollectionTitle + unique_value;
  37.  
  38. beforeAll(function () {
  39. commonHelper.acceptAlert();
  40. browser.get(signInData.link);
  41. });
  42.  
  43. afterAll(function () {
  44. commonHelper.clearAllData();
  45. });
  46.  
  47. it('should redirect on dashboard page after login', function () {
  48. signInPage.login(username, password);
  49. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  50. });
  51.  
  52. it('should open new collection page', function () {
  53. browser.get(addCollectionLink);
  54. });
  55.  
  56. it('should add new collection', function () {
  57. addCollectionPage.fillTitle(title);
  58. addCollectionPage.fillDescription(firstCollectionDescription);
  59. addCollectionPage.uploadImage(firstImage);
  60. addCollectionPage.clickPublish();
  61. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(title));
  62. commonHelper.waitUntilElementVisible(collectionListPage.collectionImage(title));
  63. });
  64.  
  65. it('should show collection page after click on collection link', function () {
  66. collectionListPage.clickCollection(title);
  67.  
  68. expect(collectionsPage.txtTitle.isDisplayed()).toBeTruthy();
  69. });
  70.  
  71. it('should open edit page for added collection', function () {
  72. commonHelper.switchToPreviousTab();
  73. collectionListPage.editCollection(title);
  74. });
  75.  
  76. it('should show correct text value in fields', function () {
  77. addCollectionPage.waitForLblAuto();
  78. expect(addCollectionPage.titleValue()).toEqual(title);
  79. expect(addCollectionPage.descriptionValue()).toEqual(firstCollectionDescription);
  80. expect(addCollectionPage.seoValue()).toEqual(title);
  81. expect(addCollectionPage.urlValue()).toEqual(title.toLowerCase());
  82. expect(addCollectionPage.eleUploadList.isDisplayed()).toBeTruthy();
  83. });
  84. });
  85.  
  86. describe('title and url fields are required', function () {
  87.  
  88. var unique_value = commonHelper.uniqueValue();
  89. var title = firstCollectionTitle + unique_value;
  90.  
  91. beforeAll(function () {
  92. commonHelper.acceptAlert();
  93. browser.get(signInData.link);
  94. });
  95.  
  96. afterAll(function () {
  97. commonHelper.clearAllData();
  98. });
  99.  
  100. it('should redirect on dashboard page after login', function () {
  101. signInPage.login(username, password);
  102. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  103. });
  104.  
  105. it('should open new collection page', function () {
  106. browser.get(addCollectionLink);
  107. });
  108.  
  109. it('should fill collection title field', function () {
  110. addCollectionPage.fillTitle(title);
  111. addCollectionPage.fillDescription(firstCollectionDescription);
  112. });
  113.  
  114. it('should remove text from collection title field', function () {
  115. addCollectionPage.txtTitle.clear();
  116. });
  117.  
  118. it('should click publish button', function () {
  119. addCollectionPage.clickPublish();
  120. commonHelper.waitUntilElementVisible(addCollectionPage.txtErrorMessage.txtTitle)
  121. });
  122.  
  123. it('should show error message for title field', function () {
  124. expect(addCollectionPage.titleError()).toEqual(titleError);
  125. });
  126.  
  127. it('should clear collection url field', function () {
  128. addCollectionPage.fillTitle(title);
  129. addCollectionPage.txtUrl.clear();
  130. });
  131.  
  132. it('should click publish button', function () {
  133. addCollectionPage.clickPublish();
  134. commonHelper.waitUntilElementVisible(addCollectionPage.txtErrorMessage.txtUrl)
  135. });
  136.  
  137. it('should show error message for url field', function () {
  138. expect(addCollectionPage.urlError()).toEqual(urlError);
  139. });
  140.  
  141. it('should fill collection url field', function () {
  142. addCollectionPage.fillUrl(title);
  143. });
  144.  
  145. it('should add new collection', function () {
  146. addCollectionPage.clickPublish();
  147. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(title));
  148. });
  149.  
  150. it('should show collection page after click on collection link', function () {
  151. collectionListPage.clickCollection(title);
  152. commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
  153.  
  154. expect(browser.getCurrentUrl()).toContain(title);
  155. commonHelper.switchToPreviousTab();
  156. });
  157. });
  158.  
  159. describe('should not be able to remove title and url from collection and save it', function () {
  160.  
  161. var unique_value = commonHelper.uniqueValue();
  162. var title = firstCollectionTitle + unique_value;
  163.  
  164. beforeAll(function () {
  165. commonHelper.acceptAlert();
  166. browser.get(signInData.link);
  167. });
  168.  
  169. afterAll(function () {
  170. commonHelper.clearAllData();
  171. });
  172.  
  173. it('should redirect on dashboard page after login', function () {
  174. signInPage.login(username, password);
  175. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  176. });
  177.  
  178. it('should open new collection page', function () {
  179. browser.get(addCollectionLink);
  180. });
  181.  
  182. it('should add new collection', function () {
  183. addCollectionPage.fillTitle(title);
  184. addCollectionPage.fillDescription(firstCollectionDescription);
  185. addCollectionPage.clickPublish();
  186. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(title));
  187. });
  188.  
  189. it('should open edit page for added collection', function () {
  190. collectionListPage.editCollection(title);
  191. });
  192.  
  193. it('should remove text from collection title field', function () {
  194. addCollectionPage.waitForLblAuto();
  195. commonHelper.moveMouseOver(addCollectionPage.txtTitle);
  196. commonHelper.waitUntilElementVisible(addCollectionPage.txtTitle);
  197. addCollectionPage.txtTitle.clear();
  198. });
  199.  
  200. it('should click publish button', function () {
  201. addCollectionPage.clickPublish();
  202. commonHelper.waitUntilElementVisible(addCollectionPage.txtErrorMessage.txtTitle)
  203. });
  204.  
  205. it('should show error message for title field', function () {
  206. expect(addCollectionPage.titleError()).toEqual(titleError);
  207. });
  208.  
  209. it('should clear collection url field', function () {
  210. addCollectionPage.fillTitle(title);
  211. addCollectionPage.txtUrl.clear();
  212. });
  213.  
  214. it('should click publish button', function () {
  215. addCollectionPage.clickPublish();
  216. commonHelper.waitUntilElementVisible(addCollectionPage.txtErrorMessage.txtUrl)
  217. });
  218.  
  219. it('should show error message for url field', function () {
  220. expect(addCollectionPage.urlError()).toEqual(urlError);
  221. });
  222.  
  223. it('should fill collection url field', function () {
  224. addCollectionPage.fillUrl(title);
  225. });
  226.  
  227. it('should add new collection', function () {
  228. addCollectionPage.clickPublish();
  229. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(title));
  230.  
  231. expect(collectionListPage.collectionName(title).isDisplayed()).toBeTruthy();
  232. });
  233.  
  234. it('should show collection page after click on collection link', function () {
  235. collectionListPage.clickCollection(title);
  236. commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
  237.  
  238. expect(browser.getCurrentUrl()).toContain(title);
  239. commonHelper.switchToPreviousTab();
  240. });
  241. });
  242.  
  243. describe('set only one image', function () {
  244.  
  245. var unique_value = commonHelper.uniqueValue();
  246. var title = firstCollectionTitle + unique_value;
  247.  
  248. var firstImageSource;
  249. var secondImageSource;
  250.  
  251. var firstThumbnailSource;
  252. var secondThumbnailSource;
  253.  
  254. beforeAll(function () {
  255. commonHelper.acceptAlert();
  256. browser.get(signInData.link);
  257. });
  258.  
  259. afterAll(function () {
  260. commonHelper.clearAllData();
  261. });
  262.  
  263. it('should redirect on dashboard page after login', function () {
  264. signInPage.login(username, password);
  265. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  266. });
  267.  
  268. it('should open new collection page', function () {
  269. browser.get(addCollectionLink);
  270. });
  271.  
  272. it('should add new collection', function () {
  273. addCollectionPage.fillTitle(title);
  274. addCollectionPage.fillDescription(firstCollectionDescription);
  275. addCollectionPage.uploadImage(firstImage);
  276. addCollectionPage.waitForUploading();
  277.  
  278. addCollectionPage.eleCollectionImage.getAttribute('style').then(function (value) {
  279. firstImageSource = value;
  280. });
  281.  
  282. addCollectionPage.clickPublish();
  283. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(title));
  284. commonHelper.waitUntilElementVisible(collectionListPage.collectionImage(title));
  285.  
  286. expect(collectionListPage.collectionName(title).isDisplayed()).toBeTruthy();
  287. });
  288.  
  289. it('should save thumbnail source', function () {
  290. collectionListPage.collectionImage(title).getAttribute('style').then(function (value) {
  291. firstThumbnailSource = value;
  292. });
  293. });
  294.  
  295. it('should open edit page for added collection', function () {
  296. collectionListPage.editCollection(title);
  297. });
  298.  
  299. it('should add collection image', function () {
  300. addCollectionPage.waitForLblAuto();
  301. addCollectionPage.uploadImage(secondImage);
  302. addCollectionPage.waitForUploading();
  303. });
  304.  
  305. it('should save source link', function () {
  306. addCollectionPage.eleCollectionImage.getAttribute('src').then(function (value) {
  307. secondImageSource = value;
  308. });
  309. });
  310.  
  311. it('should save collection', function () {
  312. addCollectionPage.clickPublish();
  313. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(title));
  314. commonHelper.waitUntilElementVisible(collectionListPage.collectionImage(title));
  315. });
  316.  
  317. it('should save thumbnail source', function () {
  318. collectionListPage.collectionImage(title).getAttribute('src').then(function (value) {
  319. secondThumbnailSource = value;
  320. });
  321. });
  322.  
  323. it('should add second image for collection', function () {
  324. expect(firstImageSource).not.toEqual(secondImageSource);
  325. expect(firstThumbnailSource).not.toEqual(secondThumbnailSource);
  326. });
  327. });
  328.  
  329. describe('add product manually', function () {
  330.  
  331. var unique_value = commonHelper.uniqueValue();
  332. var collectionTitle = firstCollectionTitle + unique_value;
  333. var productTitle = product.firstTitle + unique_value;
  334.  
  335. beforeAll(function () {
  336. commonHelper.acceptAlert();
  337. browser.get(signInData.link);
  338. });
  339.  
  340. afterAll(function () {
  341. commonHelper.clearAllData();
  342. });
  343.  
  344. it('should redirect on dashboard page after login', function () {
  345. signInPage.login(username, password);
  346. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  347. });
  348.  
  349. it('should redirect on add product page', function () {
  350. browser.get(productData.addLink);
  351. addProductPage.waitForPublishButton();
  352. });
  353.  
  354. it('should add new product', function () {
  355. addProductPage.selectType(product.type);
  356. addProductPage.selectFirstCollection();
  357. addProductPage.fillTitle(productTitle);
  358. addProductPage.fillPrice(product.price);
  359. addProductPage.clickPublish();
  360. commonHelper.waitUntilElementVisible(productListPage.productEntry(productTitle));
  361. });
  362.  
  363. it('should open new collection page', function () {
  364. browser.get(addCollectionLink);
  365. });
  366.  
  367. it('should fill title and description fields', function () {
  368. addCollectionPage.fillTitle(collectionTitle);
  369. addCollectionPage.fillDescription(firstCollectionDescription);
  370. });
  371.  
  372. it('should add manual product', function () {
  373. addCollectionPage.clickAddProducts();
  374. addCollectionPage.clickProduct(productTitle);
  375. addCollectionPage.clickCloseProducts();
  376. });
  377.  
  378. it('should add new collection', function () {
  379. addCollectionPage.clickPublish();
  380. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(collectionTitle));
  381. });
  382.  
  383. it('should show collection page after click on collection link', function () {
  384. collectionListPage.clickCollection(collectionTitle);
  385. commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
  386.  
  387. expect(collectionsPage.productTitle(productTitle).isDisplayed()).toBeTruthy();
  388. commonHelper.switchToPreviousTab();
  389. });
  390. });
  391.  
  392. describe('collection save as draft', function () {
  393.  
  394. var unique_value = commonHelper.uniqueValue();
  395. var title = firstCollectionTitle + unique_value;
  396.  
  397. beforeAll(function () {
  398. commonHelper.acceptAlert();
  399. browser.get(signInData.link);
  400. });
  401.  
  402. afterAll(function () {
  403. commonHelper.clearAllData();
  404. });
  405.  
  406. it('should redirect on dashboard page after login', function () {
  407. signInPage.login(username, password);
  408. commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
  409. });
  410.  
  411. it('should open new collection page', function () {
  412. browser.get(addCollectionLink);
  413. });
  414.  
  415. it('should add new collection', function () {
  416. addCollectionPage.fillTitle(title);
  417. addCollectionPage.fillDescription(firstCollectionDescription);
  418. addCollectionPage.uploadImage(firstImage);
  419. addCollectionPage.clickDraft();
  420. commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(title));
  421. commonHelper.waitUntilElementVisible(collectionListPage.collectionImage(title));
  422. });
  423.  
  424. it('should show collection page after click on collection link', function () {
  425. collectionListPage.clickCollection(title);
  426.  
  427. expect(collectionsPage.txtTitle.isPresent()).toBeFalsy();
  428. });
  429.  
  430. it('should show publish button', function () {
  431. commonHelper.switchToPreviousTab();
  432.  
  433. expect(collectionListPage.btnPublishAction(title, 'Publish').isDisplayed()).toBeTruthy();
  434. });
  435.  
  436. it('should open edit page for added collection', function () {
  437. collectionListPage.editCollection(title);
  438. });
  439.  
  440. it('should show correct text value in fields', function () {
  441. addCollectionPage.waitForLblAuto();
  442. expect(addCollectionPage.titleValue()).toEqual(title);
  443. expect(addCollectionPage.descriptionValue()).toEqual(firstCollectionDescription);
  444. expect(addCollectionPage.seoValue()).toEqual(title);
  445. expect(addCollectionPage.urlValue()).toEqual(title.toLowerCase());
  446. expect(addCollectionPage.eleUploadList.isDisplayed()).toBeTruthy();
  447. });
  448. });
  449. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement