This package has been deprecated

Author message:

this package has been deprecated

@studyportals/bestfit-test

1.2.0 • Public • Published

BestFit-Test

Table of Contents

About

BestFit-Test is an NPM package that contains end-to-end tests for all the BestFit front-end microservices. For the tests Cypress is used.

A list of the front-end microservices (and any BestFit services for that matter), can be found in the README of BestFit-Shared.

Getting started

Go to the right repository

The purpose of the tests included in this repository is to test the front-end microservices. Therefore, this repository stand-alone isn't a good starting point.

Therefore, the first step is to go to the repository of any of the front-end microservices. A list of the front-end microservices (and any BestFit services for that matter), can be found in the README of BestFit-Shared.

Get the BestFit-Test package

You need to make sure that the @studyportals/bestfit-test package is included in the microservice, alongside any other dependencies.

# Make sure it is installed by running:
npm install

Running the tests

There are two ways of running the tests.

Run all the tests in a headless browser

Run the following command in your console:

# Run all tests in the configured folder.
npm run cypress

Open an interface, in which you can select what to run

Run the following command in your console:

# Open the interface.
npx cypress open

This will take a while. A new window will open that will show you an overview of all the tests there are.

[Cypress screenshot]

Click on the test, and a new window will open that starts to run the tests. Or, instead, you can click on Run all specs to run all tests that are shown in the window.

Configuration

In the root of each of the BestFit front-end microservices you can find configuration that is used to determine which tests are run and how, inside the cypress.json file. The two most important json properties to consider are:

  • integrationFolder: The folder location that Cypress looks at to retrieve your set of tests.
  • baseUrl: The base url that will be used to run the tests.

As an example, here is the cypress.json file of AdmissionChance-Answer at the time of writing this documentation:

{
  "fixturesFolder": false,
  "integrationFolder": "./node_modules/@studyportals/bestfit-test/Tests/AdmissionChanceAnswer",
  "pluginsFile": false,
  "screenshotsFolder": false,
  "supportFile": false,
  "baseUrl": "https://525.mastersportal.fyi/",
  "env":{
    "username": "ETeOGtt",
    "password": "y3J6LW3"
  },
  "defaultCommandTimeout": 15000
}

As you can see, credentials for a pull request environment can also be included under the username and password properties of the env object.

Running tests inside pull requests using Travis

For each of the BestFit front-end microservices, when a pull request is open, new commits trigger Travis to run the end-to-end tests for the respective repository, once the build and staging steps have completed for the pull request environment in AWS.

For a freshly opened pull request, if no manual action is taken, the runs in Travis will break. The manual action(s) that are required, if you want to have your changes automatically tested, are dependant on the microservice:

For questionnaire microservices (AdmissionChance and BestFit-Budget) tests can run stand-alone, without the context of Mastersportal. So, all you need to do is:

  • Change the baseUrl in the configuration of the cypress.json file at the root of the project to the url of the pull request environment, e.g. https://210-ac.prtl.fyi/ and commit this change.

For AdmissionChance-Answer tests can only run in the context of Mastersportal. So, a couple more steps are needed:

  • Copy the contents of the pull request environment, e.g. https://323-aca.prtl.fyi.
  • In the QuickGlance.php file of the Portal repository, make the following change:
// Change this:
return "https://admissionchance-answer.{$env}.prtl.co/";
// To the pull request environment link you copied:
return "https://323-aca.prtl.fyi";
  • Commit this change to a new branch.
  • Open a pull request and add the label Masters to initiate a pull request environment to be opened.
  • Take note of the url and credentials of the pull request environment.
  • In the cypress.json file at the root of AdmissionChance-Answer, set the baseUrl, the env.username and the env.password to the url and credentials of the pull request environment and commit this change.

Now, with every commit, the end-to-end tests should be running on the Mastersportal pull request environment that you opened, which fetches the AdmissionChance-Answer pull request environment instead of the TST microservice.

How the tests are structured

Inside the Tests repository, you can find the following repositories, which are all related to repositories in GitHub:

  • AdmissionChanceAnswer: Tests that verify the entire flow of not only the AdmissionChance-Answer microservice itself (which also makes use of both other microservices), but the study page on Mastersportal, which loads in all three microservices.
  • AdmissionChance: Tests that verify the flow inside the academic questionnaire only.
  • BestFitBudget: Tests that verify the flow inside the budget questionnaire only.

AdmissionChance-Answer tests

The main AdmissionChance-Answer test is, by far, the longest, because the whole flow in all its details is tested. The following list was used to verify that all flow parts are included in the test:

  • [X] Opening academic questionnaire from tabs
  • [X] Opening budget questionnaire from tabs
  • [X] Opening BestFit from main incentive
  • [X] Closing questionnaire without answering any questions
  • [X] Answering all questions (both academic and budget), which includes:
    • [X] Providing the answer itself
    • [X] Validation of the input (when applicable)
    • [X] Verifying that the answer is prefilled when coming back
    • [X] Verifying the right dropdown groups are shown
    • [X] Verifying prefilling for dropdowns that should have nothing-selected-click-away-prefill behaviour (grade & institution questions)
  • [X] Checking details, which includes:
    • [X] Opening and closing accordions
    • [X] Checking tip messages
    • [X] Checking overall fit messages
  • [X] Creating an account
  • [X] Saving answers to an account without conflict
  • [X] Saving answers to an account with conflict
  • [X] Editing an answer from the details

How to write a test

All test code should end up in the Tests/flows folder, and should be used in any of the other repositories to test a part of the flow. All tests are written in JavaScript and can contain code like:

describe('Standard Visit', function(){

	it('Opens BestFit and goes through the Academic questionnaire.', function(){

		cy.visit('https://www.mastersportal.com/studies/622/economics-for-development.html');

		cy.contains('Check your fit with this programme').click().then(() => {

			cy.get('.IntroIncentiveButton:first').click();
		});
	});
});

It is possible to use selectors to find forms and textboxes. The test can run as quickly as the page renders.

Learning more about the API

Check the Introduction to Cypress.

Readme

Keywords

none

Package Sidebar

Install

npm i @studyportals/bestfit-test

Weekly Downloads

2

Version

1.2.0

License

ISC

Unpacked Size

63.1 kB

Total Files

16

Last publish

Collaborators

  • jordi-studyportals
  • fationsh
  • orlandoliccardo
  • ozanborafikir
  • prestonvantonder
  • mrmaruf-studyportal
  • alparslanylmaz
  • georgianaschipor
  • tamassoos
  • dandobrescu
  • gilalves95
  • martinestudyportals
  • simaopcsantos
  • skrothapalli1
  • armandduijnstudyportals
  • borismo
  • alexandramarginean
  • jooshuys
  • studyportals-devops
  • jens-sp
  • stormyy
  • stefanklokgieters
  • royvaneijndhovensp