1313const path = require ( 'node:path' ) ;
1414const fs = require ( 'fs' ) ;
1515// eslint-disable-next-line import/no-unresolved
16- const puppeteer = require ( 'puppeteer' ) ;
1716const mongoose = require ( 'mongoose' ) ;
1817const moment = require ( 'moment-timezone' ) ;
1918const _ = require ( 'lodash' ) ;
@@ -34,10 +33,10 @@ const { NEW_USER_BLUE_SQUARE_NOTIFICATION_MESSAGE } = require('../constants/mess
3433const timeUtils = require ( '../utilities/timeUtils' ) ;
3534const Team = require ( '../models/team' ) ;
3635const BlueSquareEmailAssignmentModel = require ( '../models/BlueSquareEmailAssignment' ) ;
36+ const playwrightLogic = require ( '../utilities/playwrightUtil' ) ;
3737const myTeam = require ( './helperModels/myTeam' ) ;
3838const dashboardHelper = require ( './dashboardhelper' ) ( ) ;
3939const reportHelper = require ( './reporthelper' ) ( ) ;
40-
4140// eslint-disable-next-line no-promise-executor-return
4241const delay = ( ms ) => new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
4342
@@ -3250,56 +3249,6 @@ const userHelper = function () {
32503249 }
32513250 } ;
32523251
3253- const puppeteerLogic = async ( ) => {
3254- // get login details from env
3255- const { PUPPETEER_EMAIL , PUPPETEER_PASSWORD , REACT_FRONTEND_URL } = process . env ;
3256- if ( ! PUPPETEER_EMAIL || ! PUPPETEER_PASSWORD ) {
3257- logger . logError ( 'Puppeteer email or password not found in environment variables' ) ;
3258- }
3259- // launch puppeteer
3260- const browser = await puppeteer . launch ( {
3261- headless : true ,
3262- args : [ '--no-sandbox' , '--disable-setuid-sandbox' ] ,
3263- } ) ;
3264- const page = await browser . newPage ( ) ;
3265- // navigate to the login page
3266- await page . goto ( `${ REACT_FRONTEND_URL } /login` , { waitUntil : 'networkidle2' } ) ;
3267- await page . setViewport ( {
3268- width : 1920 ,
3269- height : 1080 ,
3270- deviceScaleFactor : 1.5 ,
3271- } ) ;
3272- // enter email and password
3273- await page . type ( 'input[id="email"]' , PUPPETEER_EMAIL , { delay : 100 } ) ;
3274- await page . type ( 'input[id="password"]' , PUPPETEER_PASSWORD , { delay : 100 } ) ;
3275- // click the login button
3276- // await page.click('button[type="submit"]', { delay: 100 });
3277- await page . click ( '.btn.btn-primary' , { delay : 100 } ) ;
3278- // wait for navigation to complete
3279- await page . waitForNavigation ( { waitUntil : 'networkidle2' } ) ;
3280-
3281- // go to /totalorgsummary
3282- await page . goto ( `${ REACT_FRONTEND_URL } /totalorgsummary` , { waitUntil : 'networkidle2' } ) ;
3283-
3284- // click on all toggle elements
3285- const elements = await page . $$ ( '.accordian-trigger' ) ;
3286-
3287- console . log ( 'elements' , elements ) ;
3288-
3289- // Looping through and interacting with each element
3290- for ( const element of elements ) {
3291- await element . click ( ) ;
3292- await page . waitForTimeout ( 1000 ) ; // wait for the animation to complete
3293- }
3294- await page . waitForTimeout ( 50000 ) ;
3295- // take a screenshot of the page
3296- // await page.setViewport({ width: 1920, height: 1080 });
3297- await page . screenshot ( { path : 'weeklyCompanySummary.png' , fullPage : true } ) ;
3298-
3299- // close the browser
3300- await browser . close ( ) ;
3301- } ;
3302-
33033252 // Weekly Company Summary Email
33043253 const weeklyCompanySummaryEmail = async ( ) => {
33053254 console . log ( 'Weekly Company Summary Email' ) ;
@@ -3313,7 +3262,7 @@ const userHelper = function () {
33133262 <p>One Community</p>` ;
33143263
33153264 // generate screenshot
3316- await puppeteerLogic ( ) ;
3265+ await playwrightLogic ( ) ;
33173266 console . log ( 'Puppeteer logic completed' ) ;
33183267
33193268 // create an attachment object
0 commit comments