Skip to content

Commit

Permalink
Merge branch 'stage' into edge-experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
peller authored Oct 16, 2023
2 parents 0b84df5 + dd38327 commit 228453b
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"description": "Website foundation technology.",
"scripts": {
"test": "npm run wtr ; npm run jest",
"test": "npm run wtr && npm run jest",
"wtr": "wtr \"./test/**/*.test.(js|html)\" --node-resolve --port=2000 --coverage --concurrent-browsers 4",
"wtr:watch": "npm run wtr -- --watch",
"jest": "jest --coverage --coverageDirectory=coverage/jest",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* @jest-environment jsdom
*/
/* eslint-disable no-undef */
/* eslint-disable compat/compat */

import path from 'path';
import fs from 'fs';

describe('dc-converter-widget', () => {
beforeEach(async () => {
document.body.innerHTML = fs.readFileSync(
path.resolve(__dirname, './mocks/body-rearrange-pdf.html'),
'utf8',
);
jest.useFakeTimers();
});

afterEach(() => {
jest.clearAllMocks();
});

it('loads rearrange-pdf widget', async () => {
const { default: init } = await import('../../../acrobat/blocks/dc-converter-widget/dc-converter-widget.js');
window.fetch = jest.fn(() => Promise.resolve({
status: 200,
text: () => Promise.resolve(
fs.readFileSync(path.resolve(__dirname, './mocks/widget.html')),
),
}));
window.browser = { isMobile: true };
delete window.location;
window.location = new URL('https://www.adobe.com/acrobat/online/rearrange-pdf.html');
const block = document.querySelector('.dc-converter-widget');
window.performance.mark = jest.fn();
await init(block);
jest.runAllTimers();
expect(document.querySelector('.skeleton-wrapper')).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* @jest-environment jsdom
*/
/* eslint-disable no-undef */
/* eslint-disable compat/compat */

import path from 'path';
import fs from 'fs';

describe('dc-converter-widget', () => {
beforeEach(async () => {
document.body.innerHTML = fs.readFileSync(
path.resolve(__dirname, './mocks/body-rearrange-pdf.html'),
'utf8',
);
jest.useFakeTimers();
});

afterEach(() => {
jest.clearAllMocks();
});

it('loads rearrange-pdf widget 404', async () => {
const { default: init } = await import('../../../acrobat/blocks/dc-converter-widget/dc-converter-widget.js');
window.fetch = jest.fn(() => Promise.resolve({
status: 404,
text: () => Promise.resolve('Not Found'),
}));
window.browser = { isMobile: true };
delete window.location;
window.location = new URL('https://www.adobe.com/acrobat/online/rearrange-pdf.html');
const block = document.querySelector('.dc-converter-widget');
window.performance.mark = jest.fn();
await init(block);
jest.runAllTimers();
expect(document.querySelector('.skeleton-wrapper')).toBeTruthy();
});
});
7 changes: 7 additions & 0 deletions test/blocks/dc-converter-widget/mocks/body-rearrange-pdf.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<main>
<div class="dc-converter-widget">
<div>
<div>reorder-pages</div>
</div>
</div>
</main>
3 changes: 2 additions & 1 deletion test/blocks/eventwrapper/mocks/body.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<div>
<div data-section="widget" class="section">
<script id="adobe_dc_sdk_launcher" src="https://stage.acrobat.adobe.com/dc-hosted/3.8.0_2.15.2/dc-app-launcher.js" data-dropzone_id="CID" data-locale="en-us" data-server_env="stage" data-verb="compress-pdf" data-load_typekit="false" data-load_imslib="false" data-enable_unload_prompt="true"></script>
</div>
</div>
<button class="dialog-close"></button>
<div class="eventwrapper onload">
<div>
<div><a
Expand Down
17 changes: 17 additions & 0 deletions test/e2e/frictionless/features/regression/commerce.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Feature: Commerce

Background:
Given I have a new browser context

@MWPW-137510 @regression @commerce
Scenario Outline: Checkout flow for logged-in visitors
Given I go to the DC page '<Path>'
Then I sign in AdobeID
Then I click a "Commerce" Button
Then I should see the address bar contains "commerce.adobe.com"
Then I should see "Signed in as" text

Examples:
| Path |
| /acrobat/how-to/convert-excel-to-pdf |
| /acrobat/resources/how-to-create-fillable-pdf |
2 changes: 2 additions & 0 deletions test/e2e/frictionless/page-objects/dcgnav.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export class DcGnavPage extends GnavPage {
// Same in SubMenu()
this.buildProps({
buyNow: '.feds-cta-wrapper a, .gnav-cta a >> visible=true',
commerceButton: 'a[href*="commerce.adobe.com"]',
signInLabel: '[data-testid="user-title"]:has-text("Signed in as")',
fedsPopup: '.feds-popup, .gnav-navitem-menu.large-Variant, .gnav-navitem-menu.small-Variant >> visible=true',
footerPromoHeading: '[data-path^="/dc-shared/fragments/footer-promos"] .heading-l',
footerPromoBullets: '[data-path^="/dc-shared/fragments/footer-promos"] ul'
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/frictionless/step-definitions/dc.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,17 @@ Then(/^I reload DocCloud "([^"]*)"$/, async function (path) {
await this.page.native.goto(path);
});

Then(/^I should see "Signed in as" text$/, async function () {
this.context(DCPage);
await expect(this.page.signInLabel).toBeVisible({timeout: 5000});
});

Then(/^I click a "Commerce" Button$/, async function () {
this.context(DCPage);
const commerceButtons = await this.page.commerceButton;
await this.page.commerceButton.nth(0).click();
});

Then(/^I should see the footer promo elements$/, async function () {
this.context(DCPage);
await expect(this.page.footerPromoHeading).toBeVisible({timeout: 5000});
Expand Down

0 comments on commit 228453b

Please sign in to comment.