-
Notifications
You must be signed in to change notification settings - Fork 78
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
Conversation
There was a problem hiding this 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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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; |
There was a problem hiding this comment.
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 })); |
There was a problem hiding this comment.
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( | ||
` |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jcfranco can you review? |
There was a problem hiding this 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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related Issue: N/A
Summary
refactor: Update tests to use common test and apply correct default display.
renders
common test util in place of one off renders tests.