Skip to content
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

move Freestyle OPA templates to ui5-test-writer #2928

Open
wants to merge 48 commits into
base: main
Choose a base branch
from

Conversation

kjose90
Copy link
Member

@kjose90 kjose90 commented Feb 17, 2025

#2932

  • Added EJS freestyle test templates to ui5-writer-tests ad logic.
  • Added addUnits flag to freestyle Fiori App to enable tests.

Copy link

changeset-bot bot commented Feb 17, 2025

🦋 Changeset detected

Latest commit: f814276

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@sap-ux/fiori-freestyle-writer Minor
@sap-ux/fiori-generator-shared Minor
@sap-ux/ui5-test-writer Minor
@sap-ux/odata-service-inquirer Patch
@sap-ux/generator-simple-fe Patch
@sap-ux/abap-deploy-config-inquirer Patch
@sap-ux/abap-deploy-config-sub-generator Patch
@sap-ux/adp-flp-config-sub-generator Patch
@sap-ux/cap-config-writer Patch
@sap-ux/cf-deploy-config-sub-generator Patch
@sap-ux/deploy-config-generator-shared Patch
@sap-ux/fiori-elements-writer Patch
@sap-ux/flp-config-inquirer Patch
@sap-ux/flp-config-sub-generator Patch
@sap-ux/inquirer-common Patch
@sap-ux/ui5-library-reference-sub-generator Patch
@sap-ux/ui5-library-sub-generator Patch
@sap-ux/create Patch
@sap-ux/ui5-application-inquirer Patch
@sap-ux/adp-tooling Patch
@sap-ux/cf-deploy-config-inquirer Patch
@sap-ux/ui5-library-inquirer Patch
@sap-ux/ui5-library-reference-inquirer Patch
@sap-ux/preview-middleware Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kjose90
Copy link
Member Author

kjose90 commented Feb 21, 2025

@IainSAP @devinea Previously I had combined templatepackages/ui5-test-writer/templates/common/testsuite.qunit.js to be used by both FE and FF ( commit line 1 and 11 ) However, this caused whitespace discrepancies, making it challenging to align with FE snapshots. To resolve this, I reverted the change and opted to handle testsuite.qunit.js separately under freestyle templates.

Copy link
Member

@devinea devinea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments.
I think it would be easier to maintain going forward if to split templates based on UI5 template version e.g. 1.71.0 and 1.120.0

}
]
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file can be removed as it was related to handlebars?

...opaConfig,
viewNamePage: `${viewName}Page`,
appIdWithSlash,
ui5Version: templateUi5Version,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ui5Version: templateUi5Version,
templateUi5Version: templateUi5Version,

<link rel="stylesheet" type="text/css" href="../../resources/sap/ui/thirdparty/qunit-2.css">
<script src="../../resources/sap/ui/thirdparty/qunit-2.js"></script>
<script src="../../resources/sap/ui/qunit/qunit-junit.js"></script>
<% if (ui5Version !== "1.71.0") { %><script src="opaTests.qunit.js"></script><% } -%>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<% if (ui5Version !== "1.71.0") { %><script src="opaTests.qunit.js"></script><% } -%>
<% if (templateUi5Version !== "1.71.0") { %><script src="opaTests.qunit.js"></script><% } -%>

I think it is better to rename this variable for clarity

@@ -0,0 +1,17 @@
/* global QUnit */
<% if (ui5Version === '1.71.0') { -%>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<% if (ui5Version === '1.71.0') { -%>
<% if (templateUi5Version === "1.71.0") { -%>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By placing the template folders into separate folders for versions 1.71.0 and 1.120.0, this is no longer required.

// eslint-disable-next-line fiori-custom/sap-no-global-define

window.suite = function() {
'use strict';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must use double quotes in UI5 template files

* @param {Package} packageJson - The package.json object to update.
* @param {boolean} addMock - Whether to include the UI5 mock YAML configuration.
*/
function addTestScripts(packageJson: Package, addMock: boolean): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider moving this to another function in another file along with all the test related code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to packages/fiori-freestyle-writer/src/generateOPATests.ts

Copy link
Member

@devinea devinea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add tests to the writer tests packages/fiori-freestyle-writer/test/basic.test.ts ?
1.71.xand >1.120 cases.

IainSAP
IainSAP previously approved these changes Feb 21, 2025
Copy link
Contributor

@IainSAP IainSAP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kjose90

  • All comments addressed
  • Updates are clear
  • Tests to cover
  • Pending comments from @devinea to be addressed (will need re-aproval)

@kjose90
Copy link
Member Author

kjose90 commented Feb 21, 2025

Can you add tests to the writer tests packages/fiori-freestyle-writer/test/basic.test.ts ? 1.71.xand >1.120 cases.

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants