generated from Tinkoff/angular-open-source-starter
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(demo-integrations): add Cypress Component Testing (#838)
- Loading branch information
1 parent
1e9e680
commit 9539991
Showing
9 changed files
with
109 additions
and
12 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -115,9 +115,21 @@ jobs: | |
npm run cy:run -- --spec "**/(angular|react|ssr|addons|others)/**/*.cy.ts" --config baseUrl="${{ | ||
env.UNIVERSAL_SERVER }}" | ||
|
||
component-testing: | ||
if: ${{ !contains(github.head_ref, 'release/') }} | ||
runs-on: ubuntu-latest | ||
name: Component Testing | ||
steps: | ||
- uses: taiga-family/ci/actions/setup/[email protected] | ||
- uses: taiga-family/ci/actions/setup/[email protected] | ||
- uses: taiga-family/ci/actions/setup/[email protected] | ||
|
||
- name: Run Cypress tests | ||
run: npx nx component-test demo-integrations --browser=chrome | ||
|
||
result: | ||
if: ${{ !contains(github.head_ref, 'release/') }} | ||
needs: [build-demo, e2e-kit, e2e-recipes, e2e-others] | ||
needs: [build-demo, e2e-kit, e2e-recipes, e2e-others, component-testing] | ||
runs-on: ubuntu-latest | ||
name: E2E result | ||
steps: | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
6 changes: 3 additions & 3 deletions
6
projects/demo-integrations/src/support/commands/smart-tick.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
18 changes: 18 additions & 0 deletions
18
projects/demo-integrations/src/support/component-index.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,18 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta | ||
content="IE=edge" | ||
http-equiv="X-UA-Compatible" | ||
/> | ||
<meta | ||
content="width=device-width,initial-scale=1.0" | ||
name="viewport" | ||
/> | ||
<title>demo-integrations Components App</title> | ||
</head> | ||
<body> | ||
<div data-cy-root></div> | ||
</body> | ||
</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,14 @@ | ||
import './commands'; | ||
|
||
import {mount} from 'cypress/angular'; | ||
|
||
declare global { | ||
namespace Cypress { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
interface Chainable<Subject> { | ||
mount: typeof mount; | ||
} | ||
} | ||
} | ||
|
||
Cypress.Commands.add('mount', mount); |
31 changes: 31 additions & 0 deletions
31
projects/demo-integrations/src/tests/component-testing/test.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,31 @@ | ||
import {Component, Input} from '@angular/core'; | ||
import {MaskitoDirective} from '@maskito/angular'; | ||
import {MaskitoOptions} from '@maskito/core'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [MaskitoDirective], | ||
template: ` | ||
<input [maskito]="maskitoOptions" /> | ||
`, | ||
}) | ||
class TestInput { | ||
@Input() | ||
maskitoOptions: MaskitoOptions | null = null; | ||
} | ||
|
||
describe('Component testing demo', () => { | ||
it('Test #1', () => { | ||
const maskitoOptions: MaskitoOptions = {mask: /^\d+$/}; | ||
|
||
cy.mount(TestInput, {componentProperties: {maskitoOptions}}); | ||
cy.get('input').type('123abc!!!!!567').should('have.value', '123567'); | ||
}); | ||
|
||
it('Test #2', () => { | ||
const maskitoOptions: MaskitoOptions = {mask: [/\d/, /\d/, ':', /\d/, /\d/]}; | ||
|
||
cy.mount(TestInput, {componentProperties: {maskitoOptions}}); | ||
cy.get('input').type('1234').should('have.value', '12:34'); | ||
}); | ||
}); |