Skip to content

Commit

Permalink
Merge branch 'stage' into MWPW-158083
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinrivero authored Dec 23, 2024
2 parents d456224 + 75ad33f commit 748e508
Show file tree
Hide file tree
Showing 9 changed files with 205 additions and 13 deletions.
1 change: 1 addition & 0 deletions acrobat/blocks/verb-widget/icons.js

Large diffs are not rendered by default.

26 changes: 19 additions & 7 deletions acrobat/blocks/verb-widget/limits.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
const LIMITS = {
fillsign: {
maxFileSize: 100000000, // 100 MB
maxFileSize: 104857600, // 100 MB
maxFileSizeFriendly: '100 MB', // 100 MB
acceptedFiles: '.pdf',
acceptedFiles: ['application/pdf'],
maxNumFiles: 1,
multipleFiles: false,
mobileApp: true,
},
'delete-pages': {
maxFileSize: 100000000, // 1 MB
acceptedFiles: '.pdf',
acceptedFiles: ['application/pdf'],
maxNumFiles: 1,
},
'number-pages': {
maxFileSize: 100000000, // 1 MB
acceptedFiles: '.pdf',
acceptedFiles: ['application/pdf'],
maxNumFiles: 1,
},
'compress-pdf': {
maxFileSize: 100000000,
acceptedFiles: '.pdf',
maxNumFiles: 1,
maxFileSize: 2147483648,
maxFileSizeFriendly: '2 GB',
acceptedFiles: [
'application/pdf',
'application/msword',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.ms-powerpoint',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/vnd.ms-excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'image/jpeg',
'image/png',
],
multipleFiles: true,
},
};

Expand Down
9 changes: 8 additions & 1 deletion acrobat/blocks/verb-widget/verb-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,14 @@ export default async function init(element) {
}

