Skip to content

Commit

Permalink
[ADMINAPI-1044] - Add more e2e tests to cover scenarios where the off…
Browse files Browse the repository at this point in the history
…set and limit are not required (#146)

- Update DBTest to test optional offset and limit
- Add E2E test to validate optional offset and limit
  • Loading branch information
jleiva-gap authored Aug 20, 2024
1 parent 0199f8e commit d83f24d
Show file tree
Hide file tree
Showing 10 changed files with 2,746 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,91 @@ public void ShouldGetAllInstancesWithOffsetAndLimit()
});
}

[Test]
public void ShouldGetAllInstancesWithoutOffsetAndLimit()
{
Transaction(usersContext =>
{
CreateMultiple();
var command = new GetOdsInstancesQuery(usersContext, Testing.GetAppSettings());
var odsInstancesAfterOffset = command.Execute(new CommonQueryParams(), null, null, null);
odsInstancesAfterOffset.ShouldNotBeEmpty();
odsInstancesAfterOffset.Count.ShouldBe(5);
odsInstancesAfterOffset.ShouldContain(odsI => odsI.Name == "test ods instance 1");
odsInstancesAfterOffset.ShouldContain(odsI => odsI.Name == "test ods instance 2");
odsInstancesAfterOffset = command.Execute(new CommonQueryParams(), null, null, null);
odsInstancesAfterOffset.ShouldNotBeEmpty();
odsInstancesAfterOffset.Count.ShouldBe(5);
odsInstancesAfterOffset.ShouldContain(odsI => odsI.Name == "test ods instance 3");
odsInstancesAfterOffset.ShouldContain(odsI => odsI.Name == "test ods instance 4");
odsInstancesAfterOffset = command.Execute(new CommonQueryParams(), null, null, null);
odsInstancesAfterOffset.ShouldNotBeEmpty();
odsInstancesAfterOffset.Count.ShouldBe(5);
odsInstancesAfterOffset.ShouldContain(odsI => odsI.Name == "test ods instance 5");
});
}
[Test]
public void ShouldGetAllInstancesWithoutLimit()
{
Transaction(usersContext =>
{
CreateMultiple();
var offset = 0;
var command = new GetOdsInstancesQuery(usersContext, Testing.GetAppSettings());
var odsInstancesAfterOffset = command.Execute(new CommonQueryParams(offset, null), null, null, null);
odsInstancesAfterOffset.ShouldNotBeEmpty();
odsInstancesAfterOffset.Count.ShouldBe(5);
odsInstancesAfterOffset.ShouldContain(odsI => odsI.Name == "test ods instance 1");
odsInstancesAfterOffset.ShouldContain(odsI => odsI.Name == "test ods instance 2");
offset = 2;
odsInstancesAfterOffset = command.Execute(new CommonQueryParams(offset, null), null, null, null);
odsInstancesAfterOffset.ShouldNotBeEmpty();
odsInstancesAfterOffset.Count.ShouldBe(3);
odsInstancesAfterOffset.ShouldContain(odsI => odsI.Name == "test ods instance 3");
odsInstancesAfterOffset.ShouldContain(odsI => odsI.Name == "test ods instance 4");
offset = 4;
odsInstancesAfterOffset = command.Execute(new CommonQueryParams(offset, null), null, null, null);
odsInstancesAfterOffset.ShouldNotBeEmpty();
odsInstancesAfterOffset.Count.ShouldBe(1);
odsInstancesAfterOffset.ShouldContain(odsI => odsI.Name == "test ods instance 5");
});
}

[Test]
public void ShouldGetAllInstancesWithoutOffset()
{
Transaction(usersContext =>
{
CreateMultiple();
var limit = 2;
var command = new GetOdsInstancesQuery(usersContext, Testing.GetAppSettings());
var odsInstancesAfterOffset = command.Execute(new CommonQueryParams(null, limit), null, null, null);
odsInstancesAfterOffset.ShouldNotBeEmpty();
odsInstancesAfterOffset.Count.ShouldBe(2);
odsInstancesAfterOffset.ShouldContain(odsI => odsI.Name == "test ods instance 1");
odsInstancesAfterOffset.ShouldContain(odsI => odsI.Name == "test ods instance 2");
});
}

[Test]
public void ShouldGetAllInstancesWithId()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,264 @@
}
},
"response": []
},
{
"name": "Authstrategies - Without Offset and Limit",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"GET Actions: Status code is OK\", function () {\r",
" pm.response.to.have.status(200);\r",
"});\r",
"\r",
"const response = pm.response.json();\r",
"\r",
"pm.test(\"GET Actions: Response matches success format\", function () {\r",
" if (response && response.length > 0) {\r",
" pm.expect(response[0]).to.have.property(\"id\");\r",
" pm.expect(response[0]).to.have.property(\"name\");\r",
" pm.expect(response[0]).to.have.property(\"uri\");\r",
" }\r",
"});\r",
"\r",
"const GetActionsSchema = {\r",
" \"type\": \"array\",\r",
" \"items\": [\r",
" {\r",
" \"type\": \"object\",\r",
" \"properties\": {\r",
" \"id\": {\r",
" \"type\": \"integer\"\r",
" },\r",
" \"name\": {\r",
" \"type\": \"string\"\r",
" },\r",
" \"uri\": {\r",
" \"type\": \"string\"\r",
" }\r",
" },\r",
" \"required\": [\r",
" \"id\",\r",
" \"name\",\r",
" \"uri\"\r",
" ]\r",
" }\r",
" ]\r",
"}\r",
"\r",
"pm.test(\"GET Actions: Validation Schema Response\", () => {\r",
" pm.response.to.have.jsonSchema(GetActionsSchema);\r",
"});\r",
""
],
"type": "text/javascript",
"packages": {}
}
},
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{API_URL}}/v2/actions",
"host": [
"{{API_URL}}"
],
"path": [
"v2",
"actions"
]
}
},
"response": []
},
{
"name": "Authstrategies - Without Offset",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"GET Actions: Status code is OK\", function () {\r",
" pm.response.to.have.status(200);\r",
"});\r",
"\r",
"const response = pm.response.json();\r",
"\r",
"pm.test(\"GET Actions: Response matches success format\", function () {\r",
" if (response && response.length > 0) {\r",
" pm.expect(response[0]).to.have.property(\"id\");\r",
" pm.expect(response[0]).to.have.property(\"name\");\r",
" pm.expect(response[0]).to.have.property(\"uri\");\r",
" }\r",
"});\r",
"\r",
"const GetActionsSchema = {\r",
" \"type\": \"array\",\r",
" \"items\": [\r",
" {\r",
" \"type\": \"object\",\r",
" \"properties\": {\r",
" \"id\": {\r",
" \"type\": \"integer\"\r",
" },\r",
" \"name\": {\r",
" \"type\": \"string\"\r",
" },\r",
" \"uri\": {\r",
" \"type\": \"string\"\r",
" }\r",
" },\r",
" \"required\": [\r",
" \"id\",\r",
" \"name\",\r",
" \"uri\"\r",
" ]\r",
" }\r",
" ]\r",
"}\r",
"\r",
"pm.test(\"GET Actions: Validation Schema Response\", () => {\r",
" pm.response.to.have.jsonSchema(GetActionsSchema);\r",
"});\r",
""
],
"type": "text/javascript",
"packages": {}
}
},
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{API_URL}}/v2/actions?limit={{limit}}",
"host": [
"{{API_URL}}"
],
"path": [
"v2",
"actions"
],
"query": [
{
"key": "limit",
"value": "{{limit}}"
}
]
}
},
"response": []
},
{
"name": "Authstrategies - Without Limit",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"GET Actions: Status code is OK\", function () {\r",
" pm.response.to.have.status(200);\r",
"});\r",
"\r",
"const response = pm.response.json();\r",
"\r",
"pm.test(\"GET Actions: Response matches success format\", function () {\r",
" if (response && response.length > 0) {\r",
" pm.expect(response[0]).to.have.property(\"id\");\r",
" pm.expect(response[0]).to.have.property(\"name\");\r",
" pm.expect(response[0]).to.have.property(\"uri\");\r",
" }\r",
"});\r",
"\r",
"const GetActionsSchema = {\r",
" \"type\": \"array\",\r",
" \"items\": [\r",
" {\r",
" \"type\": \"object\",\r",
" \"properties\": {\r",
" \"id\": {\r",
" \"type\": \"integer\"\r",
" },\r",
" \"name\": {\r",
" \"type\": \"string\"\r",
" },\r",
" \"uri\": {\r",
" \"type\": \"string\"\r",
" }\r",
" },\r",
" \"required\": [\r",
" \"id\",\r",
" \"name\",\r",
" \"uri\"\r",
" ]\r",
" }\r",
" ]\r",
"}\r",
"\r",
"pm.test(\"GET Actions: Validation Schema Response\", () => {\r",
" pm.response.to.have.jsonSchema(GetActionsSchema);\r",
"});\r",
""
],
"type": "text/javascript",
"packages": {}
}
},
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{API_URL}}/v2/actions?offset={{offset}}",
"host": [
"{{API_URL}}"
],
"path": [
"v2",
"actions"
],
"query": [
{
"key": "offset",
"value": "{{offset}}"
}
]
}
},
"response": []
}
]
}
Expand Down
Loading

0 comments on commit d83f24d

Please sign in to comment.