audaciaconsulting / Audacia.CodeAnalysis

MIT License
1 stars 4 forks source link

HTML with grandchildren and great grandchildren etc, the fix does not apply a data-test attribute and no warning is shown #40

Closed zahra-audacia closed 2 months ago

zahra-audacia commented 2 months ago

I ran the data-test attribute (angular) autofix and noticed in many files, it was adding data test attributes to some tags and not others. For example:

<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="ibox-content">
                <table class="table ajax-table fixed-table">
                    <thead>
                        <tr>
                            <th>Test</th>
                            <th>Result</th>
                            <th>Test</th>
                        </tr>
                    </thead>
                    <tbody *ngIf="results">
                        <tr *ngFor="let result of results.data" class="search-results-row">
                            <td>{{ result.testName }}</td>
                            <td *ngIf="result.result">{{ result.result }}</td>
                            <td *ngIf="result.resultText">{{ result.resultText }}</td>
                            <td>{{ result.testedDate }}</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

My config indicates that this should add it to the a tag, the td tag and the input tag. image I noticed there are no td with a data test attribute added so that made me think it is due to being a grandchild of the first node/ or really nested in, not entirely sure though, that is just my guess from looking at the code.

jackpercy-acl commented 2 months ago

Thanks for raising this Zahra, I took a look into this and I believe it is once you add a structural directive like *ngIf or *ngFor onto an element, that element and all of it's children are no longer checked by this rule.

Will try to get a fix in for this :+1: