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
4 changes: 4 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ This repository contains three interconnected applications:

- Pay attention to available types and type guards in src/SIL.XForge.Scripture/ClientApp/src/type-utils.ts.

# Tests

- Place a line with "// SUT" before the line that causes the code being tested to be exercised.

# Running commands

- If you run frontend tests, run them in the `src/SIL.XForge.Scripture/ClientApp` directory with a command such as `npm run test:headless -- --watch=false --include '**/text.component.spec.ts' --include '**/settings.component.spec.ts'`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@
</div>
</div>

@if (shouldShowDurationComparisonCaution) {
<app-notice icon="calendar_month" type="warning">
Be careful about comparing Serval build outcomes and durations before 2025-12-18 with those after, because of
changes to the event grouping system.
</app-notice>
}

@if (!isLoading) {
@if (currentProjectFilter) {
<app-notice icon="filter_alt" mode="fill-dark">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,35 @@ describe('DraftJobsComponent', () => {
}));
});

describe('shouldShowDurationComparisonCaution', () => {
it('should return false if no date range is set', fakeAsync(() => {
const env = new TestEnvironment({ hasEvents: false });
env.wait();
env.component['currentDateRange'] = undefined;

// SUT
expect(env.component.shouldShowDurationComparisonCaution).toBeFalse();
}));

it('should return true when the date range starts before the cutoff', fakeAsync(() => {
const env = new TestEnvironment({ hasEvents: false });
env.wait();
env.setDateRange(new Date(2025, 12 - 1, 1), new Date(2026, 1 - 1, 20));

// SUT
expect(env.component.shouldShowDurationComparisonCaution).toBeTrue();
}));

it('should return false when the date range starts on or after the cutoff', fakeAsync(() => {
const env = new TestEnvironment({ hasEvents: false });
env.wait();
env.setDateRange(new Date(2026, 1 - 1, 20), new Date(2026, 2 - 1, 20));

// SUT
expect(env.component.shouldShowDurationComparisonCaution).toBeFalse();
}));
});

describe('formatDurationInHours', () => {
it('should format duration in decimal hours', fakeAsync(() => {
const env = new TestEnvironment({ hasEvents: false });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,19 @@ export class DraftJobsComponent extends DataLoadingComponent implements OnInit {
return this.formatDurationInHours(this.maxDuration);
}

/** Whether to show a caution notice about comparing older durations. */
get shouldShowDurationComparisonCaution(): boolean {
if (this.currentDateRange == null) return false;

// Day after the date when draftGenerationRequestId began to be used, which was in SFv5.46.1 at
// 2025-12-18T17:48:57Z.
const requestIdIntroductionDate: Date = new Date(2025, 12 - 1, 18 + 1);

const rangeStartMs: number = this.currentDateRange.start.getTime();
const cutoffMs: number = requestIdIntroductionDate.getTime();
return rangeStartMs < cutoffMs;
}

ngOnInit(): void {
if (
!this.columnsToDisplay.includes('buildDetails') &&
Expand Down
Loading