From 80e13f94e4a51030179ce03ecff4b270f124349a Mon Sep 17 00:00:00 2001 From: jhuerta Date: Thu, 29 Oct 2026 15:13:49 -0700 Subject: [PATCH] Started Report Build Your Report script --- index.js | 11 +- results/reportBuildYourReportPageResults.xlsx | Bin 0 -> 18533 bytes tests/Report/reportBuildYourReportPage.js | 681 ++++++++++++++++++ 3 files changed, 691 insertions(+), 1 deletion(-) create mode 100644 results/reportBuildYourReportPageResults.xlsx create mode 100644 tests/Report/reportBuildYourReportPage.js diff --git a/index.js b/index.js index d0e8220..59a9479 100644 --- a/index.js +++ b/index.js @@ -33,7 +33,10 @@ import uploadImportAlignmentsPage from './tests/Upload/uploadImportAlignmentsPag //ACTIVITY REPORT import activityReportPage from './tests/ActivityReport/ActivityReportPage.js'; -//APPROVV +//REPORT +import reportBuildYourReportPage from './tests/Report/reportBuildYourReportPage.js'; + +//APPROVE import approvePage from './tests/Approve/approvePage.js'; //Content @@ -85,6 +88,9 @@ app.get('/', (req, res) => {

ACTIVITY REPORT

Activity Report Page
+

REPORT

+
Report Page
+

APPROVE

Approve Page
@@ -136,6 +142,9 @@ app.get('/uploadImportAlignmentsPage', uploadImportAlignmentsPage); //ACTIVITY REPORT app.get('/activityReportPage', activityReportPage); +//ACTIVITY REPORT +app.get('/reportBuildYourReportPage', reportBuildYourReportPage); + //APPROVE app.get('/approvePage', approvePage); diff --git a/results/reportBuildYourReportPageResults.xlsx b/results/reportBuildYourReportPageResults.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..50ae86f9365cefd8be9277d30be85415005a6b04 GIT binary patch literal 18533 zcmeHP-HUA5Rqrtqkuf0-Q3!%?DA1RryFR+AyQ}Q3&{f?%cjn%{x9P6AnM{zl>zrLx z=l1!Ub52!vB?^;?$lzeWIEp?9J}41H9Y`cY7#{@x0tx0VFY^&J%Dng@i1=H3pRavt zSAU~Kr!RGDpMBO^d#$zCT6^uUI=cU{r+ z%z0G#eD{;jY#(!n#XyQCb`Tk$;zc`^NgM~AYBe$^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cu50tx^kfe7q{RdPjWsh$mm5FxGEybZXdYmVLUX~{TUnY!rrIY^xoOp=>P``{b@k-as1vr6K)>_d`=&fE0 z*qwuKD_vSd)Yx$nBPjjNf1Tm8i6cJ3Z$*SQ4wlo{CX@7PIrF(zYbCEyruK>Bl9OJc zeL1iff5qYM7@^Eg(7%Kaahjp{BM!G=K@hv7!TfB?^*Z@twTlBY7qy%vt7$TEz1C9` zD@``8)FP}`+tR}O)sBIW{ny1{lX^nxWiz+D#RWYa|i+BoCgXO>Kf>fgLxBNF= z%5=& { + res.send('

ExACT Automated Test Script: Report - Build Your Report Page(reportBuildYourReportPage); Initiated

