Skip to content
Draft
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
24 changes: 16 additions & 8 deletions packages/playground/website/playwright/e2e/website-ui.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -760,9 +760,9 @@ test.describe('Default Playground storage', () => {
null
);
await expect(website.page.getByText('Autosaving')).toHaveCount(0);
await expect(
website.page.getByText('Finalizing autosave')
).toHaveCount(0);
await expect(website.page.getByText('Finalizing autosave')).toHaveCount(
0
);
await expect(
website.page.getByRole('button', { name: 'Unsaved' })
).toHaveCount(0);
Expand Down Expand Up @@ -791,15 +791,23 @@ test.describe('Default Playground storage', () => {
}
)
);
expect(
saveStatusSamples.some(({ text }) => text === 'Autosaved')
).toBe(true);
expect(saveStatusSamples.some(({ text }) => text === 'Autosaved')).toBe(
true
);
expect(
saveStatusSamples.some(({ text }) => text === 'Autosaving')
).toBe(false);
const progressAriaLabels = saveStatusSamples
.map(({ ariaLabel }) => ariaLabel)
.filter((ariaLabel): ariaLabel is string =>
/^Autosaved \d+%$/.test(ariaLabel ?? '')
);
expect(progressAriaLabels.length).toBeGreaterThan(0);
expect(
saveStatusSamples.some(({ ariaLabel }) =>
/^Autosaved [1-9]\d*%$/.test(ariaLabel ?? '')
progressAriaLabels.every((ariaLabel) =>
['0', '25', '50', '75', '100'].includes(
ariaLabel.match(/^Autosaved (\d+)%$/)?.[1] ?? ''
)
)
).toBe(true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,15 @@ export function SaveStatusIndicator() {
const progress =
opfsSync?.status === 'syncing' ? opfsSync.progress : undefined;
const progressPercent = getProgressPercent(progress);
const announcedProgressPercent =
getAnnouncedProgressPercent(progressPercent);
return (
<div
className={classNames(css.indicator, css.saving)}
aria-label={`${getSyncLabel({
site: activeSite,
opfsSync,
})} ${progressPercent}%`}
})} ${announcedProgressPercent}%`}
role="status"
>
<span
Expand Down Expand Up @@ -292,3 +294,7 @@ function getProgressPercent(
}
return Math.min(100, Math.round((progress.files / progress.total) * 100));
}

function getAnnouncedProgressPercent(progressPercent: number) {
return Math.min(100, Math.floor(progressPercent / 25) * 25);
}
Loading