-
Notifications
You must be signed in to change notification settings - Fork 149
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-6456] Migrated Share File e2es to Playwright #3565
Conversation
projects/aca-playwright-shared/src/page-objects/components/dialogs/share-dialog.component.ts
Outdated
Show resolved
Hide resolved
projects/aca-playwright-shared/src/page-objects/components/dialogs/share-dialog.component.ts
Outdated
Show resolved
Hide resolved
test.describe('when logged in', () => { | ||
const expiryDateObj: Date = new Date(); | ||
expiryDateObj.setFullYear(expiryDateObj.getFullYear() + 1); | ||
const expiryDate: any = expiryDateObj.toISOString().replace('Z', '+0000'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use any
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removing 'any' here is giving a red line error on expiryDate here
await shareApi.shareFilesByIds([file6Id, file7Id], expiryDate);
because shareFileByIds() and other nested methods expect expireDate to be of type 'Date'. But strangely, the shareFilesByIds() method works only if the expireDate is of type 'string', otherwise the tests don't work as expected.
Due to this strange behavior, having 'any' helps but if I remove 'any', I will have to modify the data type of expireDate from 'Date' to 'string' at multiple places and in JS-API which will need upstream.
I have tried multiple ways to make expiryDate an object of type 'Date' so that no changes are required on the API level but that does not seem to work
What do you suggest here? Should we go ahead with 'any'? or can we use some other approach here? @MichalKinas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you need to pass a Date
there you can use expiryDateObj
object, expiryDate
should be a string and using any
here is incorrect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried using expiryDateObj but this does not help as 'shareFilesByIds()' is working properly only with expiryDate as string.
If we remove any, we get an error because 'shareFilesByIds()' expects a Date but is somehow working only with string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can try creating new date from expiryDate
but if it won't work it means that your code is not correct somewhere, any
is anti-pattern and it should be used only in specific cases and this is not one of them. any
shouldn't be used to fix an error or not working code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I understand what you are saying but the problem I am facing in doing so is that
-
the API actually expects 'expiryDate' to be of type string. (see sharedLinkBodyCreate https://api-explorer.alfresco.com/api-explorer/?urls.primaryName=Core%20API#/shared-links/createSharedLink)
-
But, in the code, the expected type of 'expiryDate' is set to Date in JS API and all related methods like 'shareNodes()' or 'shareFileByIds()'
So even if I create new date from 'expiryDate' , the API will still not run as expected.
So far, this approach (using 'any') was being used in Protractor e2es so if we remove 'any', we either get some red line errors but the tests run fine
OR
we might need to make changes in JS API which I am not sure is feasible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case you still don't have to use any
, you can declare expiryDate
as let expiryDate: Date | string = ...
and then pass it to the correct function like expiryDate as Date
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing expiryDate as Date does not help because this.apiService.share.createSharedLink(data);
fails if expiry is of type 'Date' and gives status code 400.
It gives 200 only with type string (as per swagger https://api-explorer.alfresco.com/api-explorer/?urls.primaryName=Core%20API#/shared-links/createSharedLink)
and I am blocked because I cannot set the type of expiryDate to string.
@DenysVuika, Michal suggested double-checking with you if we should make changes for this in JS-API for e2es.
Can you please suggest what would be the feasible solution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MichalKinas, as per my discussion with @DenysVuika, we can use 'any' for now and have a separate ticket to fix typings in JS-API.
I have created this JIRA https://alfresco.atlassian.net/browse/ACS-6533 for the same.
...a-playwright-shared/src/page-objects/components/datetime-picker/datetime-picker.component.ts
Outdated
Show resolved
Hide resolved
projects/aca-playwright-shared/src/page-objects/components/dialogs/share-dialog.component.ts
Outdated
Show resolved
Hide resolved
234faa8
to
8b6f822
Compare
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x")
What is the current behaviour? (You can also link to an open issue here)
Protractor is deprecated and e2es for 'share-file.test.ts' are written in Protractor.
What is the new behaviour?
Migrated the Protractor test cases into Playwright for 'share-file.test.ts' file.
Does this PR introduce a breaking change? (check one with "x")
If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...
Other information:
https://alfresco.atlassian.net/browse/ACS-6456