Skip to content
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
48 changes: 48 additions & 0 deletions example/e2e/helpers/preOnboardingRequirements.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Page, expect, test } from '@playwright/test';

/**
* Completes the Pre-Onboarding Requirements shown in the Review step for this sandbox company:
* acknowledges the Time Tracking Policy checkbox, then reviews and signs the ILA (blocked until
* the acknowledgement is checked).
*/
export async function completePreOnboardingRequirements(
page: Page,
signature: string,
) {
const hasRequirements = await page
.getByText('Pre-Onboarding Requirements')
.isVisible();

if (!hasRequirements) {
test.info().annotations.push({
type: 'pre-onboarding-requirements-absent',
description: 'No Pre-Onboarding Requirements section rendered; skipped.',
});
return;
}

const checkbox = page.locator('[data-testid^="acknowledgement-checkbox-"]');
await checkbox.click();
await expect(checkbox).toHaveAttribute('data-state', 'checked');

await signPreOnboardingDocument(page, signature);
}

async function signPreOnboardingDocument(page: Page, signature: string) {
await page.getByRole('button', { name: 'Review document' }).click();

const documentDialog = page.locator(
'[data-slot="full-screen-dialog-content"]',
);
await documentDialog.waitFor({ state: 'visible' });
await documentDialog.getByRole('button', { name: 'Sign Document' }).click();

const signatureDialog = page.locator('[data-slot="dialog-content"]');
await signatureDialog.waitFor({ state: 'visible' });
await signatureDialog
.getByLabel('Your full name (signature)')
.fill(signature);
await signatureDialog.getByRole('button', { name: 'Sign Document' }).click();

await documentDialog.waitFor({ state: 'hidden' });
}
19 changes: 18 additions & 1 deletion example/e2e/onboard-germany-employee.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
fillOnboardingBenefitsStepDynamically,
watchForBenefitsSchema,
} from './helpers/benefits';
import { completePreOnboardingRequirements } from './helpers/preOnboardingRequirements';

test.describe('Onboard Germany employee', () => {
test.beforeEach(async ({ page }) => {
Expand Down Expand Up @@ -40,8 +41,10 @@ test.describe('Onboard Germany employee', () => {
stepTitle = page.getByTestId('onboarding-step-title');
await expect(stepTitle).toHaveText('Basic Information');

const fullname = `John Doe${Date.now()}`;

await fillOnboardingStep2Form(page, {
fullname: `John Doe${Date.now()}`,
fullname,
login_email: 'personal',
personal_email: `john.doe${Date.now()}@example.com`,
work_email: `john.doe${Date.now()}@pro.com`,
Expand Down Expand Up @@ -96,5 +99,19 @@ test.describe('Onboard Germany employee', () => {

stepTitle = page.getByTestId('onboarding-step-title');
await expect(stepTitle).toHaveText('Review');

const inviteButton = page.locator('.submit-button');
await expect(inviteButton).toBeDisabled();

await completePreOnboardingRequirements(page, fullname);

const editButtons = page.locator('.back-button');
const editButtonsCount = await editButtons.count();
for (let i = 0; i < editButtonsCount; i++) {
await expect(editButtons.nth(i)).toBeDisabled();
}

await expect(inviteButton).toBeEnabled();
await expect(inviteButton).toHaveText('Invite Employee');
});
});
Loading