Skip to content

Commit 0d1c425

Browse files
authored
Playwright test: Get All Submodel Elements Endpoint(#199)
1 parent 41aaf01 commit 0d1c425

6 files changed

Lines changed: 3339 additions & 0 deletions

source/AAS.TwinEngine.Plugin.TestPlugin.PlaywrightTests/AAS.TwinEngine.Plugin.TestPlugin.PlaywrightTests.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,18 @@
114114
<None Update="SubmodelRepository\TestData\GetAllSubmodels_Expected.json">
115115
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
116116
</None>
117+
<None Update="SubmodelRepository\TestData\GetAllSubmodelElements_ContactInfo_WithLimit100_LevelDeep_ExtentWithBlobValue_Expected.json">
118+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
119+
</None>
120+
<None Update="SubmodelRepository\TestData\GetAllSubmodelElements_ContactInfo_With_Limit1_Expected.json">
121+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
122+
</None>
123+
<None Update="SubmodelRepository\TestData\GetAllSubmodelElements_ContactInfo_With_Limit1_And_Cursor_Expected.json">
124+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
125+
</None>
126+
<None Update="SubmodelRepository\TestData\GetAllSubmodelElements_ContactInfo_With_Cursor_Expected.json">
127+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
128+
</None>
117129
<None Update="Discovery\TestData\GetSpecificAssetIdByAasIdentifier_Expected.json">
118130
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
119131
</None>

source/AAS.TwinEngine.Plugin.TestPlugin.PlaywrightTests/SubmodelRepository/SubmodelElementTests.cs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,83 @@ public async Task GetSubmodelElement_CustomSubmodel_OperatingConditionsOfReliabi
6666

6767
await CompareJsonAsync(json, Path.Combine(Directory.GetCurrentDirectory(), "SubmodelRepository", "TestData", "GetSubmodelElement_CustomSubmodel_OperatingConditionsOfReliabilityCharacteristics.json"));
6868
}
69+
70+
[Fact]
71+
public async Task GetAllSubmodelElements_ContactInfo_WithLimit100_LevelDeep_ExtentWithBlobValue_ShouldReturnSuccess_WithPagedResultShape()
72+
{
73+
// Arrange
74+
var url = $"/submodels/{SubmodelIdentifierContact}/submodel-elements?limit=100&level=deep&extent=withBlobValue";
75+
76+
// Act
77+
var response = await ApiContext.GetAsync(url);
78+
79+
// Assert
80+
AssertSuccessResponse(response);
81+
var content = await response.TextAsync();
82+
Assert.False(string.IsNullOrEmpty(content));
83+
84+
var json = JsonDocument.Parse(content);
85+
Assert.NotNull(json);
86+
87+
await CompareJsonAsync(json, Path.Combine(Directory.GetCurrentDirectory(), "SubmodelRepository", "TestData", "GetAllSubmodelElements_ContactInfo_WithLimit100_LevelDeep_ExtentWithBlobValue_Expected.json"));
88+
}
89+
90+
[Fact]
91+
public async Task GetAllSubmodelElements_ContactInfo_WithLimit1_ShouldReturnAtMostOneResult()
92+
{
93+
// Arrange
94+
var url = $"/submodels/{SubmodelIdentifierContact}/submodel-elements?limit=1";
95+
96+
// Act
97+
var response = await ApiContext.GetAsync(url);
98+
99+
// Assert
100+
AssertSuccessResponse(response);
101+
var content = await response.TextAsync();
102+
Assert.False(string.IsNullOrEmpty(content));
103+
104+
var json = JsonDocument.Parse(content);
105+
Assert.NotNull(json);
106+
await CompareJsonAsync(json, Path.Combine(Directory.GetCurrentDirectory(), "SubmodelRepository", "TestData", "GetAllSubmodelElements_ContactInfo_With_Limit1_Expected.json"));
107+
}
108+
109+
[Fact]
110+
public async Task GetAllSubmodelElements_ContactInfo_WithLimit1AndCursor_ShouldReturnAtMostOneResult()
111+
{
112+
// Arrange
113+
var cursor = "Q29udGFjdEluZm9ybWF0aW9uMA";
114+
var url = $"/submodels/{SubmodelIdentifierContact}/submodel-elements?limit=1&cursor={cursor}";
115+
116+
// Act
117+
var response = await ApiContext.GetAsync(url);
118+
119+
// Assert
120+
AssertSuccessResponse(response);
121+
var content = await response.TextAsync();
122+
Assert.False(string.IsNullOrEmpty(content));
123+
124+
var json = JsonDocument.Parse(content);
125+
Assert.NotNull(json);
126+
await CompareJsonAsync(json, Path.Combine(Directory.GetCurrentDirectory(), "SubmodelRepository", "TestData", "GetAllSubmodelElements_ContactInfo_With_Limit1_And_Cursor_Expected.json"));
127+
}
128+
129+
[Fact]
130+
public async Task GetAllSubmodelElements_ContactInfo_WithCursor_ShouldReturnSuccess_WithPagedResultShape()
131+
{
132+
// Arrange
133+
var cursor = "Q29udGFjdEluZm9ybWF0aW9uMA";
134+
var url = $"/submodels/{SubmodelIdentifierContact}/submodel-elements?cursor={cursor}";
135+
136+
// Act
137+
var response = await ApiContext.GetAsync(url);
138+
139+
// Assert
140+
AssertSuccessResponse(response);
141+
var content = await response.TextAsync();
142+
Assert.False(string.IsNullOrEmpty(content));
143+
144+
var json = JsonDocument.Parse(content);
145+
Assert.NotNull(json);
146+
await CompareJsonAsync(json, Path.Combine(Directory.GetCurrentDirectory(), "SubmodelRepository", "TestData", "GetAllSubmodelElements_ContactInfo_With_Cursor_Expected.json"));
147+
}
69148
}

0 commit comments

Comments
 (0)