@burojs/test-helpers
v0.3.0
Published
Buro: typed Playwright Page Objects over the testid convention
Readme
@burojs/test-helpers
Typed Playwright page objects for buro apps, built over the framework's stable data-testid convention.
Because buro 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 @burojs/test-helpers @playwright/testUsage
import { test, expect } from '@playwright/test';
import { createBuroPage } from '@burojs/test-helpers';
test('a document can be filtered and opened', async ({ page }) => {
const app = createBuroPage(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
createBuroPage/BuroPage— 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(), paginationPrev() / paginationNext(), and the filter builder: filterButton(), filterPanel(), filterAddRow(groupPath?), filterRowField(path) / filterRowOp(path) / filterRowValue(path), filterApply(), filterReset(), filterBadge(index) / filterBadgeRemove(index), filterClearAll() and filterPinned(field).
License
MIT
