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

chore(#109): Run test suite from the apdex test automation branch #9114

Merged
merged 14 commits into from
May 21, 2024

Conversation

ralfudx
Copy link

@ralfudx ralfudx commented May 13, 2024

Description

#109

To review this you can do the following:

  • check the files changed and ensure there's nothing strange/out of place
  • Run npm ci from the repository's root directory
  • Connect your mobile device and then run npm run apdex-test
  • The tests should start running on the physical device without any error.

Code review checklist

  • Readable: Concise, well named, follows the style guide, documented if necessary.
  • Documented: Configuration and user documentation on cht-docs
  • Tested: Unit and/or e2e where appropriate
  • Internationalised: All user facing text
  • Backwards compatible: Works with existing data and configuration or includes a migration. Any breaking changes documented in the release notes.

Compose URLs

If Build CI hasn't passed, these may 404:

License

The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.

@ralfudx
Copy link
Author

ralfudx commented May 14, 2024

I have asked for help on the dev channel for the failing CI builds

Copy link
Contributor

@latin-panda latin-panda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ralfudx, the CI it's throwing an error that says:

npm ERR! npm ci can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync.

In this PR, you have made changes in package.json only, so it's not in sync with the package-lock.json.

  1. You need to run:
    npm install @wdio/appium-service --save-dev
    npm install appium-uiautomator2-driver --save-dev
    npm install ts-node --save-dev

  2. Then, commit and push those changes of package-lock.json. It should only contain changes from those 3 new dependencies.

  3. Once you have that, then remove the following from apdex-score/package.json because we already have those dependencies in the main package.json of CHT:

@wdio/allure-reporter
@wdio/appium-service
@wdio/cli
@wdio/local-runner
@wdio/mocha-framework
@wdio/spec-reporter
allure-commandline
faker we already have `@faker-js/faker`
ts-node
typescript
  1. The apdex-score folder should also have a package-lock.js file. To get it properly generated, install each dependencies manually.

  2. I have these questions:

  • Do we really really need "moment-timezone"?
  • Is it possible to keep "appium-uiautomator2-driver" in apdex-score/package.json ?

@ralfudx
Copy link
Author

ralfudx commented May 15, 2024

  1. npm install @wdio/appium-service --save-dev
    npm install appium-uiautomator2-driver --save-dev
    npm install ts-node --save-dev

@latin-panda thanks for the comment and requested changes - I had previously done these steps and I just did them again however, the build is still failing with the error I reported in the dev channel and I'm not sure why this is still happening but I noticed that even when i install the dependencies one by one with the commands you suggested above it seems the package-lock.json file doesn't contain only changes from the 3 new dependencies because I can see the file having 34,317 additions, 23,184 deletions.
At this point, I must say I'm out of ideas and will appreciate any help on this

To answer your questions:

  1. We don't need moment-timezone and I've removed it.
  2. If we keep appium-uiautomator2-driver in apdex-score/package.json the purpose of running the tests directly from the cht-core root directory will be defeated.

I have these questions though:

@latin-panda
Copy link
Contributor

Is there a specific reason why you need/want us to keep appium-uiautomator2-driver in apdex-score/package.jsonIs there a specific reason why you need/want us to keep appium-uiautomator2-driver in apdex-score/package.json

Maybe it was nice to keep it in apdex-score/package.json because it's only used there. But if it's not possible, then it's okay in the main package.json

Since we are managing dependencies and running everything from the main package.json of CHT, do we really need to still keep the apdex-score/package.json file?Since we are managing dependencies and running everything from the main package.json of CHT, do we really need to still keep the apdex-score/package.json file?

Good question. If the file ends up without dependencies to install and no scripts defined, I think it makes sense to remove it. 🤔

@ralfudx
Copy link
Author

ralfudx commented May 15, 2024

@latin-panda @lorerod @Benmuiruri can you kindly help review this? I've only made changes to the package.json file so it should be quick i guess? 😃

@ralfudx ralfudx requested a review from latin-panda May 15, 2024 11:00
Copy link
Contributor

@latin-panda latin-panda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ralfudx I'm getting this error - I tried with sudo and still not working
Screenshot 2024-05-16 at 11 06 26 AM

The apk is in the usual place
Screenshot 2024-05-16 at 11 02 20 AM

Are you getting the same error?

Also if we don't need the scripts in the apdex-score/package.json, I think you can delete the file in this PR.

 "scripts": {
    "test": "npx wdio wdio.conf.js",
    "report": "npx allure generate allure-results --clean && npx allure open",
    "apdex-test": "wdio run ./wdio.conf.js"
  },

@ralfudx
Copy link
Author

ralfudx commented May 16, 2024

Yes @latin-panda this is because the path to the apk in the wdio.conf.js file was not properly updated - You can even comment that line out if you already have the app installed on the physical device.
I have updated the path to the apk and removed the unused package files and it's running fine now. Please go ahead and try it again
Screenshot 2024-05-16 at 11 27 42

@ralfudx
Copy link
Author

ralfudx commented May 16, 2024

@Benmuiruri and @latin-panda I'd appreciate a final review on this so it can be merged this week

@latin-panda
Copy link
Contributor

@ralfudx I pulled the latest from the branch, but it is still not working after a fresh install of the repo. It seems some files are using that moment-timezone, and the browser isn't properly installed - maybe it is a missing dependency or maybe because the dependencies were downgraded?

How are you running these tests in your local environment?

Screenshot 2024-05-17 at 12 17 01 PM

@ralfudx
Copy link
Author

ralfudx commented May 17, 2024

@latin-panda I pulled the latest from apdex-automation-tests branch before making these changes and I'm using the npm run apdex-test command to run the tests from the root directory of cht-core

@latin-panda
Copy link
Contributor

latin-panda commented May 17, 2024

@ralfudx if you remove the node_modules from the root folder and apdex-score folder, and then npm ci, do you get the same error?

@ralfudx
Copy link
Author

ralfudx commented May 17, 2024

@latin-panda yes I get the same error after doing npm ci and it appears it's missing a dependency
I added moment-timezone and that fixed the issue. You can give it another try

@latin-panda
Copy link
Contributor

@ralfudx, but here, you mentioned that we don't need moment-timezone

We don't need moment-timezone and I've removed it.

It is better to remove or comment the import of this dependency in those files instead of installing the dependency into CHT. We try to add just the necessary to CHT to keep it slim

@ralfudx
Copy link
Author

ralfudx commented May 17, 2024

@latin-panda after having a deeper look I noticed we are still using it in test/page-objects/page.js to define and extract the current date+time in order to calculate the lmpDate, followUpDate, & vhtVisitDate and that's why i added it

@latin-panda
Copy link
Contributor

I see thanks @ralfudx; I took a deeper look this morning. Those values are for filling out the forms, right? They will need to be included in the form's configuration of the settings file before running the test suite every time. So, no dynamic dates are required.

However, if we still need date conversion in an edge case, the existing e2e tests use the regular moment library to calculate the fields. That library is already available in CHT.

Therefore, it is better not to add moment-timezone now. Let's leave it as the last resource in case of an edge case.
Please remove the moment-timezone and comment or remove the code using it.

@ralfudx
Copy link
Author

ralfudx commented May 20, 2024

@latin-panda i have removed moment-timezone and commented the code using it

Copy link
Contributor

@latin-panda latin-panda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ralfudx I've tested the branch and it's running the test properly with the settings file (see video)

Screen.Recording.2024-05-21.at.12.47.16.PM.mp4

However the moment-timezone wasn't properly uninstalled and the package-lock.json still has the dependency defined. (See that package-lock has 57k lines, it should be less than 40k)

Screenshot 2024-05-21 at 12 50 54 PM

Run npm uninstall moment-timezone in the root folder, that should update the package-lock

@ralfudx
Copy link
Author

ralfudx commented May 21, 2024

@latin-panda thanks for the observation, I have done this and even after running npm uninstall moment-timezone in the root folder, it seems the dependency is still listed in the package-lock.js file
I can still see 57k lines in that file - is this something that needs to be resolved manually?

Copy link
Contributor

@latin-panda latin-panda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ralfudx It's better to not fix the package-lock file because it has some special logic that is autogenerated and that can cause unexpected behaviors in the apps.

When the issue you described happens, it's better to install it (npm install moment-timezone --save-dev) and then uninstall it (npm uninstall moment-timezone --save-dev), npm will handle the package-lock and void problems.

@ralfudx
Copy link
Author

ralfudx commented May 21, 2024

@Benmuiruri and @lorerod if you'd like to provide a quick review as well, I'd appreciate that before we merge this to the apdex-automation-tests branch

Copy link
Contributor

@Benmuiruri Benmuiruri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ralfudx could you update the PR description with the steps for reviewing it ?

@ralfudx
Copy link
Author

ralfudx commented May 21, 2024

@Benmuiruri I have updated the description. Kindly let me know if something there is not clear
Thanks

Copy link
Contributor

@Benmuiruri Benmuiruri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! After making adjustments to Jenni's sample script I was able to run the tests successfully

@ralfudx ralfudx merged commit 3a2f4f7 into apdex-automation-tests May 21, 2024
31 checks passed
@ralfudx ralfudx deleted the run-tests-from-cht-core branch May 21, 2024 21:27
Copy link
Contributor

@lorerod lorerod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor suggestion.
Thanks @ralfudx

Comment on lines +180 to +224
// async extractCurrentDate(days) {
// const dateTimeString = await driver.getDeviceTime();
// let dateTime = moment(dateTimeString);
// dateTime = moment(dateTime).add(days, 'days');

// const year = dateTime.format('YY');
// const month = dateTime.format('MM');
// const day = dateTime.format('DD');
// const hour = dateTime.format('HH');
// const minute = dateTime.format('mm');

// return {year, month, day, hour, minute};
// }

// async updateCurrentDate (days) {
// const extractCurrentDate = await this.extractCurrentDate(days);
// console.log('TIME::: Year:', extractCurrentDate.year);
// console.log('TIME::: Month:', extractCurrentDate.month);
// console.log('TIME::: Day:', extractCurrentDate.day);
// console.log('TIME::: Hour:', extractCurrentDate.hour);
// console.log('TIME::: Minute:', extractCurrentDate.minute);
// console.log('TIME::: Extracted Components:', extractCurrentDate);
// const adbDateFormat = `${extractCurrentDate.month}${extractCurrentDate.day}${extractCurrentDate.hour}
// ${extractCurrentDate.minute}${extractCurrentDate.year}`;
// execSync('adb shell su root date ' + adbDateFormat, { stdio: 'inherit' });
// browser.pause(10000);
// }

// async getLmpDate () {
// const extractLmpDate = await this.extractCurrentDate(-62);
// const lmpDate = `20${extractLmpDate.year}-${extractLmpDate.month}-${extractLmpDate.day}`;
// return lmpDate;
// }

// async getFollowUpDate () {
// const extractNextDate = await this.extractCurrentDate(1);
// const followUpDate = `20${extractNextDate.year}-${extractNextDate.month}-${extractNextDate.day}`;
// return followUpDate;
// }

// async getVHTVisitDate () {
// const extractPreviousDate = await this.extractCurrentDate(-1);
// const visitDate = `20${extractPreviousDate.year}-${extractPreviousDate.month}-${extractPreviousDate.day}`;
// return visitDate;
// }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please delete the commented lines?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run a test suite from the apdex test automation branch in cht-core
4 participants