2022-05-03 21:20:36 +05:30
|
|
|
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
2021-08-27 12:21:24 +05:30
|
|
|
const Login = ({ email, name }: LoginProps): void => {
|
2022-05-03 21:20:36 +05:30
|
|
|
const emailInput = cy.findByPlaceholderText('name@yourcompany.com');
|
2021-08-27 12:21:24 +05:30
|
|
|
|
|
|
|
|
emailInput.then((emailInput) => {
|
|
|
|
|
const element = emailInput[0];
|
|
|
|
|
// element is present
|
|
|
|
|
expect(element).not.undefined;
|
2021-09-23 15:43:43 +05:30
|
|
|
expect(element.nodeName).to.be.equal('INPUT');
|
2021-08-27 12:21:24 +05:30
|
|
|
});
|
|
|
|
|
emailInput.type(email).then((inputElements) => {
|
|
|
|
|
const inputElement = inputElements[0];
|
2021-09-23 15:43:43 +05:30
|
|
|
const inputValue = inputElement.getAttribute('value');
|
2021-08-27 12:21:24 +05:30
|
|
|
expect(inputValue).to.be.equals(email);
|
|
|
|
|
});
|
|
|
|
|
|
2022-05-03 21:20:36 +05:30
|
|
|
const firstNameInput = cy.findByPlaceholderText('Your Name');
|
2021-08-27 12:21:24 +05:30
|
|
|
firstNameInput.then((firstNameInput) => {
|
|
|
|
|
const element = firstNameInput[0];
|
|
|
|
|
// element is present
|
|
|
|
|
expect(element).not.undefined;
|
2021-09-23 15:43:43 +05:30
|
|
|
expect(element.nodeName).to.be.equal('INPUT');
|
2021-08-27 12:21:24 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
|
|
firstNameInput.type(name).then((inputElements) => {
|
|
|
|
|
const inputElement = inputElements[0];
|
2021-09-23 15:43:43 +05:30
|
|
|
const inputValue = inputElement.getAttribute('value');
|
2021-08-27 12:21:24 +05:30
|
|
|
expect(inputValue).to.be.equals(name);
|
|
|
|
|
});
|
|
|
|
|
|
2021-10-22 17:07:57 +05:30
|
|
|
const gettingStartedButton = cy.findByText('Get Started');
|
2021-08-27 12:21:24 +05:30
|
|
|
gettingStartedButton.click();
|
|
|
|
|
|
2021-10-22 17:07:57 +05:30
|
|
|
cy
|
|
|
|
|
.intercept('POST', '/api/v1/user?email*', {
|
|
|
|
|
statusCode: 200,
|
|
|
|
|
})
|
|
|
|
|
.as('defaultUser');
|
|
|
|
|
|
|
|
|
|
cy.wait('@defaultUser');
|
2021-08-27 12:21:24 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export interface LoginProps {
|
|
|
|
|
email: string;
|
|
|
|
|
name: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Login;
|