Commit graph

115 commits

Author SHA1 Message Date
Sipke Schoorstra 881f0acb7a Fix tests 2021-04-02 12:43:14 +02:00
Sipke Schoorstra 23e3d1fd81 Fix JavaScriptExpressionsIntegrationTests 2021-04-02 12:43:14 +02:00
Sipke Schoorstra 38be994e31 Break up WorkflowRunner into smaller types and extracted reusable trigger logic 2021-04-02 12:43:14 +02:00
Sipke Schoorstra 4cf43882dc Update packages 2021-04-02 12:43:14 +02:00
Sipke Schoorstra 5796cf2893 Fix warnings and formatting 2021-04-02 12:43:14 +02:00
Craig Fowler e21154f7b8 Fixup for #761 - Now with 100% fewer compile errors!
Yeah, my bad :D
2021-04-01 20:25:09 +02:00
Craig Fowler 0eaa11e69d Trivial - correct a typo in class naming 2021-04-01 20:25:09 +02:00
Craig Fowler 8e16f5f269 Related to #761 - Refactor complex conversion
This removes all of the (now actually non-trivial) conversion logic from
the class which is actually responsible for executing the Jint engine.
This moves it all to a new service which uses chain of responsibility to
convert the result, using one of a few different mechanisms.

Of note is the handling of ExpandoObject when no specific type
information has been provided, and also the handling of enumerables,
with the exception of strings.
2021-04-01 20:25:09 +02:00
Craig Fowler 4b5d86135d Follow-up #761 - Fix for recursive case
Unfortunately Jint still chokes in this case if the expando contains
further nested expandos.  It turns out that I need to do this
recursively for it to always work.

We also have trouble with IEnumerable types.  They also can't be
round-tripped from/to JSON when they aren't deserialized as a very
specific type.
2021-04-01 20:25:09 +02:00
Craig Fowler 7ed875e53c Resolve #761 - Add special-case for ExpandoObject
It appears that this can be fixed by intercepting occasions
when Jint returns an ExpandoObject but the desired return type
is simply object.  In this scenario we must return
a Dictionary<string,object> instead of a simple object, or else
Jint freaks out should we try to stringify it later.

I also added a second test to prove that making this change hasn't
broken the way we expect Jint to work for us.
2021-04-01 20:25:09 +02:00
Craig Fowler dd9c1f5cdc WIP #761 - Unit test indicates location of problem
This unit test narrows the problem down to the class
JavaScriptService.
2021-04-01 20:25:09 +02:00
Craig Fowler 84f3d3d32c WIP #761 - Integration test reproduces problem
StackOverflowException reproduced exactly as reported.
2021-04-01 20:25:09 +02:00
Sipke Schoorstra 6fef9874da **BREAKING API** Update Builder API to allow to connect to named activities as well as activities by type name
This replaces the `Then(string activityName)` method with `ThenNamed(string activityName)`.
A new method is added to allow connecting to activities by type name: `ThenTypeNamed(string activityTypeName)`.

The reason for this change and addition is to allow workflow builders to connect to activity types that do not have a corresponding type.
For example, the Telnyx project has an activity type provider that *dynamically* provides activity types based on Telnyx webhook callback types.
2021-03-26 11:40:22 +01:00
Craig Fowler a81d47afff Resolve #785 - improve API for StringValuesModel
This means that the model:
* Implements IConvertible so that Jint may implicitly convert
  it to other types as if it were just a string.
* The Values & Values properties are perhaps a little less confusing
  now, and present a more consistent set of state, regardless of
  the inner model.
* There's a minor simplification to ToString, since String.Join already
  did what we wanted for one or many values.

Notable though is - because this class implements IConvertible,
it is no longer CLS compliant.  We do not currently mark this assembly
as CLS complient so as things stand that's OK.  I do not know if there
are any plans/expectations for CLS compliance in Elsa.

If we do plan to mark the assemblies as compliant then we must mark this
class [CLSCompliant(false)].
2021-03-25 21:10:25 +00:00
Craig Fowler ee7a8cdb1b
Merge pull request #775 from craigfowler/feature/738-Composite-Activities-may-be-triggers
Refactor for comprehension & add test coverage
2021-03-20 11:29:28 +00:00
Craig Fowler f91e224314 Fix intermittent failing tests
The issue here is that the elsa.db for sqlite is going in the same
path every time.  Depending on the order in which tests are run,
sometimes it means that migrations are run on a DB which is
expected to be empty but which already exists.  That causes an
error & test failure.

