Skip to content

Breakable Toy project in which I'm learning about Kotlin, Elm, CQRS and EventSourcing. And where I'm running an experiment in which I value E2E tests over unit tests.

License

Notifications You must be signed in to change notification settings

Sch3lp/scrambledeggs

Repository files navigation

Scrambled.gg

A project to get Diabotical players to play more Diabotical, by offering a website to host a Ladder, with a custom points system.

Built in Kotlin, and Elm.

Check the LiveCoding With Sch3lp Twitch Channel to see how it's going, or watch the past episodes on YouTube to see how it went.

Experiments I'm running

Valuing E2E tests over unit tests

With E2E I mean integration tests that hit my REST endpoints, and verify both rdbms and eventstore for correctness.

Hypothesis:

  • I might refactor much faster this way.
  • Running E2E tests is not that much slower than running integration tests + unit tests.

Observations:

  • I miss unit tests on my domain sometimes, so I started writing those.
  • Refactoring is easier most of the time, but running the tests does take longer.
  • Using types properly (aka Lean on the compiler) is a must.
  • I miss integration/framework tests when I don't know enough about a library/framework. For example, I usually finish my refactoring quite easily and then get failing scenario tests because I did something that JDBI doesn't like. JDBI framework tests on my DAO's would give me faster feedback.
  • Had to provide my own JWT stubbing impl, which was both fun and not fun. Normally I would write JWT -> User mgmt stuff in unit tests and then just use basic auth in scenario tests.

Contributing

Read about the design decisions in the Captain's Log.

Unsure which GitMoji to use when committing? Look over here.

Developing locally

Starting the backend:

Navigate to ScrambledApplication and run it via IntelliJ IDEA; or run ./gradlew bootRun

Starting the frontend (for development):

cd ui
npm install
npm start

The script behind npm start is the following:

elm-live src/main/elm/Main.elm --open -d src/main/resources --start-page=index.html --proxy-host=http://localhost:8080/api --proxy-prefix=/api -- --output=src/main/resources/main.js

elm-live: an npm package that runs a compile + server cycle so we can do hot-reloading at dev time.
--open: Opens a browser after successfully running the elm-live command
-d src/main/resources: Set the base-dir from where to serve from to src/main/resources (which contains our index.html and style.css)
--start-page=index.html: So that the elm-main doesn't accidentally override our index.html
--proxy-host=http://localhost:8080/api: Forward requests that are hit with the --proxy-prefix parameter to this exact address
--proxy-prefix=/api: When requests that contain this string are hit, the webserver should forward these requests to the --proxy-host parameter.
--src/main/resources/main.js: Make sure that the dist is built in the same directory as we're serving from (see -d).

Todo

  • ScenarioTests that run against the REST API
  • Get a runnable/demoable application again (starting up ScrambledApplication requires a r2dbc url)
  • How to do projections? From which class/responsible thing do we initiate it?
  • EventSourcing: what's out there? Or do we DIY it with Postgres?
  • Try to use elm-ui (and/or elm-css, dunno what it's called nowadays)
  • Do some proper error handling
  • Actually parse the JSON instead of passing a string
  • Find a better way to develop the UI locally, because gradlew :ui:build is too tedious/slow (no hot-reloading)
  • Make an initial Elm page that calls the rest api
  • Make an initial rest controller
  • Make sure we can run the SpringBoot app from an executable jar
  • Make sure elm-make's build result is served via SpringBoot
  • Make sure we can run elm-make from Gradle
  • Make sure we can run a SpringBoot app
  • Create gradle modules

About

Breakable Toy project in which I'm learning about Kotlin, Elm, CQRS and EventSourcing. And where I'm running an experiment in which I value E2E tests over unit tests.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published