Frontend for content sources service. What is it?
- Initial etc/hosts setup
- Getting started - Installation
- Getting started - Running the app
- Testing with Playwright
- PR checks and linking front-end/back-end PRs for testing
- Deploying
In order to access the https://[env].foo.redhat.com in your browser, you have to add entries to your /etc/hosts
file. This is a one-time setup that has to be done only once (unless you modify hosts) on each machine.
To setup the hosts file run following command:
yarn patch:hosts
Alternatively, add these lines to your /etc/hosts file:
127.0.0.1 prod.foo.redhat.com
::1 prod.foo.redhat.com
127.0.0.1 stage.foo.redhat.com
::1 stage.foo.redhat.com
127.0.0.1 qa.foo.redhat.com
::1 qa.foo.redhat.com
127.0.0.1 ci.foo.redhat.com
::1 ci.foo.redhat.com
-
Make sure nvm is installed
-
To ensure you have the correct node version installed do:
nvm use
. Yarn WILL prevent you from progressing if you have not updated your node version to match the one in the .nvmrc file. -
If you haven't cloned this repo recursively with all submodules, run
./test-utils.sh setup
to get the_playwright-tests/test-utils
submodule. (for existing setups, you will also need to update packages withyarn install
) -
yarn install
-
yarn build
(only required when setting up for the first time)
Keep in mind that you have to be connected to the VPN for this to work, even in the offices.
-
yarn start
to choose whether to run against stage or prod environments.
OR
yarn start:stage
to run against stage environment.
OR
yarn start:prod
to run against prod environment.
OR
yarn local
to run against a local backend running on port 8000. -
With a browser, open the URL listed in the terminal output, https://stage.foo.redhat.com:1337/insights/content for example.
Sometimes the default development proxy started with yarn start||local
can be
slow and unstable, which can be problematic while testing. To overcome this you
can use the consoledot-testing-proxy
and run the app in static mode.
-
yarn fec static
to start the app in static mode -
podman run -d -e HTTPS_PROXY=$RH_PROXY_URL -p 1337:1337 -v "$(pwd)/config:/config:ro,Z" --replace --name consoledot-testing-proxy quay.io/dvagner/consoledot-testing-proxy
to run the proxy against stage
yarn verify
will run yarn build
yarn lint
(eslint), yarn format:check
Prettier formatting check and yarn test
(Jest unit tests)
One can also: yarn test
to run the unit tests directly.
-
Ensure the correct node version is installed and in use:
nvm use
-
Copy the example env file and create a file named:
.env
For local development only the BASE_URL:https://stage.foo.redhat.com:1337
is required, which is already set in the example config. -
Install Playwright browsers and dependencies
yarn playwright install
OR
If using any OS other than Fedora/Rhel (IE:mac, ubuntu linux):
yarn playwright install --with-deps
-
Run the backend locally, steps to do this can be found in the backend repository.
Ensure that the backend is running prior to the following steps.
-
yarn local
will start up the front-end repository. If you doyarn start
and choose stage, your tests will attempt to run against the stage ENV, please do not test in stage. -
yarn playwright test
will run the playwright test suite.yarn playwright test --headed
will run the suite in a vnc-like browser so you can watch it's interactions.
For tips and recommendations on how to write Playwright tests. Check out the Playwright style guide in this repo.
It is recommended to test using vs-code and the Playwright Test module for VSCode. But other editors do have similar plugins to for ease of use, if so desired
For running the integration tests you will need to run yarn get-tests
, point playwright to stage directly (i.e.: set proxy and change URL, check playwright_example.env
), set the INTEGRATION
flag to true and run the tests.
This repo contains a _playwright-tests/test-utils
git submodule which has a set of shared helpers and fixtures (and API client) across our Playwright testing suites.
For easier interaction with this submodule there is a test-utils.sh
script that contains 4 helper commands.
setup
- This sets up (initializes the submodule and configures sparse checkout) the submodule in the regular/intended way, i.e.: pointing to our BE repo and to the commit specified in this repo. \setup-dev 'your-forks-url'
- This command is meant to be run when you would like to work on new shared test utilities while in the FE repo. To make this easier this command will setup the submodule to point to your fork as origin and our BE repo as upstream.remove
- This is meant to be run when switching between the regular and dev setups (before the setup commands), this will throw away any non-committed changes in the submodule.update
- This will fetch the newest changes of the submodule's origin and make it point to the latest commit.
Example workflow:
I am using the regular submodule setup. When working on new tests I thought of a new handy helper and want to add it as a shared one.
For that I want to work on my fork of our BE repo, so I run the ./test-utils.sh remove
and ./test-utils setup-dev 'my.forks.url'
commands.
Then I finish the helper, push those changes to my fork and make a PR from there (switch to the git context of the BE repo by entering the _playwright-tests/test-utils
directory).
After that I make a FE draft PR and return back to the regular submodule setup by running ./test-utils.sh remove
and ./test-utils setup
.
When the BE PR merges I will update the FE PR to point to the newest changes in the BE by running ./test-utils.sh update
and committing, then make it ready for review!
For podman to serve the API for client testing, enter:
podman system service -t 0 unix:///tmp/podman.sock
Uncomment the DOCKER_SOCKET option in the `.env file:
DOCKER_SOCKET="/tmp/podman.sock"
The CICD pipeline for playwright (both front-end and back-end) will check in the description of the front-end PRs for the following formatted text:
#testwith https://github.com/content-services/content-sources-backend/pull/<PR NUMBER>
Note the space in #testwith https
.
If a backend PR is linked, the front-end and back-end PR's in question will both use the corresponding linked branch for their Playwright tests in the PR check.
- The starter repo uses Travis to deploy the webpack build to another Github repo defined in
.travis.yml
- That Github repo has the following branches:
ci-beta
(deployed by pushing tomaster
ormain
on this repo)ci-stable
(deployed by pushing toci-stable
on this repo)qa-beta
(deployed by pushing toqa-beta
on this repo)qa-stable
(deployed by pushing toqa-stable
on this repo)prod-beta
(deployed by pushing toprod-beta
on this repo)prod-stable
(deployed by pushing toprod-stable
on this repo)
- That Github repo has the following branches:
- Travis uploads results to RedHatInsight's codecov account. To change the account, modify CODECOV_TOKEN on https://travis-ci.com/.