Skip to content

Commit

Permalink
fix: TMS-30455: add features and stories sections for allure
Browse files Browse the repository at this point in the history
  • Loading branch information
taipoxinous committed Jan 10, 2025
1 parent 2dc6fc9 commit 43a3486
Show file tree
Hide file tree
Showing 26 changed files with 225 additions and 82 deletions.
3 changes: 3 additions & 0 deletions Migrators/AllureExporter/AllureExporter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<SelfContained>true</SelfContained>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<PublishSingleFile>false</PublishSingleFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
Expand Down
30 changes: 15 additions & 15 deletions Migrators/AllureExporter/Client/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public async Task<List<int>> GetTestCaseIdsFromMainSuite(int projectId)
}

var content = await response.Content.ReadAsStringAsync();
var testCases = JsonSerializer.Deserialize<AllureTestCases>(content);
var testCases = JsonSerializer.Deserialize<AllureTestCases>(content)!;
totalPages = testCases.TotalPages;

testCaseIds.AddRange(testCases.Content
Expand Down Expand Up @@ -141,7 +141,7 @@ public async Task<List<int>> GetTestCaseIdsFromSuite(int projectId, int suiteId)
}

var content = await response.Content.ReadAsStringAsync();
var testCases = JsonSerializer.Deserialize<AllureTestCases>(content);
var testCases = JsonSerializer.Deserialize<AllureTestCases>(content)!;
totalPages = testCases.TotalPages;

testCaseIds.AddRange(testCases.Content
Expand Down Expand Up @@ -180,7 +180,7 @@ public async Task<List<AllureSharedStep>> GetSharedStepsByProjectId(int projectI
}

var content = await response.Content.ReadAsStringAsync();
var sharedSteps = JsonSerializer.Deserialize<AllureSharedSteps>(content);
var sharedSteps = JsonSerializer.Deserialize<AllureSharedSteps>(content)!;
totalPages = sharedSteps.TotalPages;

allSharedSteps.AddRange(sharedSteps.Content);
Expand Down Expand Up @@ -211,7 +211,7 @@ public async Task<AllureTestCase> GetTestCaseById(int testCaseId)
}

var content = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<AllureTestCase>(content);
return JsonSerializer.Deserialize<AllureTestCase>(content)!;
}

public async Task<List<AllureStep>> GetSteps(int testCaseId)
Expand All @@ -230,7 +230,7 @@ public async Task<List<AllureStep>> GetSteps(int testCaseId)
}

var content = await response.Content.ReadAsStringAsync();
var steps = JsonSerializer.Deserialize<AllureSteps>(content);
var steps = JsonSerializer.Deserialize<AllureSteps>(content)!;

return steps.Steps;
}
Expand All @@ -251,7 +251,7 @@ public async Task<AllureStepsInfo> GetStepsInfoByTestCaseId(int testCaseId)
}

var content = await response.Content.ReadAsStringAsync();
var stepsInfo = JsonSerializer.Deserialize<AllureStepsInfo>(content);
var stepsInfo = JsonSerializer.Deserialize<AllureStepsInfo>(content)!;

return stepsInfo;
}
Expand All @@ -272,7 +272,7 @@ public async Task<AllureSharedStepsInfo> GetStepsInfoBySharedStepId(int sharedSt
}

var content = await response.Content.ReadAsStringAsync();
var sharedStepsInfo = JsonSerializer.Deserialize<AllureSharedStepsInfo>(content);
var sharedStepsInfo = JsonSerializer.Deserialize<AllureSharedStepsInfo>(content)!;

return sharedStepsInfo;
}
Expand All @@ -299,7 +299,7 @@ public async Task<List<AllureAttachment>> GetAttachmentsByTestCaseId(int testCas
}

var content = await response.Content.ReadAsStringAsync();
var attachments = JsonSerializer.Deserialize<AllureAttachmentContent>(content);
var attachments = JsonSerializer.Deserialize<AllureAttachmentContent>(content)!;
totalPages = attachments.TotalPages;

allAttachments.AddRange(attachments.Content);
Expand Down Expand Up @@ -334,7 +334,7 @@ public async Task<List<AllureAttachment>> GetAttachmentsBySharedStepId(int share
}

var content = await response.Content.ReadAsStringAsync();
var attachments = JsonSerializer.Deserialize<AllureAttachmentContent>(content);
var attachments = JsonSerializer.Deserialize<AllureAttachmentContent>(content)!;
totalPages = attachments.TotalPages;

allAttachments.AddRange(attachments.Content);
Expand Down Expand Up @@ -363,7 +363,7 @@ public async Task<List<AllureLink>> GetLinks(int testCaseId)
}

var content = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<List<AllureLink>>(content);
return JsonSerializer.Deserialize<List<AllureLink>>(content)!;
}

public async Task<List<BaseEntity>> GetSuites(int projectId)
Expand All @@ -382,7 +382,7 @@ public async Task<List<BaseEntity>> GetSuites(int projectId)
}

var content = await response.Content.ReadAsStringAsync();
var suites = JsonSerializer.Deserialize<BaseEntities>(content);
var suites = JsonSerializer.Deserialize<BaseEntities>(content)!;

return suites.Content.ToList();
}
Expand Down Expand Up @@ -436,7 +436,7 @@ public async Task<List<BaseEntity>> GetTestLayers()
}

var content = await response.Content.ReadAsStringAsync();
var layers = JsonSerializer.Deserialize<BaseEntities>(content);
var layers = JsonSerializer.Deserialize<BaseEntities>(content)!;

return layers.Content.ToList();
}
Expand All @@ -457,7 +457,7 @@ public async Task<List<BaseEntity>> GetCustomFieldNames(int projectId)
}

var content = await response.Content.ReadAsStringAsync();
var customFields = JsonSerializer.Deserialize<List<BaseEntity>>(content);
var customFields = JsonSerializer.Deserialize<List<BaseEntity>>(content)!;

return customFields;
}
Expand All @@ -478,7 +478,7 @@ public async Task<List<BaseEntity>> GetCustomFieldValues(int fieldId)
}

var content = await response.Content.ReadAsStringAsync();
var values = JsonSerializer.Deserialize<BaseEntities>(content);
var values = JsonSerializer.Deserialize<BaseEntities>(content)!;

return values.Content.ToList();
}
Expand All @@ -499,7 +499,7 @@ public async Task<List<AllureCustomField>> GetCustomFieldsFromTestCase(int testC
}

var content = await response.Content.ReadAsStringAsync();
var customFields = JsonSerializer.Deserialize<List<AllureCustomField>>(content);
var customFields = JsonSerializer.Deserialize<List<AllureCustomField>>(content)!;

return customFields;
}
Expand Down
6 changes: 3 additions & 3 deletions Migrators/AllureExporter/Models/AllureAttachment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ public class AllureAttachment
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
public string Name { get; set; } = string.Empty;

[JsonPropertyName("contentType")]
public string ContentType { get; set; }
public string ContentType { get; set; } = string.Empty;
}


public class AllureAttachmentContent
{
[JsonPropertyName("content")]
public List<AllureAttachment> Content { get; set; }
public List<AllureAttachment> Content { get; set; } = new ();

[JsonPropertyName("totalPages")]
public int TotalPages { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions Migrators/AllureExporter/Models/AllureCustomField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ namespace AllureExporter.Models;
public class AllureCustomField
{
[JsonPropertyName("name")]
public string Name { get; set; }
public string Name { get; set; } = string.Empty;

[JsonPropertyName("customField")]
public CustomField CustomField { get; set; }
public CustomField? CustomField { get; set; }
}

public class CustomField
{
[JsonPropertyName("name")]
public string Name { get; set; }
public string Name { get; set; } = string.Empty;
}

4 changes: 2 additions & 2 deletions Migrators/AllureExporter/Models/AllureLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace AllureExporter.Models;
public class AllureLink
{
[JsonPropertyName("name")]
public string Name { get; set; }
public string Name { get; set; } = string.Empty;
[JsonPropertyName("url")]
public string Url { get; set; }
public string Url { get; set; } = string.Empty;
}


16 changes: 8 additions & 8 deletions Migrators/AllureExporter/Models/AllureSharedStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace AllureExporter.Models;
public class AllureSharedSteps
{
[JsonPropertyName("content")]
public List<AllureSharedStep> Content { get; set; }
public List<AllureSharedStep> Content { get; set; } = new();

[JsonPropertyName("totalPages")]
public int TotalPages { get; set; }
Expand All @@ -21,32 +21,32 @@ public class AllureSharedStepBase
public class AllureSharedStep : AllureSharedStepBase
{
[JsonPropertyName("name")]
public string Name { get; set; }
public string Name { get; set; } = string.Empty;
}

public class AllureSharedStepInfo : AllureSharedStepBase
{
[JsonPropertyName("body")]
public string Name { get; set; }
public string Name { get; set; } = string.Empty;

[JsonPropertyName("children")]
public List<int> NestedStepIds { get; set; }
public List<int> NestedStepIds { get; set; } = new();
}

public class AllureScenarioRoot
{
[JsonPropertyName("children")]
public List<int> NestedStepIds { get; set; }
public List<int> NestedStepIds { get; set; } = new();
}

public class AllureSharedStepsInfo
{
[JsonPropertyName("root")]
public AllureScenarioRoot Root { get; set; }
public AllureScenarioRoot? Root { get; set; }

[JsonPropertyName("sharedStepScenarioSteps")]
public Dictionary<string, AllureScenarioStep> SharedStepScenarioStepsDictionary { get; set; }
public Dictionary<string, AllureScenarioStep> SharedStepScenarioStepsDictionary { get; set; } = new();

[JsonPropertyName("sharedStepAttachments")]
public Dictionary<string, AllureAttachment> SharedStepAttachmentsDictionary { get; set; }
public Dictionary<string, AllureAttachment> SharedStepAttachmentsDictionary { get; set; } = new();
}
16 changes: 8 additions & 8 deletions Migrators/AllureExporter/Models/AllureStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ namespace AllureExporter.Models;
public class AllureStep
{
[JsonPropertyName("name")]
public string Name { get; set; }
public string Name { get; set; } = string.Empty;

[JsonPropertyName("attachments")]
public List<AllureAttachment>? Attachments { get; set; }

[JsonPropertyName("steps")]
public List<AllureStep> Steps { get; set; }
public List<AllureStep> Steps { get; set; } = new();

[JsonPropertyName("keyword")]
public string Keyword { get; set; }
public string Keyword { get; set; } = string.Empty;

[JsonPropertyName("expectedResult")]
public string ExpectedResult { get; set; }
public string ExpectedResult { get; set; } = string.Empty;
}

public class AllureSteps
{
[JsonPropertyName("steps")]
public List<AllureStep> Steps { get; set; }
public List<AllureStep> Steps { get; set; } = new();
}

public class AllureScenarioStep
Expand All @@ -50,11 +50,11 @@ public class AllureScenarioStep
public class AllureStepsInfo : AllureSharedStepsInfo
{
[JsonPropertyName("scenarioSteps")]
public Dictionary<string, AllureScenarioStep> ScenarioStepsDictionary { get; set; }
public Dictionary<string, AllureScenarioStep> ScenarioStepsDictionary { get; set; } = new();

[JsonPropertyName("attachments")]
public Dictionary<string, AllureAttachment> AttachmentsDictionary { get; set; }
public Dictionary<string, AllureAttachment> AttachmentsDictionary { get; set; } = new();

[JsonPropertyName("sharedSteps")]
public Dictionary<string, AllureSharedStepInfo> SharedStepsDictionary { get; set; }
public Dictionary<string, AllureSharedStepInfo> SharedStepsDictionary { get; set; } = new();
}
16 changes: 8 additions & 8 deletions Migrators/AllureExporter/Models/AllureTestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace AllureExporter.Models;
public class AllureTestCases
{
[JsonPropertyName("content")]
public List<AllureTestCaseBase> Content { get; set; }
public List<AllureTestCaseBase> Content { get; set; } = new();

[JsonPropertyName("totalPages")]
public int TotalPages { get; set; }
Expand All @@ -24,16 +24,16 @@ public class AllureTestCaseBase
public class AllureTestCase : AllureTestCaseBase
{
[JsonPropertyName("name")]
public string Name { get; set; }
public string Name { get; set; } = string.Empty;

[JsonPropertyName("description")]
public string Description { get; set; }
public string Description { get; set; } = string.Empty;

[JsonPropertyName("tags")]
public List<Tags> Tags { get; set; }
public List<Tags> Tags { get; set; } = new();

[JsonPropertyName("status")]
public Status Status { get; set; }
public Status? Status { get; set; }

[JsonPropertyName("testLayer")]
public TestLayer? Layer { get; set; }
Expand All @@ -45,17 +45,17 @@ public class AllureTestCase : AllureTestCaseBase
public class Tags
{
[JsonPropertyName("name")]
public string Name { get; set; }
public string Name { get; set; } = string.Empty;
}

public class Status
{
[JsonPropertyName("name")]
public string Name { get; set; }
public string Name { get; set; } = string.Empty;
}

public class TestLayer
{
[JsonPropertyName("name")]
public string Name { get; set; }
public string Name { get; set; } = string.Empty;
}
4 changes: 2 additions & 2 deletions Migrators/AllureExporter/Models/BaseEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ public class BaseEntity
public int Id { get; set; }

[JsonPropertyName("name")]
public string Name { get; set; }
public string Name { get; set; } = string.Empty;
}

public class BaseEntities
{
[JsonPropertyName("content")]
public List<BaseEntity> Content { get; set; }
public List<BaseEntity> Content { get; set; } = new();
}


Expand Down
2 changes: 2 additions & 0 deletions Migrators/AllureExporter/Models/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ public class Constants
public const int MainSectionId = 0;
public const string AllureStatus = "AllureStatus";
public const string AllureTestLayer = "Test Layer";
public const string Feature = "Feature";
public const string Story = "Story";
}
2 changes: 1 addition & 1 deletion Migrators/AllureExporter/Services/ExportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public virtual async Task ExportProject()
var sharedSteps = await _sharedStepService.ConvertSharedSteps(project.Id, section.MainSection.Id, attributes);
var sharedStepsMap = sharedSteps.ToDictionary(k => k.Key.ToString(), v => v.Value.Id);
var testCases =
await _testCaseService.ConvertTestCases(project.Id, sharedStepsMap, customAttributes, section.SectionDictionary);
await _testCaseService.ConvertTestCases(project.Id, sharedStepsMap, customAttributes, section);

foreach (var sharedStep in sharedSteps)
{
Expand Down
3 changes: 2 additions & 1 deletion Migrators/AllureExporter/Services/ITestCaseService.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using AllureExporter.Models;
using Models;

namespace AllureExporter.Services;

public interface ITestCaseService
{
Task<List<TestCase>> ConvertTestCases(int projectId, Dictionary<string, Guid> sharedStepMap, Dictionary<string, Guid> attributes, Dictionary<int, Guid> sectionIdMap);
Task<List<TestCase>> ConvertTestCases(int projectId, Dictionary<string, Guid> sharedStepMap, Dictionary<string, Guid> attributes, SectionInfo sectionInfo);
}
Loading

0 comments on commit 43a3486

Please sign in to comment.