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

[ACS-8951] [E2E] tags and categories e2es added in ACA #4210

Merged
merged 9 commits into from
Nov 6, 2024

Conversation

datguychen
Copy link
Contributor

JIRA ticket link or changeset's description
https://hyland.atlassian.net/browse/ACS-8951

@datguychen datguychen force-pushed the ACS-8951-add-e2e-tests-tags-categories branch from 814ef65 to 4462619 Compare October 30, 2024 09:28
@datguychen datguychen marked this pull request as draft October 30, 2024 10:30
@datguychen datguychen marked this pull request as ready for review October 30, 2024 11:03

async function createTagGetId() {
const requestTagData = await tagsApi.createTags([tagBody]);
if (Object.keys(requestTagData).includes('entry')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

we can replace this if with better code like below to replace unknown type checking.
if ('entry' in requestTagData) {
return (requestTagData as { entry: { id: string } }).entry.id;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was using 'entry' in request but sonar cloud is giving me this error:
**_Use "indexOf" or "includes" (available from ES2016) instead._**

I switched it back to using 'in' keyword and the issue occurs again. What should I do here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AleksanderSklorz the sonar cloud issue is discussed here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I see. Honestly not sure why Sonar is complaining about that. Using 'in' should be fine as well in my opinion as it looks simpler. @MichalKinas is there any reason why we can't use 'in'? Should we somehow change it for sonar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's why I used this line of code return (createdTag as { entry: { id: string } }).entry.id;, because it treats the createdTag as a specific object with entry and id, and not as TagEntry which is somehow interpreted differently in this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

So in your first case you got beforeAll failed : TypeError: Cannot use 'in' operator to search for 'entry' in undefined which means that in that case createdTag[0] is undefined which means that tagsApi.createTags didn't return tags, the rest of the code should work fine I even tested that in jsconsole ->
Zrzut ekranu 2024-11-5 o 09 45 43

Copy link
Contributor

Choose a reason for hiding this comment

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

If you still get the error please let me know how to run this case locally I will try to debug

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MichalKinas in both cases the tags are created. This is the case with createdTag[0]. I still don't understand why it creates 3 tags, but I don't think this is the issue right now. The code is up-to-date on this branch, so if you want to debug it locally, you can do it. You can message me if you encounter any issues with running the e2es.

createdTag: {
entry: { tag: 'tag-1ld4r', id: '222ce83c-e6a1-487c-ace8-3ce6a1487c98' }
}
beforeAll failed : TypeError: Cannot use 'in' operator to search for 'entry' in undefined
createdTag: {
entry: { tag: 'tag-10mri', id: '2c78ac98-e2a9-44c8-b8ac-98e2a9a4c894' }
}
beforeAll failed : TypeError: Cannot use 'in' operator to search for 'entry' in undefined
createdTag: {
entry: { tag: 'tag-137wp', id: 'bcf4dce5-93be-4955-b4dc-e593be395537' }
}
beforeAll failed : TypeError: Cannot use 'in' operator to search for 'entry' in undefined

Copy link
Contributor

Choose a reason for hiding this comment

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

XD this does not return array of 3 tags, those are 3 separate calls to create tags, that's why it fails when you try to access first element, this looks like an API inconsistency since it returns an object instead of an array, I can recall we had a ticket for that somewhere? Well anyway in that case doing return (requestTagData as { entry: { id: string } }).entry.id should be fine until that gets fixed, sorry for the confusion I didn't know that API doesn't return an array

@datguychen datguychen force-pushed the ACS-8951-add-e2e-tests-tags-categories branch from b6fdeb0 to 9e1cb96 Compare October 31, 2024 09:03
@@ -50,41 +102,139 @@ test.describe('Info Drawer - File Folder Properties', () => {

test.afterAll(async () => {
await Utils.deleteNodesSitesEmptyTrashcan(nodesApi, trashcanApi, 'afterAll failed');
await categoriesApi.deleteCategory(responseCategoryId);
Copy link
Contributor

Choose a reason for hiding this comment

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

responseCategoryId might be null if error will happen

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, please check if properly.

@@ -50,41 +102,139 @@ test.describe('Info Drawer - File Folder Properties', () => {

test.afterAll(async () => {
await Utils.deleteNodesSitesEmptyTrashcan(nodesApi, trashcanApi, 'afterAll failed');
await categoriesApi.deleteCategory(responseCategoryId);
await tagsApi.deleteTag(responseTagsId);
Copy link
Contributor

Choose a reason for hiding this comment

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

responseTagsId may be null as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, please check if properly.

@datguychen datguychen force-pushed the ACS-8951-add-e2e-tests-tags-categories branch from 479a875 to 513528f Compare November 5, 2024 13:09
Copy link

sonarcloud bot commented Nov 5, 2024

@datguychen datguychen merged commit 62f38ee into develop Nov 6, 2024
25 checks passed
@datguychen datguychen deleted the ACS-8951-add-e2e-tests-tags-categories branch November 6, 2024 07:54
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.

5 participants