Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supressednotificationstest #34

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
9970b84
suppressed notification test
brian-tidepool May 31, 2024
f4fe319
removed credentials,environment url and added them to environment var…
brian-tidepool May 31, 2024
914dbef
addressing moving assertion outsitde of custom commands and various u…
brian-tidepool Jun 5, 2024
e138f92
comments added to suppressed notifiication functions, environment var…
brian-tidepool Jun 6, 2024
888e22f
fix error due to captureElementScreenshot.js
brian-tidepool Jun 10, 2024
71b141c
add parallel tag to clinicianPageFunctional and suppressedNotificatio…
brian-tidepool Jun 11, 2024
de2bd52
rpm stats file comparison test
brian-tidepool Jun 12, 2024
5d8ace0
Updated config.yml
brian-tidepool Jun 12, 2024
0bcb695
Added first set of tests for rpm stats
brian-tidepool Jun 25, 2024
2d90b57
fix eslint errors
brian-tidepool Jul 18, 2024
0a30235
Merge branch 'main' into supressednotificationstest
ginnyyadav Jul 19, 2024
0d8b84c
Update package.json
ginnyyadav Jul 19, 2024
dde8728
eslint config and fixes
ginnyyadav Jul 19, 2024
0679588
Update Patient Tag header reference
ginnyyadav Jul 19, 2024
8155932
fix clinician list selectors and increase timeout
ginnyyadav Jul 19, 2024
d4eabfd
Update nightwatch.conf.js
ginnyyadav Jul 19, 2024
828e471
Update nightwatch.conf.js
ginnyyadav Jul 19, 2024
9434c11
Update nightwatch.conf.js
ginnyyadav Jul 19, 2024
07ff831
add quit commands after all tests to avoid timeout
ginnyyadav Jul 19, 2024
2d92e89
handle exception fter suppressed notification request
ginnyyadav Jul 19, 2024
cac0cbc
update environment variables on prd
ginnyyadav Jul 19, 2024
70405eb
add prd command for suppressed notifications
ginnyyadav Jul 19, 2024
e1710d9
remove extra screenshots
ginnyyadav Jul 19, 2024
e2b08d4
added custom commands path
ginnyyadav Jul 19, 2024
6db4615
Merge branch 'supressednotificationstest' into rpmstats
brian-tidepool Aug 2, 2024
0631838
package.json fix error
brian-tidepool Aug 2, 2024
d0fa319
fix eslintrc.js error
brian-tidepool Aug 2, 2024
b4e9c76
class-methods-use-this warn
brian-tidepool Aug 2, 2024
5002a54
revert to testParallel
brian-tidepool Aug 2, 2024
7f8d61f
Update checkFileContents.js
brian-tidepool Aug 2, 2024
bae15b7
Update checkRPMExportSufficiency.js
brian-tidepool Aug 2, 2024
322895b
date string creation moved to function createDatesLong and createDate…
brian-tidepool Aug 5, 2024
0f4324d
clinicPatientListPage comments removed
brian-tidepool Aug 6, 2024
d80c48d
add rpm.csv to .gitignore
brian-tidepool Aug 6, 2024
321052e
Merge pull request #35 from tidepool-org/rpmstats
brian-tidepool Aug 6, 2024
fdf2c3f
add try catch suppressednotifaction
brian-tidepool Aug 6, 2024
4a8c625
add waitForElementVisible for dateselector
brian-tidepool Aug 7, 2024
0a1cdc4
add idletimeout to prdchrome section nightwatchconf.js
brian-tidepool Aug 7, 2024
cc79a17
troubleshoot timeout 1
brian-tidepool Aug 7, 2024
f4fe1f3
add try catch file exists
brian-tidepool Aug 7, 2024
7b37b5e
return error checkfileexists
brian-tidepool Aug 7, 2024
6b8831a
troubleshoot2
brian-tidepool Aug 7, 2024
c2f9005
increase idle timeout
brian-tidepool Aug 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,15 @@ module.exports = {
'chai-friendly/no-unused-expressions': 'off',
'object-shorthand': ['error', 'properties'],
'no-console': 'off',
'import/no-extraneous-dependencies': ['error', { devDependencies: false, optionalDependencies: false, peerDependencies: false }],
'max-len': 'warn',
'no-plusplus': 'warn',
'class-methods-use-this': 'warn',
'no-unused-vars': 'warn',
'prefer-const': 'warn',
},
globals: {
browser: true,
},

};
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ vrt/diff
vrt/latest
ui
screens
test_evidence
test_evidence
rpm.csv
4 changes: 4 additions & 0 deletions BrowserStack - List of devices to test on.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Name,Date of Birth,MRN,# Days With Qualifying Data between 05/01/2024 and 05/30/2024,Sufficient Data for CPT-99454
"autodex1","01/01/2000",N/A,30,TRUE
"autodex2","02/02/2002","DEXCOM",30,TRUE
"autodex3","01/01/2000","DEXCOM2",30,TRUE
44 changes: 44 additions & 0 deletions custom_commands/checkFileContents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* eslint-disable linebreak-style */
const fs = require('fs');

