cypress green

This commit is contained in:
Martin McKeaveney 2020-10-27 22:06:51 +00:00
parent 454962ad02
commit a02a7ae9b9
3 changed files with 53 additions and 31 deletions

View File

@ -25,12 +25,12 @@ context("Create a View", () => {
cy.get(".title").contains("Test View") cy.get(".title").contains("Test View")
cy.get("[data-cy=table-header]").then($headers => { cy.get("[data-cy=table-header]").then($headers => {
expect($headers).to.have.length(3) expect($headers).to.have.length(3)
// const headers = $headers.map(header => header.text()) const headers = Array.from($headers).map(header => header.textContent.trim())
// expect(headers).to.deep.eq(["group", "age", "rating"]) expect(headers).to.deep.eq(["group", "age", "rating"])
}) })
}) })
xit("filters the view by age over 10", () => { it("filters the view by age over 10", () => {
cy.contains("Filter").click() cy.contains("Filter").click()
cy.contains("Add Filter").click() cy.contains("Add Filter").click()
cy.get(".menu-container") cy.get(".menu-container")
@ -43,12 +43,15 @@ context("Create a View", () => {
.select("More Than") .select("More Than")
cy.get(".menu-container").find("input").type(18) cy.get(".menu-container").find("input").type(18)
cy.contains("Save").click() cy.contains("Save").click()
cy.get(".ag-center-cols-container > div.ag-row").get($values => { cy.get("[role=rowgroup] .ag-row").get($values => {
expect($values).to.have.length(5) expect($values).to.have.length(5)
}) })
}) })
xit("creates a stats calculation view based on age", () => { it("creates a stats calculation view based on age", () => {
// Required due to responsive bug with ag grid in cypress
cy.viewport("macbook-15")
cy.contains("Calculate").click() cy.contains("Calculate").click()
cy.get(".menu-container") cy.get(".menu-container")
.find("select") .find("select")
@ -60,11 +63,9 @@ context("Create a View", () => {
.eq(1) .eq(1)
.select("age") .select("age")
cy.contains("Save").click() cy.contains("Save").click()
cy.get("[data-cy=table-header] span").then($headers => { cy.get("[data-cy=table-header]").then($headers => {
cy.log($headers)
expect($headers).to.have.length(7) expect($headers).to.have.length(7)
const headers = $headers.map(header => header.textContent) const headers = Array.from($headers).map(header => header.textContent.trim())
cy.log(headers)
expect(headers).to.deep.eq([ expect(headers).to.deep.eq([
"field", "field",
"sum", "sum",
@ -75,32 +76,36 @@ context("Create a View", () => {
"avg", "avg",
]) ])
}) })
// cy.get("tbody td").then($values => { cy.get(".ag-cell").then($values => {
// const values = $values.map((i, value) => Cypress.$(value).text()) const values = Array.from($values).map(header => header.textContent.trim())
// expect(values.get()).to.deep.eq([ expect(values).to.deep.eq([
// "age", "age",
// "155", "155",
// "20", "20",
// "49", "49",
// "5", "5",
// "5347", "5347",
// "31", "31",
// ]) ])
// }) })
}) })
xit("groups the view by group", () => { it("groups the view by group", () => {
// Required due to responsive bug with ag grid in cypress
cy.viewport("macbook-15")
cy.contains("Group By").click() cy.contains("Group By").click()
cy.get("select").select("group") cy.get("select").select("group")
cy.contains("Save").click() cy.contains("Save").click()
cy.get(".ag-center-cols-viewport").scrollTo("100%")
cy.contains("Students").should("be.visible") cy.contains("Students").should("be.visible")
cy.contains("Teachers").should("be.visible") cy.contains("Teachers").should("be.visible")
cy.get(".ag-center-cols-container > div.ag-row") cy
.first() .get(".ag-row[row-index=0]")
.find(".ag-cell") .find(".ag-cell")
.then($values => { .then($values => {
const values = $values.map(value => value.textContent) const values = Array.from($values).map(value => value.textContent)
expect(values).to.deep.eq([ expect(values).to.deep.eq([
"Students", "Students",
"70", "70",

View File

@ -44,6 +44,7 @@
customLoadingOverlay: TableLoadingOverlay, customLoadingOverlay: TableLoadingOverlay,
}, },
loadingOverlayComponent: "customLoadingOverlay", loadingOverlayComponent: "customLoadingOverlay",
animateRows: true
} }
$: { $: {
@ -135,7 +136,6 @@
{columnDefs} {columnDefs}
{loading} {loading}
on:select={({ detail }) => (selectedRows = detail)} /> on:select={({ detail }) => (selectedRows = detail)} />
/>
</section> </section>
<style> <style>

View File

@ -19,6 +19,9 @@
let menuButton let menuButton
let sortDirection = "" let sortDirection = ""
let modal let modal
let hovered
$: console.log($$restProps)
function toggleMenu() { function toggleMenu() {
showColumnMenu(menuButton) showColumnMenu(menuButton)
@ -39,9 +42,13 @@
}) })
</script> </script>
<header on:click={onSort} data-cy="table-header"> <header
on:click={onSort}
data-cy="table-header"
on:mouseover={() => (hovered = true)}
on:mouseleave={() => (hovered = false)}>
<div> <div>
<span>{displayName}</span> <span class="column-header-name">{displayName}</span>
<i class={`${SORT_ICON_MAP[sortDirection]} sort-icon`} /> <i class={`${SORT_ICON_MAP[sortDirection]} sort-icon`} />
</div> </div>
<Modal bind:this={modal}> <Modal bind:this={modal}>
@ -52,7 +59,7 @@
<CreateEditColumn onClosed={modal.hide} {field} /> <CreateEditColumn onClosed={modal.hide} {field} />
</ModalContent> </ModalContent>
</Modal> </Modal>
<div> <section class:show={hovered}>
{#if editable} {#if editable}
<span on:click|stopPropagation={showModal}> <span on:click|stopPropagation={showModal}>
<i class="ri-pencil-line" /> <i class="ri-pencil-line" />
@ -61,7 +68,7 @@
<span on:click|stopPropagation={toggleMenu} bind:this={menuButton}> <span on:click|stopPropagation={toggleMenu} bind:this={menuButton}>
<i class="ri-filter-line" /> <i class="ri-filter-line" />
</span> </span>
</div> </section>
</header> </header>
<style> <style>
@ -76,6 +83,15 @@
color: var(--ink); color: var(--ink);
} }
section {
opacity: 0;
transition: 0.2s all;
}
section.show {
opacity: 1;
}
.sort-icon { .sort-icon {
position: relative; position: relative;
top: 2px; top: 2px;
@ -91,7 +107,8 @@
color: var(--blue); color: var(--blue);
} }
i:active { i.active,
i:hover {
color: var(--blue); color: var(--blue);
} }
</style> </style>