diff --git a/system-tests/projects/angular-signals/src/control-flow/control-flow.component.cy.ts b/system-tests/projects/angular-signals/src/control-flow/control-flow.component.cy.ts new file mode 100644 index 000000000000..f8a663cda8f7 --- /dev/null +++ b/system-tests/projects/angular-signals/src/control-flow/control-flow.component.cy.ts @@ -0,0 +1,38 @@ +import { ControlFlowComponent, SuperHero } from './control-flow.component' + +// @see https://angular.dev/guide/templates/control-flow +it('works with basic control flow', () => { + const superHeroes: SuperHero[] = [ + { + name: 'Clark Kent', + nickname: 'Man of Steel', + age: 28, + isMortal: true, + }, + { + name: 'Wade T. Wilson', + nickname: 'Deadpool', + age: 43, + isMortal: false, + }, + ] + + cy.mount(ControlFlowComponent, { + componentProperties: { + superHeroes, + }, + }) + + cy.get('[data-index="0"]').as('superman') + cy.get('[data-index="1"]').as('deadpool') + + cy.get('@superman').find('[data-cy="name"]').should('contain.text', 'Clark Kent') + cy.get('@superman').find('[data-cy="nickname"]').should('contain.text', 'Man of Steel') + cy.get('@superman').find('[data-cy="age"]').should('contain.text', '28 is younger than 30') + cy.get('@superman').find('[data-cy="mortality"]').should('contain.text', 'I am mortal. I will eventually die') + + cy.get('@deadpool').find('[data-cy="name"]').should('contain.text', 'Wade T. Wilson') + cy.get('@deadpool').find('[data-cy="nickname"]').should('contain.text', 'Deadpool') + cy.get('@deadpool').find('[data-cy="age"]').should('contain.text', '43 is older than 30') + cy.get('@deadpool').find('[data-cy="mortality"]').should('contain.text', 'I am immortal and will live forever') +}) diff --git a/system-tests/projects/angular-signals/src/control-flow/control-flow.component.html b/system-tests/projects/angular-signals/src/control-flow/control-flow.component.html new file mode 100644 index 000000000000..628c7dd6099e --- /dev/null +++ b/system-tests/projects/angular-signals/src/control-flow/control-flow.component.html @@ -0,0 +1,36 @@ + +
+
+

SuperHeroes

+ +
+
diff --git a/system-tests/projects/angular-signals/src/control-flow/control-flow.component.scss b/system-tests/projects/angular-signals/src/control-flow/control-flow.component.scss new file mode 100644 index 000000000000..dd8f716300ba --- /dev/null +++ b/system-tests/projects/angular-signals/src/control-flow/control-flow.component.scss @@ -0,0 +1,4 @@ +:host { + height: 100%; + display: block; +} diff --git a/system-tests/projects/angular-signals/src/control-flow/control-flow.component.ts b/system-tests/projects/angular-signals/src/control-flow/control-flow.component.ts new file mode 100644 index 000000000000..fb85abc0690d --- /dev/null +++ b/system-tests/projects/angular-signals/src/control-flow/control-flow.component.ts @@ -0,0 +1,23 @@ +import { + ChangeDetectionStrategy, + Component, + model, +} from '@angular/core' + +export type SuperHero = { + name: string + nickname: string + age: number + isMortal: boolean +} + +@Component({ + selector: 'control-flow-component', + templateUrl: './control-flow.component.html', + styleUrls: ['./control-flow.component.scss'], + standalone: true, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class ControlFlowComponent { + superHeroes = model.required() +}