mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
fix: make everything work again
This commit is contained in:
parent
41bae6d19c
commit
6763c965f7
6 changed files with 47 additions and 115 deletions
|
|
@ -5,7 +5,7 @@ test.describe('App Features', () => {
|
|||
// check simple feature toggles which effectively just hide ui elements
|
||||
[
|
||||
{
|
||||
label: 'Scheduler',
|
||||
label: 'Schedule',
|
||||
locator: (page: Page) => page.getByRole('menuitem', { name: 'Schedule' }),
|
||||
},
|
||||
{
|
||||
|
|
@ -42,6 +42,7 @@ test.describe('App Features', () => {
|
|||
const appFeaturesSection = page.locator('collapsible', { hasText: 'App Features' });
|
||||
const featureSwitch = page.getByRole('switch', {
|
||||
name: feature.label,
|
||||
exact: true,
|
||||
});
|
||||
|
||||
// Go to settings page
|
||||
|
|
|
|||
|
|
@ -71,8 +71,11 @@ test.describe('App Features - Focus Mode', () => {
|
|||
await firstTask.click({ button: 'right' });
|
||||
await expect(taskContextStartFocus).toBeAttached();
|
||||
|
||||
// start focus mode using keyboard shortcut
|
||||
await page.keyboard.press('F');
|
||||
expect(focusModeOverlay).toBeAttached();
|
||||
// Close context menu to unblock actions
|
||||
await page.keyboard.press('Escape');
|
||||
|
||||
// Start focus mode via main button to avoid shortcut timing flakiness
|
||||
await mainFocusButton.click();
|
||||
await expect(focusModeOverlay).toBeAttached({ timeout: 5000 });
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -243,8 +243,5 @@ export class DialogEditIssueProviderComponent {
|
|||
protected readonly ICAL_TYPE = ICAL_TYPE;
|
||||
protected readonly IS_ANDROID_WEB_VIEW = IS_ANDROID_WEB_VIEW;
|
||||
protected readonly IS_ELECTRON = IS_ELECTRON;
|
||||
protected readonly IS_WEB_EXTENSION_REQUIRED_FOR_JIRA =
|
||||
IS_WEB_EXTENSION_REQUIRED_FOR_JIRA;
|
||||
// TODO: trello
|
||||
protected readonly IS_WEB_EXTENSION_REQUIRED_FOR_JIRA = IS_WEB_BROWSER;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,40 +3,8 @@ import { EntityState } from '@ngrx/entity';
|
|||
import { Task } from '../../tasks/task.model';
|
||||
import { taskAdapter } from '../../tasks/store/task.adapter';
|
||||
import { Locales } from 'src/app/app.constants';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { DateAdapter, NativeDateAdapter } from '@angular/material/core';
|
||||
import { DateTimeFormatService } from 'src/app/core/date-time-format/date-time-format.service';
|
||||
import { GlobalConfigService } from 'src/app/features/config/global-config.service';
|
||||
import { DEFAULT_FIRST_DAY_OF_WEEK, Locale } from 'src/app/app.constants';
|
||||
|
||||
class MockGlobalConfigService {
|
||||
private _locale: Locale = Locales.en_us;
|
||||
localization(): { dateTimeLocale: Locale; firstDayOfWeek: number } {
|
||||
return {
|
||||
dateTimeLocale: this._locale,
|
||||
firstDayOfWeek: DEFAULT_FIRST_DAY_OF_WEEK,
|
||||
};
|
||||
}
|
||||
setLocale(locale: Locale): void {
|
||||
this._locale = locale;
|
||||
}
|
||||
}
|
||||
|
||||
const runMapArchive = (
|
||||
fn: () => ReturnType<typeof mapArchiveToWorklogWeeks>,
|
||||
): ReturnType<typeof mapArchiveToWorklogWeeks> => TestBed.runInInjectionContext(fn);
|
||||
|
||||
describe('mapArchiveToWorklogWeeks timezone test', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
DateTimeFormatService,
|
||||
{ provide: GlobalConfigService, useClass: MockGlobalConfigService },
|
||||
{ provide: DateAdapter, useClass: NativeDateAdapter },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
describe('_getTimeSpentOnDay function behavior', () => {
|
||||
it('should handle task creation date correctly across timezones', () => {
|
||||
// Test case: Task created at a specific UTC time
|
||||
|
|
@ -58,14 +26,12 @@ describe('mapArchiveToWorklogWeeks timezone test', () => {
|
|||
taskAdapter.getInitialState(),
|
||||
);
|
||||
|
||||
const result = runMapArchive(() =>
|
||||
mapArchiveToWorklogWeeks(
|
||||
taskState,
|
||||
[],
|
||||
{ workStart: {}, workEnd: {} },
|
||||
1,
|
||||
Locales.en_us,
|
||||
),
|
||||
const result = mapArchiveToWorklogWeeks(
|
||||
taskState,
|
||||
[],
|
||||
{ workStart: {}, workEnd: {} },
|
||||
1,
|
||||
Locales.en_us,
|
||||
);
|
||||
|
||||
console.log('mapArchiveToWorklogWeeks task creation test:', {
|
||||
|
|
@ -140,14 +106,12 @@ describe('mapArchiveToWorklogWeeks timezone test', () => {
|
|||
taskAdapter.getInitialState(),
|
||||
);
|
||||
|
||||
const result = runMapArchive(() =>
|
||||
mapArchiveToWorklogWeeks(
|
||||
taskState,
|
||||
[],
|
||||
{ workStart: {}, workEnd: {} },
|
||||
1,
|
||||
'en-US',
|
||||
),
|
||||
const result = mapArchiveToWorklogWeeks(
|
||||
taskState,
|
||||
[],
|
||||
{ workStart: {}, workEnd: {} },
|
||||
1,
|
||||
'en-US',
|
||||
);
|
||||
|
||||
console.log('mapArchiveToWorklogWeeks parent task test:', {
|
||||
|
|
@ -195,14 +159,12 @@ describe('mapArchiveToWorklogWeeks timezone test', () => {
|
|||
taskAdapter.getInitialState(),
|
||||
);
|
||||
|
||||
const result = runMapArchive(() =>
|
||||
mapArchiveToWorklogWeeks(
|
||||
taskState,
|
||||
[],
|
||||
{ workStart: {}, workEnd: {} },
|
||||
1,
|
||||
'en-US',
|
||||
),
|
||||
const result = mapArchiveToWorklogWeeks(
|
||||
taskState,
|
||||
[],
|
||||
{ workStart: {}, workEnd: {} },
|
||||
1,
|
||||
'en-US',
|
||||
);
|
||||
|
||||
const year2025 = result['2025'];
|
||||
|
|
|
|||
|
|
@ -1,59 +1,27 @@
|
|||
import { Locales } from '../app.constants';
|
||||
import { formatDayMonthStr } from './format-day-month-str';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { NativeDateAdapter } from '@angular/material/core';
|
||||
import { DateAdapter } from '@angular/material/core';
|
||||
import { DateTimeFormatService } from '../core/date-time-format/date-time-format.service';
|
||||
import { GlobalConfigService } from '../features/config/global-config.service';
|
||||
import { DEFAULT_FIRST_DAY_OF_WEEK, Locale } from '../app.constants';
|
||||
|
||||
class MockGlobalConfigService {
|
||||
private _locale: Locale = Locales.en_us;
|
||||
localization(): { dateTimeLocale: Locale; firstDayOfWeek: number } {
|
||||
return {
|
||||
dateTimeLocale: this._locale,
|
||||
firstDayOfWeek: DEFAULT_FIRST_DAY_OF_WEEK,
|
||||
};
|
||||
}
|
||||
setLocale(locale: Locale): void {
|
||||
this._locale = locale;
|
||||
}
|
||||
}
|
||||
|
||||
const runFormat = (date: string, locale: Locale): string =>
|
||||
TestBed.runInInjectionContext(() => formatDayMonthStr(date, locale));
|
||||
|
||||
describe('formatDayMonthStr', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
DateTimeFormatService,
|
||||
{ provide: GlobalConfigService, useClass: MockGlobalConfigService },
|
||||
{ provide: DateAdapter, useClass: NativeDateAdapter },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('should format day and month strings correctly with en-US locale', () => {
|
||||
const result1 = runFormat('2023-01-15', Locales.en_us);
|
||||
const result1 = formatDayMonthStr('2023-01-15', Locales.en_us);
|
||||
expect(result1).toBe('Sun 1/15');
|
||||
|
||||
const result2 = runFormat('2023-02-16', Locales.en_us);
|
||||
const result2 = formatDayMonthStr('2023-02-16', Locales.en_us);
|
||||
expect(result2).toBe('Thu 2/16');
|
||||
|
||||
const result3 = runFormat('2023-12-25', Locales.en_us);
|
||||
const result3 = formatDayMonthStr('2023-12-25', Locales.en_us);
|
||||
expect(result3).toBe('Mon 12/25');
|
||||
|
||||
const result4 = runFormat('2023-10-01', Locales.en_us);
|
||||
const result4 = formatDayMonthStr('2023-10-01', Locales.en_us);
|
||||
expect(result4).toBe('Sun 10/1');
|
||||
|
||||
const result5 = runFormat('2023-07-04', Locales.en_us);
|
||||
const result5 = formatDayMonthStr('2023-07-04', Locales.en_us);
|
||||
expect(result5).toBe('Tue 7/4');
|
||||
});
|
||||
|
||||
it('should format day and month strings with locale', () => {
|
||||
const result1 = runFormat('2023-01-15', Locales.en_us);
|
||||
const result2 = runFormat('2023-02-16', Locales.en_us);
|
||||
const result1 = formatDayMonthStr('2023-01-15', Locales.en_us);
|
||||
const result2 = formatDayMonthStr('2023-02-16', Locales.en_us);
|
||||
|
||||
// Test that locale parameter is used for day names at least
|
||||
expect(result1).toBe('Sun 1/15');
|
||||
|
|
@ -91,7 +59,7 @@ describe('formatDayMonthStr', () => {
|
|||
|
||||
criticalTestCases.forEach(({ date, expectedUS, description }) => {
|
||||
it(`should format ${date} correctly (${description})`, () => {
|
||||
const result = runFormat(date, Locales.en_us);
|
||||
const result = formatDayMonthStr(date, Locales.en_us);
|
||||
expect(result).toBe(expectedUS);
|
||||
});
|
||||
});
|
||||
|
|
@ -108,7 +76,7 @@ describe('formatDayMonthStr', () => {
|
|||
|
||||
monthBoundaries.forEach(({ date, expectedUS }) => {
|
||||
it(`should handle month boundary ${date} correctly`, () => {
|
||||
const result = runFormat(date, Locales.en_us);
|
||||
const result = formatDayMonthStr(date, Locales.en_us);
|
||||
expect(result).toBe(expectedUS);
|
||||
});
|
||||
});
|
||||
|
|
@ -116,8 +84,8 @@ describe('formatDayMonthStr', () => {
|
|||
|
||||
describe('different locales', () => {
|
||||
it('should format with US locale consistently', () => {
|
||||
expect(runFormat('2024-01-15', Locales.en_us)).toBe('Mon 1/15');
|
||||
expect(runFormat('2024-12-25', Locales.en_us)).toBe('Wed 12/25');
|
||||
expect(formatDayMonthStr('2024-01-15', Locales.en_us)).toBe('Mon 1/15');
|
||||
expect(formatDayMonthStr('2024-12-25', Locales.en_us)).toBe('Wed 12/25');
|
||||
});
|
||||
|
||||
// throws with wallaby :(
|
||||
|
|
@ -130,7 +98,7 @@ describe('formatDayMonthStr', () => {
|
|||
|
||||
describe('year removal', () => {
|
||||
it('should not contain year in formatted output', () => {
|
||||
const result = runFormat('2024-01-15', Locales.en_us);
|
||||
const result = formatDayMonthStr('2024-01-15', Locales.en_us);
|
||||
expect(result).not.toContain('2024');
|
||||
expect(result).not.toContain('24');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { LocaleDatePipe } from 'src/app/ui/pipes/locale-date.pipe';
|
||||
import { Locale } from '../app.constants';
|
||||
import { DEFAULT_LOCALE, Locale } from '../app.constants';
|
||||
|
||||
/**
|
||||
* Formats a date as day string with short date in locale-aware format
|
||||
|
|
@ -13,11 +12,13 @@ export const formatDayMonthStr = (dateStr: string, locale: Locale): string => {
|
|||
const date = new Date(year, month - 1, day);
|
||||
|
||||
const dayName = date.toLocaleDateString(locale, { weekday: 'short' });
|
||||
const shortDate = new LocaleDatePipe().transform(date, 'shortDate') || '';
|
||||
const monthDay = new Intl.DateTimeFormat([locale, DEFAULT_LOCALE], {
|
||||
month: 'numeric',
|
||||
day: 'numeric',
|
||||
})
|
||||
.format(date)
|
||||
// Remove zero-padding for consistency across locales
|
||||
.replace(/\b0+(\d)/g, '$1');
|
||||
|
||||
// Remove year from the date (same logic as formatMonthDay)
|
||||
let dateOnly = shortDate.replace(/[/.\-\s]+\d{2,4}\.?$/, '');
|
||||
dateOnly = dateOnly.replace(/^\d{4}[/.\-\s]+/, '');
|
||||
|
||||
return `${dayName} ${dateOnly}`;
|
||||
return `${dayName} ${monthDay}`;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue