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

test: library integration tests #1725

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

vscaiceanu-1a
Copy link
Member

@vscaiceanu-1a vscaiceanu-1a commented Apr 26, 2024

Proposed change

Enhance the integration test campaign with tests for libraries.

  • @o3r/create should generate a project with a library
  • base Otter project should contain a library as well (along with an application)
  • check generated files by @o3r/workspace schematic for app and lib. Currently in create int tests, to be moved in workspace ones. feat(sdk): generate an sdk with spec from npm #1678 should be merged first.

Ensure test coverage for libs (similar to what we have for apps) and add assertions for app tests for:

@vscaiceanu-1a vscaiceanu-1a force-pushed the feature/lib-it-tests branch 6 times, most recently from f315253 to d77732a Compare May 13, 2024 12:22
@vscaiceanu-1a vscaiceanu-1a force-pushed the feature/lib-it-tests branch 7 times, most recently from c4bde64 to 3efc10c Compare May 22, 2024 14:03
@vscaiceanu-1a vscaiceanu-1a force-pushed the feature/lib-it-tests branch 4 times, most recently from 0d5a0c0 to 87bec2b Compare May 28, 2024 08:20
@vscaiceanu-1a vscaiceanu-1a force-pushed the feature/lib-it-tests branch 5 times, most recently from e02ef2b to 59eb752 Compare June 4, 2024 14:07
@vscaiceanu-1a vscaiceanu-1a requested a review from kpanot June 5, 2024 09:17
test('should add Otter Application to existing Angular app', () => {
const { workspacePath, isInWorkspace, appName, o3rVersion } = o3rEnvironment.testEnvironment;
const execAppOptions = {...getDefaultExecSyncOptions(), cwd: workspacePath};
packageManagerExec({script: 'ng', args: ['add', `@o3r/core@${o3rVersion}`, '--preset', 'all', '--project-name', appName, '--skip-confirmation']}, execAppOptions);
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we test ng add @o3r/application instead ?

@@ -139,7 +139,7 @@ export function updateLocalization(options: { projectName?: string | null | unde
workspaceProject.architect.build.options?.assets?.map((a: { glob: string; input: string; output: string }) => a.output).find((output: string) => output === '/localizations');

if (!alreadyExistingBuildOption) {
workspaceProject.architect.build.options.assets.push({
(workspaceProject.architect.build.options.assets || []).push({
Copy link
Contributor

@fpaul-1A fpaul-1A Jun 5, 2024

Choose a reason for hiding this comment

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

I think it might be less confusing to just add the condition in the if instead of creating a useless array

      if (!alreadyExistingBuildOption && workspaceProject.architect.build.options.assets) {

Comment on lines +160 to +163
untouchedApp,
untouchedAppPath,
untouchedLib,
untouchedLibPath,
Copy link
Contributor

Choose a reason for hiding this comment

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

as far as I can tell we'll never have to make different check between untouchedApp and untouchedLib. We always want to check that they are untouched no matter the test
So I would suggest to simplify the tests to only export an array of paths to be checked as untouched
[untouchedAppPath, untouchedLibPath]

we could even consider writing a custom matcher to make it more readable
expect(gitDiff).not.toHaveTouched(path) or something

const execAppOptions = {...getDefaultExecSyncOptions(), cwd: workspacePath};
packageManagerExec({script: 'ng', args: ['add', `@o3r/apis-manager@${o3rVersion}`, '--skip-confirmation', '--project-name', projectName]}, execAppOptions);
const packageManager = getPackageManager();
const isYarnTest = packageManager.startsWith('yarn');
Copy link
Contributor

@mrednic-1A mrednic-1A Jun 5, 2024

Choose a reason for hiding this comment

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

could this 'isYarnTest' constant be exported by o3rEnvironment.testEnvironment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment