untangled

NEW CHANNEL: #fulcro
tony.kay 2017-02-26T00:16:54.004564Z

Untangled server 0.7.0 released. NOTE: This was a major refactoring, which is why it was delayed. Should be 100% backward compatible, but adds a new more modular way to build servers, including API composition, and easy custom Ring middleware stacks.

tony.kay 2017-02-26T00:17:21.004565Z

We're using the modular stuff internally, but not the classic build server function.

tony.kay 2017-02-26T00:29:01.004566Z

This branch: https://github.com/untangled-web/untangled-template/tree/modular-server

tony.kay 2017-02-26T00:29:09.004568Z

is a template using the new modular server support

tony.kay 2017-02-26T00:29:34.004569Z

Custom Ring, composable API modules, and parser injections as component injections

lucasbradstreet 2017-02-26T05:44:34.004570Z

@tony.kay congrats

lucasbradstreet 2017-02-26T05:46:14.004571Z

I’m trying to write some tests using untangled.server.protocol-support/check-response-to-client, but I’ve hit some problems with tempids. I tried to use the :om.tempid/my-temp-id form, but there’s some translation to an om.tempid.TempId form somewhere along the way and it all goes wrong. I added a hack to treat om.tempid.TempIds as tempids in that code, and it worked fine with an om generated tempid

lucasbradstreet 2017-02-26T05:51:39.004572Z

That issue aside, is there a way to apply a series of mutations to the system, in a similar way to check-response-to-client, or is there a better testing strategy for that.

tony.kay 2017-02-26T18:13:33.004573Z

@lucasbradstreet We're kind of on the fence abt protocol support. It was an experiment that had some merit in the idea department, but in our experience it hasn't really given us good overall velocity in testing. The client-side stuff is OK, but I'm leaning much more towards operations on db objects that are easy to reason about (and test, if necessary). The composition of said functions into a mutation is also trivial to test. Integration testing mutations really should not involve as much of the stack as protocol support pushes you towards. In the small, it sounded great. In the large, I lean towards it being too heavy.

tony.kay 2017-02-26T18:16:31.004574Z

The approach we take that is working well: 1. We have the database components set up with seeding (using keyword type seeding) 2. We write small integration tests around just the database operation 3. If there is logic around the IO, then that is possibly unit tested (e.g. db op tested in (2) mocked out. THis might be, for example, the security step. 4. Anything else that is tested is more pure code (e.g. client-side mutations are just compositions of functions (f state-map) => state-map or (f table-obj) => table-obj.

tony.kay 2017-02-26T18:17:22.004575Z

usually the state-map transforms are just (swap! state (fn [m] (-> (update-in (obj-ident x) do-something-to-x) ...)))

tony.kay 2017-02-26T18:17:39.004576Z

e.g. a composition of focusing on tables and table-local operations

tony.kay 2017-02-26T18:19:16.004577Z

along with helper functions that encapsulate the swap/update-in (I'm making this up on the spot): (evolve! state (object-ident x) do-something-to-x)

tony.kay 2017-02-26T18:20:11.004579Z

or a compositional form (swap! state evolve (object-ident x) do-something-to-x do-something-else)

tony.kay 2017-02-26T18:20:52.004580Z

then the vast majority of the code is so stinkin simple you might not choose to write tests for it, and the rest is still quite easy to test.

tony.kay 2017-02-26T18:21:13.004581Z

because the ops (except for evolve) are against component-local table maps instead of the app state

tony.kay 2017-02-26T18:21:21.004582Z

this also helps with local reasoning

tony.kay 2017-02-26T18:21:57.004583Z

So, loooong-answer for a short question. The short answer is "protocol support is a mostly-failed experiment"

tony.kay 2017-02-26T18:23:14.004584Z

I would love to delete it, but don't want to break people's existing test suites. I might try moving it out to a deprecated library, so a deps change could suffice for breakage avoidance.

lucasbradstreet 2017-02-26T21:27:27.004585Z

@tony.kay thanks for the explanation. I'll stay away from protocol support style tests then. I'm looking forward to your Clojurewest talk

urbank 2017-02-26T22:30:35.004586Z

Is anyone using core.spec with untangled? Is the testing library that comes with untangled complementary to it, or a replacement?

sova-soars-the-sora 2017-02-26T22:35:25.004587Z

Hey @tony.kay i'm happy to see you on the speakers' list as well 😃

urbank 2017-02-26T23:42:29.004588Z

So for a UI child to gain access to a top-level table, its parent has to have access to it?

urbank 2017-02-26T23:43:49.004589Z

Or is there a way for a deeply nested child to reach up for an arbitrary database entry?

urbank 2017-02-26T23:53:23.004591Z

http://untangled-web.github.io/untangled/guide.html#!/untangled_devguide.D_Queries under query-example-links I can see that you can reach use links [:entities/by-id _]

urbank 2017-02-26T23:56:34.004592Z

however, I'm having trouble with a specific use-case that I'm not sure this covers

urbank 2017-02-26T23:57:24.004593Z

So basically I have a component that gets a bunch of items from the database. A list of idents and some other fields

urbank 2017-02-26T23:59:27.004595Z

This components needs the ability to edit the entites, so I've defined a field in the database that can be changed from this component