const getFile = (fileName) => new Promise((resolve) => {
resolve(browser.executeScript(`browserstack_executor: {"action": "getFileContent", "arguments": {"fileName": "${fileName}"}}`).then((content) => {
// Decode the content to Base64 and write to a file
const decodedData = Buffer.from(content, 'base64');
fs.writeFile('rpm.csv', decodedData, (err) => {
console.log(err);
// browser.quit();
});
}));
});

module.exports = class checkFileContents {
/**
* command method of class checkFileContents
* @param {*} fileName string
* @returns transfers latest downloaded file from remote server to local machine
*/
command(fileName) {
return new Promise((resolve) => {
/**
*
* @returns writes file to local
*/

/**
*asynchronous function checks if clinic id exists
*and that the suppressed notifications is enabled
* @returns {string} json body of clinic array object
*/
async function getFileRun() {
try {
resolve(await getFile(fileName));
} catch (error) {
console.error('Error:', error);
}
}

getFileRun();
});
}
};
36 changes: 36 additions & 0 deletions custom_commands/checkFileExists.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* eslint-disable linebreak-style */

function delay(ms) {
return new Promise((resolve) => { setTimeout(resolve, ms); });
}
module.exports = class checkFileExists {
/**
* command method of class checkSupressedNotification
* @param {*} hashValue string
* @returns true if file exists otherwise false
*/

command(attempts, fileName) {
let attempts1 = attempts;
return new Promise((resolve, reject) => {
browser.executeScript(
`browserstack_executor: {"action": "fileExists","arguments":{"file_name":"${fileName}"}}`,
[],
(result) => {
console.log(`res${result}`);
if (result.value) {
resolve(result.value);
} else {
console.log(`fail${attempts}`);
reject(Error);
}
},
);
}).catch((err) => {
console.log(`att${attempts}${err}`);
attempts1 -= 1;
if (attempts1 <= 0) throw err; // give up
return delay(1000).then(() => checkFileExists(attempts, browser, fileName));
});
}
};
81 changes: 81 additions & 0 deletions custom_commands/checkRPMExportSufficiency.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/* eslint-disable linebreak-style */
const fs = require('fs');
const { parse } = require('csv-parse');

async function getReadStreamPromise(filePath) {
return new Promise((resolve, reject) => {
const arr = [];
fs.createReadStream(filePath)
.pipe(parse({ delimiter: ',', from_line: 2 }))
.on('data', async (row) => {
arr.push(row);
// console.log(resArr)
})
.on('end', () => {
console.log('finished');
resolve(arr);
})
.on('error', (error) => {
console.log(error.message);
reject(error);
});
});
}
/**
* check if row in rpm report that days with qualifying data, item[3] ,
* contains the expected result for the sufficient data column
* @param {*} hashValue string
* @returns true if expected result for the sufficient data column is present
*/
function checkSufficiency(item) {
if (item[3] > 15) {
return item[4] === 'TRUE';
}

return item[4] === 'FALSE';
}

async function checkSufficiencyResult(filePath) {
const resArr = await getReadStreamPromise(filePath);
return new Promise((resolve, reject) => {
try {
console.log(`resarr${resArr}`);
const result = resArr.map(checkSufficiency).every(Boolean);
resolve(result);
} catch (error) {
reject(error);
}
});
}

