mattermost/e2e-tests/playwright/script
sabril 2116a6d94a
MM-64282 E2E/Playwright: Test documentation format (#31050)
* initial implementation of test documentation in spec file with AI-assisted prompt from Claude and linter script

* update snapshots

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-05-20 01:07:47 +08:00
..
lint-test-docs.js MM-64282 E2E/Playwright: Test documentation format (#31050) 2025-05-20 01:07:47 +08:00
post_install.sh MM-63669 E2E/Playwright: Move "e2e-tests/playwright/test" to "e2e-tests/playwright" folder (#30647) 2025-04-07 22:26:29 +08:00
README.md MM-64282 E2E/Playwright: Test documentation format (#31050) 2025-05-20 01:07:47 +08:00

Playwright E2E Test Scripts

This directory contains utility scripts for the Playwright E2E test suite.

Test Documentation Format Linter

The lint-test-docs.js script verifies that all spec files follow the required documentation format:

  • JSDoc with @objective and @precondition tags
  • Proper test title with MM-T ID (e.g., MM-T1234)
  • Tag for feature categorization (e.g., {tag: '@feature_name'})
  • Action comments (e.g., // # Action)
  • Verification comments (e.g., // * Verification)

Usage

# Run the linter directly
node script/lint-test-docs.js

# Or use the npm script
npm run lint:test-docs

Integration with CI

The linter is also integrated with the main check command, which is typically run before committing changes:

npm run check

This will run ESLint, Prettier, TypeScript type checking, and the test documentation format linter.

Requirements

All spec files should follow this format:

/**
 * @objective Clear description of what the test verifies
 *
 * @precondition
 * Special setup or conditions required for the test
 * Note: Only include for non-default requirements
 */
test('descriptive test title', {tag: '@feature_tag'}, async ({pw}) => {
    // # Initialize setup and login
    const {user} = await pw.initSetup();
    const {channelsPage} = await pw.testBrowser.login(user);

    // # Navigate to channel and post a message
    await channelsPage.goto();
    await channelsPage.postMessage('Test message');

    // * Verify message appears in the channel
    const lastPost = await channelsPage.getLastPost();
    await expect(lastPost.body).toContainText('Test message');
});

This ensures consistency across all test files and makes it easier to understand the purpose and requirements of each test.