Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ON-45075 # Add disableAutosave to Form #342

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Setup .NET SDK 6.0.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: "6.0.x"
- name: Setup .NET SDK 8.0.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"
- name: Setup .NET SDK 9.0.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: "9.0.x"
- uses: microsoft/DevSkim-Action@v1
- uses: github/codeql-action/upload-sarif@v2
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup .NET SDK 6.0.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: "6.0.x"
- name: Setup .NET SDK 8.0.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"
- name: Setup .NET SDK 9.0.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: "9.0.x"
- uses: microsoft/DevSkim-Action@v1
- uses: github/codeql-action/upload-sarif@v2
with:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

### Added

- `disableAutosave` to `Form`

### Added

- `nodes` and `type` to `FormApprovalFlowInstanceStep` and `FormApprovalStep`

## [9.0.0] - 2024-11-13
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ FormsClient formsClient = new FormsClient(ACCESS_KEY, SECRET_KEY, TenantName.ONE

### Prerequisites

- .Net runtime installed (at least one of .Net 6.0, .Net 7.0)
- .Net runtime installed (at least one of .Net 8.0, .Net 9.0)

## Security linter

Expand All @@ -31,7 +31,7 @@ SECRET_KEY=YOUR_SECRET_KEY

### Target frameworks

By default the tests will run against runtimes .Net 6.0, .Net 7.0 and .Net 8.0
By default the tests will run against runtimes .Net 8.0, and .Net 9.0
You can modify the `<TargetFramework>` value in ./OneBlink.SDK.Tests/OneBlink.SDK.Tests.csProj to the runtime/s you have available eg. `net8.0`

### Running tests
Expand Down Expand Up @@ -90,7 +90,7 @@ dotnet test

#### Prerequisites

- .Net SDK installed (at least one of .Net 6.0, .Net 7.0)
- .Net SDK installed (at least one of .Net 8.0, .Net 9.0)

1. Clone this repository

Expand Down
2 changes: 1 addition & 1 deletion OneBlink.SDK.Tests/FormElementLookupsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public async void can_search_form_element_lookups()
[Fact]
public async void can_crud_form_element_lookups()
{
FormElementLookupsClient formElementLookupsClient = new FormElementLookupsClient(ACCESS_KEY, SECRET_KEY, TenantName.ONEBLINK_TEST);
FormElementLookup newFormElementLookup = new FormElementLookup();
newFormElementLookup.name = "Unit test environment";
newFormElementLookup.type = "DATA";
Expand All @@ -68,7 +69,6 @@ public async void can_crud_form_element_lookups()
}
};

FormElementLookupsClient formElementLookupsClient = new FormElementLookupsClient(ACCESS_KEY, SECRET_KEY, TenantName.ONEBLINK_TEST);
FormElementLookup savedFormElementLookup = await formElementLookupsClient.Create(newFormElementLookup);
Assert.NotNull(savedFormElementLookup);

Expand Down
6 changes: 4 additions & 2 deletions OneBlink.SDK.Tests/FormsAppEnvironmentsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
using Xunit;
using OneBlink.SDK.Model;
using System.Net;

// Need to each test run sequenatially, both within the assembly and with in the class, as certain resources (e.g. s3 bucket) are shared
// NOTE: This assembly directive applies to the whole test project
[assembly: CollectionBehavior(CollectionBehavior.CollectionPerClass, DisableTestParallelization = true)]
namespace OneBlink.SDK.Tests
{
public class FormsAppEnvironmentsClientTests
Expand Down Expand Up @@ -56,13 +58,13 @@ public async void can_search_forms_app_environments()
[Fact]
public async void can_crud_forms_app_environments()
{
FormsAppEnvironmentsClient formsAppEnvironmentsClient = new FormsAppEnvironmentsClient(ACCESS_KEY, SECRET_KEY, TenantName.ONEBLINK_TEST);
FormsAppEnvironment newFormsAppEnvironment = new FormsAppEnvironment();
newFormsAppEnvironment.name = "Unit test environment";
newFormsAppEnvironment.description = "Created via unit test";
newFormsAppEnvironment.organisationId = organisationId;
newFormsAppEnvironment.slug = "unit-test-environment-" + DateTime.Now.ToFileTimeUtc().ToString();

FormsAppEnvironmentsClient formsAppEnvironmentsClient = new FormsAppEnvironmentsClient(ACCESS_KEY, SECRET_KEY, TenantName.ONEBLINK_TEST);
FormsAppEnvironment savedFormsAppEnvironment = await formsAppEnvironmentsClient.Create(newFormsAppEnvironment);
Assert.NotNull(savedFormsAppEnvironment);

Expand Down
21 changes: 5 additions & 16 deletions OneBlink.SDK.Tests/FormsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,6 @@ public async void can_get_submission_data()
FormsClient forms = new FormsClient(ACCESS_KEY, SECRET_KEY, TenantName.ONEBLINK_TEST);
FormSubmission<object> formSubmission = await forms.GetFormSubmission<object>(this.formId, this.submissionId);
Assert.NotNull(formSubmission);
if (formSubmission.device != null)
{
foreach (PropertyInfo propertyInfo in formSubmission.device.GetType().GetProperties())
{
Console.WriteLine("Device: {0}={1}", propertyInfo.Name, propertyInfo.GetValue(formSubmission.device, null));
}
}
if (formSubmission.user != null)
{
foreach (PropertyInfo propertyInfo in formSubmission.user.GetType().GetProperties())
{
Console.WriteLine("User: {0}={1}", propertyInfo.Name, propertyInfo.GetValue(formSubmission.user, null));
}
}
}

[Fact]
Expand Down Expand Up @@ -181,7 +167,8 @@ public async void can_crud_form()
DateTime endDate = DateTime.Today.AddDays(10);
Form newForm = new Form();
newForm.name = "Unit test";
newForm.slug = "unit-test";
string slug = "unit-test-" + DateTime.Now.ToString("o").Replace(":", "-").Replace(".", "-").Replace("+", "-").ToLower();
newForm.slug = slug;
newForm.description = "Created via unit test";
newForm.organisationId = organisationId;
newForm.isAuthenticated = false;
Expand Down Expand Up @@ -283,7 +270,7 @@ public async void can_crud_form()
Assert.NotNull(savedForm);
Form retrievedForm = await formsClient.Get(savedForm.id, true);
Assert.NotNull(retrievedForm);
Assert.Equal(newForm.slug, retrievedForm.slug);
Assert.Equal(slug, retrievedForm.slug);
Assert.Equal(tags, retrievedForm.tags);
Assert.Equal(newForm.postSubmissionReceipt.html, retrievedForm.postSubmissionReceipt.html);
// Need to convert these to UTC time as that is what comes from api, and these dates are in local time
Expand All @@ -294,6 +281,7 @@ public async void can_crud_form()
retrievedForm.description = updatedDescription;
Form updatedForm = await formsClient.Update(retrievedForm);
Assert.Equal(updatedDescription, updatedForm.description);
System.Threading.Thread.Sleep(5000); // give the API time to finish upserting s3 resources before deleting the form
await formsClient.Delete(updatedForm.id);

var oneBlinkAPIException = await Assert.ThrowsAsync<OneBlink.SDK.OneBlinkAPIException>(() => formsClient.Get(updatedForm.id, true));
Expand Down Expand Up @@ -322,6 +310,7 @@ public async void can_create_with_defaults()
)
};
Form updatedForm = await formsClient.Update(savedForm);
System.Threading.Thread.Sleep(5000); // give the API time to finish upserting s3 resources before deleting the form

await formsClient.Delete(updatedForm.id);
}
Expand Down
2 changes: 1 addition & 1 deletion OneBlink.SDK.Tests/OneBlink.SDK.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<RootNamespace>unit_tests</RootNamespace>

<IsPackable>false</IsPackable>
Expand Down
8 changes: 7 additions & 1 deletion OneBlink.SDK/models/Form.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public Form(
List<string> customCssClasses = default,
Guid? pointAddressEnvironmentId = null,
bool? allowGeoscapeAddresses = null,
FormEnableSubmission enableSubmission = null
FormEnableSubmission enableSubmission = null,
bool? disableAutosave = null
)
{
if (id.HasValue)
Expand Down Expand Up @@ -153,6 +154,7 @@ public Form(
this.pointAddressEnvironmentId = pointAddressEnvironmentId ?? null;
this.allowGeoscapeAddresses = allowGeoscapeAddresses ?? null;
this.enableSubmission = enableSubmission;
this.disableAutosave = disableAutosave;
}
public long id
{
Expand Down Expand Up @@ -302,5 +304,9 @@ public FormEnableSubmission enableSubmission
{
get; set;
}
public bool? disableAutosave
{
get; set;
}
}
}
1 change: 1 addition & 0 deletions docs/models/Form.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
| `allowGeoscapeAddresses` | No | `bool?` | Optional configuration to allow use of Geoscape elements on the form | `null` |
| `slug` | No | `string` | Unique domain safe text to identify the form | `null` |
| `enableSubmission` | No | `FormEnableSubmission` | Conditionally enable form submission | `null` |
| `disableAutosave` | No | `bool?` | Optionally disable autosave | `null` |

### Other properties

Expand Down
Loading