Skip to content

Conversation

hienha-sw
Copy link

This pull request adds a comprehensive documentation guide for language-agnostic testing in Playwright using the @shopware-ag/acceptance-test-suite. The guide explains how to write tests that adapt to different locales by using translation keys and provides step-by-step instructions for integrating and customizing translation support in your own projects. It covers usage patterns, environment configuration, translation file organization, and common troubleshooting tips.

Language-Agnostic Testing Concepts:

  • Introduces the translate() function and the Translate fixture for replacing hardcoded strings with translation keys in tests and page objects, enabling tests to work across multiple languages.
  • Explains translation key patterns, locale file structure, and provides example translation files for English and German.

Custom Integration and Extension:

  • Details how to extend the base test suite with custom translation fixtures, merge translation resources, and define type-safe translation keys for IntelliSense and compile-time validation.
  • Describes how to organize locale files, create an index for imports, and merge custom translations with the base suite.

Environment and Configuration:

  • Provides instructions for configuring Playwright to support dynamic language switching via environment variables and browser arguments, ensuring the browser UI matches the test language.
  • Lists common issues and troubleshooting steps

@hienha-sw hienha-sw self-assigned this Oct 6, 2025
@hienha-sw hienha-sw requested review from Copilot and a team October 6, 2025 13:16
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds comprehensive documentation for language-agnostic testing in Playwright using the @shopware-ag/acceptance-test-suite. The guide enables developers to write tests that work across multiple languages by using translation keys instead of hardcoded strings.

  • Introduces the translate() function and Translate fixture for creating locale-aware tests
  • Provides detailed integration guide for custom projects with translation support
  • Documents translation key patterns, file organization, and environment configuration

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


```bash
# German
lang=de npx playwright test
Copy link
Preview

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

Environment variable assignment should use uppercase 'LANG' for consistency with other examples in the document and standard Unix conventions.

Suggested change
lang=de npx playwright test
LANG=de npx playwright test

Copilot uses AI. Check for mistakes.


export const test = base.extend<CustomTranslateFixture>({
Translate: async ({}, use) => {
let lang = process.env.lang || process.env.LANGUAGE || process.env.LANG || 'en';
Copy link
Preview

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

The environment variable check order should prioritize 'LANG' over 'lang' since 'LANG' is the standard Unix environment variable, and lowercase 'lang' appears to be a custom variable that's inconsistently used.

Suggested change
let lang = process.env.lang || process.env.LANGUAGE || process.env.LANG || 'en';
let lang = process.env.LANG || process.env.LANGUAGE || process.env.lang || 'en';

Copilot uses AI. Check for mistakes.

@hienha-sw hienha-sw force-pushed the docs/add-language-agnostic-for-playwright-test branch from 38ad87e to 14175e2 Compare October 6, 2025 13:35
@hienha-sw hienha-sw force-pushed the docs/add-language-agnostic-for-playwright-test branch from 14175e2 to e38e506 Compare October 6, 2025 13:50
Correct formatting of code block for locales structure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants