Skip to content

Commit

Permalink
feat(ui5-dynamic-page): add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kineticjs committed Dec 14, 2023
1 parent 3cbfb6f commit 77cf84c
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
</ui5-dynamic-page>

<template id="templateDiv">
<div style="height:100%;display:flex;flex-direction:column;background-color: #00800037;">
<div id="content" style="height:100%;display:flex;flex-direction:column;background-color: #00800037;">
<div>first item</div>
<div style="height:100%;"></div>
<div>last item</div>
Expand Down
53 changes: 53 additions & 0 deletions packages/fiori/test/specs/DynamicPage.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { assert } from "chai";

describe("Page content with 100% height", () => {
before(async () => {
await browser.url(`test/pages/DynamicPageWithFullscreenContent.html`);
});

it("footer does not hide the content", async () => {
const page = await browser.$("#page");
const content = await browser.$("#content");
const footer = await browser.$("#footer");

assert.ok(await page.getProperty("showFooter"), "Footer is shown");

const contentBottom = await browser.execute((el) => {
return el.getBoundingClientRect().bottom;
}, content);
const footerTop = await browser.execute((el) => {
return el.getBoundingClientRect().top;
}, footer);

assert.ok(contentBottom <= footerTop, "No overlap");
});

it("content expands to fill the space between header and footer", async () => {
const page = await browser.$("#page");
const content = await browser.$("#content");
const header = await browser.$("#page ui5-dynamic-page-header");
const footerSpacer = await page.shadow$(".ui5-dynamic-page-spacer");

assert.ok(await page.getProperty("showFooter"), "Footer is shown");

const headerBottom = await browser.execute((el) => {
return el.getBoundingClientRect().bottom;
}, header);

const footerTop = await browser.execute((el) => {
return el.getBoundingClientRect().top;
}, footerSpacer);

const contentTop = await browser.execute((el) => {
return el.getBoundingClientRect().top;
}, content);

const contentBottom = await browser.execute((el) => {
return el.getBoundingClientRect().bottom;
}, content);

assert.strictEqual(contentTop, headerBottom, "Content is rendered right below header");
assert.strictEqual(contentBottom, footerTop, "Content is rendered right above footer");
});

});

0 comments on commit 77cf84c

Please sign in to comment.