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

Use deep piercing selectors instead of separate selector + shadow selectors in common test helpers #9090

Open
1 of 5 tasks
jcfranco opened this issue Apr 8, 2024 · 4 comments
Labels
0 - new New issues that need assignment. calcite-components Issues specific to the @esri/calcite-components package. estimate - 8 Requires input from team, consider smaller steps. needs milestone Planning workflow - pending milestone assignment, has priority and/or estimate. p - low Issue is non core or affecting less that 10% of people using the library refactor Issues tied to code that needs to be significantly reworked. spike Issues that need quick investigations for time estimations, prioritization, or a quick assessment.
Milestone

Comments

@jcfranco
Copy link
Member

jcfranco commented Apr 8, 2024

Description

Stencil v4.14.0 added support for deep piercing selectors (E2EPage). We should explore whether our common helpers can be simplified by using a single selector prop vs an additional one for the shadow DOM.

Proposed Advantages

Simplified test helper APIs.

Which Component

Helpers from commonTests using both a selector and shadowSelector prop (or similar).

Relevant Info

No response

Calcite package

  • @esri/calcite-components
  • @esri/calcite-components-angular
  • @esri/calcite-components-react
  • @esri/calcite-design-tokens
  • @esri/eslint-plugin-calcite-components
@jcfranco jcfranco added refactor Issues tied to code that needs to be significantly reworked. 0 - new New issues that need assignment. needs triage Planning workflow - pending design/dev review. labels Apr 8, 2024
@github-actions github-actions bot added the calcite-components Issues specific to the @esri/calcite-components package. label Apr 8, 2024
@benelan
Copy link
Member

benelan commented Apr 19, 2024

Let's also use this issue to change tests that use shadowRoot.querySelector instead of deep piercing. For example, we should be able to change this:

const input = (
await page.waitForFunction(() =>
document
.querySelector("calcite-input-date-picker")
.shadowRoot.querySelector("calcite-input-text")
.shadowRoot.querySelector("input"),
)
).asElement();

to this:

const input = await page.find("calcite-input-date-picker >>> input");

The following utils could also be removed/replaced by the deep piercing selector:

async function navigateMonth(page: E2EPage, direction: "previous" | "next"): Promise<void> {
const linkIndex = direction === "previous" ? 0 : 1;
await page.evaluate(
async (MONTH_HEADER_CSS, linkIndex: number): Promise<void> =>
document
.querySelector("calcite-input-date-picker")
.shadowRoot.querySelector("calcite-date-picker")
.shadowRoot.querySelector("calcite-date-picker-month-header")
.shadowRoot.querySelectorAll<HTMLAnchorElement>(`.${MONTH_HEADER_CSS.chevron}`)
[linkIndex].click(),
MONTH_HEADER_CSS,
linkIndex,
);
await page.waitForChanges();
}
async function selectDayInMonth(page: E2EPage, day: number): Promise<void> {
const dayIndex = day - 1;
await page.evaluate(
async (dayIndex: number) =>
document
.querySelector<HTMLCalciteInputDatePickerElement>("calcite-input-date-picker")
.shadowRoot.querySelector<HTMLCalciteDatePickerElement>("calcite-date-picker")
.shadowRoot.querySelector<HTMLCalciteDatePickerMonthElement>("calcite-date-picker-month")
.shadowRoot.querySelectorAll<HTMLCalciteDatePickerDayElement>("calcite-date-picker-day[current-month]")
[dayIndex].click(),
dayIndex,
);
await page.waitForChanges();
}
async function getActiveMonth(page: E2EPage): Promise<string> {
return page.evaluate(
async (MONTH_HEADER_CSS) =>
document
.querySelector("calcite-input-date-picker")
.shadowRoot.querySelector("calcite-date-picker")
.shadowRoot.querySelector("calcite-date-picker-month-header")
.shadowRoot.querySelector(`.${MONTH_HEADER_CSS.month}`).textContent,
MONTH_HEADER_CSS,
);
}
async function getDateInputValue(page: E2EPage, type: "start" | "end" = "start"): Promise<string> {
const inputIndex = type === "start" ? 0 : 1;
return page.evaluate(
async (inputIndex: number): Promise<string> =>
document
.querySelector("calcite-input-date-picker")
.shadowRoot.querySelectorAll("calcite-input-text")
[inputIndex].shadowRoot.querySelector("input").value,
inputIndex,
);
}

@geospatialem
Copy link
Member

Blocked by #10310

@geospatialem geospatialem added blocked This issue is blocked by another issue. and removed needs triage Planning workflow - pending design/dev review. labels Sep 26, 2024
@geospatialem geospatialem added this to the Stalled milestone Sep 26, 2024
@geospatialem geospatialem added p - low Issue is non core or affecting less that 10% of people using the library estimate - 8 Requires input from team, consider smaller steps. labels Sep 26, 2024
Copy link
Contributor

Issue #10310 has been closed, this issue is ready for re-evaluation.

cc @geospatialem,@DitwanP

@github-actions github-actions bot removed the blocked This issue is blocked by another issue. label Nov 26, 2024
@geospatialem geospatialem added needs milestone Planning workflow - pending milestone assignment, has priority and/or estimate. spike Issues that need quick investigations for time estimations, prioritization, or a quick assessment. labels Nov 26, 2024
@geospatialem
Copy link
Member

Spike to determine if the above is still valid and we should pursue it with the move from Stencil to Lit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 - new New issues that need assignment. calcite-components Issues specific to the @esri/calcite-components package. estimate - 8 Requires input from team, consider smaller steps. needs milestone Planning workflow - pending milestone assignment, has priority and/or estimate. p - low Issue is non core or affecting less that 10% of people using the library refactor Issues tied to code that needs to be significantly reworked. spike Issues that need quick investigations for time estimations, prioritization, or a quick assessment.
Projects
None yet
Development

No branches or pull requests

3 participants