Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. import { expect } from 'chai';
  2. import TestData from 'src/data/TestData';
  3. import AddNewCandidatePage from 'src/pages/AddNewCandidatePage';
  4. // import AddNewPage from 'src/pages/AddNewPage';
  5. import CandidateDetailsPage from 'src/pages/CandidateDetailsPage';
  6. import DashboardPage from 'src/pages/DashboardPage';
  7. import LoginPage from 'src/pages/LoginPage';
  8. import NavBarPage from 'src/pages/NavBarPage';
  9. import { config } from '../src/config/index';
  10. // import PrideExcel from '../src/utils/PrideExcel';
  11. import PrideJson from '../src/utils/PrideJson';
  12. import AddNewPage from 'src/pages/AddNewPage';
  13. import assert from 'assert';
  14.  
  15. const Q = require('q');
  16. const xlSx = require('node-xlsx');
  17.  
  18. const objWbInfo = PrideJson.readConfigValue('candidate');
  19.  
  20. const getExcelData = function(fileName) {
  21. const deferred = Q.defer();
  22. // turn into async call
  23. const xlsObject = xlSx.parse(fileName);
  24. deferred.resolve(xlsObject);
  25. return deferred.promise;
  26. };
  27.  
  28. //const objCandidate = PrideExcel.convertExcelToJson(objWbInfo);
  29. let objCandidate = TestData.TC_0002;
  30. //console.log('***********************CANDIDATE NAME INFO***********************');
  31. //const candidateFullName = `${objCandidate.firstName}' '${objCandidate.firstLastName} `;
  32. //console.log('**********************FINISHED EXECUTING BEFORE FUNCTION.********************************');
  33.  
  34. describe('Add new candidate page.', () => {
  35. LoginPage.open;
  36. it('Verify the presence of dashboard', () => {
  37. LoginPage.loginWithCredentials(config.username);
  38. expect(DashboardPage.pageTitle.getText()).to.equal('Dashboard');
  39.  
  40. });
  41.  
  42. it('Read data from excel and populate json object with candidate information', () => {
  43.  
  44. let loop = Q();
  45. return getExcelData(objWbInfo.fileName).then((data) => {
  46. data[0].data.forEach((d) => {
  47. loop = loop.then(() => {
  48.  
  49. if (parseInt(d[0]) === objWbInfo.nextKey) {
  50. objCandidate = AddNewCandidatePage.updateCandidateInfo(objCandidate, d);
  51. }
  52. // Read the row data (Column A or d[0] = first name, Column B or d[1] = last name)
  53. //return loopTest(driver, d[0], d[1]);
  54. });
  55. });
  56. // return last so mocha knows all records are finished.
  57. });
  58. });
  59.  
  60.  
  61. it('Add new Candidate', () => {
  62. NavBarPage.clickNew();
  63. AddNewPage.clickCandidate();
  64. AddNewCandidatePage.addNewCandidate(objCandidate);
  65. try {
  66. expect(CandidateDetailsPage.getCandidateFullName(objCandidate)).to.equal(`${objCandidate.firstName} ${objCandidate.lastName}`);
  67. PrideJson.writeConfigValue('candidate');
  68. } catch (err) {
  69. console.log(`Exception: ${err}`);
  70. assert.fail();
  71. }
  72. });
  73. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement