Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed i18n toggle from labs UI (#21927) #21975

Merged
merged 3 commits into from
Jan 21, 2025
Merged

Removed i18n toggle from labs UI (#21927) #21975

merged 3 commits into from
Jan 21, 2025

Conversation

ErisDS
Copy link
Member

@ErisDS ErisDS commented Jan 8, 2025

Trying again! 🙈

ref bb9a69e
ref https://linear.app/ghost/issue/ENG-1753/labs-flags-cleanup

  • We promoted i18n to GA several weeks ago now, and it's going fine
  • Removing the UI first to reduce confusion before cleaning up all the other references to the flag
  • Also changed the i18n test to set the language back at the end of the test, to ensure no conflicts

Summary by CodeRabbit

  • Removed Feature

    • Removed the 'Portal translation' feature toggle from the Labs settings.
  • Testing

    • Introduced a new function for setting the publication language in internationalization (i18n) test cases, enhancing readability and reducing redundancy.

Copy link

coderabbitai bot commented Jan 20, 2025

Walkthrough

The changes involve removing the internationalization (i18n) feature toggle from the admin settings and updating a related end-to-end test file. The modification simplifies the labs settings by eliminating the portal translation feature toggle, while simultaneously refactoring the language-setting test logic into a more modular and reusable function.

Changes

File Change Summary
apps/admin-x-settings/src/components/settings/advanced/labs/BetaFeatures.tsx Removed LabItem for portal translation feature toggle
ghost/core/test/e2e-browser/admin/i18n.spec.js Added setLanguage() function to centralize language setting logic in test

Poem

🐰 A rabbit's tale of code so neat,
Translations fade, tests now complete
No more toggles, no more fuss
Language settings? Just discuss!
Clean and simple, that's our way
Coding magic on display 🔧


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a506838 and d4dd38b.

📒 Files selected for processing (1)
  • ghost/core/test/e2e-browser/admin/i18n.spec.js (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ghost/core/test/e2e-browser/admin/i18n.spec.js
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Regression tests (Node 20.11.1, sqlite3)
  • GitHub Check: Database tests (Node 20.11.1, sqlite3)
  • GitHub Check: Regression tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 18.12.1, mysql8)
  • GitHub Check: Admin-X Settings tests
  • GitHub Check: Unit tests (Node 20.11.1)
  • GitHub Check: Unit tests (Node 18.12.1)
  • GitHub Check: Lint
  • GitHub Check: i18n

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
ghost/core/test/e2e-browser/admin/i18n.spec.js (2)

5-12: Good extraction of reusable function, consider adding error handling and documentation.

The function follows good practices with proper selector usage and clear responsibility. Consider these improvements:

  1. Add JSDoc documentation for better reusability
  2. Add error handling for invalid languages
  3. Verify successful language change
+/**
+ * Sets the publication language in Ghost admin settings
+ * @param {import('@playwright/test').Page} sharedPage - The shared page object
+ * @param {string} language - The language code (e.g., 'en', 'fr')
+ * @throws {Error} If language change fails
+ */
 async function setLanguage(sharedPage, language) {
     await sharedPage.goto('/ghost/#/settings/publication-language');
     const section = sharedPage.getByTestId('publication-language');
     await section.getByRole('button', {name: 'Edit'}).click();
     const input = section.getByPlaceholder('Site language');
     await input.fill(language);
     await section.getByRole('button', {name: 'Save'}).click();
+    // Verify language was set
+    await section.getByText(language, {exact: true}).waitFor({state: 'visible'});
 }

39-40: Consider using afterEach for language reset.

Good practice resetting the language to prevent test interference! Consider moving this to an afterEach hook for better test structure and automatic cleanup:

 test.describe('i18n', () => {
+    test.afterEach(async ({sharedPage}) => {
+        await setLanguage(sharedPage, 'en');
+    });
+
     test.describe('Newsletter', () => {
         test('changing the site language immediately translates strings in newsletters', async ({sharedPage}) => {
             await setLanguage(sharedPage, 'fr');
             // ... test code ...
-            // Set the language back before the next test!
-            await setLanguage(sharedPage, 'en');
         });
     });
 });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d93def and 6c4bbb4.

📒 Files selected for processing (2)
  • apps/admin-x-settings/src/components/settings/advanced/labs/BetaFeatures.tsx (0 hunks)
  • ghost/core/test/e2e-browser/admin/i18n.spec.js (2 hunks)
💤 Files with no reviewable changes (1)
  • apps/admin-x-settings/src/components/settings/advanced/labs/BetaFeatures.tsx
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Browser tests
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Database tests (Node 20.11.1, sqlite3)
  • GitHub Check: Database tests (Node 20.11.1, mysql8)
  • GitHub Check: Regression tests (Node 20.11.1, sqlite3)
  • GitHub Check: Database tests (Node 18.12.1, mysql8)
  • GitHub Check: Regression tests (Node 20.11.1, mysql8)
  • GitHub Check: Admin-X Settings tests
🔇 Additional comments (1)
ghost/core/test/e2e-browser/admin/i18n.spec.js (1)

Line range hint 17-38: Well-structured test with clear assertions!

The test properly sets up the French language environment, performs the newsletter operations, and validates the translations with explicit expectations.

ref bb9a69e
ref https://linear.app/ghost/issue/ENG-1753/labs-flags-cleanup

- We promoted i18n to GA several weeks ago now, and it's going fine
- Removing the UI first to reduce confusion before cleaning up all the other references to the flag
- Also changed the i18n test to set the language back at the end of the test, to ensure no conflicts
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
ghost/core/test/e2e-browser/admin/i18n.spec.js (3)

5-11: Good extraction of reusable functionality, consider adding error handling.

The function follows good practices by using test IDs and maintaining consistent async/await patterns. However, it could be more robust.

Consider these improvements:

 async function setLanguage(sharedPage, language) {
+    if (!language || typeof language !== 'string') {
+        throw new Error('Language parameter must be a non-empty string');
+    }
     await sharedPage.goto('/ghost/#/settings/publication-language');
     const section = sharedPage.getByTestId('publication-language');
     const input = section.getByPlaceholder('Site language');
     await input.fill(language);
     await section.getByRole('button', {name: 'Save'}).click();
+    // Verify save was successful
+    await section.getByText('Saved').waitFor();
 }

38-39: Enhance the cleanup comment to be more descriptive.

The current comment could better explain the importance of the language reset.

-    // Set the language back before the next test!
+    // Reset language to English to maintain consistent test environment and prevent side effects in subsequent tests
     await setLanguage(sharedPage, 'en');

16-16: Consider verifying the language reset.

While the test properly resets the language, it doesn't verify that the reset was successful.

Consider adding an assertion after the reset:

     await setLanguage(sharedPage, 'en');
+    // Verify reset was successful
+    await sharedPage.goto('/ghost');
+    const metaTextAfterReset = await sharedPage.frameLocator('iframe.gh-pe-iframe').locator('td.post-meta').first().textContent();
+    expect(metaTextAfterReset).toContain('By Joe Bloggs');
+    expect(metaTextAfterReset).not.toContain('Par Joe Bloggs');

Also applies to: 39-39

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6c4bbb4 and 52020ef.

📒 Files selected for processing (2)
  • apps/admin-x-settings/src/components/settings/advanced/labs/BetaFeatures.tsx (0 hunks)
  • ghost/core/test/e2e-browser/admin/i18n.spec.js (2 hunks)
💤 Files with no reviewable changes (1)
  • apps/admin-x-settings/src/components/settings/advanced/labs/BetaFeatures.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Browser tests

@ErisDS ErisDS merged commit 3211a14 into main Jan 21, 2025
22 checks passed
@ErisDS ErisDS deleted the i18n-flag-again branch January 21, 2025 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant