From 65b280fdadc33f5384d9c912897e7c6cbb09c0a1 Mon Sep 17 00:00:00 2001 From: jhuerta Date: Thu, 10 Oct 2024 21:08:50 -0700 Subject: [PATCH] Started Dashboard My Content script --- dashboardMyContentResults.xlsx | Bin 0 -> 23391 bytes tests/ExACT_dashboardMyContent.js | 343 ++++++++++++++++++++++++++++++ 2 files changed, 343 insertions(+) create mode 100644 dashboardMyContentResults.xlsx create mode 100644 tests/ExACT_dashboardMyContent.js diff --git a/dashboardMyContentResults.xlsx b/dashboardMyContentResults.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..2a285970825e3300e92c4fa0cd61dcae325ac721 GIT binary patch literal 23391 zcmeHP-ES;MR(II2LP4t~T98&qh}KB(z{;NKneoRMdsgsQzjhf;3R$#mSXt(yt+0p7&&4?4`+sq4m zXSa6c#I-MWKl9wq1IJ?tnBuV;#s;ML@osILB;j_w9$RB)!s4|cbbP!S2GN8i_!^Ds zA+yfe$f-9Qjg2}qC}h;Sl1$@8d$$(7Xqz?T>?%af*UJuuL)UT+0&6;P{6td)w?7^` zP6DAU8ac^sjUeGgah-pdgiWokSEhNJ$|L~EDHP#f>-_&qb!gqD4smkjp+$2v#P?+o zv~RU~YKvnhVKz%xp~WOE$@Hj8&elDVoW1ec$LIg_Q!6X<_c`J0DwI#|tWYMW@tx9Ek&6gKgXA zCVj+LanFm48S~(~u5SkyXU--3*<*2n7rV6v|3@BN&zZbr0dI-#i2qCZQU?3H$?J?p zgS=AnsNLB-$mMeaFPW!1JUr|jnz=kqz$^=v3SG)F+ecgGekQX-Bp&Bw_ZsVswoG4= z-0*Cy;y5FLSl2q{MU zMuH$bWEQ-*$0mcwWmEy%c3A0+D6-rAxmPs!~9X1@%!KY?SK8lH;jMz&bPk*_V4QH5!#B1KK%2y zKKR?;(G#Kv6@(xC-aFs>?mHj-{%`&BpT4aj-;3CwOn&B0oY=VUTo@0632fuQ$eKHY z=w=*eW9CX6Yz)~N(TB-cBD{aaJRRM>BZK!aLh#TLzA$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j-I0|;4QMze0G z&9g_%LkGYd{7M=(4-5}PvvHG#K*nPsHpRu^@}l}W>d&;~Or<5$z$n)0(V*;$y>2T$oZA^_)SW$5S(b&YKo5B%OFI_kw= zWkHf|ep29m>CyB5aSyjd(ch0EMv7~qen75xi=BmYgEHlc;u`-NV*N=7al|Kig%1(#8MG?y+OOjj{h35hrZ@iH!w@P)<} z#5Y2wyOaKo2Im_Q*2Qg$XuFz`LPFN;)(`-*h)}1u7{WDt1G-UeA>Yim*Cz3*bBT;= zjd%GqFtF%qZNhMc(VTmg+_FB>?I zme(*rp5%Rji_x1fn1l*MxZMNSPExs^17|h098|977`a0&2bJqNoQa;}a+Tibc`g?6 z&>KC^qfl?lqtIDo41Xm%l|XC>PqF|2lrPeZztUB+geSCB)XLq2-s(}nxpegHn|N6o zBPjhX?j`*~+7VyIEvb=8fseRgUsgqWyUkvQ!`%7<65z6ei z{A={!zvC%iU-~pEaADU}Sp2H%W{tcYcK%bbWi{u?YL-mgtoF>sl*vY=8sYXlzkV8I zHJR { + res.send('

ExACT Automated Test Script - Dashboard - My Content: Initiated

'); + (async function example() { + let driver = await new Builder().forBrowser('chrome').build(); + let testStatus = 'Failed'; + let workbook; + let worksheet; + const startTime = new Date().toISOString(); + +//Page title +const expectedDashboardTitle = 'Correlation Dashboard'; + const expectedDashboardTitleColor = 'rgba(40, 39, 90, 1)'; //navy blue + const expectedDashboardTitleFont = '32px'; +//My Content widget +const expectedMyContentWidgetTitle = 'My Content'; + const expectedWidgetTitleColor = 'rgba(40, 39, 90, 1)'; //navy blue + const expectedWidgetTitleFont = '18px'; +//Ellipsis +const expectedEllipsisIconColor = 'rgba(40, 39, 90, 1)'; //navy blue + //Create Content + const expectedCreateContentSetIconColor = 'rgba(33, 37, 41, 1)'; //navy blue (different?) + const expectedCreateContentSetLinkText = 'Create Content Set'; + const expectedCreateContentSetLinkTextColor = 'rgba(33, 37, 41, 1)'; //navy blue (different?) + //Export Content + const expectedExportContentSetIconColor = 'rgba(33, 37, 41, 1)'; //navy blue (different?) + const expectedExportContentSetLinkText = 'Export Content Set'; + const expectedExportContentSetLinkTextColor = 'rgba(33, 37, 41, 1)'; //navy blue (different?) +//Filter +const expectedSearchIconColor = 'rgba(40, 39, 90, 1)'; //navy blue +const expectedFilterPlaceholder = 'filter...'; +//Sort +const expectedSortLabel = 'Sort:'; +const expectedSortDropDown = 'count'; + +const steps = [ + { description: 'Navigate to ExACT Landing Page', action: async () => await driver.navigate().to('https://stage.edgate.com/exact/login.php') }, //PROD - https://correlation.edgate.com/exact/login.php + { description: 'Expand browser', action: async () => await driver.manage().window().maximize() }, + + //Login + { description: 'Enter username', action: async () => await driver.findElement(By.css('.form-control:nth-child(2)')).sendKeys('exact_juan') }, + { description: 'Enter password', action: async () => await driver.findElement(By.css('.passfield')).sendKeys('Edgate1!') }, + { description: 'Click Login button', action: async () => await driver.findElement(By.css('.login')).click() }, + { description: 'Wait for login process to complete', action: async () => await driver.sleep(10000) }, + + //Dashboard title + { + description: 'Validate dashboard title', + action: async () => { + const elementText = await driver.findElement(By.css('.e-heading')).getText(); + if (elementText !== expectedDashboardTitle) { + throw new Error(`Expected: "${expectedWelcomeBackText}"; Actual: "${elementText}"`); + } + console.log('Passed: Dashboard title matched as expected'); + } + }, + + //Dashboard title text color + { + description: 'Validate dashboard title text color', + action: async () => { + const elementStyle = await driver.findElement(By.css('.e-heading')).getCssValue('color'); + if (elementStyle !== expectedDashboardTitleColor) { + throw new Error(`Expected: "${expectedDashboardTitleColor}"; Actual: "${elementStyle}"`); + } + console.log('Passed: Dashboard title text color matched as expected'); + } + }, + + //Dashboard title text font + { + description: 'Validate dashboard title text font size', + action: async () => { + const elementStyle = await driver.findElement(By.css('.e-heading')).getCssValue('font-size'); + if (elementStyle !== expectedDashboardTitleFont) { + throw new Error(`Expected: "${expectedDashboardTitleFont}"; Actual: "${elementStyle}"`); + } + console.log('Passed: Dashboard title text font-size matched as expected'); + } + }, + + //Widget title + { + description: 'Validate widget title', + action: async () => { + const elementText = await driver.findElement(By.css('.h-100 h2:nth-child(2)')).getText(); + if (elementText !== expectedMyContentWidgetTitle) { + throw new Error(`Expected: "${expectedMyContentWidgetTitle}"; Actual: "${elementText}"`); + } + console.log('Passed: Widget title matched as expected'); + } + }, + + //Widget title text color + { + description: 'Validate widget title text color', + action: async () => { + const elementStyle = await driver.findElement(By.css('.h-100 h2:nth-child(2)')).getCssValue('color'); + if (elementStyle !== expectedWidgetTitleColor) { + throw new Error(`Expected: "${expectedWidgetTitleColor}"; Actual: "${elementStyle}"`); + } + console.log('Passed: Widget title text color matched as expected'); + } + }, + + //Widget title text font + { + description: 'Validate widget title text font size', + action: async () => { + const elementStyle = await driver.findElement(By.css('.h-100 h2:nth-child(2)')).getCssValue('font-size'); + if (elementStyle !== expectedWidgetTitleFont) { + throw new Error(`Expected: "${expectedWidgetTitleFont}"; Actual: "${elementStyle}"`); + } + console.log('Passed: Widget title text font-size matched as expected'); + } + }, + + //Ellipsis icon color + { + description: 'Validate ellipsis icon color', + action: async () => { + const elementStyle = await driver.findElement(By.css('.fa-ellipsis-h')).getCssValue('color'); + if (elementStyle !== expectedEllipsisIconColor) { + throw new Error(`Expected: "${expectedEllipsisIconColor}"; Actual: "${elementStyle}"`); + } + console.log('Passed: Ellipsis icon color matched as expected'); + } + }, + + //Search icon color + { + description: 'Validate search icon color', + action: async () => { + const elementStyle = await driver.findElement(By.css('.col-12 > .fa')).getCssValue('color'); + if (elementStyle !== expectedSearchIconColor) { + throw new Error(`Expected: "${expectedSearchIconColor}"; Actual: "${elementStyle}"`); + } + console.log('Passed: Search icon color matched as expected'); + } + }, + + //Filter textbox placeholder + { + description: 'Validate Filter placeholder text', + action: async () => { + const elementValue = await driver.findElement(By.css('#content-org-filter')).getAttribute('placeholder'); + if (elementValue !== expectedFilterPlaceholder) { + throw new Error(`Expected: "${expectedFilterPlaceholder}"; Actual: "${elementValue}"`); + } + console.log('Passed: Filter placeholder text matched as expected'); + } + }, + + //Sort + { + description: 'Validate sort label', + action: async () => { + const elementText = await driver.findElement(By.css('.col-4')).getText(); + if (elementText !== expectedSortLabel) { + throw new Error(`Expected: "${expectedSortLabel}"; Actual: "${elementText}"`); + } + console.log('Passed: Sort label matched as expected'); + } + }, + + //Sort Dropdown + { + description: 'Validate sort dropdown option', + action: async () => { + const elementOption = await driver.findElement(By.css('#orgsort')).getAttribute('value'); + if (elementOption !== expectedSortDropDown) { + throw new Error(`Expected: "${expectedSortDropDown}"; Actual: "${elementOption}"`); + } + console.log('Passed: Sort dropdown option matched as expected'); + } + }, + + { description: 'Click ellipsis icon', action: async () => await driver.findElement(By.css('.fa-ellipsis-h')).click() }, + + //Create Content Set icon color + { + description: 'Validate create content set icon color', + action: async () => { + const elementStyle = await driver.findElement(By.css('.fa-plus')).getCssValue('color'); + if (elementStyle !== expectedCreateContentSetIconColor) { + throw new Error(`Expected: "${expectedCreateContentSetIconColor}"; Actual: "${elementStyle}"`); + } + console.log('Passed: Create Content Set icon color matched as expected'); + } + }, + + //Create Content Set link text + { + description: 'Validate create content set link text', + action: async () => { + const elementText = await driver.findElement(By.linkText('Create Content Set')).getText(); + if (elementText !== expectedCreateContentSetLinkText) { + throw new Error(`Expected: "${expectedCreateContentSetLinkText}"; Actual: "${elementText}"`); + } + console.log('Passed: Create Content Set link text matched as expected'); + } + }, + + //Create Content Set link text color + { + description: 'Validate create content set link text color', + action: async () => { + const elementStyle = await driver.findElement(By.linkText('Create Content Set')).getCssValue('color'); + if (elementStyle !== expectedCreateContentSetLinkTextColor) { + throw new Error(`Expected: "${expectedCreateContentSetLinkTextColor}"; Actual: "${elementStyle}"`); + } + console.log('Passed: Create Content Set link text color matched as expected'); + } + }, + + //Export Content Set icon color + { + description: 'Validate export content set icon color', + action: async () => { + const elementStyle = await driver.findElement(By.css('.fa-download')).getCssValue('color'); + if (elementStyle !== expectedExportContentSetIconColor) { + throw new Error(`Expected: "${expectedExportContentSetIconColor}"; Actual: "${elementStyle}"`); + } + console.log('Passed: Export Content icon color matched as expected'); + } + }, + + //Export Content Set link text + { + description: 'Validate export content set link text', + action: async () => { + const elementText = await driver.findElement(By.linkText('Export Content Set')).getText(); + if (elementText !== expectedExportContentSetLinkText) { + throw new Error(`Expected: "${expectedExportContentSetLinkText}"; Actual: "${elementText}"`); + } + console.log('Passed: Export Content Set link text matched as expected'); + } + }, + + //Export Content Set link text color + { + description: 'Validate export content set link text color', + action: async () => { + const elementStyle = await driver.findElement(By.linkText('Export Content Set')).getCssValue('color'); + if (elementStyle !== expectedExportContentSetLinkTextColor) { + throw new Error(`Expected: "${expectedExportContentSetLinkTextColor}"; Actual: "${elementStyle}"`); + } + console.log('Passed: Export Content Set icon color matched as expected'); + } + }, +]; + +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', 'dashboardMyContent'); + + const screenshotFileName = `step_${stepIndex}_${stepDescription.replace(/\s+/g, '_')}.png`; + const screenshotPath = path.join(dir, screenshotFileName); + fs.writeFileSync(screenshotPath, screenshot, 'base64'); + return screenshotPath; +}; + +const clearOldResults = () => { + // Remove old screenshots + const screenshotDir = path.join('screenshots', 'dashboardMyContent'); + if (fs.existsSync(screenshotDir)) { + fs.rmSync(screenshotDir, { recursive: true, force: true }); + } + fs.mkdirSync(screenshotDir, { recursive: true }); + + // Remove old Excel file + if (fs.existsSync('dashboardMyContentResults.xlsx')) { + fs.unlinkSync('dashboardMyContentResults.xlsx'); + } +}; + +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, ''); + + for (const step of steps) { + const stepIndex = steps.indexOf(step) + 1; + const timestamp = new Date().toISOString(); + + try { + await step.action(); + const screenshotPath = await takeScreenshot(driver, stepIndex, step.description); + worksheet = logStep(worksheet, step.description, 'Passed', stepIndex, timestamp, screenshotPath); + } catch (error) { + 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}`); + testStatus = 'Failed'; + } + } + + //Check if login was successful + const usernameValidation = await driver.wait(until.elementLocated(By.css('#navbarDropdown > span')), 5000).catch(() => false); + + if (usernameValidation) { + console.log('PASSED: System logged in as expected'); + testStatus = 'Passed'; + } else { + console.log('FAILED: Unable to log in'); + 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, 'dashboardMyContentResults.xlsx'); +} finally { + await driver.quit(); +} +})(); +} + +export default ExACT_dashboardMyContent;