const widgetMobileButton = createTag('a', { class: 'verb-mobile-cta', href: mobileLink }, window.mph['verb-widget-cta-mobile']);
const button = createTag('input', { type: 'file', accept: LIMITS[VERB].acceptedFiles, id: 'file-upload', class: 'hide', 'aria-hidden': true });
const button = createTag('input', {
type: 'file',
accept: LIMITS[VERB]?.acceptedFiles,
id: 'file-upload',
class: 'hide',
'aria-hidden': true,
...(LIMITS[VERB]?.multipleFiles && { multiple: '' }),
});
const widgetImage = createTag('div', { class: 'verb-image' });
const verbIconName = `${VERB}`;
const verbImageSvg = createSvgElement(verbIconName);
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"homepage": "https://github.com/adobecom/dc#readme",
"devDependencies": {
"@amwp/platform-ui-automation": "^0.0.6",
"@amwp/platform-ui-lib-adobe": "^0.0.7",
"@amwp/platform-ui-lib-adobe": "^0.0.9",
"@babel/core": "7.23.2",
"@babel/eslint-parser": "7.22.15",
"@babel/register": "7.22.15",
Expand Down
26 changes: 26 additions & 0 deletions test/e2e/features/unity/verbs.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Feature: Frictionless Converter Block

Background:
Given I have a new browser context

@smoke @unity @sign-pdf @choosefile
Scenario Outline: L1 Verb - Upload and sign-in
Given I go to the <Verb> page
Then I choose the file "<File>" to upload
Then I wait for 5 seconds
Then I should see the address bar contains "acrobat.adobe.com"

Examples:
| Verb | File |
| sign-pdf | test-files/test.pdf |

@smoke @unity @sign-pdf @dragndrop
Scenario Outline: L1 Verb - Upload and sign-in
Given I go to the <Verb> page
Then I drag-and-drop the file "<File>" to upload
Then I wait for 5 seconds
Then I should see the address bar contains "acrobat.adobe.com"

Examples:
| Verb | File |
| sign-pdf | test-files/test.pdf |
34 changes: 34 additions & 0 deletions test/e2e/page-objects/unity.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { classes } from "polytype";
import { DcGnavPage } from "./dcgnav.page";
import { CaaSSection } from "./caas.section";
import { VerbWidgetSection } from "./verbwidget.section";

export class UnityPage extends classes(DcGnavPage, VerbWidgetSection, CaaSSection) {
constructor(contentPath) {
super({
super: DcGnavPage,
arguments: [contentPath],
});
this.buildProps({
howToDefault: 'div[data-path*="how-to/default"]',
howTo2ndConversion: '[data-tag="2nd conversion"] div[data-path*="how-to/2nd-conversion"]',
verbSubfooter: '.verb-subfooter',
reviewComponent: '.review',
reviewStats: '.hlx-ReviewStats',
reviewSubmitResponse: '.hlx-submitResponse',
reviewDisabled: '.hlx-Review-ratingFields[disabled]',
reviewCommentField: '.hlx-Review-commentFields textarea',
reviewCommentSubmit: '.hlx-Review-commentFields input[type="submit"]',
reviewInputField: 'fieldset.hlx-Review-ratingFields input',
signUp: '[href*="https://auth.services.adobe.com"][href*="signup"]',
extensionModal: '#chromeext, #edgeext',
closeExtensionModal: '#chromeext .dialog-close, #edgeext .dialog-close',
eventwrapperOnload: '.eventwrapper.onload',
previewDescription: 'div[class*="previewDescription"]',
});
}

reviewStartInput(rating) {
return this.native.locator(`.hlx-Review-ratingFields input[value="${rating}"]`);
}
}
69 changes: 69 additions & 0 deletions test/e2e/page-objects/verbwidget.section.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import fs from 'fs';
import path from 'path';
import { Section } from '@amwp/platform-ui-automation/lib/common/page-objects/section';

export class VerbWidgetSection extends Section {
constructor() {
super();
this.buildProps({
selectButton: '.verb-cta',
fileUploadInput: '#file-upload',
dropZone: '#drop-zone',
})
}

async chooseFiles(filePaths) {
const fileChooserPromise = this.native.waitForEvent('filechooser');
this.selectButton.click();
const fileChooser = await fileChooserPromise;
await fileChooser.setFiles(filePaths);
}

async dragndropFiles(filePaths) {
const filePath = filePaths[0];
const buffer = fs.readFileSync(filePath).toString('base64');
const basename = path.basename(filePath);

const dataTransfer = await this.dropZone.evaluateHandle(async({bufferData, basename}) => {
const dt = new DataTransfer();
const blobData = await fetch(bufferData).then((res) => res.blob());
const file = new File([blobData], basename, { type: 'application/pdf' });
dt.items.add(file);
return dt;
}, {
bufferData: `data:application/octet-stream;base64,${buffer}`,
basename
});

await this.dropZone.dispatchEvent('drop', { dataTransfer });
}
}

async function dragAndDropFile(
page,
selector,
filePath,
fileName,
fileType = ''
) {
const buffer = readFileSync(filePath).toString('base64');

const dataTransfer = await page.evaluateHandle(
async ({ bufferData, localFileName, localFileType }) => {
const dt = new DataTransfer();

const blobData = await fetch(bufferData).then((res) => res.blob());

const file = new File([blobData], localFileName, { type: localFileType });
dt.items.add(file);
return dt;
},
{
bufferData: `data:application/octet-stream;base64,${buffer}`,
localFileName: fileName,
localFileType: fileType,
}
);

await page.dispatchEvent(selector, 'drop', { dataTransfer });
};
43 changes: 43 additions & 0 deletions test/e2e/step-definitions/dc.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { MergePdfPage } from "../page-objects/mergepdf.page";
import { CompressPdfPage } from "../page-objects/compresspdf.page";
import { PasswordProtectPdfPage } from "../page-objects/passwordprotectpdf.page";
import { FrictionlessPage } from "../page-objects/frictionless.page";
import { UnityPage } from "../page-objects/unity.page";
import { DCPage } from "../page-objects/dc.page";
import { cardinal } from "../support/cardinal";
import { expect } from "@playwright/test";
Expand Down Expand Up @@ -643,3 +644,45 @@ Then(/^I confirm phone number is different and has geo-ip value "([^"]*)"$/, asy
expect(this.phoneNumber).not.toEqual(geoIpPhoneNumber);
expect(geoIpPhoneNumber).toEqual(geoIpPhoneNumberValue);
})

Then(/^I choose the (?:PDF|file|files) "([^\"]*)" to upload$/, async function (filePath) {
this.context(UnityPage);
const filePaths = filePath.split(",");
const absPaths = filePaths.map((x) =>
path.resolve(global.config.profile.site, x)
);
let retry = 3;
while (retry > 0) {
await expect(this.page.selectButton).toHaveCount(1, { timeout: 15000 });
await this.page.native.waitForTimeout(2000);
try {
await this.page.chooseFiles(absPaths);
await this.page.native.waitForTimeout(2000);
await expect(this.page.selectButton).toHaveCount(0, { timeout: 15000 });
retry = 0;
} catch {
retry--;
}
}
});

Then(/^I drag-and-drop the (?:PDF|file|files) "([^\"]*)" to upload$/, async function (filePath) {
this.context(UnityPage);
const filePaths = filePath.split(",");
const absPaths = filePaths.map((x) =>
path.resolve(global.config.profile.site, x)
);
let retry = 3;
while (retry > 0) {
await expect(this.page.selectButton).toHaveCount(1, { timeout: 15000 });
await this.page.native.waitForTimeout(2000);
try {
await this.page.dragndropFiles(absPaths);
await this.page.native.waitForTimeout(2000);
await expect(this.page.selectButton).toHaveCount(0, { timeout: 15000 });
retry = 0;
} catch {
retry--;
}
}
});

0 comments on commit 748e508

Please sign in to comment.