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

Add Password Tests #370

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
118 changes: 118 additions & 0 deletions cypress/component/integration/Password.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import '../../../src/global.css';
import { Password } from '../../../src/components';
import { compareSnapshot } from '../../compareSnapshot';

describe('Component | Integration | Password', function () {
describe('Input', () => {
describe('default password', () => {
beforeEach(() => {
cy.mount(
<div className="theme-dark">
pivilartisant marked this conversation as resolved.
Show resolved Hide resolved
<Password />
</div>,
);
});

it('should render', () => {
cy.get('[data-testid="password-input"]').should('exist');
});

it('should focus on click', () => {
cy.get('[data-testid="password-input"]').focus().should('be.focused');
});

it('should receive typed input', () => {
cy.get('[data-testid="password-input"]')
.type('typed content')
.should('have.value', 'typed content')
.clear();
});

it('should hide typed input', () => {
cy.get('[data-testid="password-input"]')
.type('typed content')
.should('have.value', 'typed content');
cy.get('[data-testid="password-input"]').should('have.attr', 'type');
cy.get('[data-testid="password-input"]')
.invoke('attr', 'type')
.should('eq', 'password');
});

it('should show typed input', () => {
cy.get('[data-testid="password-input"]')
.type('typed content')
.should('have.value', 'typed content');

cy.get('[data-testid="password-icon"]').should('exist').click();

cy.get('[data-testid="password-input"]')
.invoke('attr', 'type')
.should('eq', 'text');
});

it('should show typed input', () => {
cy.get('[data-testid="password-input"]')
.type('typed content')
.should('have.value', 'typed content');

cy.get('[data-testid="password-icon"]').should('exist').click();

cy.get('[data-testid="password-input"]')
.invoke('attr', 'type')
.should('eq', 'text');
});

it('should match snapshot', () => {
compareSnapshot(cy, 'default-password');
});
});

describe('default password with error', () => {
beforeEach(() => {
cy.mount(
<div className="theme-dark">
<Password error={'error'} />
</div>,
);
});

it('should render', () => {
cy.get('[data-testid="password-input"]').should('exist');
});

it('should display error message', () => {
cy.get('[data-testid="input-field-message"]')
.should('exist')
.contains('error');
});

it('should match snapshot', () => {
compareSnapshot(cy, 'default-password-with-error');
});
});

describe('default password with warning', () => {
beforeEach(() => {
cy.mount(
<div className="theme-dark">
<Password warning={'warning'} />
</div>,
);
});

it('should render', () => {
cy.get('[data-testid="password-input"]').should('exist');
});

it('should display warning message', () => {
cy.get('[data-testid="input-field-message"]')
.should('exist')
.contains('warning');
});

it('should match snapshot', () => {
compareSnapshot(cy, 'default-password-with-warning');
pivilartisant marked this conversation as resolved.
Show resolved Hide resolved
});
});
});
});
60 changes: 0 additions & 60 deletions src/components/Password/Password.test.tsx

This file was deleted.