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: Update tests to use common test and apply correct default display. #3778

Merged
merged 9 commits into from
Dec 30, 2021

Conversation

driskull
Copy link
Member

Related Issue: N/A

Summary

refactor: Update tests to use common test and apply correct default display.

  • Uses renders common test util in place of one off renders tests.
  • Adds default display values where necessary. These will need to be verified.

@github-actions github-actions bot added this to the Sprint 12/20 - 12/31 milestone Dec 22, 2021
@github-actions github-actions bot added the refactor Issues tied to code that needs to be significantly reworked. label Dec 22, 2021
Copy link
Member Author

@driskull driskull left a comment

Choose a reason for hiding this comment

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

Questions

@@ -45,6 +45,10 @@ $loader-circumference: ($loader-scale - (2 * $stroke-width)) * 3.14159;
@apply py-0;
}

:host {
@apply hidden;
Copy link
Member Author

Choose a reason for hiding this comment

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

loader should be hidden by default and displayed when active.

Copy link
Member

Choose a reason for hiding this comment

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

Sort of a separate discussion, but maybe we should use hidden for this? Looks like it's only used for visibility. cc @macandcheese

Copy link
Member Author

Choose a reason for hiding this comment

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

Its a separate discussion but by default the loader is not shown until it has an active attribute/property. We can evaluate changing this so that the active property is not necessary and just remove it.

Copy link
Member

Choose a reason for hiding this comment

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

@@ -1,3 +1,7 @@
:host {
@apply inline-block w-auto align-middle;
Copy link
Member Author

Choose a reason for hiding this comment

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

Copied this from calcite-button. is this correct @eriklharper?

Copy link
Member

Choose a reason for hiding this comment

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

Should the non-display styles be set on the container instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

That looks right since the native <button> is also inline-block by default.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should the non-display styles be set on the container instead?

Good question. I think the display should probably be set on the host element, but as far as the other properties, there's probably a lot you can move to a container div, unless the host needs like a position property or some other parent-child css property that enables styles to work for elements underneath the host element, like flex for example.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll remove the width and align stuff.

@@ -1,3 +1,7 @@
:host {
@apply block;
Copy link
Member Author

Choose a reason for hiding this comment

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

@eriklharper what display should this component have? Should it be "block"? Seems like its already block now but I'm not sure why.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

inline-block is what the native input does, so that's probably the more appropriate one to use for this.

Copy link
Member Author

Choose a reason for hiding this comment

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

If I change this to inline-block the screener tests will change due to width differences. I will leave as now. If you think it should be changed I think a different issue is needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I do agree that both of these should probably be inline-block like their native counterparts. However, I didn't want to break screener tests and user apps. So this would likely be a breaking change.

@@ -1,3 +1,7 @@
:host {
@apply block;
Copy link
Member Author

Choose a reason for hiding this comment

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

@eriklharper is this correct? seems input is block.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would advocate inline-block for this too.

Copy link
Member Author

Choose a reason for hiding this comment

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

If I change this to inline-block the screener tests will change due to width differences. I will leave as now. If you think it should be changed I think a different issue is needed.

@driskull driskull marked this pull request as ready for review December 23, 2021 00:18
@driskull driskull requested a review from a team as a code owner December 23, 2021 00:18
Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

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

This is looking great. Thanks for setting this up.

@@ -1,3 +1,7 @@
:host {
@apply inline-block w-auto align-middle;
Copy link
Member

Choose a reason for hiding this comment

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

Should the non-display styles be set on the container instead?

});
it("renders", () => renders("calcite-tab", { display: "none", visible: false }));

it("renders: active", () => renders("<calcite-tab active></calcite-tab>", { display: "block", visible: true }));
Copy link
Member

Choose a reason for hiding this comment

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

Let's try to group related tests whenever possible w/ describe.

import { E2EPage } from "@stencil/core/testing";
import { newE2EPage } from "@stencil/core/testing";
import { CSS } from "./resources";
import { html } from "../../tests/utils";

describe("calcite-inline-editable", () => {
it("renders", () =>
renders(
`
Copy link
Member

Choose a reason for hiding this comment

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

Can you use the html helper on multi-line HTML for formatting?

@@ -45,6 +45,10 @@ $loader-circumference: ($loader-scale - (2 * $stroke-width)) * 3.14159;
@apply py-0;
}

:host {
@apply hidden;
Copy link
Member

Choose a reason for hiding this comment

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

Sort of a separate discussion, but maybe we should use hidden for this? Looks like it's only used for visibility. cc @macandcheese

@@ -1,3 +1,7 @@
:host {
@apply block;
Copy link
Member

Choose a reason for hiding this comment

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

@driskull driskull requested a review from jcfranco December 27, 2021 18:19
@driskull
Copy link
Member Author

@jcfranco can you review?

Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

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

LGTM!

@eriklharper @macandcheese I second @driskull's suggestion to open a new issue if any of the defaults need to change.

@@ -60,7 +60,7 @@ export async function renders(
componentTagOrHTML: TagOrHTML,
options?: {
visible?: boolean;
display?: string;
display: string;
Copy link
Member

Choose a reason for hiding this comment

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

🏆

@@ -45,6 +45,10 @@ $loader-circumference: ($loader-scale - (2 * $stroke-width)) * 3.14159;
@apply py-0;
}

:host {
@apply hidden;
Copy link
Member

Choose a reason for hiding this comment

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

@driskull driskull merged commit e4ee0a5 into master Dec 30, 2021
@driskull driskull deleted the dris0000/default-display-tests branch December 30, 2021 19:38
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.

3 participants