The JS mock services carried MPE_TABLES.pre_edit_hook / post_edit_hook values but never acted on them, so a table configured with hooks behaved differently in the mock than in production. Add mockHookSource() to dcMockUtils (resolving a hook program name to the source of its .js counterpart on the Drive) and run the hook where the SAS backend does: - editors/getdata runs the pre-edit hook after filtering, letting it reassign visibleRows / visibleColumns (the work.OUT contract) - so an empty mirror can display the live rows of the table it points at - editors/stagedata and editors/loadfile run the post-edit hook before the MPE_SUBMIT row is written, letting it reassign libref / dsn (the call symputx contract) - so a changeset submitted against a mirror is raised against the real table Seed a demo pair in makedata (TESTDATA.DEMO_ORDERS plus an empty TESTDATA.DEMO_MIRROR with both hooks) and cover it with a Cypress spec.
32 lines
1.6 KiB
JavaScript
32 lines
1.6 KiB
JavaScript
// ─────────────────────────────────────────────────────────────────────────────
|
|
// Mock of a POST_EDIT_HOOK program
|
|
//
|
|
// Registered against TESTDATA.DEMO_MIRROR (MPE_TABLES.post_edit_hook).
|
|
//
|
|
// This file is eval'd by editors/stagedata.js and editors/loadfile.js
|
|
// (mirroring how mpe_loader.sas %includes the hook program via %mpe_runhook),
|
|
// so it shares the caller's scope: libref, dsn, libds and every dcMockUtils
|
|
// function are available directly.
|
|
//
|
|
// The real hook runs in mpe_loader BEFORE the submit record is written, while
|
|
// LIBREF / DS are still ordinary macro variables - which is what lets it
|
|
// re-point a changeset at a different table:
|
|
//
|
|
// data _null_;
|
|
// call symputx('libref','TESTDATA');
|
|
// call symputx('ds','DEMO_ORDERS');
|
|
// run;
|
|
//
|
|
// (call symputx reaches the calling service's variable because LIBREF/DS are
|
|
// not declared %local in mpe_loader; a %let creates a new variable in the
|
|
// hook's own scope and is discarded.)
|
|
//
|
|
// The mock's equivalent is to reassign libref / dsn, so the MPE_SUBMIT record
|
|
// names the real table and the approval is raised against it rather than
|
|
// against the empty mirror.
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
|
|
libref = 'TESTDATA'
|
|
dsn = 'DEMO_ORDERS'
|
|
console.log('[HOOK DEBUG] demo_mirror_postedit: routing changeset to ' + libref + '.' + dsn)
|