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

[AI Test Tool] Improve compare page #1927

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ permissionset 149033 "AI Test Toolkit - Read"

IncludedPermissionSets = "AI Test Toolkit - Obj";

Permissions = tabledata "AIT Test Suite" = R,
Permissions = tabledata "AIT Run History" = R,
tabledata "AIT Test Suite" = R,
tabledata "AIT Test Method Line" = R,
tabledata "AIT Log Entry" = R;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ permissionset 149034 "AI Test Toolkit - View"

IncludedPermissionSets = "AI Test Toolkit - Read";

Permissions = tabledata "AIT Test Suite" = IMD,
Permissions = tabledata "AIT Run History" = IMD,
tabledata "AIT Test Suite" = IMD,
tabledata "AIT Test Method Line" = IMD,
tabledata "AIT Log Entry" = IMD;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,26 @@ permissionset 149031 "AI Test Toolkit - Obj"
Assignable = false;
Access = Public;

Permissions = table "AIT Test Suite" = X,
Permissions = table "AIT Run History" = X,
table "AIT Test Suite" = X,
table "AIT Test Method Line" = X,
table "AIT Log Entry" = X,
codeunit "AIT Test Suite Mgt." = X,
codeunit "AIT AL Test Suite Mgt" = X,
codeunit "AIT Install" = X,
codeunit "AIT Log Entry" = X,
codeunit "AIT Test Suite Mgt." = X,
codeunit "AIT Test Run Iteration" = X,
codeunit "AIT Test Context" = X,
codeunit "AIT Test Context Impl." = X,
xmlport "AIT Test Suite Import/Export" = X,
page "AIT CommandLine Card" = X,
page "AIT Test Data" = X,
page "AIT Test Data Compare" = X,
page "AIT Test Method Lines" = X,
page "AIT Test Method Lines Compare" = X,
page "AIT Test Method Lines Lookup" = X,
page "AIT Log Entries" = X,
page "AIT Log Entry API" = X,
page "AIT Test Suite" = X,
page "AIT Test Suite List" = X;
page "AIT Test Suite List" = X,
page "AIT Run History" = X;
}
27 changes: 24 additions & 3 deletions src/Tools/AI Test Toolkit/src/Logs/AITLogEntries.Page.al
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ page 149033 "AIT Log Entries"
ToolTip = 'Specifies the test input of the test.';

trigger OnDrillDown()
var
AITTestData: Page "AIT Test Data Compare";
begin
Message(Rec.GetInputBlob());
AITTestData.SetRecord(Rec);
AITTestData.Run();
end;
}
field("Output Text"; OutputText)
Expand All @@ -97,8 +100,11 @@ page 149033 "AIT Log Entries"
ToolTip = 'Specifies the test output of the test.';

trigger OnDrillDown()
var
AITTestData: Page "AIT Test Data Compare";
begin
Message(Rec.GetOutputBlob());
AITTestData.SetRecord(Rec);
AITTestData.Run();
end;
}
field("Tokens Consumed"; Rec."Tokens Consumed")
Expand Down Expand Up @@ -241,7 +247,20 @@ page 149033 "AIT Log Entries"
begin
AITALTestSuiteMgt.DownloadTestOutputFromLogToFile(Rec);
end;
}
action("View Test Data")
{
Caption = 'View Test Data';
Image = CompareCOA;
ToolTip = 'View Test Data.';

trigger OnAction()
var
AITTestData: Page "AIT Test Data Compare";
begin
AITTestData.SetRecord(Rec);
AITTestData.Run();
end;
}
}
area(Promoted)
Expand All @@ -266,6 +285,9 @@ page 149033 "AIT Log Entries"
actionref("Download Test Output_Promoted"; "Download Test Output")
{
}
actionref("View Test Data_Promoted"; "View Test Data")
{
}
}
}
}
Expand Down Expand Up @@ -317,7 +339,6 @@ page 149033 "AIT Log Entries"
begin
InputText := '';
OutputText := '';

if Rec.Sensitive and not ShowSensitiveData then begin
Rec.CalcFields("Input Data", "Output Data");
if Rec."Input Data".Length > 0 then
Expand Down
144 changes: 143 additions & 1 deletion src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,163 @@

namespace System.TestTools.AITestToolkit;

using System.TestTools.TestRunner;

