Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5a716e2
Update GHA workflow
justinyoo Aug 18, 2024
cd02479
Merge branch 'aliencube:main' into main
yjchun626 Aug 19, 2024
8a0e04f
Merge branch 'aliencube:main' into main
yjchun626 Aug 20, 2024
831c6a1
Playground project에 FluentUI 패키지 추가 & dropdown UI 컴포넌트 .razor 파일 생성
yjchun626 Aug 20, 2024
916d068
Home.razor에 DeploymentModelListComponent 추가
yjchun626 Aug 20, 2024
a4b34b8
Merge branch 'aliencube:main' into feature/172-deployment-model-list
yjchun626 Aug 20, 2024
652e8b6
Merge branch 'aliencube:main' into main
yjchun626 Aug 20, 2024
2b7cd4b
DeploymentModelListComponent에 대한 test 코드 파일 추가
yjchun626 Aug 21, 2024
401853d
test code 파일 수정
yjchun626 Aug 21, 2024
504634f
Merge branch 'main' of https://github.com/yjchun626/azure-openai-sdk-…
yjchun626 Aug 21, 2024
a003f6c
DeploymentModelList 컴포넌트 파일 & 테스트 코드 파일 수정
yjchun626 Aug 22, 2024
13d5817
Merge branch 'feature/172-deployment-model-list' of https://github.co…
yjchun626 Aug 22, 2024
4427061
PackageReference 관련 파일 수정
yjchun626 Aug 22, 2024
ed640f6
Merge branch 'feature/172-deployment-model-list' of https://github.co…
yjchun626 Aug 22, 2024
1b9fc5c
Test code (Playwright, bUnit) 수정
yjchun626 Aug 22, 2024
3f9c2dc
Playwright test code - Headless mode 설정
yjchun626 Aug 22, 2024
7cfe09e
Playwright test code 수정 및 컴포넌트 테스트 용 Tests.razor 페이지 추가
yjchun626 Aug 22, 2024
3a190c2
Merge branch 'aliencube:main' into feature/172-deployment-model-list
yjchun626 Aug 23, 2024
74c05ca
Playwright 로컬 호스트 접속 url 수정
yjchun626 Aug 23, 2024
6f30180
Playwright 테스트 코드 수정
yjchun626 Aug 23, 2024
86aa7a7
중복 코드 및 bUnit 테스트 삭제
yjchun626 Aug 24, 2024
03d54e5
Merge branch 'aliencube:main' into feature/172-deployment-model-list
yjchun626 Aug 26, 2024
cd545ac
DeploymentModelListComponent.razor 수정 - 컴포넌트 이벤트 콜백 부분 수정
yjchun626 Aug 26, 2024
b820b07
Playwright 테스트 코드 수정(현재 로컬에서 테스트 시 모두 fail - 수정 더 필요함)
yjchun626 Aug 26, 2024
a5d4b50
Merge branch 'aliencube:main' into feature/172-deployment-model-list
yjchun626 Aug 27, 2024
4a67022
DeploymentModelList 컴포넌트 파일에 OnInitializedAsync(), Tests.razor에 OnAft…
yjchun626 Aug 27, 2024
7449723
Merge branch 'aliencube:main' into feature/172-deployment-model-list
yjchun626 Aug 28, 2024
3b8b85f
DeploymentModelList 컴포넌트 파일 이벤트 콜백 메소드 & 테스트 코드 파일 메소드 이름 수정, Tests.r…
yjchun626 Aug 28, 2024
cb045ea
Merge branch 'aliencube:main' into feature/172-deployment-model-list
yjchun626 Aug 28, 2024
101c17e
Tests.razor OnInitialized -> OnInitializedAsync로 변경
yjchun626 Aug 28, 2024
9dfcaeb
Merge branch 'aliencube:main' into feature/172-deployment-model-list
yjchun626 Aug 31, 2024
07a052c
Test 코드 - Arrange, Act, Assert 명시 및 파라미터라이징 등 수정, 드롭다운 컴포넌트 코드 - 필드 s…
yjchun626 Aug 31, 2024
34a9bae
Merge branch 'feature/172-deployment-model-list' of https://github.co…
yjchun626 Aug 31, 2024
8e20784
드롭다운 컴포넌트 파일 - 불필요한 using 삭제
yjchun626 Aug 31, 2024
48f9ea7
Tests.razor 메소드 async 수정 및 드롭다운 컴포넌트 값 확인 DebugButtonComponent로 가능하게 수정
yjchun626 Sep 1, 2024
f3ed222
Merge branch 'aliencube:main' into feature/172-deployment-model-list
yjchun626 Sep 1, 2024
c02dd33
Merge branch 'aliencube:main' into feature/172-deployment-model-list
yjchun626 Sep 1, 2024
1b882c9
Merge branch 'aliencube:main' into feature/172-deployment-model-list
yjchun626 Sep 2, 2024
f2d63f7
DeploymentModelListComponent - Id 파라미터 추가 및 Tests.razor 컴포넌트에 Id 값 지정…
yjchun626 Sep 2, 2024
f540bb6
Merge branch 'aliencube:main' into feature/172-deployment-model-list
yjchun626 Sep 6, 2024
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
12 changes: 11 additions & 1 deletion src/AzureOpenAIProxy.PlaygroundApp/Components/Pages/Tests.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@
<DebugTargetComponent Id="debug-target" OnValueChanged="SetInput" />
<DebugButtonComponent Id="debug-button" Input="@currentValue" />

