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(commonTests, alert, combobox, dropdown, input-date-picker, modal, popover, tooltip): extracts a general test utility OpenClose for all components implementing openCloseComponent util #7379

Merged
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
04f2697
test(commonTests): extracts a general test utility emitsOpenCloseTran…
Elijbet Jul 25, 2023
57d3038
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Jul 25, 2023
b25d73e
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Jul 27, 2023
16ed200
refactor to simplify var and test names and to eliminate repetitive code
Elijbet Jul 27, 2023
d4b1978
add extra checks and move selectors to resources to avoid hard coding
Elijbet Jul 27, 2023
dfbc66e
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Jul 27, 2023
858848f
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Aug 4, 2023
7307dda
Split into 2 test coverages for with and without animation and refact…
Elijbet Aug 4, 2023
1dd336b
get the initial value of toggleProp dynamically and toggle accordingly
Elijbet Aug 4, 2023
00ba742
assume the element will be visible (or not visible) to avoid checking…
Elijbet Aug 4, 2023
01d09d6
wire up this helper in comobobox and alert
Elijbet Aug 4, 2023
136c9dc
rename HTML block
Elijbet Aug 4, 2023
c304d33
cleanup
Elijbet Aug 4, 2023
1979adf
add modal test imports of openClose util: regular use case and when i…
Elijbet Aug 4, 2023
4d6d984
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Aug 4, 2023
bb73ff5
applied to popover, to-do: fix failing tests with disabled animation
Elijbet Aug 5, 2023
4d1ae22
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Aug 7, 2023
13a0f1f
fix for popover
Elijbet Aug 7, 2023
bb3e086
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Aug 7, 2023
62ba3bd
add tooltip tests for checking openClose emits via prop as well as us…
Elijbet Aug 8, 2023
0b4737e
userInputDevice - Optional argument with functions to simulate user i…
Elijbet Aug 8, 2023
3b08700
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Aug 8, 2023
4e6caad
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Aug 8, 2023
5728d42
modify test for
Elijbet Aug 8, 2023
b805d7c
resolve merge
Elijbet Aug 15, 2023
8d28259
cleanups and refactors
Elijbet Aug 15, 2023
c8774f5
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Aug 15, 2023
59a3ee7
cleanups and refactors
Elijbet Aug 15, 2023
8d99c26
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Aug 15, 2023
fb3a2ce
Refactor the commonTest util to include newProgrammaticE2EPage setup …
Elijbet Aug 16, 2023
228035a
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Aug 16, 2023
49814ec
merge
Elijbet Aug 29, 2023
bd76e7c
worked out merge conflicts
Elijbet Aug 29, 2023
c162352
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Aug 29, 2023
d31d215
WIP: cleanup
Elijbet Aug 30, 2023
8f5588a
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Aug 30, 2023
90390fb
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Sep 4, 2023
7984977
revert unrelated eslint change
Elijbet Sep 4, 2023
c061a29
refactors
Elijbet Sep 4, 2023
0524a93
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Sep 6, 2023
4048fe5
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Sep 6, 2023
3afe7c7
simplify util by extracting a OpenCloseOptions interface
Elijbet Sep 6, 2023
967d2eb
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Sep 7, 2023
07c0b55
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Sep 7, 2023
2fc3686
merge conflicts
Elijbet Sep 11, 2023
66ed1a9
rename togglePropName to openPropName; since the pattern use open/clo…
Elijbet Sep 11, 2023
39d4518
rename togglePropName to openPropName; since the pattern use open/clo…
Elijbet Sep 11, 2023
e82808b
rename userInputDevice to inputOptions
Elijbet Sep 11, 2023
f3d01b3
revert
Elijbet Sep 11, 2023
c4c3ade
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Sep 13, 2023
536e87d
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Sep 18, 2023
62aa8a0
refactor openClose call signature in the individual test and add a mo…
Elijbet Sep 19, 2023
1ac7257
for methods, use setUp (verb) vs setup (noun) convention
Elijbet Sep 19, 2023
f19a24c
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Sep 19, 2023
7d3f147
Shorten comment
Elijbet Sep 19, 2023
fe48292
Merge branch 'main' into elijbet/4968-add-common-test-util-for-all-Op…
Elijbet Sep 19, 2023
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
53 changes: 5 additions & 48 deletions packages/calcite-components/src/components/alert/alert.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { html } from "../../../support/formatting";
import { accessible, defaults, hidden, HYDRATED_ATTR, renders, t9n } from "../../tests/commonTests";
import { getElementXY } from "../../tests/utils";
import { CSS, DURATIONS } from "./resources";
import { openClose } from "../../tests/commonTests";

describe("defaults", () => {
defaults("calcite-alert", [
Expand Down Expand Up @@ -38,6 +39,10 @@ describe("calcite-alert", () => {
`);
});

describe("openClose", () => {
openClose("calcite-alert");
});

it("renders default props when none are provided", async () => {
const page = await newE2EPage();
await page.setContent(`
Expand Down Expand Up @@ -280,54 +285,6 @@ describe("calcite-alert", () => {
});
});

it("should emit component status for transition-chained events: 'calciteAlertBeforeOpen', 'calciteAlertOpen', 'calciteAlertBeforeClose', 'calciteAlertClose'", async () => {
const page = await newE2EPage();
await page.setContent(html`<calcite-alert> ${alertContent} </calcite-alert>`);

const element = await page.find("calcite-alert");
const container = await page.find(`calcite-alert >>> .${CSS.container}`);

expect(await container.isVisible()).toBe(false);

const calciteAlertBeforeOpenEvent = page.waitForEvent("calciteAlertBeforeOpen");
const calciteAlertOpenEvent = page.waitForEvent("calciteAlertOpen");

const calciteAlertBeforeOpenSpy = await element.spyOnEvent("calciteAlertBeforeOpen");
const calciteAlertOpenSpy = await element.spyOnEvent("calciteAlertOpen");

await element.setProperty("open", true);
await page.waitForChanges();

await calciteAlertBeforeOpenEvent;
await calciteAlertOpenEvent;

expect(await element.getProperty("open")).toBe(true);

expect(calciteAlertBeforeOpenSpy).toHaveReceivedEventTimes(1);
expect(calciteAlertOpenSpy).toHaveReceivedEventTimes(1);

expect(await container.isVisible()).toBe(true);

const calciteAlertBeforeCloseEvent = page.waitForEvent("calciteAlertBeforeClose");
const calciteAlertCloseEvent = page.waitForEvent("calciteAlertClose");

const calciteAlertBeforeCloseSpy = await element.spyOnEvent("calciteAlertBeforeClose");
const calciteAlertClose = await element.spyOnEvent("calciteAlertClose");

await element.setProperty("open", false);
await page.waitForChanges();

await calciteAlertBeforeCloseEvent;
await calciteAlertCloseEvent;

expect(await element.getProperty("open")).toBe(false);

expect(calciteAlertBeforeCloseSpy).toHaveReceivedEventTimes(1);
expect(calciteAlertClose).toHaveReceivedEventTimes(1);

expect(await container.isVisible()).toBe(false);
});

it("should update number of queued alerts with a calcite-chip when removing an alert", async () => {
const page = await newE2EPage();
await page.setContent(html`
Expand Down
108 changes: 12 additions & 96 deletions packages/calcite-components/src/components/combobox/combobox.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import {
accessible,
defaults,
disabled,
hidden,
floatingUIOwner,
formAssociated,
hidden,
labelable,
openClose,
reflects,
renders,
t9n,
} from "../../tests/commonTests";

import { html } from "../../../support/formatting";
import { CSS as ComboboxItemCSS } from "../combobox-item/resources";
import { CSS } from "./resources";
import { CSS as XButtonCSS } from "../functional/XButton";
import { skipAnimations } from "../../tests/utils";

Expand Down Expand Up @@ -143,51 +143,17 @@ describe("calcite-combobox", () => {
disabled("calcite-combobox");
});

it("filter properly when items have duplicate values with parents", async () => {
const page = await newE2EPage();
await page.setContent(
html`
<calcite-combobox>
<calcite-combobox-item-group label="arcgis-app-identity">
<calcite-combobox-item
value="./html/arcgis-app-identity/index.html"
text-label="index.html"
></calcite-combobox-item>
</calcite-combobox-item-group>
<calcite-combobox-item-group label="arcgis-configuration-editor">
<calcite-combobox-item
value="./html/arcgis-configuration-editor/composite-field-editor.html"
text-label="composite-field-editor.html"
></calcite-combobox-item>
<calcite-combobox-item
value="./html/arcgis-configuration-editor/index.html"
text-label="index.html"
></calcite-combobox-item>
<calcite-combobox-item
value="./html/arcgis-configuration-editor/rule-editor.html"
text-label="rule-editor.html"
></calcite-combobox-item>
</calcite-combobox-item-group>
</calcite-combobox>
`
);

const combobox = await page.find("calcite-combobox");
await combobox.click();
await page.waitForChanges();
await combobox.type("conf");
await page.waitForChanges();

const items = await page.findAll("calcite-combobox-item");
const groups = await page.findAll("calcite-combobox-item-group");

expect(await groups[0].isVisible()).toBe(false);
expect(await items[0].isVisible()).toBe(false);
const simpleComboboxHTML = html`
<calcite-combobox id="myCombobox">
<calcite-combobox-item value="Raising Arizona" text-label="Raising Arizona"></calcite-combobox-item>
<calcite-combobox-item value="Miller's Crossing" text-label="Miller's Crossing"></calcite-combobox-item>
<calcite-combobox-item value="The Hudsucker Proxy" text-label="The Hudsucker Proxy"></calcite-combobox-item>
<calcite-combobox-item value="Inside Llewyn Davis" text-label="Inside Llewyn Davis"></calcite-combobox-item>
</calcite-combobox>
`;

expect(await groups[1].isVisible()).toBe(true);
expect(await items[1].isVisible()).toBe(true);
expect(await items[2].isVisible()).toBe(true);
expect(await items[3].isVisible()).toBe(true);
describe("openClose", () => {
openClose(simpleComboboxHTML);
});

it("filtering does not match property with value of undefined", async () => {
Expand Down Expand Up @@ -1593,56 +1559,6 @@ describe("calcite-combobox", () => {
);
});

it("should emit component status for transition-chained events: 'calciteComboboxBeforeOpen', 'calciteComboboxOpen', 'calciteComboboxBeforeClose', 'calciteComboboxClose'", async () => {
const page = await newE2EPage();
await page.setContent(html`
<calcite-combobox id="myCombobox">
<calcite-combobox-item value="Raising Arizona" text-label="Raising Arizona"></calcite-combobox-item>
<calcite-combobox-item value="Miller's Crossing" text-label="Miller's Crossing"></calcite-combobox-item>
<calcite-combobox-item value="The Hudsucker Proxy" text-label="The Hudsucker Proxy"></calcite-combobox-item>
<calcite-combobox-item value="Inside Llewyn Davis" text-label="Inside Llewyn Davis"></calcite-combobox-item>
</calcite-combobox>
`);
const element = await page.find("calcite-combobox");
const container = await page.find(`calcite-combobox >>> .${CSS.listContainer}`);

expect(await container.isVisible()).toBe(false);

const calciteComboboxBeforeOpenEvent = page.waitForEvent("calciteComboboxBeforeOpen");
const calciteComboboxOpenEvent = page.waitForEvent("calciteComboboxOpen");

const calciteComboboxBeforeOpenSpy = await element.spyOnEvent("calciteComboboxBeforeOpen");
const calciteComboboxOpenSpy = await element.spyOnEvent("calciteComboboxOpen");

await element.setProperty("open", true);
await page.waitForChanges();

await calciteComboboxBeforeOpenEvent;
await calciteComboboxOpenEvent;

expect(calciteComboboxBeforeOpenSpy).toHaveReceivedEventTimes(1);
expect(calciteComboboxOpenSpy).toHaveReceivedEventTimes(1);

expect(await container.isVisible()).toBe(true);

const calciteComboboxBeforeCloseEvent = page.waitForEvent("calciteComboboxBeforeClose");
const calciteComboboxCloseEvent = page.waitForEvent("calciteComboboxClose");

const calciteComboboxBeforeCloseSpy = await element.spyOnEvent("calciteComboboxBeforeClose");
const calciteComboboxClose = await element.spyOnEvent("calciteComboboxClose");

await element.setProperty("open", false);
await page.waitForChanges();

await calciteComboboxBeforeCloseEvent;
await calciteComboboxCloseEvent;

expect(calciteComboboxBeforeCloseSpy).toHaveReceivedEventTimes(1);
expect(calciteComboboxClose).toHaveReceivedEventTimes(1);

expect(await container.isVisible()).toBe(false);
});

it("should have input--icon class when placeholder-icon is parsed", async () => {
const page = await newE2EPage();
await page.setContent(html` <calcite-combobox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
floatingUIOwner,
focusable,
hidden,
openClose,
reflects,
renders,
} from "../../tests/commonTests";
import { GlobalTestProps, getFocusedElementProp } from "../../tests/utils";
import { CSS } from "./resources";

describe("calcite-dropdown", () => {
const simpleDropdownHTML = html`
Expand Down Expand Up @@ -74,6 +74,10 @@ describe("calcite-dropdown", () => {
});
});

describe("openClose", () => {
openClose(simpleDropdownHTML);
});

interface SelectedItemsAssertionOptions {
/**
* IDs from items to assert selection
Expand Down Expand Up @@ -1228,58 +1232,5 @@ describe("calcite-dropdown", () => {
}
);
});

it("should emit component status for transition-chained events: 'calciteDropdownBeforeOpen', 'calciteDropdownOpen', 'calciteDropdownBeforeClose', 'calciteDropdownClose'", async () => {
const page = await newE2EPage();
await page.setContent(html`
<calcite-dropdown>
<calcite-button slot="trigger">Open dropdown</calcite-button>
<calcite-dropdown-group id="group-1">
<calcite-dropdown-item id="item-1"> Dropdown Item Content </calcite-dropdown-item>
<calcite-dropdown-item id="item-2" selected> Dropdown Item Content </calcite-dropdown-item>
<calcite-dropdown-item id="item-3"> Dropdown Item Content </calcite-dropdown-item>
</calcite-dropdown-group>
</calcite-dropdown>
`);
const element = await page.find(`calcite-dropdown`);
const group = await page.find(`calcite-dropdown >>> .${CSS.calciteDropdownContent}`);

expect(await group.isVisible()).toBe(false);

const calciteDropdownBeforeOpenEvent = page.waitForEvent("calciteDropdownBeforeOpen");
const calciteDropdownOpenEvent = page.waitForEvent("calciteDropdownOpen");

const calciteDropdownBeforeOpenSpy = await element.spyOnEvent("calciteDropdownBeforeOpen");
const calciteDropdownOpenSpy = await element.spyOnEvent("calciteDropdownOpen");

element.setProperty("open", true);
await page.waitForChanges();

expect(await element.getProperty("open")).toBe(true);
await calciteDropdownBeforeOpenEvent;
await calciteDropdownOpenEvent;

expect(calciteDropdownBeforeOpenSpy).toHaveReceivedEventTimes(1);
expect(calciteDropdownOpenSpy).toHaveReceivedEventTimes(1);

expect(await group.isVisible()).toBe(true);

const calciteDropdownBeforeCloseEvent = page.waitForEvent("calciteDropdownBeforeClose");
const calciteDropdownCloseEvent = page.waitForEvent("calciteDropdownClose");

const calciteDropdownBeforeCloseSpy = await element.spyOnEvent("calciteDropdownBeforeClose");
const calciteDropdownCloseSpy = await element.spyOnEvent("calciteDropdownClose");

element.setProperty("open", false);
await page.waitForChanges();

await calciteDropdownBeforeCloseEvent;
await calciteDropdownCloseEvent;

expect(calciteDropdownBeforeCloseSpy).toHaveReceivedEventTimes(1);
expect(calciteDropdownCloseSpy).toHaveReceivedEventTimes(1);

expect(await group.isVisible()).toBe(false);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export const SLOTS = {
dropdownTrigger: "trigger",
};

export const CSS = {
calciteDropdownContent: "calcite-dropdown-content",
Elijbet marked this conversation as resolved.
Show resolved Hide resolved
};
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { E2EElement, E2EPage, newE2EPage } from "@stencil/core/testing";
import {
accessible,
defaults,
disabled,
formAssociated,
labelable,
floatingUIOwner,
renders,
hidden,
labelable,
openClose,
renders,
t9n,
accessible,
} from "../../tests/commonTests";
import { html } from "../../../support/formatting";
import { CSS } from "./resources";
Expand Down Expand Up @@ -55,6 +56,10 @@ describe("calcite-input-date-picker", () => {
disabled("calcite-input-date-picker");
});

describe("openClose", () => {
openClose(`<calcite-input-date-picker id="pickerOpenClose" value="2021-12-08"></calcite-input-date-picker>`);
});

it.skip("supports t9n", () => t9n("calcite-input-date-picker"));

async function navigateMonth(page: E2EPage, direction: "previous" | "next"): Promise<void> {
Expand Down Expand Up @@ -499,50 +504,6 @@ describe("calcite-input-date-picker", () => {
expect(await input.getProperty("value")).toBe("");
});

it("should emit component status for transition-chained events: 'calciteInputDatePickerBeforeOpen', 'calciteInputDatePickerOpen', 'calciteInputDatePickerBeforeClose', 'calciteInputDatePickerClose'", async () => {
const page = await newE2EPage();
await page.setContent(
html` <calcite-input-date-picker id="pickerOpenClose" value="2021-12-08"></calcite-input-date-picker> `
);

const element = await page.find("calcite-input-date-picker");
const container = await page.find(`calcite-input-date-picker >>> .${CSS.menu}`);

const calciteInputDatePickerBeforeOpenEvent = page.waitForEvent("calciteInputDatePickerBeforeOpen");
const calciteInputDatePickerOpenEvent = page.waitForEvent("calciteInputDatePickerOpen");

const calciteInputDatePickerBeforeOpenSpy = await element.spyOnEvent("calciteInputDatePickerBeforeOpen");
const calciteInputDatePickerOpenSpy = await element.spyOnEvent("calciteInputDatePickerOpen");

await element.setProperty("open", true);
await page.waitForChanges();

expect(container).toHaveClass(CSS.menuActive);

await calciteInputDatePickerBeforeOpenEvent;
await calciteInputDatePickerOpenEvent;

expect(calciteInputDatePickerBeforeOpenSpy).toHaveReceivedEventTimes(1);
expect(calciteInputDatePickerOpenSpy).toHaveReceivedEventTimes(1);

const calciteInputDatePickerBeforeCloseEvent = page.waitForEvent("calciteInputDatePickerBeforeClose");
const calciteInputDatePickerCloseEvent = page.waitForEvent("calciteInputDatePickerClose");

const calciteInputDatePickerBeforeCloseSpy = await element.spyOnEvent("calciteInputDatePickerBeforeClose");
const calciteInputDatePickerClose = await element.spyOnEvent("calciteInputDatePickerClose");

await element.setProperty("open", false);
await page.waitForChanges();

expect(container).not.toHaveClass(CSS.menuActive);

await calciteInputDatePickerBeforeCloseEvent;
await calciteInputDatePickerCloseEvent;

expect(calciteInputDatePickerBeforeCloseSpy).toHaveReceivedEventTimes(1);
expect(calciteInputDatePickerClose).toHaveReceivedEventTimes(1);
});

it("should return endDate time as 23:59:999 when end value is typed", async () => {
const page = await newE2EPage();
await page.setContent(html` <calcite-input-date-picker layout="horizontal" range></calcite-input-date-picker>`);
Expand Down
Loading