'); + (async function example() { + let driver = await new Builder() + .forBrowser('chrome') + .setChromeOptions( + new ChromeOptions() + .addArguments('--disable-features=MediaRouter') + .addArguments('--disable-extensions') + .addArguments('--disable-background-networking') + .addArguments('--log-level=3') + ) + .build(); + let testStatus = 'Failed'; + let workbook; + let worksheet; + const startTime = new Date().toISOString(); + +const steps = [ + { description: 'Navigate to ExACT Landing Page', action: async () => await driver.navigate().to('https://correlation.edgate.com/exact/login.php') }, + { description: 'Expand browser', action: async () => await driver.manage().window().maximize() }, + + //Login + { + description: 'Login', + action: async () => { + const multipleChecks = 'Log In'; + + console.log('------------->| REPORT - BUILD YOUR REPORT PAGE |<-------------'); + const errors = []; + + await driver.findElement(By.css('.form-control:nth-child(2)')).sendKeys('exact_juan'); + await driver.findElement(By.css('.passfield')).sendKeys('Edgate1!'); + await driver.findElement(By.css('.login')).click(); + console.log('----->| NEXT ACTION: Entered credentials and logged in'); + + //Wait for page readyState + await driver.wait(async () => { + const readyState = await driver.executeScript('return document.readyState'); + return readyState === 'complete'; + }, 30000, 'ExACT Dashboard did not fully load within 30 seconds'); + + //Wait for the dashboard container to exist in DOM + await driver.wait( + until.elementLocated(By.css('.gap-idle-wrap > img')), + 30000, + 'Dashboard image did not appear within 30 seconds' + ); + + //Wait for it to be: visible + await driver.wait(async () => { + try { + const img = await driver.findElement(By.css('.gap-idle-wrap > img')); + return await img.isDisplayed(); + } catch (e) { + return false; + } + }, 30000, 'Dashboard image did not become visible within 30 seconds'); + + //Wait for any loading spinners to disappear + await driver.wait(async () => { + try { + const spinners = await driver.findElements(By.css('.spinner-border')); + for (const spinner of spinners) { + if (await spinner.isDisplayed()) return false; + } + return true; + } catch (e) { + return true; + } + }, 30000, 'Loading spinners did not disappear within 30 seconds'); + + //Wait for the slowest resource to complete + await driver.wait(async () => { + const completed = await driver.executeScript(` + const entries = performance.getEntriesByType('resource'); + return entries.some(entry => + entry.name.includes('content_sets.php') && + entry.responseEnd > 0 + ); + `); + return completed; + }, 30000, 'My Content widget (content_sets.php) did not complete loading within 30 seconds'); + console.log('Passed: My Content widget (content_sets.php) loaded successfully - Dashboard fully loaded'); + + //Final sleep to allow any remaining dynamic content to settle + await driver.sleep(2000); + + console.log('Passed: ExACT Dashboard loaded successfully'); + + if (errors.length > 0) { + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + throw new Error(errors.join('\n')); + } + } + }, + + //Dashboard title + { + description: 'Dashboard title text, size, and color', + action: async () => { + const multipleChecks = 'Dashboard title'; + + const element = await driver.findElement(By.css('.e-heading')); + + //Get text, font, size, and color + const elementText = await element.getText(); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + + //Track all errors + const errors = []; + + //text + if (elementText === 'Correlation Dashboard') { + console.log('Passed: Dashboard title text matched as expected'); + } else { + errors.push(`Expected: "Correlation Dashboard"; Actual: "${elementText}"`); + } + + //font + if (elementFont === `"DM Serif Display", serif`) { + console.log('Passed: Dashboard title font-family matched as expected'); + } else { + errors.push(`Expected: Dashboard title font-family "DM Serif Display, serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '32px') { + console.log('Passed: Dashboard title text font-size matched as expected'); + } else { + errors.push(`Expected: Dashboard title text font-size "32px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Dashboard title text color matched as expected'); + } else { + errors.push(`Expected: Dashboard title text color: "rgba(40, 39, 90, 1)"; Actual: "${elementColor}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + //NEXT ACTION + { + description: 'Click Report navigation link', + action: async () => { + await driver.findElement(By.linkText('Report')).click(); + console.log('----->| NEXT ACTION: Clicked Report navigation link'); + + //Wait for page readyState + await driver.wait(async () => { + const readyState = await driver.executeScript('return document.readyState'); + return readyState === 'complete'; + }, 30000, 'Report page did not fully load within 30 seconds'); + + //Wait until the element exists in the DOM + const reportPageTitle = await driver.wait( + until.elementLocated(By.css('h2')), + 30000 + ); + + //Wait until it becomes visible + await driver.wait( + until.elementIsVisible(reportPageTitle), + 30000 + ); + } + }, + + //Report page title + { + description: 'Report page title text, size, and color', + action: async () => { + const multipleChecks = 'Report page title'; + + const element = await driver.findElement(By.css('h2')); + + //Get text, font, size, and color + const elementText = await element.getText(); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + + //Track all errors + const errors = []; + + //text + if (elementText === 'Report') { + console.log('Passed: Report page title text matched as expected'); + } else { + errors.push(`Expected: "Report"; Actual: "${elementText}"`); + } + + //font + if (elementFont === `"DM Serif Display", serif`) { + console.log('Passed: Report page title font-family matched as expected'); + } else { + errors.push(`Expected: Report page title font-family "DM Serif Display, serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '32px') { + console.log('Passed: Report page title text font-size matched as expected'); + } else { + errors.push(`Expected: Report page title text font-size "32px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Report page title text color matched as expected'); + } else { + errors.push(`Expected: Report page title text color: "rgba(40, 39, 90, 1)"; Actual: "${elementColor}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + //Build your report tab + { + description: 'Build your report tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Build your report tab title'; + + const element = await driver.findElement(By.linkText('Build your report')); + + //Get text, font, size, color, and background color + const elementText = await element.getText(); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + const elementBgColor = await element.getCssValue('background-color'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Build your report') { + console.log('Passed: Build your report tab title text matched as expected'); + } else { + errors.push(`Expected: "Build your report"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Build your report tab title font-family matched as expected'); + } else { + errors.push(`Expected: Build your report tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Build your report tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Build your report tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(255, 255, 255, 1)') { + console.log('Passed: Build your report tab title text color matched as expected'); + } else { + errors.push(`Expected: Build your report tab title text color: "rgba(255, 255, 255, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Build your report tab title background color matched as expected'); + } else { + errors.push(`Expected: Build your report tab title background color: "rgba(40, 39, 90, 1)"; Actual: "${elementBgColor}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + //View queued reports tab + { + description: 'View queued reports tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'View queued reports tab title'; + + const element = await driver.findElement(By.linkText('View queued reports')); + + //Get text, font, size, color, and background color + const elementText = await element.getText(); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + const elementBgColor = await element.getCssValue('background-color'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'View queued reports') { + console.log('Passed: View queued reports tab title text matched as expected'); + } else { + errors.push(`Expected: "View queued reports"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: View queued reports tab title font-family matched as expected'); + } else { + errors.push(`Expected: View queued reports tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: View queued reports tab title text font-size matched as expected'); + } else { + errors.push(`Expected: View queued reports tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: View queued reports tab title text color matched as expected'); + } else { + errors.push(`Expected: View queued reports tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: View queued reports tab title background color matched as expected'); + } else { + errors.push(`Expected: View queued reports tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + //Specialty Reports tab + { + description: 'Specialty Reports tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Specialty Reports tab title'; + + const element = await driver.findElement(By.linkText('Specialty Reports')); + + //Get text, font, size, color, and background color + const elementText = await element.getText(); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + const elementBgColor = await element.getCssValue('background-color'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Specialty Reports') { + console.log('Passed: Specialty Reports tab title text matched as expected'); + } else { + errors.push(`Expected: "Specialty Reports"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Specialty Reports tab title font-family matched as expected'); + } else { + errors.push(`Expected: Specialty Reports tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Specialty Reports tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Specialty Reports tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Specialty Reports tab title text color matched as expected'); + } else { + errors.push(`Expected: Specialty Reports tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Specialty Reports tab title background color matched as expected'); + } else { + errors.push(`Expected: Specialty Reports tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + + + + + + + + + + + + + + + + + + + + + + + + + + + //FOOTER + //EdGate Copyright Logo + { + description: 'EdGate Copyright Logo', + action: async () => { + const multipleChecks = 'EdGate Copyright Logo'; + + const element = await driver.findElement(By.css('footer .pull-right > a')); + const elementLogo = await element.findElement(By.css('img')); + const expectedHref = 'https://www.edgate.com/'; + + //Track all errors + const errors = []; + + //icon present + if (await elementLogo.isDisplayed()) { + console.log('Passed: EdGate Copyright Logo was displayed as expected'); + } else { + errors.push('Expected: EdGate Copyright Logo was not displayed'); + } + + //href - browser resolves the link with a trailing slash, so remove it before comparing + const actualHref = await element.getAttribute('href'); + if (actualHref && actualHref === expectedHref) { + console.log('Passed: EdGate Copyright Logo href matched as expected'); + } else { + errors.push(`Expected: EdGate Copyright Logo href to be: "https://www.edgate.com/"; actual: "${actualHref}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + //NEXT ACTION + { + description: 'Log Out', + action: async () => { + const multipleChecks = 'Log Out'; + + //Track all errors + const errors = []; + + await driver.findElement(By.css('#navbarDropdown > span')).click(); + await driver.sleep(2000); + await driver.findElement(By.linkText('Log Out')).click(); + console.log('----->| NEXT ACTION: Clicked User Profile and Logged Out'); + + //Wait until the element exists in the DOM + const exactLogo = await driver.wait( + until.elementLocated(By.css('.logo')), + 30000 + ); + + //Wait until it becomes visible + await driver.wait( + until.elementIsVisible(exactLogo), + 30000 + ); + + //Wait for page to load completely + await driver.wait(async () => { + const readyState = await driver.executeScript('return document.readyState'); + return readyState === 'complete'; + }, 30000, 'ExACT Langing page did not fully load within 30 seconds'); + console.log('Passed: ExACT Landing Page loaded successfully'); + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, +]; + +const logStep = (worksheet, stepDescription, status, stepIndex, timestamp, screenshotPath) => { + const json_data = XLSX.utils.sheet_to_json(worksheet, { header: 1 }); + json_data.push([stepIndex, stepDescription, status, timestamp, screenshotPath]); + return XLSX.utils.aoa_to_sheet(json_data); +}; + +const takeScreenshot = async (driver, stepIndex, stepDescription) => { + const screenshot = await driver.takeScreenshot(); + + const dir = path.join('screenshots', 'reportBuildYourReportPage'); + + const screenshotFileName = `step_${stepIndex}_${stepDescription.replace(/\s+/g, '_')}.png`; + const screenshotPath = path.join(dir, screenshotFileName); + fs.writeFileSync(screenshotPath, screenshot, 'base64'); + return screenshotPath; +}; + +const resultsFile = path.join('results', 'reportBuildYourReportPageResults.xlsx'); + +const clearOldResults = () => { + //Remove old screenshots + const screenshotDir = path.join('screenshots', 'reportBuildYourReportPage'); + if (fs.existsSync(screenshotDir)) { + fs.rmSync(screenshotDir, { recursive: true, force: true }); + } + fs.mkdirSync(screenshotDir, { recursive: true }); + + //Remove old Excel file + if (fs.existsSync(resultsFile)) { + fs.unlinkSync(resultsFile); + } + fs.mkdirSync('results', { recursive: true }); +}; + +try { + //Initialize workbook and worksheet + clearOldResults(); + + //Initialize workbook and worksheet + workbook = XLSX.utils.book_new(); + worksheet = XLSX.utils.aoa_to_sheet([ + ['Step Number', 'Step Description', 'Status', 'Timestamp', 'Screenshot'] + ]); + XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1'); + + //Log test start time + worksheet = logStep(worksheet, 'Test Start', 'Started', '', startTime, ''); + + let allStepsPassed = true; + + const failedSteps = []; //Track failed steps + + for (const step of steps) { + const stepIndex = steps.indexOf(step) + 1; + const timestamp = new Date().toISOString(); + + try { + //Screenshot of failed step + await step.action(); + + //Log a successful step with no screenshot + worksheet = logStep( + worksheet, + step.description, + 'Passed', + stepIndex, + timestamp, + null //No screenshot for passed steps + ); + + } catch (error) { + //Only take screenshot if the step fails + const screenshotPath = await takeScreenshot( + driver, + stepIndex, + `${step.description}_Failed` + ); + + worksheet = logStep( + worksheet, + step.description, + 'Failed', + stepIndex, + timestamp, + screenshotPath + ); + + console.error(`Step ${stepIndex} FAILED: ${error.message}`); + failedSteps.push(`Step ${stepIndex}: ${step.description} - ${error.message}`); //Track failed step + testStatus = 'Failed'; + allStepsPassed = false; + } + } + + if (allStepsPassed) { + console.log('------------->| THE END |<-------------'); + console.log('PASSED: Report - Build Your Report Page(reportBuildYourReportPage); All test steps completed successfully'); + testStatus = 'Passed'; + } else { + console.log('------------->| THE END |<-------------'); + console.log('FAILED: Report Build Your Report Page(reportBuildYourReportPage); One or more test steps failed'); + console.log('FAILED STEPS:'); + failedSteps.forEach(step => console.error(` ✗ ${step}`)); + testStatus = 'Failed'; + } + + //Log test end time + const endTime = new Date().toISOString(); + worksheet = logStep(worksheet, 'Test End', testStatus, '', endTime, ''); + + //Write the updated worksheet back to the workbook and save it + workbook.Sheets['Sheet1'] = worksheet; + XLSX.writeFile(workbook, resultsFile); +} finally { + await driver.quit(); +} + })(); +} + +export default reportBuildYourReportPage;