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

refactor: prepare tests for migration #10509

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Conversation

maxpatiiuk
Copy link
Member

@maxpatiiuk maxpatiiuk commented Oct 9, 2024

Make minor adjustments to Calcite code to have post-migration tests pass.

Changes that need to be done post-migration are encoded in the following codemod files in the arcgis-web-components repository:

  • /packages/support-packages/stencil-to-lit/src/code/fileSpecific.ts
  • /packages/support-packages/stencil-to-lit/src/component/fileSpecific.ts

At this point, I am finishing up the failing tests in the S components and will be pretty much done with all A-S component (with exception of #10394 and #10495)

@maxpatiiuk maxpatiiuk self-assigned this Oct 9, 2024
@github-actions github-actions bot added the refactor Issues tied to code that needs to be significantly reworked. label Oct 9, 2024
Comment on lines -915 to -919
// initialize page with calcite-color-picker to make it available in the evaluate callback below
const page = await newE2EPage({
html: "<calcite-color-picker></calcite-color-picker>",
html: "",
});
await page.setContent("");
Copy link
Member Author

Choose a reason for hiding this comment

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

This seems wrong.
The html option of newE2EPage just calls setContent behind the scenes.
Each time setContent is called, the page is re-created from scratch - there is no information carried over in between.


await page.evaluate(async (color) => {
const picker = document.createElement("calcite-color-picker");
picker.value = color;
document.body.append(picker);

await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
await picker.componentOnReady();
Copy link
Member Author

Choose a reason for hiding this comment

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

componentOnReady is more suited for this

@@ -104,7 +104,6 @@ export class Loader implements LocalizedComponent {
[CSS.loaderPart]: true,
[CSS.loaderPartId(index)]: true,
}}
key={index}
Copy link
Member Author

Choose a reason for hiding this comment

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

key={index} seems useless?

Lumina has a warning about using index as a key (it suggests not using the key at all in those cases)

@@ -22,7 +22,7 @@ describe("calcite-navigation-user", () => {
},
{
propertyName: "textDisabled",
value: "",
value: true,
Copy link
Member Author

Choose a reason for hiding this comment

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

In Stencil, casting is done both to property and attribute (thus setting boolean property to "" will cast to true). In Lit, casting is only done when converting attribute to property or property to attribute.

See https://qawebgis.esri.com/arcgis-components/?path=/docs/references-lumina-transition-from-stencil--docs#attribute-to-property-casting

@@ -15,7 +15,7 @@ describe("calcite-navigation", () => {
reflects("calcite-navigation", [
{
propertyName: "navigationAction",
value: "",
value: true,
Copy link
Member Author

Choose a reason for hiding this comment

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

same

@@ -9,7 +9,7 @@ describe("calcite-pick-list-item", () => {
});

describe("honors hidden attribute", () => {
hidden("calcite-list-item");
hidden("calcite-pick-list-item");
Copy link
Member Author

Choose a reason for hiding this comment

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

typo

@@ -399,7 +399,7 @@ describe("calcite-rating", () => {
expect(labels[4]).not.toHaveClass("partial");
});

it("should update the ui of the rating when a hover event triggers on a rating label", async () => {
it("should update the UI of the rating when a hover event triggers on a rating label", async () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

consistency with usages in previous test titles

@@ -118,7 +118,7 @@ describe("calcite-shell-panel", () => {
"calcite-shell-panel",
(panel: HTMLCalciteShellPanelElement, containerClass: string, contentClass: string) => {
const container = panel.shadowRoot.querySelector(containerClass);
return container.firstElementChild.className == contentClass;
return container.firstElementChild.classList.contains(contentClass);
Copy link
Member Author

Choose a reason for hiding this comment

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

In Lumina, when class={} prop is an object, the attribute is set to not just "value" but to " value " (notice the spaces.
Adjusting this to use classList.contains to have the code work both pre and post migration

@@ -290,7 +290,7 @@ function invalidHandler(event: Event) {
formComponent.status = "idle";
}

if ("validationIcon" in formComponent && !formComponent.validationIcon) {
if ("validationIcon" in formComponent) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Unless I am wrong, it seems like this condition should not have been here and it worked in Stencil accidentally:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Issues tied to code that needs to be significantly reworked.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant