Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 9 additions & 14 deletions app/samples/webapp/test/integration/ListReportJourney.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import runner from './pages/JourneyRunner';

// Currently open type errors:
// - sap.fe.test onTable "vTableIdentifier" should be optional
// - opa5.waitFor returns type Opa5 -> chaining of custom actions/assertions not possible
// - sap.fe.test actions/assertions return type "object" does not contain "and" -> chaining not possible

function journey() {
// there should be no blanks in Qunit module name in case of a piper based traceability mapping
Expand All @@ -29,29 +27,26 @@ function journey() {
opaTest('Should be able to adapt filters', function (Given: Given, When: When, Then: Then) {
When.onTheListReport.onFilterBar().iOpenFilterAdaptation();

Then.onTheListReport.onFilterBar().iCheckAdaptationFilterField({ property: 'modifiedBy' }, { selected: false });
Then.onTheListReport.onFilterBar().iCheckAdaptationFilterField({ property: 'modifiedAt' }, { selected: false });
Then.onTheListReport.onFilterBar().iCheckAdaptationFilterField({ property: 'createdBy' }, { selected: false });
Then.onTheListReport.onFilterBar().iCheckAdaptationFilterField({ property: 'createdAt' }, { selected: false });

Then.onTheListReport.onFilterBar().iConfirmFilterAdaptation();
Then.onTheListReport.onFilterBar()
.iCheckAdaptationFilterField({ property: 'modifiedBy' }, { selected: false })
.and.iCheckAdaptationFilterField({ property: 'modifiedAt' }, { selected: false })
.and.iCheckAdaptationFilterField({ property: 'createdBy' }, { selected: false })
.and.iCheckAdaptationFilterField({ property: 'createdAt' }, { selected: false })
.and.iConfirmFilterAdaptation();
});

opaTest('Should be able to create and delete samples', function (Given: Given, When: When, Then: Then) {
Then.onTheListReport.onTable('').iCheckCreate({ visible: true });
Then.onTheListReport.onTable('').iCheckDelete({ visible: true });
Then.onTheListReport.onTable('').iCheckCreate({ visible: true }).and.iCheckDelete({ visible: true });
});

opaTest('Should be able to filter', function (Given: Given, When: When, Then: Then) {
When.onTheListReport.onFilterBar().iChangeFilterField({ property: 'name' }, 'Test', true);
When.onTheListReport.onFilterBar().iExecuteSearch();
When.onTheListReport.onFilterBar().iChangeFilterField({ property: 'name' }, 'Test', true).and.iExecuteSearch();

Then.onTheListReport.onTable('').iCheckRows(undefined, 1);
});

opaTest('Should be able to remove a filter', function (Given: Given, When: When, Then: Then) {
When.onTheListReport.onFilterBar().iChangeFilterField({ property: 'name' }, '', true);
When.onTheListReport.onFilterBar().iExecuteSearch();
When.onTheListReport.onFilterBar().iChangeFilterField({ property: 'name' }, '', true).and.iExecuteSearch();

Then.onTheListReport.onTable('').iCheckRows(undefined, 3);
});
Expand Down
19 changes: 8 additions & 11 deletions app/samples/webapp/test/integration/ObjectPageJourney.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ function journey() {
);

opaTest('Should see the Object Page Sections', function (Given: Given, When: When, Then: Then) {
Then.onTheObjectPage.iShouldSeeSection('generalInformation');
Then.onTheObjectPage.iShouldSeeSection('CommentsSection');
Then.onTheObjectPage.iShouldSeeSection('generalInformation').and.iShouldSeeSection('CommentsSection');
});

opaTest('Should see the Object Page in edit mode', function (Given: Given, When: When, Then: Then) {
When.onTheObjectPage.onHeader().iExecuteEdit();

Then.onTheObjectPage.iShouldSeeSection('EditableHeaderSection');
Then.onTheObjectPage.iShouldSeeSection('generalInformation');
Then.onTheObjectPage.iShouldSeeSection('CommentsSection');
Then.onTheObjectPage
.iShouldSeeSection('EditableHeaderSection')
.and.iShouldSeeSection('generalInformation')
.and.iShouldSeeSection('CommentsSection');
});

opaTest('Should see the editable header content', function (Given: Given, When: When, Then: Then) {
Expand All @@ -53,26 +53,23 @@ function journey() {
opaTest('Should be able to add a comment and cancel', function (Given: Given, When: When, Then: Then) {
When.onTheObjectPage.onHeader().iExecuteEdit();
When.onTheObjectPage.iAddComment('Test2');
When.onTheObjectPage.onFooter().iExecuteCancel();
When.onTheObjectPage.onFooter().iConfirmCancel();
When.onTheObjectPage.onFooter().iExecuteCancel().and.iConfirmCancel();

Then.onTheObjectPage.iShouldSeeComments(2);
});

opaTest('Should be able to delete a comment and cancel', function (Given: Given, When: When, Then: Then) {
When.onTheObjectPage.onHeader().iExecuteEdit();
When.onTheObjectPage.iDeleteComment(0);
When.onTheObjectPage.onFooter().iExecuteCancel();
When.onTheObjectPage.onFooter().iConfirmCancel();
When.onTheObjectPage.onFooter().iExecuteCancel().and.iConfirmCancel();

Then.onTheObjectPage.iShouldSeeComments(2);
});

opaTest('Should be able to edit a comment and cancel', function (Given: Given, When: When, Then: Then) {
When.onTheObjectPage.onHeader().iExecuteEdit();
When.onTheObjectPage.iEditComment(0, 'TestTest');
When.onTheObjectPage.onFooter().iExecuteCancel();
When.onTheObjectPage.onFooter().iConfirmCancel();
When.onTheObjectPage.onFooter().iExecuteCancel().and.iConfirmCancel();

Then.onTheObjectPage.iShouldSeeComments(2);
});
Expand Down
46 changes: 34 additions & 12 deletions app/samples/webapp/test/integration/types/OpaJourneyTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@ import type { actions as TemplatePageActions, assertions as TemplatePageAssertio
import type Shell from 'sap/fe/test/Shell';
import type BaseArrangements from 'sap/fe/test/BaseArrangements';

/**
* Enables OPA5 fluent `.and` chaining on page objects and their sub-objects.
*
* @example
* Then.onTheObjectPage.iShouldSeeSection('A').and.iShouldSeeSection('B');
* When.onTheObjectPage.onFooter().iExecuteCancel().and.iConfirmCancel();
* When.onTheListReport.onTable('').iPressRow({}).and.iDoOther();
*/
type WithAnd<T> = {
[K in keyof T | 'and']: K extends 'and'
? WithAnd<T>
: K extends keyof T
? T[K] extends (...args: infer A) => infer R
? (...args: A) => (R extends Opa5 | object ? (keyof R extends never ? WithAnd<T> : [R] extends [Opa5] ? WithAnd<T> : WithAnd<R>) : WithAnd<T>)
: T[K]
: never;
};

type ExperimentalObjectPageAssertions = {
iSeeLinkWithText: (text: string) => void;
iSeeContactDetailsPopover: (text: string) => void;
Expand All @@ -28,22 +46,26 @@ type Given = Opa5 &

type When = Opa5 &
BaseArrangements & {
onTheListReport: Opa5 & ListReportActions & TemplatePageActions;
onTheObjectPage: Opa5 &
ObjectPageActions &
TemplatePageActions &
typeof CustomObjectPageActions &
ExperimentalObjectPageActions;
onTheListReport: WithAnd<Opa5 & ListReportActions & TemplatePageActions>;
onTheObjectPage: WithAnd<
Opa5 &
ObjectPageActions &
TemplatePageActions &
typeof CustomObjectPageActions &
ExperimentalObjectPageActions
>;
onTheShell: Shell;
};

type Then = Opa5 &
BaseArrangements & {
onTheListReport: Opa5 & ListReportAssertions & TemplatePageAssertions & typeof CustomListReportAssertions;
onTheObjectPage: Opa5 &
ObjectPageAssertions &
TemplatePageAssertions &
typeof CustomObjectPageAssertions &
ExperimentalObjectPageAssertions;
onTheListReport: WithAnd<Opa5 & ListReportAssertions & TemplatePageAssertions & typeof CustomListReportAssertions>;
onTheObjectPage: WithAnd<
Opa5 &
ObjectPageAssertions &
TemplatePageAssertions &
typeof CustomObjectPageAssertions &
ExperimentalObjectPageAssertions
>;
onTheShell: Shell;
};