Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Fix component delete function in UE #165

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

pranay-tippa
Copy link

@pranay-tippa pranay-tippa commented Sep 10, 2024

Please always provide the GitHub issue(s) your PR is for, as well as test URLs where your change can be observed (before and after):

Fix #

Test URLs:

Copy link

aem-code-sync bot commented Sep 10, 2024

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run PSI checks
  • Re-sync branch
Commits

Copy link

aem-code-sync bot commented Sep 10, 2024

Page Scores Audits Google
📱 / PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI
🖥️ / PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

// eslint-disable-next-line no-await-in-loop
await adaptiveFormPath.first().click();

// eslint-disable-next-line max-len,no-await-in-loop
const isComponentSelected = await frame.locator(this.componentSelectorValidation(component)).isVisible();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

componentSelectorValidation is coupled with text-input. this makes the code confusing to understand.
we should just have an API to get the selected component from the content tree and then decide whether it's a form or not.

const isAdaptiveFormSelected = await frame.locator(this.selectors.selectedAdaptiveFormWithComponent).isVisible();

// eslint-disable-next-line no-await-in-loop
if (!isComponentSelected && isAdaptiveFormSelected) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid too many eslint disables. better to take out these lines as a separate func outside while


// eslint-disable-next-line no-await-in-loop
if (!isComponentSelected && isAdaptiveFormSelected) {
const expandButton = frame.locator(this.getExpandCollapseButton('Expand'));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets have a common method to expand the component in the tree

// eslint-disable-next-line no-await-in-loop
await frame.locator(`li[data-resource*="/${component}"]`).click();
// eslint-disable-next-line no-await-in-loop,max-len
expect(await frame.locator(this.componentSelectorValidation(component)).isVisible()).toBe(true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets have a isComponentSelected method.

if (await frame.locator(this.selectors.adaptiveFormPathInContentTree).isVisible()) {
break;
}

// eslint-disable-next-line no-await-in-loop
await frame.locator(this.selectors.deleteButton).click();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

common method to deleteComponent is required here.

@nit23uec
Copy link
Collaborator

nit23uec commented Sep 11, 2024

The tests code is quite unreadable at present and thus, not maintainable.
I'd suggest to consider refactoring of this code to improve its readability and maintainability.
lets have 3 classes for:

  1. ComponentUtils (with addComponent, deleteComponent methods)
  2. ContentTreeUtils (with getSelectedComponent, expandContainer, collapseContainer, selectComponent, isComponentSelected methods)
  3. CanvasUtils (with isComponentPresent, selectComponent methods)
    and then reuse these methods from base UE test class

Copy link
Collaborator

@nit23uec nit23uec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requires refactoring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants