Skip to content

Local development

Vladimir edited this page Mar 13, 2025 · 4 revisions

Testing with payments (Stripe)

  • Get a test publishable API key, test secret API key and stripe connect test ID
  • Save them in the form at http://localhost/admin/settings
  • To connect restaurant page to Stripe, go in the restaurant settings page

Test Stripe webhooks locally

To test Stripe webhooks locally, install Stripe CLI & launch it

stripe listen --load-from-webhooks-api --forward-to localhost

Testing push notifications

Android: Configuring Firebase Cloud Messaging

It is possible to test remote push notifications locally on Android using the emulator or a physical device.

To achieve this, you need

  1. Download a private key (.json file) for the Firebase Admin SDK service account (In Firebase Console choose your Firebase project; go to Project settings -> Service accounts -> Firebase Admin SDK -> Generate new private key)

  2. Put the private key (.json file) in a folder accessible from a Docker container, for example: var/push_notifications

  3. Reference this key in the .env FIREBASE_CREDENTIALS, for example: FIREBASE_CREDENTIALS=/var/www/html/var/push_notifications/dev-coopcycle-firebase-adminsdk.json

❗️the current setup (April 2024) require APNs to be configured for any push notifications to be send. If you want to test only android notifications, you can comment out apnsClient dependency and any usaged of it in RemotePushNotificationManager file https://github.com/coopcycle/coopcycle-web/blob/master/src/Service/RemotePushNotificationManager.php#L28

iOS: Configuring Apple Push Notification service (APNs)

Limited testing can be done in a simulator, but it requires preparing the notification payload manually, look for " In Simulator, drag and drop an APNs file onto the target simulator" in https://developer.apple.com/documentation/xcode-release-notes/xcode-11_4-release-notes

Testing push notifications end-to-end require a physical device and Apple Developer Program subscription.

  1. Follow instructions on https://developer.apple.com/documentation/usernotifications/establishing-a-token-based-connection-to-apns to generate and download a new private key (.p8 file)

  2. Put the private key (.p8 file) in a folder accessible from a Docker container, for example: var/push_notifications

  3. Reference this key and set other required parameters in the .env, for example:

APNS_PRIVATE_KEY_FILE=/var/www/html/var/push_notifications/AuthKey_apns.p8
APNS_CERTIFICATE_PASS_PHRASE=
APNS_KEY_ID=PUT_YOUR_KEY_ID
APNS_TEAM_ID=PUT_YOUR_TEAM_ID
APNS_APP_BUNDLE_ID=PUT_YOUR_BUNDLE_ID
APNS_IS_PRODUCTION_ENV=false

Testing frontend on mobile devices

  1. Update with your local IP address and uncomment the following line in webpack.config.js (restart docker containers to apply changes):
  // .setPublicPath('/build')

  // Use this if you want to debug on a real device
  .setPublicPath('http://192.168.0.11:8080')
  .setManifestKeyPrefix('/build')
  1. Use your local IP address from a mobile device to access a local instance.

  2. Use browser developer tools to inspect the web page on mobile device. For example: https://developer.chrome.com/docs/devtools/remote-debugging

Testing with large amount of data (simulating high-volume instances)

To test the application with a large amount of data, you can use Fixtures (https://github.com/nelmio/alice) to generate and load a large number of users, orders, etc. into the database.

To do this, you can run the following command on the test environment:

docker compose exec php bin/console coopcycle:fixtures:load -s cypress/fixtures/setup.yml -f cypress/fixtures/high_volume_instance.yml --env test

Or inside php docker container:

bin/console coopcycle:fixtures:load -s cypress/fixtures/setup.yml -f cypress/fixtures/high_volume_instance.yml --env test

You can run such commands on dev environment as well, but it will override all your data. Another option, when you need to access mock data from the dev environment, is to temporarily switch to a test database:

To do this, temporarily set COOPCYCLE_DB_NAME to coopcycle_test in .env file https://github.com/coopcycle/coopcycle-web/blob/master/.env.dist#L19

Troubleshoot your local installation

File permission issues in the docker environment

A pain that can appear with Docker development is that your filesystem permissions or the permission on folder created by docker are not suitable for the docker's www-data user which is running the php process (different from your local www-data) user. If you have issues with restaurant images, riders's avatars or cache folder you may try the following.

docker compose exec php /bin/sh
# in container shell
chown -R www-data:www-data web/
chown -R www-data:www-data var/

Tips

Connect to PostgreSQL through Docker

docker-compose exec postgres psql -U postgres -d coopcycle

Connect to Redis through Docker

docker-compose exec redis redis-cli -h redis -p 6379

Connect to Tile38 through Docker

docker-compose exec tile38 tile38-cli

Profiling the Webpack production build locally

docker-compose run webpack node_modules/.bin/encore production --json > stats.json

Then you can upload the stats.json file on Webpack Analyse Tool