module.exports = class checkRPMReportSufficiency {
/**
* command method of class checkSupressedNotification
* @param {*} filePath
* @returns true or false if hashvalue matches
*/
async command(filePath) {
return new Promise((resolve) => {
/**
*
* @returns returns true if rpm exported file column 5 has the
* correct boolean value based on column 4 else false
*/

/**
*asynchronous function checks if clinic id exists
*and that the suppressed notifications is enabled
* @returns {string} json body of clinic array object
*/
async function checkSufficiencyResultRun() {
try {
resolve(await checkSufficiencyResult(filePath));
} catch (error) {
console.error('Error:', error);
}
}

checkSufficiencyResultRun();
});
}
};
91 changes: 91 additions & 0 deletions custom_commands/checkSuppressedNotification.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/* eslint-disable linebreak-style */
const axios = require('axios');

module.exports = class checkSuppressedNotification {
/**
* command method of class checkSupressedNotification
* @param {*} clinicianUsername
* @param {*} clinicianPassword
* @param {*} environment
* @returns
*/
command(clinicId, clinicianId, clinicianUsername, clinicianPassword, environment) {
return new Promise((resolve) => {
const auth = btoa(`${clinicianUsername}:${clinicianPassword}`);
/**
*
* @returns @{string} session token
*/
const getToken = async () => {
const response = await axios.post(
`${environment}/auth/login`,
'',
{
headers: {
Authorization: `Basic ${auth}`,
'Content-Type': 'application/x-www-form-urlencoded',
},
},
);
return response.headers['x-tidepool-session-token'];
};
/**
*asynchronous function checks if clinic id exists
*and that the suppressed notifications is enabled
* @returns {string} json body of clinic array object
*/
const clinicData = async () => {
const token = await getToken();
try {
const response = await axios.get(`${environment}/v1/clinicians/${clinicianId}/clinics`, {

params: {
limit: '1000',
offset: '0',
},
headers: {
authority: this.api.browser_url,
accept: '*/*',
'accept-language': 'en-US,en;q=0.9',
cookie: '_ga=GA1.1.516068539.1692684735; _ga_RWXQ3R57PB=GS1.1.1694192507.4.0.1694192507.0.0.0',
referer: this.api.browser_url,
'sec-ch-ua': '"Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36',
'x-tidepool-session-token': token,
'x-tidepool-trace-session': '92df086f-917e-4df5-b32d-cb30d15df795',
},
});
return response.data;
} catch (error) {
return console.error(error);
}
};
/**
* function calls asynchronous function clinicData and awaits for result
* @returns a resolved promise with true or false if suppressed notifications are enabled
*/
const clinicDataRun = async () => {
let found = false;
const data = await clinicData();
for (let i = 0; i < data.length; i += 1) {
if (data[i].clinic.id === clinicId) {
if (data[i].clinic.suppressedNotifications.patientClinicInvitation === true) {
resolve(true);
found = true;
break;
}
}
}
if (found === false) {
resolve(false);
}
};
clinicDataRun();
});
}
};
21 changes: 21 additions & 0 deletions custom_commands/createDatesLong.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = class createDatesLong {
/**
* command method of class checkSupressedNotification
* @param {*} start
* @param {*} end
* @returns startDate, endDate, startDateFile, endDateFile
*/

command(start, end) {
return new Promise((resolve) => {
const startDate = start.format('MMMM D, YYYY');
const endDate = end.format('MMMM D, YYYY');
const startDateFile = start.format('MM-DD-YYYY');
const endDateFile = end.format('MM-DD-YYYY');
const fileName = `RPM Report (${startDateFile} - ${endDateFile}).csv`;
resolve({
startDate, endDate, startDateFile, endDateFile, fileName,
});
});
}
};
21 changes: 21 additions & 0 deletions custom_commands/createDatesShort.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = class createDatesShort {
/**
* command method of class checkSupressedNotification
* @param {*} start
* @param {*} end
* @returns startDate, endDate, startDateFile, endDateFile
*/

command(start, end) {
return new Promise((resolve) => {
const startDate = start.format('MMM D, YYYY');
const endDate = end.format('MMM D, YYYY');
const startDateFile = start.format('MM-DD-YYYY');
const endDateFile = end.format('MM-DD-YYYY');
const fileName = `RPM Report (${startDateFile} - ${endDateFile}).csv`;
resolve({
startDate, endDate, startDateFile, endDateFile, fileName,
});
});
}
};
Loading