Here I've just used temp folders to ensure that the DB file is in a
different path every time.
2021-03-20 11:14:35 +00:00
Craig Fowler 2539f6425a WIP #738 - Integration tests for Trigger Indexer
One of these tests is failing and this is the one which
demonstrates issue #738. The composite activity which begins
with ReceiveSignal doesn't generate a trigger.
2021-03-20 10:42:41 +00:00
Craig Fowler 3943e64c70 WIP #738 - Add test coverage to replace big test
The large/complex test is now removed, replaced by
smaller/simpler unit tests for the individual units in
the overall process of getting triggers.
2021-03-19 19:45:16 +00:00
Craig Fowler 6700ac2402 WIP #738 - Simplify unit test
Now that the class is a little less complex, this
simplified unit test covers just what remains.
2021-03-18 21:22:19 +00:00
Craig Fowler 9ec698c7bc WIP #738 - Refactor a troublesome extension method
This extension method is quite complex and is frustrating
when a unit test passes-through it.  That's because extension
methods can't be mocked in tests.
2021-03-18 21:09:04 +00:00
Craig Fowler d9724e5267 WIP #738 - Refactor-out a further service
The triggers-for-activity-blueprint functionality
is quite complex just on its own, so I have moved this to
a new service.

Once again the integration test which is left behind proves
that it still does the same job.
2021-03-18 20:29:06 +00:00
Craig Fowler 654f3072d9 WIP #738 - Refactor some logic into services
This simplifies the unit a little and the test proves that
it still does the same thing overall.  Strictly speaking, this
is now an integration test.
2021-03-18 19:35:05 +00:00
Craig Fowler 1dee17b904 WIP #738 - Add test coverage for new service
This test passes, but as you can see it's
massive because of the complexity of what the
class has to do.
2021-03-18 18:54:23 +00:00
Sipke Schoorstra 0434b4825a Update packages 2021-03-18 11:24:04 +01:00
Sipke Schoorstra 0c15c94ea7
Telnyx Activities (#768)
* Fix liquid syntax for accessing activity output

* Initial scaffolding of Telnyx module + API changes

* Make Telnyx Notification activity blocking

* Implement Telnyx correlation

* Post workflow suspension tasks improvements

* Add Telnyx activities

* Add HangupCall and TransferCall activities

* Call activity improvements
2021-03-17 13:07:14 +01:00
Craig Fowler 4bc3539c4d
Merge branch 'feature/elsa-2.0' into feature/748-multi-tenant-EntityFramework 2021-03-14 13:51:06 +00:00
Craig Fowler 2320d216f2
Resolve #683 - Tests to prove no exception (#758)
As stated in the comments for
  WorkflowMayContainDuplicateActivitiesIntegrationTests

These tests might not describe actually-desired behaviour.
If they begin to "get in the way" in future, then it would
probably be safe to remove them.
2021-03-14 14:38:58 +01:00
Craig Fowler 4873aac316 Resolve #748 - Test coverage for EF Db Contexts
As well as providing a unit test which matches other persistence
provider tests (round-tripping a workflow instance), two other tests
are included here:

* When using the default DI registration extension method, this sets
  up pooling of DB contexts and so a resolved context will come from
  the pool.

* When using the non-pooled DI registration extension method, this
  sets up EF without pooling, which is more useful in a multi-tenanted
  environment.

There are also some other changes in this commit corresponding to
improving the tests.  Mainly de-duplicating logic & improving names.
2021-03-13 15:21:44 +00:00
Sipke Schoorstra 044caf533f MongoDB provider improvements 2021-03-11 22:50:50 +01:00
Craig Fowler 8751bead5a WIP #728 - Make WorkflowBurst default behaviour
In the comments to #728 it was suggested that
WorkflowBurst persistence behaviour was a more
sane default.
2021-03-09 19:57:45 +00:00
Craig Fowler 32bcf9a751 WIP #728 - Add test cases for persistence
This also includes a change to the workflow used in the test-case.
There are quite complex reasons for this, as explained here:

  https://github.com/elsa-workflows/elsa-core/issues/728#issuecomment-794319236

The real crux of it is that the workflow must have an activity
which suspends it, and that activity that suspends the workflow
must not be the starting activity.  This is why I added an unused
set-variable activity as the starter.

This commit shows that the various persistence test cases _mostly_
work OK, with the one exception of ActivityExecuted.
2021-03-09 19:57:02 +00:00
Craig Fowler 2c79a9395c WIP #728 - Add test for in-memory persistence
This test case shows that in-memory persistence is
also affected.  It seems that that would mean that this
issue is not related to only a single persistence provider.

In fact, in retrospect this is not really a persistence
problem at all, but a problem with the test case.  More
information is available in the comments to #728.
2021-03-09 19:56:14 +00:00
Craig Fowler 672e32a7ca WIP #552 - Add unit test to repro
Actually, this unit test does not repro the issue.
Frustratingly I can't get it to save the executed workflow
into MongoDB at all.  I see workflow execution logs
being saved, but the instance doesn't go in.

I'm not sure if this is a mistake I'm making or whether
I have found a different bug of some sort.
2021-03-06 17:22:37 +00:00
Craig Fowler cbc7c2d461 WIP #552 - Refactor test logic (reusability)
This refactor of integration test logic is to boost its
reusability.  Moving some functionality to attributes &
customization classes means I can reuse elsewhere without
duplication.
2021-03-06 13:55:19 +00:00
Craig Fowler ed81b5679a WIP #564 - Rename & alter temporal activity setup
Temporal activities no longer have a generalised extension method
for registering them with a service collecton.  It is still static and has
the same rough shape as an extension method.  This way it is less
visible and less likely to be called by accident.

Also in-line with changes in this branch, things have been renamed
  Timers → Temporal
2021-02-28 20:49:34 +01:00
Craig Fowler a61ecda036 WIP #564 - Add test coverage for app startup
This indicates that you can't start an app with just timer/temporal
activities, but you could start with either Hangfire or Quartz
activities.
2021-02-28 20:49:34 +01:00
Craig Fowler e340a37d93 Resolve #486 - Signal input is emitted as output
It actually turns out that no change is required to the SignalReceived
activity in order to achieve this.  As these unit tests prove & document,
that is already the current behaviour.
2021-02-27 20:00:54 +01:00
Craig Fowler df83b9a1de WIP #665 - Beginnings of SonarCloud integration
Adds an XUnit test logger to each test csproj
file (will be used by test script).

Also add a skeleton SonarCloud analysis config file with a couple
of settings for starters: Don't analyse exception classes or samples
for coverage.
2021-02-27 14:33:45 +00:00
Craig Fowler 8d4339f4b0 Revert "Merge branch 'feature/665-SonarCloud-integration' into feature/elsa-2.0"
This reverts commit 3dc1b79b3b, reversing
changes made to 1dbafd8ba2.

The previous merge of work on #665 broke the build so this commit
reverts it back out.
2021-02-27 13:58:06 +00:00
Craig Fowler 8deb1a1f56 WIP #665 - Beginnings of SonarCloud integration
Adds an XUnit test logger to each test csproj
file (will be used by test script).

Also add a skeleton SonarCloud analysis config file with a couple
of settings for starters: Don't analyse exception classes or samples
for coverage.
2021-02-27 12:41:55 +00:00
Craig Fowler f34409696d
Should resolve #653 - Reinstate tests in CI process for v2 branch (#658)
* WIP #653 - Delete two tests

These two couldn't easily be fixed, in both cases they were
integration tests which involved passing through many classes.
It wasn't immediately clear what needed to be done to fix them.

As noted in the issue description, removing them was an
acceptable fix.

* WIP #653 - Fix a failing test

I split this test into two.  Per the discussion at:
  https://github.com/xunit/xunit/issues/350
XUnit seems quite opinonated about not having assertion messages.
Thus, without changing assertion library (which deserves discussion
before I just do it), the logical next best thing is to split into two
single-assert tests, so it's clear which assertion failed on a test
failure.

Also, I moved the AutoMoqData attribute to the shared test lib, so
that it can be used anywhere.  That allowed me to eliminate the
constructor for this test class, except for initialising the base class.

* Provisionally resolve #653 - reinstate tests in CI

This should complete the issue although we need to see a
passing CI build with this code change before we can say
it's done.

* Provisionally resolves #653 - Add test script
2021-02-25 09:24:00 +01:00
Craig Fowler b583c7f1a9
Resolves #485 - Add PurgeVariables functionality (#654)
* Trivial - Add VS Code workspace

* Trivial - Add VSCode build task & extra ignore

On GNU/Linux, auto-generated .directory
files should be ignored.

* WIP #485 - Boilerplate for unit test project

* WIP #485 - Add test coverage (Remove/RemoveAll)

* WIP #485 - Implement RemoveAll

* Remove redundant logic, covered by IDictionary

Per the following, the contract for a generic IDictionary,
the Remove method already deals with non-existent keys.

  https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.idictionary-2.remove?view=net-5.0#System_Collections_Generic_IDictionary_2_Remove__0_

* Resolve #485 - Add PurgeVariables methods

These are convenience methods upon ActivityExecutionContext
and WorkflowExecutionContext, consistent with their current APIs.

Also in this commit are tests for those simple methods.
There's a bit of test-scaffold as well included, such as:
* Autofixture Xunit2 integration
* New project for unit tests
* Customize attribute for avoiding crashes on Autofixture recursion
* Reusable specimen builder for creating IServiceProvider which
  resolves services from Autofixture
* Custonize attribute for a parameter to use that ^^ specimen builder
2021-02-24 14:29:03 +01:00
Sipke Schoorstra f048e6d3ef
Refactor Switch builder API (#649)
* Refactor Switch builder API

* Remove unused namespaces
2021-02-20 20:47:56 +01:00
Sipke Schoorstra 0bf3fecf18 Rename IfElse to If 2021-02-20 15:56:32 +01:00
Sipke Schoorstra 86980a752e
Designer web component (#636)
* Activity picker dialog

* Activity picker

* Activity editor

* Activity property fields

* Blazor bindings for Elsa designer

* Only index triggers from published & enabled workflow definitions

* Handle case of null workflow blueprint not found

* Add check for zero duration and general scheduler exceptions

* Don't rethrow expression evaluation failure

* Workflow definition settings editor modal

* Integration between stencil and blazor 🎉

* Fix expression type conversion

* Add publish button and restructure components

* Fix up workflow definition ID vs workflow definition version ID

* Update EF Core migrations

* Fix Workflow Publisher

* Fix version display

* Add Import menu item
2021-02-16 09:55:13 +01:00
Sipke Schoorstra a02147d2ee Fix Finish + CompositeActivity 2021-02-13 11:16:20 +01:00
Sipke Schoorstra 7cfe24ba94
Implement revival of faulted workflow (#595)
* Initial version of workflow reviver

* Fix DI things

* Rename workflow builder parameter to `builder`

* Update EF Core stores to use short-lived db contexts

* Update serializer to use new settings to reset ID seed

* Write fault details

* Add faulty workflows sample project

* Switch to free & open source Z.EntityFramework.Plus.EFCore

* Add content type header

* Fix call to virtual OnSaving/OnLoading

* Fix retry
2021-01-30 12:47:50 +01:00
Sipke Schoorstra 59189bd330
Revise trigger API (#593)
* Update triggers

* Fix service registrations

* Add support for startup task ordering

* Add missing Rebus Activities project

* Handle indexing of many workflow instances

* Update sample

* Separate bookmarks from start triggers

* Add trigger API

* Fix queue worker

* Delete sqlite temp files
2021-01-29 16:16:45 +01:00
Sipke Schoorstra e6f42aca8f Update packages 2021-01-21 12:45:10 +01:00
Sipke Schoorstra fcfe7f08b4 Change For/While/ForEach/IfElse behavior
Before this change, the aforementioned activities would always schedule the Done outcome.
After this change, the Done outcome is scheduled **after** the Iterate branch and True or False branches have completed
2021-01-12 09:28:48 +01:00