Skip to content

Commit

Permalink
fix: planningcalender special case (#371)
Browse files Browse the repository at this point in the history
* feat(test): add test for planningCalendar
* test(planningcalendar): create working test
* fix(js-app): numer of expected buttons

Co-authored-by: dominikfeininger <[email protected]>
  • Loading branch information
dominikfeininger and dominikfeininger authored Nov 16, 2022
1 parent e230423 commit 0258d71
Show file tree
Hide file tree
Showing 9 changed files with 670 additions and 77 deletions.
4 changes: 4 additions & 0 deletions client-side-js/injectUI5.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ async function clientSide_injectUI5(config, waitForUI5Timeout, browserInstance)
return {
id: element.data("InputWithSuggestionsListItem").getId()
}
} else if (controlType === "sap.m.PlanningCalendar") {
return {
id: `${element.getId()}-CLI`
}
} else {
return {
id: element.getId()
Expand Down
478 changes: 478 additions & 0 deletions examples/ui5-js-app/webapp/controller/Calendar.controller.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions examples/ui5-js-app/webapp/controller/Main.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ sap.ui.define(
this.getView().setModel(oModel, "Countries")
},

navCalendar() {
return this.getOwnerComponent().getRouter().navTo("RouteCalendar")
},

navFwd() {
return this.getOwnerComponent().getRouter().navTo("RouteOther")
},
Expand Down
12 changes: 12 additions & 0 deletions examples/ui5-js-app/webapp/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
"pattern": "",
"target": ["TargetMain"]
},
{
"name": "RouteCalendar",
"pattern": "calendar",
"target": ["TargetCalendar"]
},
{
"name": "RouteMainNamed",
"pattern": "main",
Expand All @@ -122,6 +127,13 @@
"clearControlAggregation": false,
"viewId": "Other",
"viewName": "Other"
},
"TargetCalendar": {
"viewType": "XML",
"transition": "slide",
"clearControlAggregation": false,
"viewId": "Calendar",
"viewName": "Calendar"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/ui5-js-app/webapp/test/e2e/allControls.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ describe("ui5 basic, get all buttons", () => {

it("check number of buttons", async () => {
const buttons = await browser.allControls(selector)
// 7 buttons in view and the panel expand button => 8
expect(buttons.length).toEqual(8)
// 8 buttons in view and the panel expand button => 8
expect(buttons.length).toEqual(9)
})

it("no force select", async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const { wdi5 } = require("wdio-ui5-service")
const Page = require("./Page")

// const planningCalendarRow = {
// selector: {
// controlType: "sap.m.internal.PlanningCalendarRowListItem",
// id: /__row0-__xmlview0--schedulePlanningCalendar-0-CLI$/
// }
// }

class ComponentLocator extends Page {
async open(path) {
wdi5.goTo(path)
}

async open() {
await super.open(`#/Calendar`)
}

async getShowButton() {
const showSummary = {
selector: {
controlType: "sap.m.Button",
id: /TodayBtn$/
}
}

return await browser.asControl(showSummary)
}

async getCloseSummaryButton() {
const closeSummary = {
selector: {
controlType: "sap.m.Button",
id: /closeSummaryButton$/
}
}

return await browser.asControl(closeSummary)
}

async getPlanningCalendar() {
const planningCalendar = {
selector: {
controlType: "sap.m.PlanningCalendar",
id: /PC1/
}
}

return await browser.asControl(planningCalendar)
}
}

module.exports = new ComponentLocator()
44 changes: 44 additions & 0 deletions examples/ui5-js-app/webapp/test/e2e/planningCalendar.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const CL = require("./pageObjects/ComponentLocator")

describe("Planning Calendar test spec", () => {
before(async () => {
await CL.open()
})

it("should show aggreates of planning calendar", async () => {
// I wait for a button to be clickable (which means that my app has loaded
const showBtn = await CL.getShowButton()
await browser.waitUntil(() => showBtn.$().isClickable())
// I get the planning calendar
const pc = await CL.getPlanningCalendar()
// I get aggregated rows
const rows = await pc.getRows()
// each people has a row

const cells0 = await rows[0].getCells()
// the first two rows have two cell which are the the reminders and the appointments, third row does not have reminders!
const appointments0 = await cells0[1].getAppointments()
expect(appointments0.length).toBeGreaterThan(4) // four appointments visible on the selected date, but 22 in total

// every first appointment is a meeting
// the first three appointment are in the past and not visible -> not in DOM -> see error logs
const appointments0Text = await appointments0[3].getTitle()
expect(appointments0Text).toContain("Meet Max Mustermann")

const cells1 = await rows[1].getCells()
// the first two rows have two cell which are the the reminders and the appointments, third row does not have reminders!
const appointments1 = await cells1[1].getAppointments()
expect(appointments1.length).toBeGreaterThan(4) // three appointments visible on the selected date, but 11 in total

// every first appointment is a meeting
// the first three appointment are in the past and not visible -> not in DOM -> see error logs
const appointments1Text = await appointments1[3].getTitle()
expect(appointments1Text).toContain("Team meeting")

// test in all rows
for (const row of rows) {
const rowInfo = await row.getControlInfo()
expect(rowInfo.className).toBe("sap.m.internal.PlanningCalendarRowListItem")
}
})
})
44 changes: 44 additions & 0 deletions examples/ui5-js-app/webapp/view/Calendar.view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<mvc:View controllerName="test.Sample.controller.Calendar" displayBlock="true"
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc"
xmlns:core="sap.ui.core"
xmlns:unified="sap.ui.unified">

<Page title="Planning Calendar">
<content>
<VBox class="sapUiSmallMargin">
<PlanningCalendar id="PC1" startDate="{path: '/startDate'}" rows="{path: '/people'}" appointmentsVisualization="Filled" appointmentSelect="handleAppointmentSelect" showEmptyIntervalHeaders="false" showWeekNumbers="true">
<toolbarContent>
<Title text="Title" titleStyle="H4"/>
</toolbarContent>
<rows>
<PlanningCalendarRow icon="{pic}" title="{name}" text="{role}" appointments="{path : 'appointments', templateShareable: false}" intervalHeaders="{path: 'headers', templateShareable: false}">
<customData>
<core:CustomData key="emp-name" value="{name}" writeToDom="true"/>
</customData>
<appointments>
<unified:CalendarAppointment startDate="{start}" endDate="{end}" icon="{pic}" title="{title}" text="{info}" type="{type}" tentative="{tentative}">
</unified:CalendarAppointment>
</appointments>
<intervalHeaders>
<unified:CalendarAppointment startDate="{start}" endDate="{end}" icon="{pic}" title="{title}" type="{type}">
</unified:CalendarAppointment>
</intervalHeaders>
</PlanningCalendarRow>
</rows>
</PlanningCalendar>
<Label text="Add available built-in views to the example:"/>
<MultiComboBox selectionFinish="handleSelectionFinish" width="230px" placeholder="Choose built-in views">
<items>
<core:Item key="Hour" text="Hour" />
<core:Item key="Day" text="Day" />
<core:Item key="Month" text="Month" />
<core:Item key="Week" text="1 week" />
<core:Item key="One Month" text="1 month" />
</items>
</MultiComboBox>
</VBox>
</content>
</Page>

</mvc:View>
103 changes: 28 additions & 75 deletions examples/ui5-js-app/webapp/view/Main.view.xml
Original file line number Diff line number Diff line change
@@ -1,49 +1,26 @@
<mvc:View controllerName="test.Sample.controller.Main"
xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc"
displayBlock="true"
xmlns:mvc="sap.ui.core.mvc" displayBlock="true"
xmlns="sap.m">

<Page id="page"
title="{i18n>appTitle}">
<Page id="page" title="{i18n>appTitle}">
<headerContent>
<core:Icon color="#1873B4"
src="sap-icon://sap-ui5"
size="2rem" />
<core:Icon color="#1873B4" src="sap-icon://sap-ui5" size="2rem" />
<Text text="{LatestUI5>/latest}" />
</headerContent>
<content>
<Title level="H1"
id="Title::NoAction.h1"
titleStyle="H1"
text="{i18n>startPage.title.text}"
width="100%"
textAlign="Center" />
<Title level="H1" id="Title::NoAction.h1" titleStyle="H1" text="{i18n>startPage.title.text}" width="100%" textAlign="Center" />
<HBox>
<VBox alignItems="Center"
justifyContent="Center"
height="100%">
<VBox alignItems="Center" justifyContent="Center" height="100%">

<Button icon="sap-icon://forward"
id="NavFwdButton"
text="{i18n>startPage.navButton.text}"
press="navFwd" />
<Button icon="sap-icon://forward"
id="NavFwdButtonDisabled"
text="can't click :("
press="navFwd"
busy="true" />
<Button icon="sap-icon://user-edit"
id="user-test-button"
text="{i18n>startPage.userButton.text}" />
<Button text="IA Sync"
id="idIaSync"
press="onPress" />
<Button icon="sap-icon://forward" id="NavFwdButton" text="{i18n>startPage.navButton.text}" press="navFwd" />
<Button icon="sap-icon://forward" id="NavFwdButtonDisabled" text="can't click :(" press="navFwd" busy="true" />
<Button icon="sap-icon://forward" id="NavCalendarButton" text="Naviagte to Planningcalendar" press="navCalendar" />
<Button icon="sap-icon://user-edit" id="user-test-button" text="{i18n>startPage.userButton.text}" />
<Button text="IA Sync" id="idIaSync" press="onPress" />
<Text text="{i18n>startPage.text.username}" />
<Input id="mainUserInput"
value="{/Customers('TRAIH')/ContactName}" />
<Panel expandable="true"
headerText="Header Text">
<Input id="mainUserInput" value="{/Customers('TRAIH')/ContactName}" />
<Panel expandable="true" headerText="Header Text">
<headerToolbar>
<OverflowToolbar>
<Title text="Custom Toolbar with a header text" />
Expand All @@ -53,67 +30,43 @@
<Text text="Lorem ipsum dolor st amet" />
</content>
</Panel>
<Label labelFor="idDateTime"
text="labelFor DateTimePicker" />
<DateTimePicker id="idDateTime"
placeholder="Enter Date ..." />
<Button text="{testModel>/buttonText}"
press="onTest"
class="myTestClass" />
<Label labelFor="idDateTime" text="labelFor DateTimePicker" />
<DateTimePicker id="idDateTime" placeholder="Enter Date ..." />
<Button text="{testModel>/buttonText}" press="onTest" class="myTestClass" />
<Input value="{testModel>/inputValue}" />
<CheckBox id="idCheckbox"
selected="{testModel>/checkbox}"
text="test checkbox"
select="onSelect" />
<Button text="open Barcodescanner"
press="scanBarcode"
id="barcodescannerplugin" />
<Input id="barcodeValue"
value="{testModel>/barcode}" />
<Input id="invisibleInputField"
value="bla"
visible="false" />
<Button text="open Dialog"
press="openDialog"
id="openDialogButton" />
<CheckBox id="idCheckbox" selected="{testModel>/checkbox}" text="test checkbox" select="onSelect" />
<Button text="open Barcodescanner" press="scanBarcode" id="barcodescannerplugin" />
<Input id="barcodeValue" value="{testModel>/barcode}" />
<Input id="invisibleInputField" value="bla" visible="false" />
<Button text="open Dialog" press="openDialog" id="openDialogButton" />

</VBox>
<VBox>
<Label text="Country Combobox" />
<ComboBox id="combobox"
items="{
<ComboBox id="combobox" items="{
path: 'Countries>/CountriesCollection',
sorter: { path: 'text' }
}">
<core:Item key="{Countries>key}"
text="{Countries>text}" />
<core:Item key="{Countries>key}" text="{Countries>text}" />
</ComboBox>
<Label text="Country MultiCombobox" />
<MultiComboBox id="multiComboBox"
items="{
<MultiComboBox id="multiComboBox" items="{
path: 'Countries>/CountriesCollection',
sorter: { path: 'text' }
}">
<core:Item key="{Countries>key}"
text="{Countries>text}" />
<core:Item key="{Countries>key}" text="{Countries>text}" />
</MultiComboBox>
<Label text="sap.m.SearchField" />

<SearchField id="idSearchfield"
value="{testModel>/searchValue}"
placeholder="Search..."
search="onSearch" />
<Text id="idSearchResult"
text="" />
<SearchField id="idSearchfield" value="{testModel>/searchValue}" placeholder="Search..." search="onSearch" />
<Text id="idSearchResult" text="" />

<Label text="sap.m.Select" />
<Select id="select"
items="{
<Select id="select" items="{
path: 'Countries>/CountriesCollection',
sorter: { path: 'text' }
}">
<core:Item key="{Countries>key}"
text="{Countries>text}" />
<core:Item key="{Countries>key}" text="{Countries>text}" />
</Select>
</VBox>
</HBox>
Expand Down

0 comments on commit 0258d71

Please sign in to comment.