Skip to content

Commit

Permalink
Merge pull request #758 from adobecom/MWPW-156372
Browse files Browse the repository at this point in the history
MWPW-156372
  • Loading branch information
Blainegunn authored Aug 15, 2024
2 parents cc442ad + 95fb004 commit 49169b0
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 104 deletions.
39 changes: 0 additions & 39 deletions acrobat/blocks/dc-converter-widget/dc-converter-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,6 @@ const localeMap = {
vn_vi: 'vi-vn',
};

// import verbToRedirectLinkSuffix from './verbRedirMap.js'
const verbRedirMap = {
createpdf: 'createpdf',
'crop-pages': 'crop',
'delete-pages': 'deletepages',
'extract-pages': 'extract',
'combine-pdf': 'combine',
'protect-pdf': 'protect',
'add-comment': 'addcomment',
'pdf-to-image': 'pdftoimage',
'reorder-pages': 'reorderpages',
sendforsignature: 'sendforsignature',
'rotate-pages': 'rotatepages',
fillsign: 'fillsign',
'split-pdf': 'split',
'insert-pdf': 'insert',
'compress-pdf': 'compress',
'png-to-pdf': 'jpgtopdf',
'number-pages': 'number',
'ocr-pdf': 'ocr',
'chat-pdf': 'chat',
};

const exhLimitCookieMap = {
'to-pdf': 'ac_cr_p_c',
'pdf-to': 'ac_ex_p_c',
Expand Down Expand Up @@ -210,16 +187,6 @@ export default async function init(element) {
GENERATE_CACHE_URL_DIV.remove();
}

// Redirect
const fallBack = 'https://www.adobe.com/go/acrobat-overview';
const redDir = () => {
if (window.location.hostname !== 'www.adobe.com' && window.location.hostname !== 'sign.ing' && window.location.hostname !== 'edit.ing') {
window.location = `https://www.adobe.com/go/acrobat-${verbRedirMap[VERB] || VERB.split('-').join('')}-${ENV}` || REDIRECT_URL;
} else {
window.location = REDIRECT_URL || `https://www.adobe.com/go/acrobat-${verbRedirMap[VERB] || VERB.split('-').join('')}` || fallBack;
}
};

const widgetContainer = document.createElement('div');
widgetContainer.id = 'CID';
widgetContainer.className = `fsw wapper-${VERB}`;
Expand Down Expand Up @@ -260,12 +227,6 @@ export default async function init(element) {
}

window.addEventListener('IMS:Ready', async () => {
// Redirect Usage
if (window.adobeIMS.isSignedInUser()) {
redDir();
return;
}

const { default: frictionless } = await import('../../scripts/frictionless.js');
frictionless(VERB);
});
Expand Down
65 changes: 0 additions & 65 deletions test/blocks/dc-converter-widget/dc-converter-widget.jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,71 +136,6 @@ describe('dc-converter-widget', () => {
expect(document.querySelector('#CID').children).toHaveLength(0);
});

it.each`
hostname
${'stage--dc--adobecom.hlx.page'}
${'main--dc--adobecom.hlx.page'}
${'stage--dc--adobecom.hlx.live'}
${'www.stage.adobe.com'}
${'main--dc--adobecom.hlx.live'}
`('redirects when signed in on stage', async ({ hostname }) => {
window.fetch = jest.fn(() => Promise.resolve(
{
status: 200,
text: () => Promise.resolve(fs.readFileSync(path.resolve(__dirname, './mocks/widget.html'))),
},
));
window.adobeIMS = { isSignedInUser: jest.fn(() => true) };
delete window.location;
window.location = new URL(`https://${hostname}/acrobat/online/pdf-to-ppt.html`);
const block = document.querySelector('.dc-converter-widget');
await init(block);
window.dispatchEvent(new CustomEvent('IMS:Ready'));
expect(window.location).toBe('https://www.adobe.com/go/acrobat-pdftoppt-stage');
});

it.each`
hostname
${'www.adobe.com'}
`('redirects when signed in', async ({ hostname }) => {
window.fetch = jest.fn(() => Promise.resolve(
{
status: 200,
text: () => Promise.resolve(fs.readFileSync(path.resolve(__dirname, './mocks/widget.html'))),
},
));
window.adobeIMS = { isSignedInUser: jest.fn(() => true) };
delete window.location;
window.location = new URL(`https://${hostname}/acrobat/online/pdf-to-ppt.html`);
const block = document.querySelector('.dc-converter-widget');
await init(block);
window.dispatchEvent(new CustomEvent('IMS:Ready'));
expect(window.location).toBe('https://www.adobe.com/go/acrobat-pdftoppt');
});

it.each`
hostname
${'www.adobe.com'}
`('redirects when signed in - redirect link in block', async ({ hostname }) => {
document.body.innerHTML = fs.readFileSync(
path.resolve(__dirname, './mocks/body_redirect.html'),
'utf8',
);
window.fetch = jest.fn(() => Promise.resolve(
{
status: 200,
text: () => Promise.resolve(fs.readFileSync(path.resolve(__dirname, './mocks/widget.html'))),
},
));
window.adobeIMS = { isSignedInUser: jest.fn(() => true) };
delete window.location;
window.location = new URL(`https://${hostname}/acrobat/online/pdf-to-ppt.html`);
const block = document.querySelector('.dc-converter-widget');
await init(block);
window.dispatchEvent(new CustomEvent('IMS:Ready'));
expect(window.location).toBe('https://www.adobe.com/go/testredirect');
});

it.each`
name | version
${'Internet Explorer'} | ${'10.0.0.0'}
Expand Down

0 comments on commit 49169b0

Please sign in to comment.