# SpiritHub

Spirit Hub is an engine build on top of core

## Usage

To use it you must install core and then, in the dockerfile add the volume declaration line like this :
`- ../spirit_hub:/app/packages/spirit_hub `
You must do that for app, sidekiq and sidekiq2

## Installation

Then you just launch docker as usual

There's a seed command to populate the db with data, **be care this command remove all other data in your DB**

```ruby
bin/rails db:spirit_hub_seed
```

## Testing

To launch test, in the core app console

```bash
bin/rspec packages/spirit_hub/spec/**/*spec.rb
```

to launch a core console, in terminal, in core base folder :

```bash
docker compose run app bash
```

### E2E Testing with Cypress

The project includes end-to-end testing using Cypress. The test suite is managed through a shell script that handles the test environment setup and teardown automatically.

```bash
plugandwork/
├── core/                    # Main Rails application
│   ├── app/
│   └── ...
│
├── spirit_hub/             # Engine
│   ├── app/
│   ├── cypress.sh
│   └── ...
│
└── docker-compose.cypress.yml
```
To run the E2E tests you need to run the following command with the spirit_hub directory as your working directory:

```bash
# Setup environment
cp config/cypress/.env.example config/cypress/.env # Edit .env file

# Run all tests
./cypress.sh run

# Specific test
./cypress.sh run ./e2e/cypress/e2e/features/basics/dashboad.feature
⏳ Waiting for application to be ready...
🔄 Checking... (1/30)
🔄 Checking... (2/30)
🔄 Checking... (3/30)
✅ Application is ready!
🧪 Starting Cypress with: yarn cypress run ./e2e/cypress/e2e/features/basics/dashboad.feature
...
```

This script will:
1. Start the required Docker containers using `docker-compose.cypress.yml`
2. Wait for the Rails application to be ready (default timeout: 30 retries)
3. Execute Cypress tests
4. Clean up containers on completion or in case of interruption

For development mode with Cypress UI:

```bash
./cypress.sh open
```

For logging test backend output:

```bash
docker logs -f cypress-core-app --tail=100
```


## License

All rights reserved, plugandwork 2024
