# UI dev environment

## Overview


:::warning
if you’re in Windows you need to install [WSL](https://learn.microsoft.com/fr-fr/windows/wsl/install) or use Github code spaces

:::


## Using OntoPortal UI utility script

### Install docker

To see how to install `docker` and `docker compose`, see https://docs.docker.com/compose/install/

### Clone the code

Choose a version of code to clone  <https://github.com/ontoportal-lirmm/bioportal_web_ui/> , <https://github.com/ncbo/bioportal_web_ui/>, or <https://github.com/ontoportal/ontoportal_web_ui> (or your own version)

### Read the help

```bash
bin/ontoportal help
```

  
You should see something like this:

```javascript
Usage: bin/ontoportal {dev|test|run|help} [--reset-cache] [--api-url API_URL] [--api-key API_KEY]
  dev            : Start the Ontoportal API development server.
                  Example: bin/ontoportal dev --api-url http://localhost:9393
                  Use --reset-cache to remove volumes: bin/ontoportal dev --reset-cache
  test           : Run tests.
  run            : Run a command in the Ontoportal API Docker container.
  help           : Show this help message.

Description:
  This script provides convenient commands for managing an Ontoportal API
  application using Docker Compose. It includes options for starting the development server,
  running tests, and executing commands within the Ontoportal API Docker container.

Goals:
  - Simplify common tasks related to Ontoportal API development using Docker.
  - Provide a consistent and easy-to-use interface for common actions.
```


### Run a development server

```bash
bin/ontoportal dev  --api-url <api url> --api-key <apikey> 
```

  
Example for stageportal.lirmm.fr


```javascript
 bin/ontoportal dev --api-key 1de0a270-29c5-4dda-b043-7c3580628cd5 --api-url https://data.stageportal.lirmm.fr/ 
```

  
Open the browser at [http://localhost:3000](http://localhost:3000/) to see the running server

  
By default, the script creates and uses these configuration files  `.env`  and  `config/bioportal_config_development.rb` , `config/database.yml` created respectively from the samples `.env.sample` ,  `config/bioportal_config_env.rb.sample` and `config/database.yml.sample`


### Run tests using a local OntoPortal API

```bash
bin/ontoportal test 
```

  
This will run a local API and run integration and controller tests

* **Integration Tests**: Integration tests in Rails focus on testing interactions between different components or subsystems of your application. They ensure that various parts of your application work together as expected.

  **Example**: Suppose you want to test the interaction between the UsersController and SessionsController in your application. You can write an integration test to simulate signing up a new user and then logging in with the newly created user.

  
* **Functional Tests** (also known as Controller Tests):  Controller tests in Rails focus on testing the behavior of controllers in response to HTTP requests. They ensure that the controllers handle requests correctly and produce the expected responses.

  **Example**: Let's say you have a UsersController responsible for handling user-related actions like creating a new user. You can write a controller test to verify that the create action behaves as expected.

  


### Run system tests using a local OntoPortal API

```javascript
 bin/ontoportal test test/system/*
```

  
This will run a local API and virtual machine with Chrome and run system tests

**System Tests** (or End-to-End Tests): System tests in Rails simulate user interactions with your application through a web browser. They test the application's functionality from end to end, including the interaction between various components like controllers, views, and JavaScript.

**Example**: Suppose you want to test the functionality of signing up a new user on your Rails application. You can write a system test to simulate a user visiting the sign-up page, filling out the form, submitting it, and then verifying that the user is redirected to the correct page after signing up.


### Run a specific test file on a local OntoPortal API

```javascript
 bin/ontoportal test test/system/login_flows_test.rb:22
```

  
this will the test in the line `22` of the file `test/system/login_flows_test.rb`

---

**Documents**

- [💁‍♂️ Acknowledgments](https://wiki.agroportal.eu/s/e6158eda-c109-4385-852c-51a42de9a412/doc/acknowledgments-15GdRXLQdm)
- [📚Publications and references](https://wiki.agroportal.eu/s/e6158eda-c109-4385-852c-51a42de9a412/doc/publications-and-references-87tEoeoGKy)
- [🗽Terms & Conditions](https://wiki.agroportal.eu/s/e6158eda-c109-4385-852c-51a42de9a412/doc/terms-conditions-naDsDo2Zxq)
- [🧞‍♂️Metadata guidelines and recommendations](https://wiki.agroportal.eu/s/e6158eda-c109-4385-852c-51a42de9a412/doc/metadata-guidelines-and-recommendations-pOFbK9sIfp)
- [📜 AgroPortal Release Notes](https://wiki.agroportal.eu/s/e6158eda-c109-4385-852c-51a42de9a412/doc/agroportal-release-notes-btKjZk5tU2)
- [ 👩‍🚀 User Guide](https://wiki.agroportal.eu/s/e6158eda-c109-4385-852c-51a42de9a412/doc/user-guide-ZszoBwfjGF)
- [📎 API Documentation](https://wiki.agroportal.eu/s/e6158eda-c109-4385-852c-51a42de9a412/doc/api-documentation-kMCurGKD97)
- [🤖 Developer Documentation](https://wiki.agroportal.eu/s/e6158eda-c109-4385-852c-51a42de9a412/doc/developer-documentation-LhsrucqGTa)
- [🗃External Documentation](https://wiki.agroportal.eu/s/e6158eda-c109-4385-852c-51a42de9a412/doc/external-documentation-vNPQCdArrr)
- [AgroPortal infrastructure](https://wiki.agroportal.eu/s/e6158eda-c109-4385-852c-51a42de9a412/doc/agroportal-infrastructure-ietsAU4kPs)