allianz / ng-aquila

Angular UI Component library for the Open Insurance Platform
https://allianz.github.io/ng-aquila/
Other
205 stars 32 forks source link

[NxDataDisplayHarness] Issues when having a data display with and without a label on the same page #64

Closed Dominik-Kriese closed 1 month ago

Dominik-Kriese commented 1 month ago

Reproduction Link

As one needs to run tests for the problem to occur, I created a little repository for the reproduction. I hope this is fine as well. https://github.com/Dominik-Kriese/ng-aquilla-test-repo

Steps to reproduce:

  1. Open the app.component.spec.ts
  2. Have a look at the test titled 'does not work by label even if the label is correct'.

πŸ“— Expected Behavior

This test should find the according nx data display.

πŸ“• Actual Behavior

The harness errors as there is a nx data display present without a label

πŸ“¦ Environment

Current information:

I took a look into it and it seems to be this file that creates the issue:

    // projects/ng-aquila/src/data-display/testing/data-display-harness.ts
    async getLabel(): Promise<string> {
        return (await this._getLabel()).text();
    }

I would propose the following change, which ensures, that a non present label is interpreted as undefined:

    // projects/ng-aquila/src/data-display/testing/data-display-harness.ts
    async getLabel(): Promise<string> {
        return (await this._getLabel()).text().catch(() => undefined);
    }

If that is a valid solution, I could provide a pull request.

Best Regards and thanks in advance.

Dominik-Kriese commented 1 month ago

I talked to a colleague of mine and will port this issue to the internal repositories. Sorry for the wrong place to post this.