codeunit 149032 "AIT Log Entry"
{
Access = Internal;

var
LineNoFilterLbl: Label 'Codeunit %1 "%2" (Input: %3)', Locked = true;

procedure DrillDownFailedAITLogEntries(AITSuiteCode: Code[100]; LineNo: Integer; VersionNo: Integer)
var
AITLogEntries: Record "AIT Log Entry";
begin
AITLogEntries.SetRange(Version, VersionNo);
DrillDownFailedAITLogEntries(AITLogEntries, AITSuiteCode, LineNo);
end;

procedure DrillDownFailedAITLogEntries(AITSuiteCode: Code[100]; LineNo: Integer; Tag: Text[20])
var
AITLogEntries: Record "AIT Log Entry";
begin
AITLogEntries.SetRange(Tag, Tag);
DrillDownFailedAITLogEntries(AITLogEntries, AITSuiteCode, LineNo);
end;

local procedure DrillDownFailedAITLogEntries(var AITLogEntries: Record "AIT Log Entry"; AITSuiteCode: Code[100]; LineNo: Integer)
var
AITLogEntry: Page "AIT Log Entries";
begin
AITLogEntries.SetFilterForFailedTestProcedures();
AITLogEntries.SetRange("Test Suite Code", AITSuiteCode);
AITLogEntries.SetRange(Version, VersionNo);
if LineNo <> 0 then
AITLogEntries.SetRange("Test Method Line No.", LineNo);
AITLogEntry.SetTableView(AITLogEntries);
AITLogEntry.Run();
end;

procedure UpdateRunHistory(Code: Code[100]; LineNo: Integer; AITViewBy: Enum "AIT Run History - View By"; var TempAITRunHistory: Record "AIT Run History" temporary)
var
AITRunHistory: Record "AIT Run History";
SeenTags: List of [Text[20]];
begin
TempAITRunHistory.DeleteAll();
AITRunHistory.SetRange("Test Suite Code", Code);

if AITViewBy = AITViewBy::Version then
if AITRunHistory.FindSet() then
repeat
TempAITRunHistory.TransferFields(AITRunHistory);
TempAITRunHistory.Insert();
until AITRunHistory.Next() = 0;

if AITViewBy = AITViewBy::Tag then
if AITRunHistory.FindSet() then
repeat
if not SeenTags.Contains(AITRunHistory.Tag) then begin
TempAITRunHistory.TransferFields(AITRunHistory);
TempAITRunHistory.Insert();
end;
SeenTags.Add(AITRunHistory.Tag);
until AITRunHistory.Next() = 0;

if (LineNo <> 0) then
TempAITRunHistory.SetRange("Line No. Filter", LineNo)
end;

procedure LookupTestMethodLine(TestSuiteCode: Code[100]; var LineNoFilter: Text; var LineNo: Integer)
var
AITTestMethodLine: Record "AIT Test Method Line";
AITTestMethodLines: Page "AIT Test Method Lines Lookup";
begin
AITTestMethodLine.SetRange("Test Suite Code", TestSuiteCode);

AITTestMethodLines.SetTableView(AITTestMethodLine);
AITTestMethodLines.LookupMode(true);

if not (AITTestMethodLines.RunModal() = Action::LookupOK) then
exit;

AITTestMethodLines.GetRecord(AITTestMethodLine);

AITTestMethodLine.CalcFields("Codeunit Name");
LineNoFilter := StrSubstNo(LineNoFilterLbl, AITTestMethodLine."Codeunit ID", AITTestMethodLine."Codeunit Name", AITTestMethodLine."Input Dataset");
LineNo := AITTestMethodLine."Line No.";
end;

procedure UpdateTestInput(TestInput: Text; TestInputView: Enum "AIT Test Input - View"): Text
var
TestData: Codeunit "Test Input Json";
begin
InitTestData(TestInput, TestData);

case TestInputView of
TestInputView::"Full Input":
exit(TestInput);
TestInputView::Question:
exit(GetTestDataElement('question', TestData));
TestInputView::Context:
exit(GetTestDataElement('context', TestData));
TestInputView::"Test Setup":
exit(GetTestDataElement('test_setup', TestData));
TestInputView::"Ground Truth":
exit(GetTestDataElement('ground_truth', TestData));
TestInputView::"Expected Data":
exit(GetTestDataElement('expected_data', TestData));
else
exit('');
end;
end;

procedure UpdateTestOutput(TestOutput: Text; TestOutputView: Enum "AIT Test Output - View"): Text
var
TestData: Codeunit "Test Input Json";
begin
InitTestData(TestOutput, TestData);

case TestOutputView of
TestOutputView::"Full Output":
exit(TestOutput);
TestOutputView::Answer:
exit(GetTestDataElement('answer', TestData));
TestOutputView::Question:
exit(GetTestDataElement('question', TestData));
TestOutputView::Context:
exit(GetTestDataElement('context', TestData));
TestOutputView::"Ground Truth":
exit(GetTestDataElement('ground_truth', TestData));
else
exit('');
end;
end;

local procedure InitTestData(TestDataText: Text; var TestData: Codeunit "Test Input Json")
begin
if TestDataText = '' then
TestData.Initialize()
else
TestData.Initialize(TestDataText);
end;

local procedure GetTestDataElement(ElementName: Text; TestData: Codeunit "Test Input Json"): Text
var
ElementTestDataJson: Codeunit "Test Input Json";
ElementExists: Boolean;
begin
ElementTestDataJson := TestData.ElementExists('turns', ElementExists);

if ElementExists then
TestData := ElementTestDataJson;

ElementTestDataJson := TestData.ElementExists(ElementName, ElementExists);

if ElementExists and (ElementTestDataJson.ToText() <> '{}') then
exit(ElementTestDataJson.ToText())
else
exit('');
end;


}
1 change: 1 addition & 0 deletions src/Tools/AI Test Toolkit/src/Logs/AITLogEntry.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ table 149034 "AIT Log Entry"
DataClassification = SystemMetadata;
DrillDownPageId = "AIT Log Entries";
LookupPageId = "AIT Log Entries";
DataCaptionFields = "Codeunit Name", "Procedure Name", "Test Input Code";
Extensible = false;
Access = Internal;
ReplicateData = false;
Expand Down
Loading
Loading