Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class GeoExperiment extends BaseModel {

static TYPES = {
ONSITE_OPPORTUNITY_DEPLOYMENT: 'onsite_opportunity_deployment',
OPTIMIZE_AT_SOURCE: 'optimize_at_source',
};

static STATUSES = {
Expand All @@ -47,6 +48,14 @@ class GeoExperiment extends BaseModel {
POST_ANALYSIS_DONE: 'post_analysis_done',
IMPACT_MEASUREMENT_STARTED: 'impact_measurement_started',
IMPACT_MEASUREMENT_DONE: 'impact_measurement_done',
// optimize-at-source (OAS) strategy phases
OAS_INITIATED: 'oas_initiated',
OAS_BASELINE_STARTED: 'oas_baseline_started',
OAS_BASELINE_DONE: 'oas_baseline_done',
OAS_AWAITING_PUBLISH: 'oas_awaiting_publish',
OAS_PUBLISH_VERIFIED: 'oas_publish_verified',
OAS_POST_SNAPSHOT: 'oas_post_snapshot',
OAS_COMPLETED: 'oas_completed',
};

/**
Expand Down Expand Up @@ -83,6 +92,15 @@ class GeoExperiment extends BaseModel {
OAE_VALIDATION_JOBS: 'oaeValidationJobs',
// Baseline (window 0) measurement bookkeeping, e.g. { taskId, startedAt, retryCount }.
BASELINE_MEASUREMENT: 'baselineMeasurement',
// optimize-at-source bookkeeping.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (blocking): These four new METADATA_KEYS break exposes METADATA_KEYS constant (test/unit/models/geo-experiment/geo-experiment.model.test.js:78-87). That test deep-equals the old 6-key object, so the Test job fails with expected { ...(10) } to deeply equal { ...(6) }. No test covers the other new values either:

  • TYPES.OPTIMIZE_AT_SOURCE (line 25) is the only runtime behavior change here. geo-experiment.schema.js builds the type enum from Object.values(GeoExperiment.TYPES), so the model now accepts optimize_at_source on create.
  • The seven OAS_* phases (lines 52-58) have no assertions.

These strings become a persisted contract between services, and the file already pins the existing phase literals (lines 140-152) to protect them.

Fix:

  • add the four new key/value pairs to the expected object at lines 79-86
  • add a setType(GeoExperiment.TYPES.OPTIMIZE_AT_SOURCE) round-trip to gets and sets type
  • add an exposes the optimize-at-source phases test that asserts each OAS_* literal

// URLs the external UI deployed, to be publish-checked, e.g. ['https://example.com/a'].
DEPLOYED_URLS: 'deployedUrls',
// Publish-check progress, e.g. { verifiedUrls: [...], lastCheckedAt }.
PUBLISH_CHECK: 'publishCheck',
// 14-day post window bookkeeping, e.g. { startedAt, lastSnapshotAt, snapshotCount }.
POST_WINDOW: 'postWindow',
// S3 location (key) of the raw daily SEO-metric snapshots.
SNAPSHOTS_LOCATION: 'snapshotsLocation',
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,31 @@ describe('GeoExperimentModel', () => {
ROUTING_VALIDATION: 'routingValidation',
OAE_VALIDATION_JOBS: 'oaeValidationJobs',
BASELINE_MEASUREMENT: 'baselineMeasurement',
DEPLOYED_URLS: 'deployedUrls',
PUBLISH_CHECK: 'publishCheck',
POST_WINDOW: 'postWindow',
SNAPSHOTS_LOCATION: 'snapshotsLocation',
});
});

it('exposes the optimize-at-source experiment type', () => {
expect(GeoExperiment.TYPES.OPTIMIZE_AT_SOURCE).to.equal('optimize_at_source');
});

it('exposes the optimize-at-source phases, in lifecycle order', () => {
const oasPhases = Object.entries(GeoExperiment.PHASES)
.filter(([key]) => key.startsWith('OAS_'));
expect(oasPhases).to.deep.equal([
['OAS_INITIATED', 'oas_initiated'],
['OAS_BASELINE_STARTED', 'oas_baseline_started'],
['OAS_BASELINE_DONE', 'oas_baseline_done'],
['OAS_AWAITING_PUBLISH', 'oas_awaiting_publish'],
['OAS_PUBLISH_VERIFIED', 'oas_publish_verified'],
['OAS_POST_SNAPSHOT', 'oas_post_snapshot'],
['OAS_COMPLETED', 'oas_completed'],
]);
});

it('exposes SCHEDULE_CONFIG_KEYS constant', () => {
expect(GeoExperiment.SCHEDULE_CONFIG_KEYS).to.deep.equal({
CRON_EXPRESSION: 'cronExpression',
Expand Down
Loading