Skip to content

Commit a4b81e9

Browse files
csharpfritzCopilot
andcommitted
fix: UpdatePanel Playwright tests use correct locators
BWFC Button renders as <input type='submit'>, not <button>. Tests used 'button.btn-primary' which never matched. Fixed to: - Scope each test to data-audit-control section for isolation - Use input[type='submit'] locators (matching actual BWFC output) - Fix text mismatches ('Click Me' vs actual 'Increment') - Fix inline mode: 'The time is:' vs actual 'The current time is' Fixes 3 Playwright integration test failures on CI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3ebe107 commit a4b81e9

1 file changed

Lines changed: 21 additions & 12 deletions

File tree

samples/AfterBlazorServerSide.Tests/InteractiveComponentTests.cs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3248,19 +3248,22 @@ public async Task UpdatePanel_BlockMode_RendersAsDivAndInteractsCorrectly()
32483248
Assert.NotNull(blockHeading);
32493249
Assert.Contains("Block Mode", blockHeading);
32503250

3251+
// Scope to the Block Mode section
3252+
var blockSection = page.Locator("div[data-audit-control='UpdatePanel-3']");
3253+
32513254
// Assert - Initial click count is 0
3252-
var initialCount = await page.Locator("strong").Filter(new() { HasTextString = "0" }).First.TextContentAsync();
3255+
var initialCount = await blockSection.Locator("strong").First.TextContentAsync();
32533256
Assert.Equal("0", initialCount);
32543257

3255-
// Act - Click the button in Block mode section
3256-
var blockButton = page.Locator("button.btn-primary").Filter(new() { HasTextString = "Click Me" }).First;
3258+
// Act - Click the button (BWFC Button renders as <input type="submit">)
3259+
var blockButton = blockSection.Locator("input[type='submit']").First;
32573260
await blockButton.ClickAsync();
32583261

32593262
// Wait for Blazor to update
32603263
await page.WaitForTimeoutAsync(500);
32613264

32623265
// Assert - Click count incremented to 1
3263-
var updatedCount = await page.Locator("p").Filter(new() { HasTextString = "Click count:" }).First.Locator("strong").TextContentAsync();
3266+
var updatedCount = await blockSection.Locator("p").Filter(new() { HasTextString = "Block click count:" }).First.Locator("strong").TextContentAsync();
32643267
Assert.Equal("1", updatedCount);
32653268

32663269
Assert.Empty(consoleErrors);
@@ -3301,24 +3304,27 @@ public async Task UpdatePanel_ContentTemplate_RendersAndInteractsCorrectly()
33013304
var contentTemplateHeading = await page.Locator("h3").Filter(new() { HasTextString = "Web Forms ContentTemplate Syntax" }).TextContentAsync();
33023305
Assert.NotNull(contentTemplateHeading);
33033306

3307+
// Scope to the ContentTemplate section
3308+
var contentSection = page.Locator("div[data-audit-control='UpdatePanel-2']");
3309+
33043310
// Assert - ContentTemplate alert div exists with the expected content
3305-
var alertDiv = page.Locator("div.alert-info").Filter(new() { HasTextString = "ContentTemplate" });
3311+
var alertDiv = contentSection.Locator("div.alert-info");
33063312
var alertVisible = await alertDiv.IsVisibleAsync();
33073313
Assert.True(alertVisible);
33083314

33093315
// Assert - Initial ContentTemplate click count is 0
3310-
var initialText = await page.Locator("p").Filter(new() { HasTextString = "ContentTemplate click count:" }).First.TextContentAsync();
3316+
var initialText = await contentSection.Locator("p").Filter(new() { HasTextString = "ContentTemplate click count:" }).First.TextContentAsync();
33113317
Assert.Contains("0", initialText);
33123318

3313-
// Act - Click the ContentTemplate button
3314-
var contentTemplateButton = page.Locator("button.btn-success").Filter(new() { HasTextString = "Click Me" }).First;
3319+
// Act - Click the ContentTemplate button (BWFC Button renders as <input type="submit">)
3320+
var contentTemplateButton = contentSection.Locator("input[type='submit']").First;
33153321
await contentTemplateButton.ClickAsync();
33163322

33173323
// Wait for Blazor to update
33183324
await page.WaitForTimeoutAsync(500);
33193325

33203326
// Assert - ContentTemplate click count incremented to 1
3321-
var updatedText = await page.Locator("p").Filter(new() { HasTextString = "ContentTemplate click count:" }).First.TextContentAsync();
3327+
var updatedText = await contentSection.Locator("p").Filter(new() { HasTextString = "ContentTemplate click count:" }).First.TextContentAsync();
33223328
Assert.Contains("1", updatedText);
33233329

33243330
Assert.Empty(consoleErrors);
@@ -3359,8 +3365,11 @@ public async Task UpdatePanel_InlineMode_RendersAndRefreshesCorrectly()
33593365
var inlineHeading = await page.Locator("h3").Filter(new() { HasTextString = "Inline Mode" }).TextContentAsync();
33603366
Assert.NotNull(inlineHeading);
33613367

3368+
// Scope to the Inline Mode section
3369+
var inlineSection = page.Locator("div[data-audit-control='UpdatePanel-4']");
3370+
33623371
// Assert - Time display exists (UpdatePanel in Inline mode)
3363-
var timeParagraph = page.Locator("p").Filter(new() { HasTextString = "The time is:" }).First;
3372+
var timeParagraph = inlineSection.Locator("p").First;
33643373
var timeVisible = await timeParagraph.IsVisibleAsync();
33653374
Assert.True(timeVisible);
33663375

@@ -3369,8 +3378,8 @@ public async Task UpdatePanel_InlineMode_RendersAndRefreshesCorrectly()
33693378
Assert.NotNull(initialTime);
33703379
Assert.NotEmpty(initialTime);
33713380

3372-
// Act - Click the Refresh button
3373-
var refreshButton = page.Locator("button.btn-outline-secondary").Filter(new() { HasTextString = "Refresh" }).First;
3381+
// Act - Click the Refresh button (BWFC Button renders as <input type="submit">)
3382+
var refreshButton = inlineSection.Locator("input[type='submit']").First;
33743383
await refreshButton.ClickAsync();
33753384

33763385
// Wait for Blazor to update

0 commit comments

Comments
 (0)