-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
10469 should fetch actual footer layout if it exists (#12843)
* Add endpoint in preview to get footer * Add tests * Fix PR comments * Simplify Footer definition class
- Loading branch information
Showing
17 changed files
with
177 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
using JetBrains.Annotations; | ||
|
||
namespace Altinn.Studio.Designer.Models; | ||
public class FooterFile | ||
{ | ||
[JsonPropertyName("$schema")] | ||
public string Schema { get; set; } | ||
|
||
[JsonPropertyName("footer")] | ||
public List<FooterLayout> Footer { get; set; } | ||
} | ||
|
||
public class FooterLayout | ||
{ | ||
[JsonPropertyName("type")] | ||
[JsonConverter(typeof(JsonStringEnumConverter))] | ||
public ComponentType Type { get; set; } | ||
|
||
[JsonPropertyName("title")] | ||
public string Title { get; set; } | ||
|
||
[JsonPropertyName("target")] | ||
[CanBeNull] | ||
public string Target { get; set; } | ||
|
||
[JsonPropertyName("icon")] | ||
[JsonConverter(typeof(JsonStringEnumConverter))] | ||
public IconType? Icon { get; set; } | ||
} | ||
|
||
public enum ComponentType | ||
{ | ||
Email, | ||
Link, | ||
Phone, | ||
Text | ||
} | ||
|
||
public enum IconType | ||
{ | ||
Information, | ||
Email, | ||
Phone | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
backend/tests/Designer.Tests/Controllers/PreviewController/GetFooterTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.IO; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Text.Json; | ||
using System.Threading.Tasks; | ||
using Altinn.Studio.Designer.Models; | ||
using Designer.Tests.Utils; | ||
using FluentAssertions; | ||
using Microsoft.AspNetCore.Mvc.Testing; | ||
using SharedResources.Tests; | ||
using Xunit; | ||
|
||
namespace Designer.Tests.Controllers.PreviewController | ||
{ | ||
public class GetFooterTests : PreviewControllerTestsBase<GetFooterTests>, IClassFixture<WebApplicationFactory<Program>> | ||
{ | ||
public GetFooterTests(WebApplicationFactory<Program> factory) : base(factory) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public async Task Get_Footer_Exists_Ok() | ||
{ | ||
string expectedFooter = TestDataHelper.GetFileFromRepo(Org, AppV4, Developer, "App/ui/footer.json"); | ||
FooterFile actualFooterFile = JsonSerializer.Deserialize<FooterFile>(expectedFooter); | ||
|
||
string dataPathWithData = $"{Org}/{AppV4}/api/v1/footer"; | ||
using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); | ||
|
||
using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); | ||
Assert.Equal(HttpStatusCode.OK, response.StatusCode); | ||
|
||
string responseString = await response.Content.ReadAsStringAsync(); | ||
FooterFile responseFooterFile = JsonSerializer.Deserialize<FooterFile>(responseString); | ||
|
||
responseFooterFile.Footer.Should().BeEquivalentTo(actualFooterFile.Footer); | ||
} | ||
|
||
[Fact] | ||
public async Task Get_Footer_Non_Existing_Ok() | ||
{ | ||
string dataPathWithData = $"{Org}/{AppV3}/api/v1/footer"; | ||
using HttpRequestMessage httpRequestMessage = new(HttpMethod.Get, dataPathWithData); | ||
|
||
using HttpResponseMessage response = await HttpClient.SendAsync(httpRequestMessage); | ||
Assert.Equal(HttpStatusCode.OK, response.StatusCode); | ||
|
||
string responseString = await response.Content.ReadAsStringAsync(); | ||
responseString.Should().BeEmpty(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...Designer.Tests/_TestData/Repositories/testUser/ttd/app-with-layoutsets/App/ui/footer.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"$schema": "https://altinncdn.no/toolkits/altinn-app-frontend/4/schemas/json/layout/footer.schema.v1.json", | ||
"footer": [ | ||
{ | ||
"type": "Text", | ||
"title": "**Frontend Test**<br>*Testdepartementet*" | ||
}, | ||
{ | ||
"type": "Link", | ||
"icon": "information", | ||
"title": "general.accessibility", | ||
"target": "general.accessibility_url" | ||
}, | ||
{ | ||
"type": "Email", | ||
"title": "hjelp@etaten.no", | ||
"target": "hjelp@etaten.no" | ||
}, | ||
{ | ||
"type": "Phone", | ||
"title": "+47 987 65 432", | ||
"target": "+4798765432" | ||
} | ||
] | ||
} |