Created
March 27, 2024 16:43
-
-
Save itz4blitz/892e45973545a3c635e851e599d5e9be to your computer and use it in GitHub Desktop.
example of perm method
This file contains hidden or 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
| async verifyAllowedToMakeNormalPayments(newPage: any, role: any, user: any, api: API, request: APIRequestContext, positiveScenario = true) { | |
| let commonpo = new commonPO(newPage); | |
| let paymentspo = new paymentsPO(newPage); | |
| let origin = process.env.BASE_URL!; | |
| async function adminSeed() { | |
| let random = new randomGen(); | |
| let sqlQuery = new SQLquery(); | |
| const facility = await api.facility.createFacility(request, api.bearerToken, await api.facility.defaultFacilityValues(random.facilityName)); | |
| const testWorker = await api.user.createUser(request, api.bearerToken, await api.user.defaultWorkerValues()); | |
| await api.user.credentialedWorker(request, api.bearerToken, testWorker.id, true, 1); | |
| await sqlQuery.importWorkerToProliant(testWorker.id); | |
| const payRate = await api.payRate.createPayRate(request, api.bearerToken, await api.payRate.defaultTravelPayRateValues(random.payRateName)); | |
| await api.onAssignment.createOnAssignment(request, api.bearerToken, await api.onAssignment.defaultAssignmentValues(payRate.id, facility.id), testWorker.id); | |
| const timecard = await api.timecard.createPendingApprovalTimecard(request, api.bearerToken, await api.timecard.defaultTimecardValues(testWorker.id, facility.id)); | |
| const getTimecard = await api.timecard.getTimecard(request, api.bearerToken, timecard.id); | |
| await api.timecard.approveTimecard(request, api.bearerToken, await api.timecard.defaultTimecardValuesForApproving(timecard.id, testWorker.id, payRate.id, getTimecard.updatedAt)); | |
| await sqlQuery.addProliantTaxesResponseToTimecards(); | |
| } | |
| async function adminFlow() { | |
| if (positiveScenario) { | |
| await test.step(`Verify ${role} has access to make normal payments`, async () => { | |
| await newPage.goto(`${origin}admin/payments`); | |
| await expect(commonpo.pageTitle).toContainText('Payments'); | |
| await expect(paymentspo.addTopUpButton).toBeVisible(); | |
| }); | |
| } else { | |
| await adminSeed(); | |
| await test.step(`Verify ${role} does not have access to make normal payments`, async () => { | |
| await newPage.goto(`${origin}admin/payments`); | |
| await expect(paymentspo.addTopUpButton).not.toBeVisible(); | |
| }); | |
| } | |
| } | |
| await adminFlow(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment