Skip to content

Commit 6dfa1a9

Browse files
authored
feat(frontend): unify feed/result state flow (#943)
## Summary - unify guest/member/result flow around a consistent dominant-field interaction model - refine app panels and result display behavior for readiness and retry states - align related frontend hooks/api wiring and test coverage with the updated UI state contract - rename frontend type entrypoint from env.d.ts to environment.d.ts This pull request updates and improves the frontend test suites for the application, focusing on consistency in terminology, better test reliability, and improved clarity in test expectations. The changes include standardizing user-facing text in tests, switching from `window` to `globalThis` for global objects, and updating test logic to match recent UI and API changes. Most important changes: **Terminology and Text Consistency:** * Standardized the access token prompt from "Add access token" to "Enter access token" across all relevant tests, ensuring consistency with the application's UI. [[1]](diffhunk://#diff-41620153491a2a4a4ebddd835700a5287e416230bd73f3e964afe00f889f8e31L59-R59) [[2]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L166-R179) [[3]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L367-R374) [[4]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L429-R440) * Updated test expectations to use new user-facing messages, such as changing "Feed generation failed" to "Could not create feed link", "Your feed is ready" to "Feed ready", and other similar updates for clarity and consistency. [[1]](diffhunk://#diff-0f9368690552ac79a208dde6e3f09cf9f4e350e910d0de10c35dc2cc235479b1L67-R67) [[2]](diffhunk://#diff-0f9368690552ac79a208dde6e3f09cf9f4e350e910d0de10c35dc2cc235479b1L162-R164) [[3]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L252-R287) [[4]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L397-R404) [[5]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L212-R217) **Test Reliability and Modernization:** * Replaced usage of `window` with `globalThis` for accessing global objects like `localStorage` and `history` in tests, improving compatibility and reliability in different testing environments. [[1]](diffhunk://#diff-0f9368690552ac79a208dde6e3f09cf9f4e350e910d0de10c35dc2cc235479b1L11-R11) [[2]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14R37-R49) [[3]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L147-R154) [[4]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L419-R426) [[5]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L429-R440) * Changed test selectors from `document.getElementById` to `document.querySelector` for improved robustness and flexibility in selecting DOM elements. [[1]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L166-R179) [[2]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L338-R345) [[3]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L409-R416) **Test Data and Mocking Improvements:** * Updated all mock return values in tests to use `undefined` instead of `null` for uninitialized or missing values, aligning with current code conventions. [[1]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14R37-R49) [[2]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L68-R78) [[3]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L86-R87) [[4]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L130-R131) [[5]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L202-R207) [[6]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L233-R245) [[7]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L252-R287) [[8]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L290-R297) [[9]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L308-R326) [[10]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L355-R362) [[11]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L383-R390) [[12]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L445-R460) [[13]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L481-R488) [[14]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L507-R514) **UI and UX Flow Adjustments:** * Updated test logic to match new UI flows, such as changing error handling and retry button labels from "Try ... instead" to "Retry with ...", and updating messages about feed creation and readiness. [[1]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L252-R287) [[2]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L462-R470) [[3]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L497-R504) **Minor Test and Code Cleanups:** * Removed unused imports (e.g., `h` from `preact`) and improved array creation for utility items in tests for better readability. [[1]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L3) [[2]](diffhunk://#diff-1f633b86af4bf00bbb33177b2e1a51a960711d1bb9901ce853b34e53d6bd7d14L308-R326) These changes collectively improve test accuracy, maintainability, and ensure that tests reflect the current application behavior and user interface.
1 parent 424fb0a commit 6dfa1a9

25 files changed

Lines changed: 1116 additions & 653 deletions

frontend/e2e/smoke.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ test.describe('frontend smoke', () => {
5656
await page.getByLabel('Page URL').fill('https://example.com/articles');
5757
await page.getByRole('button', { name: 'Generate feed URL' }).click();
5858

59-
await expect(page.getByRole('heading', { name: 'Add access token' })).toBeVisible();
59+
await expect(page.getByRole('heading', { name: 'Enter access token' })).toBeVisible();
6060
await expect(page.getByRole('textbox', { name: 'Access token' })).toBeVisible();
6161
await expect(page.getByRole('button', { name: 'Save and continue' })).toBeVisible();
6262
await expect(page.getByRole('button', { name: 'Back' })).toBeVisible();

frontend/src/__tests__/App.contract.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('App contract', () => {
88
const token = 'contract-token';
99

1010
const authenticate = () => {
11-
window.localStorage.setItem('html2rss_access_token', token);
11+
globalThis.localStorage.setItem('html2rss_access_token', token);
1212
};
1313

1414
it('shows feed result when API responds with success', async () => {
@@ -64,7 +64,7 @@ describe('App contract', () => {
6464
fireEvent.click(screen.getByRole('button', { name: 'Generate feed URL' }));
6565

6666
await waitFor(() => {
67-
expect(screen.getByText('Your feed is ready')).toBeInTheDocument();
67+
expect(screen.getByText('Feed ready')).toBeInTheDocument();
6868
expect(screen.getByText('Example Feed')).toBeInTheDocument();
6969
expect(screen.getByLabelText('Feed URL')).toBeInTheDocument();
7070
expect(screen.getByRole('button', { name: 'Copy feed URL' })).toBeInTheDocument();
@@ -159,8 +159,8 @@ describe('App contract', () => {
159159

160160
await screen.findByText('Access token was rejected. Paste a valid token to continue.');
161161

162-
expect(screen.getByText('Add access token')).toBeInTheDocument();
163-
expect(screen.queryByText('Feed generation failed')).not.toBeInTheDocument();
164-
expect(window.localStorage.getItem('html2rss_access_token')).toBeNull();
162+
expect(screen.getByText('Enter access token')).toBeInTheDocument();
163+
expect(screen.queryByText('Could not create feed link')).not.toBeInTheDocument();
164+
expect(globalThis.localStorage.getItem('html2rss_access_token')).toBeNull();
165165
});
166166
});

0 commit comments

Comments
 (0)