Skip to content

Commit bc0325b

Browse files
committed
Add fluent slider range test
1 parent 692ddfb commit bc0325b

File tree

2 files changed

+58
-7
lines changed

2 files changed

+58
-7
lines changed

test/AzureOpenAIProxy.PlaygroundApp.Tests/Pages/PlaygroundPageConfigWindowTests.cs

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,8 @@ public async Task Given_ParameterTab_When_Updated_Then_Parameter_Slider_Should_B
380380
// Arrange
381381
var configTab = Page.Locator("div.config-grid")
382382
.Locator("fluent-tabs#config-tabs");
383-
384-
var parameterTab = configTab.Locator("fluent-tab#parameters-tab");
385-
await parameterTab.ClickAsync();
383+
await configTab.Locator("fluent-tab#parameters-tab")
384+
.ClickAsync();
386385

387386
var component = configTab.Locator("fluent-tab-panel#parameters-tab-panel")
388387
.Locator($"div#{id}");
@@ -406,9 +405,8 @@ public async Task Given_ParameterTab_When_Updated_Then_Parameter_MultiSelect_Sho
406405
// Arrange
407406
var configTab = Page.Locator("div.config-grid")
408407
.Locator("fluent-tabs#config-tabs");
409-
410-
var parameterTab = configTab.Locator("fluent-tab#parameters-tab");
411-
await parameterTab.ClickAsync();
408+
await configTab.Locator("fluent-tab#parameters-tab")
409+
.ClickAsync();
412410

413411
var component = configTab.Locator("fluent-tab-panel#parameters-tab-panel")
414412
.Locator($"div#{id}");
@@ -422,4 +420,43 @@ public async Task Given_ParameterTab_When_Updated_Then_Parameter_MultiSelect_Sho
422420
labelText.Should().StartWith(label);
423421
await Expect(multiselect).ToBeVisibleAsync();
424422
}
425-
}
423+
424+
[Test]
425+
[TestCase("range-past-messages", 1, 20, 10)]
426+
[TestCase("range-max-response", 1, 16000, 800)]
427+
[TestCase("range-temperature", 0, 1, 0.7)]
428+
[TestCase("range-top-p", 0, 1, 0.95)]
429+
[TestCase("range-frequency-penalty", 0, 2, 0)]
430+
[TestCase("range-presence-penalty", 0, 2, 0)]
431+
public async Task Given_ParameterTab_When_Updated_Then_Parameter_Range_Should_Have_Correct_Range(string id, decimal min, decimal max, decimal start)
432+
{
433+
// Arrange
434+
var configTab = Page.Locator("div.config-grid")
435+
.Locator("fluent-tabs#config-tabs");
436+
await configTab.Locator("fluent-tab#parameters-tab")
437+
.ClickAsync();
438+
439+
var content = configTab.Locator("fluent-tab-panel#parameters-tab-panel")
440+
.Locator($"div#{id}")
441+
.Locator($"div#{id}-content");
442+
443+
// Act
444+
var slider = content.Locator("fluent-slider.parameter-component-slider");
445+
var textfield = content.Locator("fluent-text-field.parameter-component-textfield");
446+
447+
var handle = slider.Locator("div.thumb-cursor");
448+
var bound = await handle.BoundingBoxAsync();
449+
450+
// Assert
451+
(await slider.GetAttributeAsync("current-value")).Should().Be(start.ToString());
452+
(await textfield.GetAttributeAsync("current-value")).Should().Be(start.ToString());
453+
454+
await Page.Mouse.DragToPoint(handle, 0, bound!.Y);
455+
(await slider.GetAttributeAsync("current-value")).Should().Be(min.ToString());
456+
(await textfield.GetAttributeAsync("current-value")).Should().Be(min.ToString());
457+
458+
await Page.Mouse.DragToPoint(handle, float.MaxValue, bound!.Y);
459+
(await slider.GetAttributeAsync("current-value")).Should().Be(max.ToString());
460+
(await textfield.GetAttributeAsync("current-value")).Should().Be(max.ToString());
461+
}
462+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Microsoft.Playwright;
2+
3+
namespace AzureOpenAIProxy.PlaygroundApp.Tests.Pages;
4+
5+
internal static class PlaywrightPageExtensions
6+
{
7+
public static async Task DragToPoint(this IMouse mouse, ILocator source, float x, float y)
8+
{
9+
await source.HoverAsync();
10+
await mouse.DownAsync();
11+
await mouse.MoveAsync(x, y);
12+
await mouse.UpAsync();
13+
}
14+
}

0 commit comments

Comments
 (0)