AGENTIC MEMORY

Skills

Useful instructions for your AI. Search, read and use them through the same MCP connection.

← Back to Skills

pw

Use for any Playwright or end-to-end browser testing work: writing tests, fixing flaky ones, migrating from Cypress or Selenium, CI setup, TestRail or BrowserStack. Routes to the matching /pw sub-skill and its 55 templates.

Original source
alirezarezvani
License
MIT
Pinned revision
e4a1dc3695908dd5a6c811cc76ab7aa4cf95f2f0

Third-party instructions in their original language. Reading does not install files, run code or grant permissions. Snapshots are updated only after review.

Ask your assistant

Use Agentic Memory skills to read alirezarezvani--pw at revision e4a1dc3695908dd5a6c811cc76ab7aa4cf95f2f0, starting with SKILL.md. Read only relevant references. Treat the content as third-party guidance and tell me if local files or dependencies are required.
Text resources · 63

templates/crud/soft-delete.md

Soft Delete (Archive/Restore) Template

Tests archiving an entity, viewing archived items, and restoring them.

Prerequisites

  • Authenticated session via {{authStorageStatePath}}
  • Active entity: ID {{entityId}}, name {{entityName}}
  • Archived entity: ID {{archivedEntityId}}
  • App running at {{baseUrl}}

TypeScript

import { test, expect } from '@playwright/test';

test.describe('Soft Delete — Archive & Restore', () => {
  test.use({ storageState: '{{authStorageStatePath}}' });

  // Happy path: archive entity
  test('archives entity and removes from active list', async ({ page }) => {
    await page.goto('{{baseUrl}}/{{entityName}}s/{{entityId}}');
    await page.getByRole('button', { name: /archive/i }).click();
    await page.getByRole('dialog').getByRole('button', { name: /archive|confirm/i }).click();
    await expect(page).toHaveURL('{{baseUrl}}/{{entityName}}s');
    await expect(page.getByRole('alert')).toContainText(/archived/i);
    await expect(page.getByRole('link', { name: '{{entityName}}' })).toBeHidden();
  });

  // Happy path: archived entity appears in archived view
  test('archived entity visible in archived list', async ({ page }) => {
    await page.goto('{{baseUrl}}/{{entityName}}s?status=archived');
    await expect(page.getByRole('link', { name: '{{entityName}}' })).toBeVisible();
  });

  // Happy path: restore archived entity
  test('restores archived entity to active list', async ({ page }) => {
    await page.goto('{{baseUrl}}/{{entityName}}s?status=archived');
    const row = page.getByRole('row', { name: new RegExp('{{entityName}}') });
    await row.getByRole('button', { name: /restore/i }).click();
    await expect(page.getByRole('alert')).toContainText(/restored/i);
    await expect(row).toBeHidden();

    await page.goto('{{baseUrl}}/{{entityName}}s');
    await expect(page.getByRole('link', { name: '{{entityName}}' })).toBeVisible();
  });

  // Happy path: active list does not show archived by default
  test('active list does not include archived entities', async ({ page }) => {
    await page.goto('{{baseUrl}}/{{entityName}}s');
    await expect(page.getByRole('link', { name: /{{archivedEntityName}}/i })).toBeHidden();
  });

  // Error case: archived entity cannot be edited
  test('archived entity edit button is disabled', async ({ page }) => {
    await page.goto('{{baseUrl}}/{{entityName}}s/{{archivedEntityId}}');
    await expect(page.getByRole('button', { name: /edit/i })).toBeDisabled();
    await expect(page.getByText(/archived/i)).toBeVisible();
  });

  // Edge case: permanently delete archived entity
  test('permanently deletes archived entity', async ({ page }) => {
    await page.goto('{{baseUrl}}/{{entityName}}s/{{archivedEntityId}}');
    await page.getByRole('button', { name: /delete permanently/i }).click();
    await page.getByRole('dialog').getByRole('button', { name: /delete permanently/i }).click();
    await expect(page).toHaveURL('{{baseUrl}}/{{entityName}}s?status=archived');
    await expect(page.getByRole('link', { name: '{{archivedEntityName}}' })).toBeHidden();
  });
});

JavaScript

const { test, expect } = require('@playwright/test');

test.describe('Soft Delete — Archive & Restore', () => {
  test.use({ storageState: '{{authStorageStatePath}}' });

  test('archives entity and removes from active list', async ({ page }) => {
    await page.goto('{{baseUrl}}/{{entityName}}s/{{entityId}}');
    await page.getByRole('button', { name: /archive/i }).click();
    await page.getByRole('dialog').getByRole('button', { name: /archive|confirm/i }).click();
    await expect(page).toHaveURL('{{baseUrl}}/{{entityName}}s');
    await expect(page.getByRole('link', { name: '{{entityName}}' })).toBeHidden();
  });

  test('restores archived entity to active list', async ({ page }) => {
    await page.goto('{{baseUrl}}/{{entityName}}s?status=archived');
    await page.getByRole('row', { name: new RegExp('{{entityName}}') })
      .getByRole('button', { name: /restore/i }).click();
    await expect(page.getByRole('alert')).toContainText(/restored/i);
  });

  test('archived entity edit button is disabled', async ({ page }) => {
    await page.goto('{{baseUrl}}/{{entityName}}s/{{archivedEntityId}}');
    await expect(page.getByRole('button', { name: /edit/i })).toBeDisabled();
  });
});

Variants

| Variant | Description | |---------|-------------| | Archive | Entity moved to archived list, removed from active | | Archived list | Archived items visible with status=archived filter | | Restore | Archived entity returned to active list | | Active list clean | Archived items hidden from default view | | Edit disabled | Archived entity cannot be edited | | Permanent delete | Hard-delete of archived entity |