Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cypress/angular-signals support for InputSignalWithTransform #30682

Open
bohoffi opened this issue Nov 27, 2024 · 4 comments
Open

cypress/angular-signals support for InputSignalWithTransform #30682

bohoffi opened this issue Nov 27, 2024 · 4 comments
Assignees
Labels
CT Issue related to component testing npm: @cypress/angular @cypress/angular package issues stage: needs investigating Someone from Cypress needs to look at this

Comments

@bohoffi
Copy link

bohoffi commented Nov 27, 2024

What would you like?

#29264 brought support for the assignment of pure InputSignal which works fine as long as you do not plan on working with InputSignalWithTransform like:

public readonly enablePreview: InputSignalWithTransform<boolean, unknown> = input(false, {
  transform: booleanAttribute
});

Why is this needed?

The componentProperties of MountConfig<T> from cypress/angular-signals needs to be updated from

componentProperties?: Partial<{
        [P in keyof T]: T[P] extends InputSignal<infer V> ? InputSignal<V> | WritableSignal<V> | V : T[P];
    }>;

to

componentProperties?: Partial<{
        [P in keyof T]: T[P] extends InputSignal<infer V> | InputSignalWithTransform<infer V, unknown> ? InputSignal<V> | WritableSignal<V> | V : T[P];
    }>;

I'd be willing to provide a PR adding the missing type.

@AtofStryker AtofStryker self-assigned this Dec 2, 2024
@AtofStryker
Copy link
Contributor

@bohoffi thank you for opening this issue. I think InputSignalWithTransform was included in Angular 17 and we should be able to add this to the Cypress 14 release if that is the case. We will be merging the cypress/angular-signals harness upstream into cypress/angular for Cypress 14.

@AtofStryker AtofStryker added npm: @cypress/angular @cypress/angular package issues Cypress 14 Issues scoped for Cypress 14 labels Dec 2, 2024
@bohoffi
Copy link
Author

bohoffi commented Dec 2, 2024

@AtofStryker yes, InputSignalWithTransform was introduced with Angular 17.2.0 (PR 54053).

Thank you for taking it into account for Cypress 14 🙏
Having it will resolve our as unknown as workaround :)

@jennifer-shehane jennifer-shehane added the CT Issue related to component testing label Dec 4, 2024
@AtofStryker
Copy link
Contributor

@bohoffi I'm taking a look into this today. It looks like supporting the type is trivial, but the transform on the input signal doesn't actually get called mainly because of how we handle signals in the test harness via Inferred Generic Type or Writable Signals https://docs.cypress.io/app/component-testing/angular/examples#Testing-Signals.

I can go ahead and fix the type, but it looks like its very hard to access the transforms and alias declared on the input signal since it lives in an internal symbol

@bohoffi
Copy link
Author

bohoffi commented Dec 11, 2024

@AtofStryker I'll see if I can find some time to look into it myself to find something to work with.

@jennifer-shehane jennifer-shehane added stage: needs investigating Someone from Cypress needs to look at this and removed Cypress 14 Issues scoped for Cypress 14 labels Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CT Issue related to component testing npm: @cypress/angular @cypress/angular package issues stage: needs investigating Someone from Cypress needs to look at this
Projects
None yet
Development

No branches or pull requests

3 participants