-
Notifications
You must be signed in to change notification settings - Fork 272
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
chore(ui5-table): migrate TableNavigation (fixedHeader) wdio tests to cypress #10646
Open
nowakdaniel
wants to merge
6
commits into
main
Choose a base branch
from
chore-tablenav-fixedheader-cypress
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f1fbd14
chore(ui5-table): migrate TableNavigation (fixedHeader) wdio tests to…
nowakdaniel e484196
Merge branch 'main' into chore-tablenav-fixedheader-cypress
nowakdaniel bb3330b
Merge branch 'main' into chore-tablenav-fixedheader-cypress
nowakdaniel 30378c8
chore(ui5-table): changed type to realPress
nowakdaniel 433da59
chore(ui5-table): tests now only mount necessary html code
nowakdaniel b9bdce1
chore(ui5-table): moved script block into html code
nowakdaniel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
199 changes: 199 additions & 0 deletions
199
packages/main/cypress/specs/TableNavigationFixedHeader.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
import { html } from "lit"; | ||
|
||
import "../../src/Table.js"; | ||
import "../../src/TableHeaderRow.js"; | ||
import "../../src/TableHeaderCell.js"; | ||
import "../../src/TableRow.js"; | ||
import "../../src/TableCell.js"; | ||
import "../../src/TableGrowing.js"; | ||
import "../../src/Bar.js"; | ||
import "../../src/Title.js"; | ||
import "../../src/Slider.js"; | ||
|
||
describe("Table - Keyboard Navigation with Fixed Headers", () => { | ||
function isDisplayedInsideViewport(element: string) { | ||
cy.get(element).then($el => { | ||
const el = $el[0]; | ||
const rect = el.getBoundingClientRect(); | ||
|
||
expect(rect.top).to.be.at.least(0); | ||
expect(rect.left).to.be.at.least(0); | ||
expect(rect.bottom).to.be.lessThan(Cypress.config("viewportHeight")); | ||
expect(rect.right).to.be.lessThan(Cypress.config("viewportWidth")); | ||
}); | ||
} | ||
|
||
it("scrollable container - focused row should always be below the header", () => { | ||
cy.mount(html` | ||
<div style="height:300px; overflow:auto;"> | ||
<ui5-bar id="toolbar" design="Header" accessible-name-ref="title" style="position: sticky; top: 0; z-index: 2; height: 50px;"> | ||
<ui5-title tabindsex="0" level="H3" id="title" slot="startContent">My Selectable Products (3)</ui5-title> | ||
<ui5-slider id="slider" min="0" max="100" step="1" value="100" | ||
label-interval="0"></ui5-slider> | ||
</ui5-bar> | ||
<ui5-table id="table0" overflow-mode="Popin" sticky-top="50px" accessible-name-ref="title" no-data-text="No data found"> | ||
<ui5-table-header-row sticky slot="headerRow"> | ||
<ui5-table-header-cell id="colA" min-width="300px"><span>ColumnA</span></ui5-table-header-cell> | ||
<ui5-table-header-cell id="colB" min-width="200px">Column B</ui5-table-header-cell> | ||
<ui5-table-header-cell id="colC" min-width="200px">Column C</ui5-table-header-cell> | ||
<ui5-table-header-cell id="colD" min-width="150px">Column D</ui5-table-header-cell> | ||
</ui5-table-header-row> | ||
<ui5-table-row id="row-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-2"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-3"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-4"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-5"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-6"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-7"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-8"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-9"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-10"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-11"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-12"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-13"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-14"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-15"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-16"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-17"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-18"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-19"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-20"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-21"> <ui5-table-cell>A</ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
</ui5-table> | ||
</div> | ||
`); | ||
|
||
cy.get("#table0").children("ui5-table-row").as("rows"); | ||
cy.get("#table0").children("ui5-table-header-row").as("headerRow"); | ||
cy.get("@rows").get("#row-21").as("lastRow"); | ||
|
||
cy.get("@lastRow").scrollIntoView(); | ||
cy.get("@lastRow").click("left"); | ||
cy.get("@lastRow").should("be.focused"); | ||
|
||
for (let i = 20; i > 0; i--) { | ||
cy.realPress("{uparrow}"); | ||
cy.get("@rows").get(`#row-${i}`).should("be.focused"); | ||
|
||
isDisplayedInsideViewport("@headerRow"); | ||
|
||
cy.get("@headerRow").then($headerRow => { | ||
cy.get("@rows").get(`#row-${i}`).then($row => { | ||
const headerRowBottom = $headerRow[0].getBoundingClientRect().bottom; | ||
const focusedRowTop = $row[0].getBoundingClientRect().top; | ||
|
||
expect(focusedRowTop).to.be.at.least(headerRowBottom); | ||
}); | ||
}); | ||
} | ||
}); | ||
|
||
it("scrollable table - focused row should always be below the header", () => { | ||
cy.mount(html` | ||
<ui5-table id="table1" overflow-mode="Popin" sticky-top="0" accessible-name-ref="title" no-data-text="No data found" style="height: 300px; overflow: auto;"> | ||
<ui5-table-header-row sticky slot="headerRow"> | ||
<ui5-table-header-cell id="colA" min-width="300px"><span>ColumnA</span></ui5-table-header-cell> | ||
<ui5-table-header-cell id="colB" min-width="200px">Column B</ui5-table-header-cell> | ||
<ui5-table-header-cell id="colC" min-width="200px">Column C</ui5-table-header-cell> | ||
<ui5-table-header-cell id="colD" min-width="150px">Column D</ui5-table-header-cell> | ||
</ui5-table-header-row> | ||
<ui5-table-row id="row-1-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-2-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-3-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-4-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-5-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-6-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-7-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-8-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-9-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-10-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-11-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-12-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-13-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-14-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-15-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-16-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-17-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-18-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-19-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-20-1"> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
<ui5-table-row id="row-21-1"> <ui5-table-cell>A</ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> <ui5-table-cell></ui5-table-cell> </ui5-table-row> | ||
</ui5-table> | ||
`); | ||
|
||
cy.get("#table1").children("ui5-table-row").as("rows"); | ||
cy.get("#table1").children("ui5-table-header-row").as("headerRow"); | ||
cy.get("@rows").get("#row-21-1").as("lastRow"); | ||
|
||
cy.get("@lastRow").scrollIntoView(); | ||
cy.get("@lastRow").click("left"); | ||
cy.get("@lastRow").should("be.focused"); | ||
|
||
for (let i = 20; i > 0; i--) { | ||
cy.realPress("{uparrow}"); | ||
cy.get("@rows").get(`#row-${i}-1`).should("be.focused"); | ||
|
||
isDisplayedInsideViewport("@headerRow"); | ||
|
||
cy.get("@headerRow").then($headerRow => { | ||
cy.get("@rows").get(`#row-${i}-1`).then($row => { | ||
const headerRowBottom = $headerRow[0].getBoundingClientRect().bottom; | ||
const focusedRowTop = $row[0].getBoundingClientRect().top; | ||
|
||
expect(focusedRowTop).to.be.at.least(headerRowBottom); | ||
}); | ||
}); | ||
} | ||
}); | ||
|
||
it("body as scroll container - focused row should always be below the header", () => { | ||
cy.mount(html` | ||
<ui5-bar id="toolbar2" design="Header" accessible-name-ref="title" style="position: sticky; top: 0; z-index: 2; height: 50px;"> | ||
<ui5-title tabindsex="0" level="H3" id="title" slot="startContent">My Selectable Products (3)</ui5-title> | ||
<ui5-slider id="slider" min="0" max="100" step="1" value="100" | ||
label-interval="0"></ui5-slider> | ||
</ui5-bar> | ||
<ui5-table id="table2" overflow-mode="Popin" sticky-top="50px" accessible-name-ref="title" no-data-text="No data found"> | ||
<ui5-table-header-row sticky slot="headerRow"> | ||
<ui5-table-header-cell id="colA" min-width="300px"><span>ColumnA</span></ui5-table-header-cell> | ||
<ui5-table-header-cell id="colB" min-width="200px">Column B</ui5-table-header-cell> | ||
<ui5-table-header-cell id="colC" min-width="200px">Column C</ui5-table-header-cell> | ||
<ui5-table-header-cell id="colD" min-width="150px">Column D</ui5-table-header-cell> | ||
</ui5-table-header-row> | ||
${Array.from({ length: 100 }).map((row, index) => html` | ||
<ui5-table-row id="${`row-${index + 1}-2`}"> | ||
<ui5-table-cell><ui5-label><b>Notebook Basic ${index + 1}</b><br>HT-100${index + 1}</ui5-label></ui5-table-cell> | ||
<ui5-table-cell><ui5-label>Technocom</ui5-label></ui5-table-cell> | ||
<ui5-table-cell><ui5-label>32 x 21 x 4 cm</ui5-label></ui5-table-cell> | ||
<ui5-table-cell><ui5-label style="color: #2b7c2b"><b>3.7</b> KG</ui5-label></ui5-table-cell> | ||
<ui5-table-cell style="text-align: end;"><ui5-label style="text-align: end;"><b>29</b> EUR</ui5-label></ui5-table-cell> | ||
</ui5-table-row> | ||
`)} | ||
</ui5-table> | ||
`); | ||
|
||
cy.get("#table2").children("ui5-table-row").as("rows"); | ||
cy.get("#table2").children("ui5-table-header-row").as("headerRow"); | ||
cy.get("@rows").get("#row-100-2").as("lastRow"); | ||
|
||
cy.get("@lastRow").scrollIntoView(); | ||
cy.get("@lastRow").click("left"); | ||
cy.get("@lastRow").should("be.focused"); | ||
|
||
for (let i = 99; i > 0; i--) { | ||
cy.realPress("{uparrow}"); | ||
cy.get("@rows").get(`#row-${i}-2`).should("be.focused"); | ||
|
||
isDisplayedInsideViewport("@headerRow"); | ||
|
||
cy.get("@headerRow").then($headerRow => { | ||
cy.get("@rows").get(`#row-${i}-2`).then($row => { | ||
const headerRowBottom = $headerRow[0].getBoundingClientRect().bottom; | ||
const focusedRowTop = $row[0].getBoundingClientRect().top; | ||
|
||
expect(focusedRowTop).to.be.at.least(headerRowBottom); | ||
}); | ||
}); | ||
} | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hello Daniel @nowakdaniel ,
lit-html is no longer the mount engine for the Cypress tests, we use preact + jsx (as for the component templates)
You will have to adopt this change in your PR. You can refer to this PR how to do this
#10653. Or, just check out the cypress tests in the main branch - they are all migrated already.