@refinest/test-helpers
v0.2.0
Published
Refinest: typed Playwright Page Objects over the testid convention
Downloads
189
Readme
@refinest/test-helpers
Typed Playwright page objects for refinest apps, built over the framework's stable data-testid convention.
Because refinest generates its own test ids (list-row:<resource>:<id>, picker-quickcreate:<resource>, …), your e2e tests can address a screen you never hand-wrote.
Install
pnpm add -D @refinest/test-helpers @playwright/testUsage
import { test, expect } from '@playwright/test';
import { createRefinestPage } from '@refinest/test-helpers';
test('a document can be filtered and opened', async ({ page }) => {
const app = createRefinestPage(page);
const documents = app.resource('document_document');
const list = documents.list();
await list.goto();
await list.search().fill('invoice');
await list.paginationNext().click();
await expect(documents.show('42').field('title').input()).toBeVisible();
});Every locator above is derived from the resource name, so none of these test ids are hand-written in your app.
Main exports
createRefinestPage/RefinestPage— the entry point; wraps a PlaywrightPage. Exposesresource(name),contextPicker(slice),notification(type),actionConfirm(resource, scope, action)and the rawpage.createResourceObject/ResourceObject— one resource's four surfaces:list(),create(),edit(id),show(id), pluspicker().createFormView/FormView/FormFieldObject— form fields across create/edit/show:field(name).input(),.error(),.help(), andsection(key).createShowView/ShowView— the detail surface (aFormViewinshowmode).createPickerObject/PickerObject— relation pickers, including quick-create.createConfirmDialog/ConfirmDialogObject— confirmation dialogs raised by declared actions.
The list surface (documents.list()) covers goto(), row(id), search(), filter(col), addFilter(), removeFilter(col), clearFilters() and paginationPrev() / paginationNext().
License
MIT
