nycmeshnet / meshforms

Frontend for common meshdb operations
1 stars 2 forks source link

meshforms

Deployment Status

Forms for meshdb. Live version hosted at https://forms.nycmesh.net/

This repo currently powers three separate forms:

Development

You will either need a copy of meshdb running locally, or point your local copy of this package to the beta/production endpoints in order to do development:

To get started with this package, first, create your own copy of the .env file:

cp .env.sample .env

Edit the MESHDB_URL value based on your choice above in your favorite text editor. For example:

nano .env
# Press Ctrl-X and then y to exit

Next run the following commands to run the nextjs app on your local machine:

npm install

npm run dev

Finally, open http://127.0.0.1:3000 in your web browser to interact with your copy of the application

Formatting

We use Prettier for formatting our code. There is a GitHub check that will get mad at you if you don't format your code correctly.

To appease it, run npx prettier . --write

Testing

[!WARNING]
Make sure you run playwright from the root of the repo, otherwise you will get some errors about invalid URLs.

We use playwright to do integration tests. You can run them with the following instructions:

  1. Setup a dev instance of meshdb

  2. Copy .env.sample into .env.local (.env will not work!) and fill it out

  3. Run the integration tests with npx playwright test

Tips for Testing

UI Mode

Run with npx playwright test --ui to get a nice UI to see your tests with.

https://playwright.dev/docs/running-tests#run-tests-in-ui-mode

Headed Mode

Playwright will show you the browser window it is using with --headed, and you can pause a test to examine the browser by inserting page.pause() in your test.

Running a specific test

To run a specific test, you can use -g:

npx playwright test -g 'missing name'

See the docs for more information about playwright.

Troubleshooting Tests

If you get an error like this one:

[WebServer] [Error: ENOENT: no such file or directory, open '/home/wilnil/Code/nycmesh/meshforms/.next/BUILD_ID'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/home/wilnil/Code/nycmesh/meshforms/.next/BUILD_ID'
}

Error: Process from config.webServer was not able to start. Exit code: 1

Try running npm run build

Internationalization

[!NOTE] Do you speak a language besides English? Please help us by adding more languages, validating our existing translations, or translating more of Meshforms!

We use next-intl as a library for internationalization.

To add a new language:

[!WARNING] Please keep the language codes alphabetical!

Thank you for your contributions!