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(shell): add token theming tests #9458

Merged
merged 7 commits into from
Jun 19, 2024
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 70 additions & 1 deletion packages/calcite-components/src/components/shell/shell.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { newE2EPage } from "@stencil/core/testing";
import { accessible, hidden, renders, slots } from "../../tests/commonTests";
import { accessible, hidden, renders, slots, themed } from "../../tests/commonTests";
import { html } from "../../../support/formatting";
import { ComponentTestTokens } from "../../tests/commonTests/themed";
import { CSS, SLOTS } from "./resources";

describe("calcite-shell", () => {
Expand Down Expand Up @@ -122,3 +123,71 @@ describe("calcite-shell", () => {
expect(panelTop).toBeNull();
});
});

const tipManagerHTML = html`
<calcite-tip-manager>
<calcite-tip heading="Example tip title">
<calcite-link href="http://www.esri.com">An example link</calcite-link>
</calcite-tip>
</calcite-tip-manager>
`;

describe("theme", () => {
const shellHTML = html`
<calcite-shell>
${tipManagerHTML}
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: tipManagerHTML is only used once, so it could be inlined here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll inline it, although I feel like separating chunks makes it visually easier to parse through html.

<calcite-panel heading="Leading panel content"></calcite-panel>
<calcite-flow heading="Leading panel content"></calcite-flow>
<calcite-shell-center-row slot="${SLOTS.panelBottom}"></calcite-shell-center-row>
<calcite-shell-center-row slot="${SLOTS.panelTop}"></calcite-shell-center-row>
<calcite-shell-center-row slot="${SLOTS.centerRow}"></calcite-shell-center-row>
</calcite-shell>
`;

describe("slotted overrides", () => {
const tokens: ComponentTestTokens = {
"--calcite-shell-border-color": [
{
selector: `calcite-panel`,
targetProp: "borderColor",
},
{
selector: `calcite-flow`,
targetProp: "borderColor",
},
{
selector: `calcite-shell-center-row[slot="${SLOTS.panelBottom}"]`,
targetProp: "borderColor",
},
{
selector: `calcite-shell-center-row[slot="${SLOTS.panelTop}"]`,
targetProp: "borderColor",
},
{
selector: `calcite-shell-center-row[slot="${SLOTS.centerRow}"]`,
targetProp: "borderColor",
},
],
};
themed(async () => shellHTML, tokens);
});

describe("default", () => {
const tokens: ComponentTestTokens = {
"--calcite-shell-background-color": {
targetProp: "backgroundColor",
},
};
themed(async () => shellHTML, tokens);
});

describe("deprecated", () => {
const tokens: ComponentTestTokens = {
"--calcite-shell-tip-spacing": {
selector: `calcite-tip-manager`,
targetProp: "insetInline",
},
};
themed(async () => shellHTML, tokens);
});
});