Skip to content

refactor(scripts): extract seed-onboarding's schema filler and pick holiday-free start dates - #1423

Open
gabrielseco wants to merge 5 commits into
mainfrom
refactor/seed-onboarding-fill-schema
Open

gabrielseco wants to merge 5 commits into
mainfrom
refactor/seed-onboarding-fill-schema

Conversation

@gabrielseco

@gabrielseco gabrielseco commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Makes the onboarding seed script create employments that the API accepts more reliably, and moves its form-filling logic into a shared module so the schema canary can reuse it.

Why

npm run seed:onboarding regularly failed for some countries. The start date it picked (21 days out) could land on a local public holiday, or fall short of a country's minimum notice (Iceland needs about 20 working days).

The schema canary in #1382 needs the same form-filling logic. Splitting it out here keeps #1382 focused on the canary itself and easier to review.

What changed

Toggle details
  • New scripts/fill-schema.ts with fillSchema, fakeValueFor and preferNoOption, moved out of seed-onboarding.ts unchanged except for the points below.
  • New pickSafeDate / safeStartDateYears: the start date is now the earliest Monday to Thursday at least 35 days out that isn't a public holiday, checked against a 60-day window. seed-onboarding.ts fetches /v1/countries/{country}/holidays/{year} and passes that date in as provisional_start_date. If one year's holiday lookup fails, that year is skipped with a warning and the years that did load are still used.
  • Only Monday to Thursday because Tiger blocks some start weekdays per country (ISL: Friday and Saturday; BOL, BRA, COL, ECU, HND, MEX, PAN, PER, PRY, URY: Saturday and Sunday), and the public API doesn't expose those rules. Skipping Friday to Sunday covers every rule today without copying Tiger's table.
  • Dev-only scripts: nothing ships in the npm package, and there is no public API change.
  • Known limitation: Tiger also rejects LATAM start dates on or after the 15th of the month (20th for MEX), behind the check_latam_provisional_start_date_before_payroll_run flag. The flag looks off in sandbox (every LATAM country seeds today), so this isn't handled yet.

Screenshots

N/A

Related Resources

Testing

  • Tested against the example/ app in a browser: N/A, script only
  • Feature flag: N/A

Exercised through #1382's schema canary CI runs, which seed a real sandbox employment for every EOR country with this code (latest run: 91/92 seeded; ISL failed because its date landed on a Friday, which this PR now avoids).

Manual runs of npm run seed:onboarding -- --country=<X> --env=sandbox:

  • ISL, DEU, BRA on today's date: all seeded (start date Tue 2026-11-03).
  • job_title stays lorem words: PRT, ISL, DEU, BRA, GBR, USA, FRA, ESP, NLD, IND, MEX, JPN all seeded with lorem job titles, so no eligibility-specific title is needed.
  • ISL with the clock shifted so 35 days out is a Friday: the previous code sent 2026-11-06 and got cannot be set to a Friday; this PR sends Mon 2026-11-09 and seeds.
  • ISL with the clock shifted so 35 days out is 2026-12-24 and the 2027 holidays request forced to 500: the previous code fell back to 2026-12-24 and got cannot be in a holiday; this PR logs a warning, keeps the 2026 holidays, sends 2026-12-28 and seeds.

🤖 Generated with Claude Code


Note

Low Risk
Changes are limited to dev seed scripts; they improve reliability of test data creation without touching production app code or public APIs.

Overview
Extracts onboarding schema auto-fill (fillSchema, fakeValueFor, preferNoOption) into shared scripts/fill-schema.ts so dev seeding and the upcoming schema canary can reuse the same logic.

seed-onboarding now picks provisional_start_date via findSafeStartDate: it loads country holidays from the API, then pickSafeDate chooses the earliest Mon–Thu date at least 35 days out that is not a holiday (60-day search window). Generic date filler offsets move from 21 to 35 days. Failed holiday fetches for a year are warned and skipped without discarding other years.

Risk: Low — dev-only scripts; no product API or package surface change.

Reviewed by Cursor Bugbot for commit 75f68e7. Bugbot is set up for automated code reviews on this repo. Configure here.

…oliday-free start dates

Moves fillSchema/fakeValueFor/preferNoOption out of seed-onboarding.ts into
scripts/fill-schema.ts so the upcoming schema canary (#1382) can reuse them.

Along the way, seeded employments get:
- a provisional_start_date at least 35 days out that skips the country's
  public holidays (fetched from /v1/countries/{country}/holidays/{year}),
  since 21 days wasn't enough lead time for some countries (e.g. Iceland)
  and fixed offsets regularly landed on local holidays
- job_title "Software Engineer" instead of lorem words, which some
  countries' job title eligibility checks reject

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Deploy preview for adp-cost-calculator ready!

Project:adp-cost-calculator
Status: ✅  Deploy successful!
Preview URL:https://adp-cost-calculator-i4mf75d9x-remotecom.vercel.app
Latest Commit:75f68e7

Deployed with vercel-action

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Deploy preview for remote-flows ready!

Project:remote-flows
Status: ✅  Deploy successful!
Preview URL:https://remote-flows-k1dulggx9-remotecom.vercel.app
Latest Commit:75f68e7

Deployed with vercel-action

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

📊 Coverage Report

⚪ Coverage unchanged

Metric Current Previous Change Status
Lines 86.82% 86.82% 0% ⚪
Statements 86.39% 86.39% 0% ⚪
Functions 85.42% 85.42% 0% ⚪
Branches 78.19% 78.19% 0% ⚪

Detailed Breakdown

Lines Coverage
  • Covered: 5006 / 5766
  • Coverage: 86.82%
  • Change: 0% (0 lines)
Statements Coverage
  • Covered: 5095 / 5898
  • Coverage: 86.39%
  • Change: 0% (0 statements)
Functions Coverage
  • Covered: 1330 / 1557
  • Coverage: 85.42%
  • Change: 0% (0 functions)
Branches Coverage
  • Covered: 3093 / 3956
  • Coverage: 78.19%
  • Change: 0% (0 branches)

✅ Coverage check passed

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread scripts/seed-onboarding.ts Outdated
gabrielseco and others added 3 commits September 29, 2026 12:59
…holiday lookups

Tiger blocks some start weekdays per country (ISL: Friday/Saturday, much
of LATAM: Saturday/Sunday) and the public API doesn't expose that table,
so pickSafeDate now only returns a Monday-Thursday date.

A failed holidays lookup for one year no longer throws away the years
that did load; it logs a warning and skips just that year.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ay years

The extraction swapped SeedField/FieldOption for $TSFixMe and dropped an
optional chain on tel option meta. safeStartDateYears now reads the UTC
year so it matches the UTC ISO dates pickSafeDate compares against.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"Software Engineer" was added on the assumption that job title
eligibility checks reject lorem titles, but the failures that prompted
it had a different cause. Seeding PRT, ISL, DEU, BRA, GBR, USA, FRA, ESP,
NLD, IND, MEX and JPN in sandbox with lorem job titles all succeed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 12dcd3c. Configure here.

Comment thread scripts/fill-schema.ts

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant