Write playwright campaigns

From PrestaShop/PrestaShop · View interactive version

Write playwright campaigns is an AI agent skill from the GitHub repository PrestaShop/PrestaShop. Write Playwright test campaigns for a migrated entity: CRUD lifecycle, bulk actions, filter/sort, position reorder, and per-tab field verification. Campaigns live in the core repo and import page objects from ui-testing-library. Trigger: "write Playwright tests for {Domain}".

How to use this skill

Skill file

write-playwright-campaigns

Read @.ai/Component/Playwright/CONTEXT.md for conventions (testIdentifier, baseContext, Mocha structure, POM usage).

1. Directory and naming

Place campaigns in tests/UI/campaigns/functional/BO/{XX_section}/{XX_subsection}/:

2. Campaign boilerplate

Every campaign follows this structure:

import testContext from '@utils/testContext';
import {expect} from 'chai';
import {
  boDashboardPage, boLoginPage, bo{Domain}Page, bo{Domain}CreatePage,
  type BrowserContext, Faker{Domain}, type Page, utilsPlaywright,
} from '@prestashop-core/ui-testing';

const baseContext: string = 'functional_BO_{section}_{subsection}_{campaignName}';

describe('BO - {Section} : {Campaign description}', async () => {
  let browserContext: BrowserContext;
  let page: Page;

  before(async function () {
    browserContext = await utilsPlaywright.createBrowserContext(this.browser);
    page = await utilsPlaywright.newTab(browserContext);
  });

  after(async () => {
    await utilsPlaywright.closeBrowserContext(browserContext);
  });

  it('should login in BO', async function () {
    await testContext.addContextItem(this, 'testIdentifier', 'loginBO', baseContext);
    // ...login steps...
  });

  // ... test steps ...
});

3. CRUD campaign (`01_CRUD{Domain}.ts`)

4. Filter/sort campaign (`02_filterSort{Domain}s.ts`)

5. Bulk actions campaign (`03_quickEditAndBulkActions.ts`)

Conditional — only if bulk actions exist:

6. Position campaign (`04_changePosition.ts`)

Conditional — only if entity has PositionColumn:

7. Per-tab campaigns (`05_tabName.ts`, `06_tabName.ts`, ...)

Conditional — only for multi-tab forms:

8. Common tests (reusable blocks)

Check tests/UI/commonTests/BO/ for existing reusable describe blocks:

import {createProductTest, deleteProductTest} from '@commonTests/BO/catalog/product';

// Use as pre/post test setup
createProductTest(productData, baseContext);
// ... your test ...
deleteProductTest(productData, baseContext);

Import and reuse these instead of duplicating setup/teardown logic.

Rules

Conventions (testIdentifier, function() not arrow, feature flag setup, toggle AJAX, drag-and-drop, per-tab campaigns, campaign numbering) are in Playwright/CONTEXT.md. Skill-specific reminders:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.