Package Test

Unit Tests of the install, uninstall, update, and search packages methods.

Summary

The Package unit tests are made to ensure the new features implemented by developers are running in an expected state, so that optimistically the next release of Drop can be bug free.

Note: Every develop on Drop development need to run through the tests before merging the new features to the Production environment!

The unit tests require the developers to manually spin up the frontend and backend servers as well as adjusting some parameters in the Drop desktop project. Follow the next section How to start the unit tests to learn how to set it up.

How to start the unit tests?

The unit tests have its own MongoDB database and S3 bucket - Make sure to coordinate with the team lead to learn more information.

Setup Frontend

  1. Find the the environment.ts file under the src/environments folder

  2. [To be merged into Main] Make sure to add Base_URL: "http://localhost:3017" in the environment variable

  3. Comment out the rest of the BASE_URLs. This tells the frontend to look at the local backend server that connects to the testing database.

  4. Type ng serve to run the backend testing local server.

Setup Backend

  1. Find and open keys.js under the keys folder.

  2. [To be merged into Main] Add the line else if (process.env.NODE_ENV == "test") { console.log("Running in test environment...!"); module.exports = require("./test.keys"); } before the else condition.

  3. [To be merged into Main] Create a javascript file named test.keys.js under the keys folder.

  4. [To be merged into Main] Add the necessary S3 and AWS credentials in this file, and point the Base_URL to the

    Base_URL: "http://localhost:3017/"
  5. [To be merged into Main] Add this test:

    "test:windows": "set NODE_ENV=test&&node ./bin/www"

    command for starting the test backend server in the package.json

  6. Open the Command Prompt at the root directory of the Backend project.

  7. Type npm run windows:test to run the backend testing local server.

Setup Desktop

  1. Find the DropSettings.json under the CORE.Drop.Library project.

  2. Add the lines in the packageRepos list: { "type": "URL", "url": "http://localhost:3017", "name": "Drop Localhost", "enabled": true }

  3. Turn the enabled for the current active repo to false, make sure localhost:3017 is the only repo is true.

  4. If you follow all the steps above, you are ready to go with the unit tests.

  5. Find the Test folder directly under the CORE.Drop.Desktop solution.

  6. Finally, Run CORE.Packaging.Test unit test project.

Where are the testing packages?

[To be merged into Main] The source folder of the testing packages is located in your local repo folder - CORE.Drop.Desktop\sample\TestCases

When the unit tests are initiated, each test will try to install the packages from the testing packages source folder to the %userprofile%/.core-drop folder, make sure to uninstall all the packages that you installed previously from Drop to keep the .core-drop folder clean before the tests.

Handle Corrupted Packages

Install Packages

Install Packages with Dependencies

Update Packages

Update Packages with Dependencies

Uninstall Packages

Uninstall Packages with Dependencies

Last updated