-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add built-in control flow tests with signals
- Loading branch information
1 parent
b6d6f7e
commit 3f93d59
Showing
4 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
system-tests/projects/angular-signals/src/control-flow/control-flow.component.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') | ||
}) |
36 changes: 36 additions & 0 deletions
36
system-tests/projects/angular-signals/src/control-flow/control-flow.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
<div> | ||
<div data-cy="control-flow-superheroes-display"> | ||
<h1> SuperHeroes</h1> | ||
<ul data-cy="control-flow-superheroes-list" > | ||
@for (superHero of superHeroes(); track superHero.name; let idx = $index) { | ||
<li [attr.data-index]="idx"> | ||
<p data-cy="name"> Name: {{ superHero.name }} </p> | ||
<p data-cy="nickname">Nickname: {{ superHero.nickname }} </p> | ||
<p data-cy="age"> | ||
@if (superHero.age > 30) { | ||
{{ superHero.age }} is older than 30 | ||
} @else if (30 > superHero.age) { | ||
{{ superHero.age }} is younger than 30 | ||
} @else { | ||
Age is unknown | ||
} | ||
</p> | ||
<p data-cy="mortality"> | ||
@switch (superHero.isMortal) { | ||
@case (true) { | ||
I am mortal. I will eventually die | ||
} | ||
@case (false) { | ||
I am immortal and will live forever | ||
} | ||
@default { | ||
Mortality status unknown | ||
} | ||
} | ||
</p> | ||
</li> | ||
} | ||
</ul> | ||
</div> | ||
</div> |
4 changes: 4 additions & 0 deletions
4
system-tests/projects/angular-signals/src/control-flow/control-flow.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
:host { | ||
height: 100%; | ||
display: block; | ||
} |
23 changes: 23 additions & 0 deletions
23
system-tests/projects/angular-signals/src/control-flow/control-flow.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<SuperHero[]>() | ||
} |
3f93d59
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
3f93d59
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
3f93d59
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally: