Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions test/core/workflow/workflow-acrobat/action-binder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,28 @@ describe('ActionBinder', () => {
expect(result).to.be.true;
});

it('should set referrer to the authored referrer when present', async () => {
actionBinder.workflowCfg.referrer = 'file-compressor';
const cOpts = { payload: { verb: 'compress-pdf' } };
const filesData = { test: 'data' };
const result = await actionBinder.handleRedirect(cOpts, filesData);

expect(cOpts.payload.referrer).to.equal('file-compressor');
expect(actionBinder.getRedirectUrl.calledWith(cOpts)).to.be.true;
expect(result).to.be.true;
});

it('should fall back referrer to the verb when no referrer is authored', async () => {
actionBinder.workflowCfg.referrer = '';
const cOpts = { payload: { verb: 'compress-pdf' } };
const filesData = { test: 'data' };
const result = await actionBinder.handleRedirect(cOpts, filesData);

expect(cOpts.payload.referrer).to.equal('compress-pdf');
expect(actionBinder.getRedirectUrl.calledWith(cOpts)).to.be.true;
expect(result).to.be.true;
});

it('should handle redirect with feedback for multi-file validation failure', async () => {
actionBinder.multiFileValidationFailure = true;
const cOpts = { payload: {} };
Expand Down
1 change: 1 addition & 0 deletions unitylibs/core/workflow/workflow-acrobat/action-binder.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ export default class ActionBinder {
}

async handleRedirect(cOpts, filesData) {
cOpts.payload.referrer = this.workflowCfg.referrer || cOpts.payload.verb;
try {
cOpts.payload.newUser = !localStorage.getItem('unity.user');
const numAttempts = parseInt(localStorage.getItem(`${this.workflowCfg.enabledFeatures[0]}_attempts`), 10) || 0;
Expand Down
3 changes: 3 additions & 0 deletions unitylibs/core/workflow/workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,13 @@ class WfInitiator {
let product = '';
let feature = '';
let psw = '';
let referrer = '';
[...this.el.classList].forEach((cn) => {
if (cn.match('workflow-')) wfName = cn;
if (cn.match('product-')) product = cn.replace('product-', '');
if (cn.match('feature-')) feature = cn.replace('feature-', '');
if (cn.match('psw-enabled')) psw = cn;
if (cn.startsWith('referrer-')) referrer = cn.replace('referrer-', '');
});
const workflowCfg = {
'workflow-photoshop': {
Expand Down Expand Up @@ -301,6 +303,7 @@ class WfInitiator {
errors: {},
supportedTexts: workflowCfg[wfName]?.stList ?? null,
pswFeature: !!psw,
referrer,
};
}

Expand Down
Loading