Skip to content

Commit

Permalink
run lint
Browse files Browse the repository at this point in the history
  • Loading branch information
afmicka committed Dec 12, 2024
1 parent 75615b8 commit c52d61a
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 222 deletions.
2 changes: 1 addition & 1 deletion nala/libs/baseurl.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable */
import pkg from 'axios';

const { head } = pkg;
Expand Down
34 changes: 17 additions & 17 deletions nala/libs/webutil.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-undef */
/* eslint-disable no-unused-vars */
/* eslint-disable max-len */
// eslint-disable-next-line import/no-import-module-exports
import { expect } from '@playwright/test';

Expand Down Expand Up @@ -120,7 +120,7 @@ exports.WebUtil = class WebUtil {
* @param {Object} cssProps - The CSS properties and expected values to verify.
* @returns {Boolean} - True if all CSS properties match the expected values, false otherwise.
*/
// eslint-disable-next-line no-underscore-dangle
async verifyCSS_(locator, cssProps) {
this.locator = locator;
let result = true;
Expand Down Expand Up @@ -177,7 +177,7 @@ exports.WebUtil = class WebUtil {
* @param {Object} attProps - The attribute properties and expected values to verify.
* @returns {Boolean} - True if all attribute properties match the expected values, false otherwise.
*/
// eslint-disable-next-line no-underscore-dangle
async verifyAttributes_(locator, attProps) {
this.locator = locator;
let result = true;
Expand Down Expand Up @@ -215,7 +215,7 @@ exports.WebUtil = class WebUtil {
async scrollPage(direction, speed) {
const scroll = async (args) => {
const { dir, spd } = args;
// eslint-disable-next-line no-promise-executor-return
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const scrollHeight = () => document.body.scrollHeight;
const start = dir === 'down' ? 0 : scrollHeight();
Expand All @@ -225,7 +225,7 @@ exports.WebUtil = class WebUtil {
console.error(start, shouldStop(start), increment);
for (let i = start; !shouldStop(i); i += increment) {
window.scrollTo(0, i);
// eslint-disable-next-line no-await-in-loop
await delay(delayTime);
}
};
Expand Down Expand Up @@ -304,15 +304,15 @@ exports.WebUtil = class WebUtil {
|| url.includes('sstats.adobe.com/ee/or2/v1/collect')) {
networklogs.push(url);
const firstEvent = route.request().postDataJSON().events[0];
// eslint-disable-next-line no-underscore-dangle
if (firstEvent.data._adobe_corpnew.digitalData.primaryEvent) {
// eslint-disable-next-line no-underscore-dangle
networklogs.push(JSON.stringify(firstEvent.data._adobe_corpnew.digitalData.primaryEvent));
}

// eslint-disable-next-line no-underscore-dangle
if (firstEvent.data._adobe_corpnew.digitalData.search) {
// eslint-disable-next-line no-underscore-dangle
networklogs.push(JSON.stringify(firstEvent.data._adobe_corpnew.digitalData.search));
}
}
Expand All @@ -332,7 +332,7 @@ exports.WebUtil = class WebUtil {
* @param {string} project - The project identifier, defaulting to 'milo' if not provided.
* @returns {string} - A string formatted as 'gnav|<project>|nopzn|nopzn'.
*/
// eslint-disable-next-line class-methods-use-this
async getGnavDaalh(project = milo) {
return `gnav|${project}|nopzn|nopzn`;
}
Expand All @@ -344,7 +344,7 @@ exports.WebUtil = class WebUtil {
* @param {string} pznFileName - Manifest filename, which is sliced to its first 20 characters.
* @returns {string} - A string formatted as 'gnav|<project>|<pznExpName>|<pznFileName>'.
*/
// eslint-disable-next-line class-methods-use-this, default-param-last
async getPznGnavDaalh(project = milo, pznExpName, pznFileName) {
const slicedExpName = pznExpName.slice(0, 15);
const slicedFileName = pznFileName.slice(0, 15);
Expand All @@ -356,7 +356,7 @@ exports.WebUtil = class WebUtil {
* @param {number|string} counter - A counter value used to generate the section identifier.
* @returns {string} - A string formatted as 's<counter>'.
*/
// eslint-disable-next-line class-methods-use-this
async getSectionDaalh(counter) {
return `s${counter}`;
}
Expand All @@ -369,7 +369,7 @@ exports.WebUtil = class WebUtil {
* @param {string} pznExpName - Manifest filename, which is sliced to its first 20 characters.
* @returns {string} - A string formatted as 'b<counter>|<slicedBlockName>|<pznExpName>|<pznExpName>'.
*/
// eslint-disable-next-line class-methods-use-this
async getPznBlockDaalh(blockName, counter, pznExpName, pznFileName) {
const slicedBlockName = blockName.slice(0, 20);
const slicedExpName = pznExpName.slice(0, 15);
Expand All @@ -385,7 +385,7 @@ exports.WebUtil = class WebUtil {
* @param {string} [pzntext='nopzn'] - The pzntext to use when pzn is true, sliced to its first 15 characters.
* @returns {string} - A formatted string.
*/
// eslint-disable-next-line class-methods-use-this
async getBlockDaalh(blockName, counter, pzn = false, pzntext = 'nopzn') {
const slicedBlockName = blockName.slice(0, 20);
const slicedPzntext = pzntext.slice(0, 15);
Expand All @@ -403,7 +403,7 @@ exports.WebUtil = class WebUtil {
* @param {boolean} [pzn=false] - boolean parameter, defaulting to false.(for personalization)
* @returns {string} - A string formatted as '<cleanedLinkText>-<counter>--<cleanedLastHeaderText>'.
*/
// eslint-disable-next-line class-methods-use-this
async getLinkDaall(linkText, counter, lastHeaderText, pzn = false) {
const cleanAndSliceText = (text) => text
?.replace(/[^\w\s]+/g, ' ')
Expand Down
52 changes: 28 additions & 24 deletions nala/studio/studio.page.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
export default class StudioPage {
constructor(page) {
this.page = page;
constructor(page) {
this.page = page;

this.searchInput = page.locator('sp-search input');
this.searchIcon = page.locator('sp-search sp-icon-magnify');
this.filter = page.locator('sp-action-button[label="Filter"]');
this.topFolder = page.locator('sp-picker[label="TopFolder"] > button');
this.renderView = page.locator('render-view');
this.suggestedCard = page.locator('merch-card[variant="ccd-suggested"]');
this.sliceCard = page.locator('merch-card[variant="ccd-slice"]');
this.sliceCardWide = page.locator('merch-card[variant="ccd-slice"][size="wide"]');
this.searchInput = page.locator('sp-search input');
this.searchIcon = page.locator('sp-search sp-icon-magnify');
this.filter = page.locator('sp-action-button[label="Filter"]');
this.topFolder = page.locator('sp-picker[label="TopFolder"] > button');
this.renderView = page.locator('render-view');
this.suggestedCard = page.locator(
'merch-card[variant="ccd-suggested"]',
);
this.sliceCard = page.locator('merch-card[variant="ccd-slice"]');
this.sliceCardWide = page.locator(
'merch-card[variant="ccd-slice"][size="wide"]',
);
}

}
async getCard(id, cardType) {
const cardVariant = {
suggested: this.suggestedCard,
slice: this.sliceCard,
'slice-wide': this.sliceCardWide,
};

async getCard(id, cardType) {
const cardVariant = {
suggested: this.suggestedCard,
slice: this.sliceCard,
'slice-wide': this.sliceCardWide,
};
const card = cardVariant[cardType];
if (!card) {
throw new Error(`Invalid card type: ${cardType}`);
}

const card = cardVariant[cardType];
if (!card) {
throw new Error(`Invalid card type: ${cardType}`);
return card.filter({
has: this.page.locator(`aem-fragment[fragment="${id}"]`),
});
}

return card.filter({ has: this.page.locator(`aem-fragment[fragment="${id}"]`) });
}

}
44 changes: 22 additions & 22 deletions nala/studio/studio.spec.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
export default {
FeatureName: 'M@S Studio',
features: [
{
tcid: '0',
name: '@studio-direct-search',
path: '/studio.html',
data: {
cardid: '206a8742-0289-4196-92d4-ced99ec4191e',
title: 'Automation Test Card',
eyebrow: 'DO NOT EDIT',
description: 'MAS repo validation card for Nala tests.',
price: 'US$22.99/mo',
strikethroughPrice: 'US$37.99/mo',
cta: 'Buy now',
offerid: '30404A88D89A328584307175B8B27616',
linkText: 'See terms',
linkUrl: '',
},
browserParams: '#query=',
tags: '@mas @mas-studio @smoke @regression',
},
],
FeatureName: 'M@S Studio',
features: [
{
tcid: '0',
name: '@studio-direct-search',
path: '/studio.html',
data: {
cardid: '206a8742-0289-4196-92d4-ced99ec4191e',
title: 'Automation Test Card',
eyebrow: 'DO NOT EDIT',
description: 'MAS repo validation card for Nala tests.',
price: 'US$22.99/mo',
strikethroughPrice: 'US$37.99/mo',
cta: 'Buy now',
offerid: '30404A88D89A328584307175B8B27616',
linkText: 'See terms',
linkUrl: '',
},
browserParams: '#query=',
tags: '@mas @mas-studio @smoke @regression',
},
],
};
75 changes: 41 additions & 34 deletions nala/studio/studio.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,49 @@ let studio;
const { features } = studiopkg;

test.beforeEach(async ({ page, browserName }) => {
test.skip(browserName !== 'chromium', 'Not supported to run on multiple browsers.');
studio = new StudioPage(page);
test.skip(
browserName !== 'chromium',
'Not supported to run on multiple browsers.',
);
studio = new StudioPage(page);
});


test.describe('M@S Studio feature test suite', () => {
// @studio-direct-search - Validate direct search feature in mas studio
test(`${features[0].name},${features[0].tags}`, async ({ page, baseURL }) => {
test.slow();
const { data } = features[0];
const testPage = `${baseURL}${features[0].path}${miloLibs}${features[0].browserParams}${data.cardid}`;
console.info('[Test Page]: ', testPage);

await test.step('step-1: Log in to MAS studio', async () => {
await page.goto(testPage);
await page.waitForURL('**/auth.services.adobe.com/en_US/index.html**/');
features[0].url = 'https://main--mas--adobecom.aem.live/studio.html';
await ims.fillOutSignInForm(features[0], page);
await expect(async () => {
const response = await page.request.get(features[0].url);
expect(response.status()).toBe(200);
}).toPass();
await page.waitForLoadState('domcontentloaded');
});

await test.step('step-2: Go to MAS Studio test page', async () => {
await page.goto(testPage);
await page.waitForLoadState('domcontentloaded');
// @studio-direct-search - Validate direct search feature in mas studio
test(`${features[0].name},${features[0].tags}`, async ({
page,
baseURL,
}) => {
test.slow();
const { data } = features[0];
const testPage = `${baseURL}${features[0].path}${miloLibs}${features[0].browserParams}${data.cardid}`;
console.info('[Test Page]: ', testPage);

await test.step('step-1: Log in to MAS studio', async () => {
await page.goto(testPage);
await page.waitForURL(
'**/auth.services.adobe.com/en_US/index.html**/',
);
features[0].url =
'https://main--mas--adobecom.aem.live/studio.html';
await ims.fillOutSignInForm(features[0], page);
await expect(async () => {
const response = await page.request.get(features[0].url);
expect(response.status()).toBe(200);
}).toPass();
await page.waitForLoadState('domcontentloaded');
});

await test.step('step-2: Go to MAS Studio test page', async () => {
await page.goto(testPage);
await page.waitForLoadState('domcontentloaded');
});

await test.step('step-3: Validate search results', async () => {
await expect(await studio.renderView).toBeVisible();

const cards = await studio.renderView.locator('merch-card');
expect(await cards.count()).toBe(1);
});
});

await test.step('step-3: Validate search results', async () => {
await expect(await studio.renderView).toBeVisible();

const cards = await studio.renderView.locator('merch-card');
expect(await cards.count()).toBe(1);
});
});

});
2 changes: 1 addition & 1 deletion nala/utils/base-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export default class BaseReporter {
return { name, tags, url, browser, env, branch, repo};
}

// eslint-disable-next-line class-methods-use-this, no-empty-function
async persistData() {}

printPersistingOption() {
Expand Down
Loading

0 comments on commit c52d61a

Please sign in to comment.