qe-fe-automation
Version:
FE test automation framework using cypress
52 lines (49 loc) • 1.62 kB
text/typescript
import { LoginPage } from '@admin-lib/login';
import { GuestInvite } from '@admin-factory/interface';
type createGuestInviteData = (
userResponse: any,
paymentMethodUuid: string
) => GuestInvite;
export class GuestInviteUtility {
static createGuestInviteForTraveler(guestInviteData: createGuestInviteData) {
const adminUser = {
name: '',
password: Cypress.env('newUser').NEW_USER_PASSWORD,
paymentMethodUuid: ''
};
cy.task<string>('getDataFromCache', 'companyCreationEmail')
.then((_name: string) => {
adminUser.name = _name;
})
.then(() => {
cy.task('getDataFromCache', 'paymentMethod').then(
(paymentMethodResponse: any) => {
adminUser.paymentMethodUuid = paymentMethodResponse.uuid;
}
);
})
.then(() => {
LoginPage.createNewTravelerAndLogin();
})
.then(() => {
cy.task<string>('getDataFromCache', 'travelerEmail').then((email: string) => {
cy.retrieveUserByEmail(email);
});
})
.then(() => {
cy.loginWithAuthToken({ email: adminUser.name, password: adminUser.password })
.then(() => cy.task('getDataFromCache', 'userResponse'))
.then((userResponse) =>
cy.createGuestInvite(
guestInviteData(userResponse, adminUser.paymentMethodUuid)
)
);
});
cy.task<string>('getDataFromCache', 'travelerEmail').then((email: string) => {
cy.loginWithAuthToken({
email,
password: Cypress.env('newUser').NEW_USER_PASSWORD
});
});
}
}