<DeploymentModelListComponent Id="deployment-model-list" OnUserOptionSelected="HandleSelectedModelValue" @rendermode="InteractiveServer" />
<DebugButtonComponent Id="debug-button-selected-model" Input="@selectedModelValue" />

@code {
private object? currentValue;
private string? selectedModelValue = "";

private async Task SetInput(int newValue)
{
currentValue = newValue;
await Task.CompletedTask;
}
}

private async Task HandleSelectedModelValue(string val)
{
selectedModelValue = val;
await Task.CompletedTask;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<FluentLayout Id="@Id" Style="margin: 10px;">
<div style="display: flex; align-items: center; margin-bottom: 5px;">
<label id="deployment-model-label" for="deployment-model-list-options" style="margin-right: 5px;">Deployment</label>
<span style="color: red;">*</span>
</div>

<FluentSelect Items=@deploymentModelOptions Id="deployment-model-list-options" name="deployment-models"
TOption="Option<string>" Height="300px"
OptionText="@(e => e.Text?.ToString())"
OptionValue="@(e => e.Value?.ToString())"
OptionSelected="@(e => e.Selected)"
@bind-SelectedOption="@selectedOption"
@onclick="OnValueChanged"
aria-labelledby="deployment-model-label">
</FluentSelect>
</FluentLayout>

@code {
[Parameter]
public string? Id { get; set; }
private Option<string>? selectedOption { get; set; } = new();

[Parameter]
public EventCallback<string> OnUserOptionSelected { get; set; }

private async Task OnValueChanged()
{
string? selectedValue = selectedOption?.Value?.ToString();
await OnUserOptionSelected.InvokeAsync(selectedValue);
}

static List<Option<string>> deploymentModelOptions = new()
{
new Option<string> { Value = "AL", Text = "Alabama" },
new Option<string> { Value = "AK", Text = "Alaska" },
new Option<string> { Value = "AZ", Text = "Arizona" },
new Option<string> { Value = "AR", Text = "Arkansas" },
new Option<string> { Value = "CA", Text = "California" },
new Option<string> { Value = "CO", Text = "Colorado" },
new Option<string> { Value = "CT", Text = "Connecticut" },
new Option<string> { Value = "DE", Text = "Delaware" },
new Option<string> { Value = "FL", Text = "Florida" },
new Option<string> { Value = "GA", Text = "Georgia" },
new Option<string> { Value = "HI", Text = "Hawaii" },
new Option<string> { Value = "ID", Text = "Idaho" },
new Option<string> { Value = "IL", Text = "Illinois" },
new Option<string> { Value = "IN", Text = "Indiana" },
new Option<string> { Value = "IA", Text = "Iowa" },
new Option<string> { Value = "KS", Text = "Kansas" },
new Option<string> { Value = "KY", Text = "Kentucky" },
new Option<string> { Value = "LA", Text = "Louisiana" },
new Option<string> { Value = "ME", Text = "Maine" },
new Option<string> { Value = "MD", Text = "Maryland" },
new Option<string> { Value = "MA", Text = "Massachussets" },
new Option<string> { Value = "MI", Text = "Michigain" },
new Option<string> { Value = "MN", Text = "Minnesota" },
new Option<string> { Value = "MS", Text = "Mississippi" },
new Option<string> { Value = "MO", Text = "Missouri" },
new Option<string> { Value = "MT", Text = "Montana" },
new Option<string> { Value = "NE", Text = "Nebraska" },
new Option<string> { Value = "NV", Text = "Nevada" },
new Option<string> { Value = "NH", Text = "New Hampshire" },
new Option<string> { Value = "NJ", Text = "New Jersey" },
new Option<string> { Value = "NM", Text = "New Mexico" },
new Option<string> { Value = "NY", Text = "New York" },
new Option<string> { Value = "NC", Text = "North Carolina" },
new Option<string> { Value = "ND", Text = "North Dakota" },
new Option<string> { Value = "OH", Text = "Ohio" },
new Option<string> { Value = "OK", Text = "Oklahoma" },
new Option<string> { Value = "OR", Text = "Oregon" },
new Option<string> { Value = "PA", Text = "Pennsylvania" }
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
<PackageReference Include="NUnit3TestAdapter" Version="$(NUnitVersion)" />
</ItemGroup>

<!--<ItemGroup>
<!-- <ItemGroup>
<ProjectReference Include="..\..\src\AzureOpenAIProxy.PlaygroundApp\AzureOpenAIProxy.PlaygroundApp.csproj" />
</ItemGroup>-->
</ItemGroup> -->

<ItemGroup>
<Using Include="NUnit.Framework" />
Expand Down
17 changes: 17 additions & 0 deletions test/AzureOpenAIProxy.PlaygroundApp.Tests/Pages/TestsPageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ public async Task Setup()
await Page.WaitForLoadStateAsync(LoadState.NetworkIdle);
}

[Test]
[TestCase("debug-target")]
[TestCase("debug-button")]
[TestCase("deployment-model-list")]
[TestCase("debug-button-selected-model")]
public async Task Given_ComponentID_When_Page_Loaded_Then_Component_Should_Be_Visible(string id)
{
// Arrange
var expectedId = id;

// Act
var component = Page.Locator($"#{expectedId}");

// Assert
await Expect(component).ToBeVisibleAsync();
}

[Test]
public async Task Given_No_Input_On_DebugTarget_When_DebugButton_Clicked_Then_Toast_Should_Show_NullMessage()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
using Microsoft.Playwright.NUnit;
using Microsoft.Playwright;
using FluentAssertions;

namespace AzureOpenAIProxy.PlaygroundApp.Tests.UI
{
[Parallelizable(ParallelScope.Self)]
[TestFixture]
[Property("Category", "Integration")]
public class ModelDropdownListComponentTests : PageTest
{
public override BrowserNewContextOptions ContextOptions() => new()
{
IgnoreHTTPSErrors = true,
};

[SetUp]
public async Task Init()
{
await Page.GotoAsync("http://localhost:5000/tests");
await Page.WaitForLoadStateAsync(LoadState.NetworkIdle);
}

[Test]
public async Task Given_DropdownComponentID_When_Page_Loaded_Then_DropdownComponent_Should_Be_Visible()
{
// Arrange
var expectedId = "deployment-model-list";

// Act
var component = Page.Locator($"#{expectedId}");

// Assert
await Expect(component).ToBeVisibleAsync();
}

[Test]
// 페이지에서 컴포넌트 레이블이 올바르게 표시되는지 확인
public async Task Given_Label_When_Page_Loaded_Then_Label_Should_Be_Visible()
{
// Act
var label = Page.GetByText("Deployment");

// Assert
await Expect(label).ToBeVisibleAsync();
}

[Test]
// 페이지에서 드롭다운 컴포넌트가 올바르게 표시되는지 확인
public async Task Given_DropdownList_When_Page_Loaded_Then_DropdownList_Should_Be_Visible()
{
// Act
var fluentSelect = Page.Locator("fluent-select#deployment-model-list-options");

// Assert
await Expect(fluentSelect).ToBeVisibleAsync();
}

[Test]
// 드롭다운의 옵션 값이 존재하는지 확인
public async Task Given_DropdownList_When_DropdownList_Clicked_And_DropdownOptions_Appeared_Then_All_DropdownOptions_Should_Be_Visible()
{
// Arrange
var fluentSelect = Page.Locator("fluent-select#deployment-model-list-options");

// Act
await fluentSelect.ClickAsync();
var fluentOptions = fluentSelect.Locator("fluent-option");

// Assert
for (int i = 0; i < await fluentOptions.CountAsync(); i++)
{
await Expect(fluentOptions.Nth(i)).ToBeVisibleAsync();
}
}

[Test]
[TestCase("AZ", 2)]
[TestCase("CA", 4)]
[TestCase("CT", 6)]
[TestCase("FL", 8)]
// 드롭다운의 옵션 값을 선택하면 부모 컴포넌트(페이지 컴포넌트)에 올바르게 업데이트 되는지 확인
public async Task Given_DropdownOptions_And_ExpectedValue_When_Third_DropdownOption_Selected_And_DropdownValue_Updated_Then_DropdownValue_Should_Match_ExpectedValue(string exp, int n)
{
// Arrange
var fluentSelect = Page.Locator("fluent-select#deployment-model-list-options");
await fluentSelect.ClickAsync();
var fluentOptions = fluentSelect.Locator("fluent-option");
var expectedValue = exp; // 실제 컴포넌트 옵션 값

// Act
await fluentOptions.Nth(n).ScrollIntoViewIfNeededAsync(); // 선택할 컴포넌트 옵션 보이도록 스크롤
await fluentOptions.Nth(n).ClickAsync(); // 옵션 클릭
var actualValue = await Page.EvaluateAsync<string>("() => document.querySelector('fluent-select#deployment-model-list-options').value"); // 페이지 내 컴포넌트 값 가져오기

// Assert
actualValue.Should().Be(expectedValue);
}

[TearDown]
public async Task CleanUp()
{
await Page.CloseAsync();
}
}
}
Loading