UNPKG

qe-fe-automation

Version:
79 lines (71 loc) 3.23 kB
import { LegalData } from 'cypress/artifacts/base/data/legal'; const selectors = { formSaveButton: '[cdkfocusinitial=""] > .ta-button-v2', formPopup: '.pac-item', legalEntitiesURL: '/app/admin2/en/company/organization/billable_entities', legalFormName: 'input[formcontrolname="legalName"]', legalFormState: 'input[formcontrolname="localTaxId"]', legalFormAddress: 'input[formcontrolname="address1"]', officeFormName: 'input[formcontrolname="officeName"]', officeFormAddress: 'input[formcontrolname="address1"]', officeFormUuid: 'mat-select#billableEntityUuid', officeFormPos: 'mat-select#agencyCompanyAssociationUuid', officeFormOption: 'mat-option', officeGuidesURL: '/app/user2/office-guides/find-an-office', officeGuidesToggle: '.show-office', officeGuideEntry: '.office', officeGuideSearch: 'input[formcontrolname="search"]', orgEntitiesButton: '#mat-button-toggle-1', orgOfficeButton: '#mat-button-toggle-2', secondaryButton: '.mat-stroked-button' }; export class OfficeGuides { static visitAdminOrgPage(): void { cy.allure().logStep('Visiting Admin Organization page'); cy.visit(selectors.legalEntitiesURL); } static visitOfficeGuidesPage(): void { cy.allure().logStep('Visiting Office Guides page'); cy.visit(selectors.officeGuidesURL); } static createOfficeGuide(): void { const officeInfo = LegalData.generateOfficeData('uuid', true); cy.allure().logStep('Creating an office guide'); cy.get(selectors.orgOfficeButton).click(); cy.get(selectors.secondaryButton).click(); cy.get(selectors.officeFormName).should('be.visible').type(officeInfo.officeName); cy.get(selectors.officeFormAddress).type(officeInfo.address1); cy.get(selectors.formPopup).click(); cy.get(selectors.officeFormUuid).click(); cy.get(selectors.officeFormOption).eq(1).click(); cy.get(selectors.officeFormPos).click(); cy.get(selectors.officeFormOption).eq(1).click(); cy.get(selectors.formSaveButton).click(); } static createLegalEntity(): void { const legalEntity = LegalData.generateLegalEntitiesData(); cy.allure().logStep('Adding a legal entity'); cy.get(selectors.orgEntitiesButton).click(); cy.get(selectors.secondaryButton).click(); cy.get(selectors.legalFormName).type(legalEntity.legalName); cy.get(selectors.legalFormState).type(legalEntity.state); cy.get(selectors.legalFormAddress).type(legalEntity.address1); cy.get(selectors.formPopup).click(); cy.get(selectors.formSaveButton).click(); } static verifyOfficeToggles(): void { cy.allure().logStep('Verifiying presence of show office toggles'); cy.get(selectors.officeGuidesToggle).should('be.visible'); } static verifyOfficeSearch(officeName: string): void { cy.allure().logStep('Verifiying office guides search functionality'); cy.get(selectors.officeGuideSearch).type('blank'); cy.get(selectors.officeGuideEntry).should('not.exist'); cy.clearInputAndType(selectors.officeGuideSearch, officeName); cy.get(selectors.officeGuideEntry).should('be.visible'); } static openOfficeGuide(): void { cy.allure().logStep('Open office guide'); cy.get(selectors.officeGuideEntry).click(); } }