aspire icon indicating copy to clipboard operation
aspire copied to clipboard

Improve CheckDashboardHasResourcesAsync in workload tests

Open JamesNK opened this issue 1 year ago • 6 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

CheckDashboardHasResourcesAsync has some improvements I'd like to see to make it less brittle to changes and improve the error message output.

Expected Behavior

  • Asserts are hardcoded to cell position and number. The test will break if the number or order of columns changes. I'd like the test to get cells using something other than position. Perhaps we can give each cell a class to look up. Or if that isn't possible, then embed content in divs with classes. I think it's ok to make some modest changes to the generated HTML to make testing better.
  • If a row's content doesn't match the expected content, then the test doesn't match the row and skips adding it to found rows. But that means the error message just says that the resource wasn't found. It doesn't say exactly what didn't match for the row (e.g. the wrong number of endpoints). Knowing why it didn't match would be useful.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version info

No response

Anything else?

No response

JamesNK avatar Jul 10 '24 03:07 JamesNK

cc @radical

JamesNK avatar Jul 10 '24 03:07 JamesNK

@adamint would you be interested in taking this up, since you recently worked on dashboard playwright tests?

radical avatar Jul 10 '24 03:07 radical

@radical sure!

adamint avatar Jul 10 '24 12:07 adamint

Also, queries such as //fluent-data-grid-row[@class='resource-row'] require the exact classes to match the query. It would be better if the query returned elements named fluent-data-grid-row with the class resource-row and any other classes.

Is there a better way to write this kind of query that isn't so brittle to HTML changes?

See https://github.com/dotnet/aspire/pull/4892#discussion_r1680435584

JamesNK avatar Jul 17 '24 05:07 JamesNK

Also, queries such as //fluent-data-grid-row[@class='resource-row'] require the exact classes to match the query. It would be better if the query returned elements named fluent-data-grid-row with the class resource-row and any other classes.

Is there a better way to write this kind of query that isn't so brittle to HTML changes?

See #4892 (comment)

Yes, it is recommended not to use css classes or html elements where possible

adamint avatar Jul 17 '24 12:07 adamint

What's the alternative?

JamesNK avatar Jul 17 '24 12:07 JamesNK