Skip to content

Commit

Permalink
[test-only] e2e test. set expiration date to share (#10292)
Browse files Browse the repository at this point in the history
* set expiration date to share

* fix after review
  • Loading branch information
ScharfViktor authored Jan 5, 2024
1 parent a5750d3 commit b45047b
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 94 deletions.
2 changes: 0 additions & 2 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ config = {
"webUISharingInternalUsers",
"webUISharingInternalUsersBlacklisted",
"webUISharingInternalUsersCollaborator",
"webUISharingExpirationDate",
],
"oCISSharingInternal3": [
"webUISharingInternalGroupsSharingIndicator",
Expand Down Expand Up @@ -221,7 +220,6 @@ basicTestSuites = [
"webUIResharing2",
"webUISharingAcceptShares",
"webUISharingAutocompletion",
"webUISharingExpirationDate",
"webUISharingFilePermissionMultipleUsers",
"webUISharingFilePermissionsGroups",
"webUISharingFolderAdvancedPermissionMultipleUsers",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ Other free text and markdown formatting can be used elsewhere in the document if
### [Share additional info](https://github.com/owncloud/ocis/issues/1253)
- [webUISharingInternalUsersShareWithPage/shareWithUsers.feature:126](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUISharingInternalUsersShareWithPage/shareWithUsers.feature#L126)

### [Expiration date set is not implemented in user share](https://github.com/owncloud/ocis/issues/1250)
- [webUISharingInternalGroups/shareWithGroups.feature:228](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUISharingInternalGroups/shareWithGroups.feature#L228)

### [Different path for shares inside folder](https://github.com/owncloud/ocis/issues/1231)

### [Implement expiration date for shares](https://github.com/owncloud/ocis/issues/1250)
- [webUISharingInternalGroups/shareWithGroups.feature:208](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUISharingInternalGroups/shareWithGroups.feature#L208)
- [webUISharingExpirationDate/shareWithExpirationDate.feature:21](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUISharingExpirationDate/shareWithExpirationDate.feature#L21)

### [Listing shares via ocs API does not show path for parent folders](https://github.com/owncloud/ocis/issues/1231)
- [webUISharingPublicManagement/shareByPublicLink.feature:110](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUISharingPublicManagement/shareByPublicLink.feature#L111)

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -203,55 +203,3 @@ Feature: Sharing files and folders with internal groups
Then the following resources should have the following collaborators
| fileName | expectedCollaborators |
| simple-folder | Brian Murphy, grp1 |

@issue-ocis-1250
Scenario: change existing expiration date of an existing share with another internal group
Given user "Carol" has created file "lorem.txt" in the server
And user "Carol" has created a new share with following settings in the server
| path | lorem.txt |
| shareTypeString | group |
| shareWith | grp1 |
| expireDate | +14 |
And user "Carol" has logged in using the webUI
When the user edits the collaborator expiry date of "grp1" of file "lorem.txt" to "+7" days using the webUI
Then user "Alice" should have received a share with target "Shares/lorem.txt" and expiration date in 7 days in the server
And user "Brian" should have received a share with target "Shares/lorem.txt" and expiration date in 7 days in the server
And user "Carol" should have a share with these details in the server:
| field | value |
| path | /lorem.txt |
| share_type | group |
| uid_owner | Carol |
| share_with | grp1 |
| expiration | +7 |

@issue-ocis-1317 @issue-ocis-1250
Scenario: share a resource with another internal group with default expiration date
Given the setting "shareapi_default_expire_date_group_share" of app "core" has been set to "yes" in the server
And the setting "shareapi_expire_after_n_days_group_share" of app "core" has been set to "42" in the server
And user "Carol" has created file "lorem.txt" in the server
And user "Carol" has logged in using the webUI
When the user shares folder "lorem.txt" with group "grp1" as "Viewer" using the webUI
Then user "Carol" should have a share with these details in the server:
| field | value |
| path | /lorem.txt |
| share_type | group |
| uid_owner | Carol |
| share_with | grp1 |
| expiration | +42 |
And user "Alice" should have received a share with target "Shares/lorem.txt" and expiration date in 42 days in the server
And user "Brian" should have received a share with target "Shares/lorem.txt" and expiration date in 42 days in the server

@issue-ocis-1250
Scenario Outline: share a resource with another internal group with expiration date beyond maximum enforced expiration date
Given the setting "shareapi_default_expire_date_group_share" of app "core" has been set to "yes" in the server
And the setting "shareapi_enforce_expire_date_group_share" of app "core" has been set to "yes" in the server
And the setting "shareapi_expire_after_n_days_group_share" of app "core" has been set to "5" in the server
And user "Carol" has created file "lorem.txt" in the server
And user "Carol" has created folder "simple-folder" in the server
And user "Carol" has logged in using the webUI
When the user tries to share resource "<shared-resource>" with group "grp1" which expires in "+6" days using the webUI
Then user "Alice" should not have created any shares in the server
Examples:
| shared-resource |
| lorem.txt |
| simple-folder |
8 changes: 5 additions & 3 deletions tests/e2e/cucumber/features/smoke/reshare.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ Feature: reshare
And "Alice" shares the following resource using API
| resource | recipient | type | role |
| folder_to_shared | Brian | user | Can edit |

And "Brian" logs in
And "Brian" opens the "files" app
And "Brian" navigates to the shared with me page

# re-share with expiration date
And "Brian" reshares the following resource
| resource | recipient | type | role | resourceType |
| folder_to_shared | sales | group | Can view | folder |
| resource | recipient | type | role | resourceType | expirationDate |
| folder_to_shared | sales | group | Can view | folder | +5 days |

And "Carol" logs in
And "Carol" opens the "files" app
Expand Down
38 changes: 37 additions & 1 deletion tests/e2e/cucumber/features/smoke/share.feature
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Feature: share
| testavatar.jpeg | Brian | user | Can view | file |
| simple.pdf | Brian | user | custom_permissions:read,update,share | file |
| sharedFile.txt | Brian | user | Can edit | file |

And "Brian" opens the "files" app
And "Brian" navigates to the shared with me page
Then "Brian" should not see a sync status for the file "shareToBrian.txt"
Expand Down Expand Up @@ -133,3 +133,39 @@ Feature: share
| shareToBrian.txt | Alice Hansen |
| shareToBrian.md | Alice Hansen |
And "Brian" logs out


Scenario: share with expiration date
Given "Admin" creates following group using API
| id |
| sales |
And "Admin" adds user to the group using API
| user | group |
| Brian | sales |
And "Alice" logs in
And "Alice" creates the following folder in personal space using API
| name |
| myfolder |
| mainFolder |
And "Alice" creates the following files into personal space using API
| pathToFile | content |
| new.txt | some content |
And "Alice" opens the "files" app
When "Alice" shares the following resource using the sidebar panel
| resource | recipient | type | role | resourceType | expirationDate |
| new.txt | Brian | user | Can edit | file | +5 days |
| myfolder | sales | group | Can view | folder | +10 days |
| mainFolder | Brian | user | Can edit | folder | |

# set expirationDate to existing share
And "Alice" sets the expiration date of share "mainFolder" of user "Brian" to "+5 days"
And "Alice" sets the expiration date of share "myfolder" of group "sales" to "+3 days"
And "Alice" logs out

And "Brian" navigates to the shared with me page
And "Brian" accepts the following share
| name |
| new.txt |
| myfolder |
| mainFolder |
And "Brian" logs out
31 changes: 29 additions & 2 deletions tests/e2e/cucumber/steps/ui/shares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ICollaborator } from '../../../support/objects/app-files/share/collabor

const parseShareTable = function (stepTable: DataTable, usersEnvironment) {
return stepTable.hashes().reduce((acc, stepRow) => {
const { resource, recipient, type, role, resourceType } = stepRow
const { resource, recipient, type, role, resourceType, expirationDate } = stepRow

if (!acc[resource]) {
acc[resource] = []
Expand All @@ -19,7 +19,8 @@ const parseShareTable = function (stepTable: DataTable, usersEnvironment) {
: usersEnvironment.getUser({ key: recipient }),
role,
type,
resourceType
resourceType,
expirationDate
})

return acc
Expand Down Expand Up @@ -279,3 +280,29 @@ When(
}
}
)

When(
/^"([^"]*)" sets the expiration date of share "([^"]*)" of (group|user) "([^"]*)" to "([^"]*)"?$/,
async function (
this: World,
stepUser: string,
resource: string,
collaboratorType: 'user' | 'group',
collaboratorName: string,
expirationDate: string
): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const shareObject = new objects.applicationFiles.Share({ page })
await shareObject.addExpirationDate({
resource,
collaborator: {
collaborator:
collaboratorType === 'group'
? this.usersEnvironment.getGroup({ key: collaboratorName })
: this.usersEnvironment.getUser({ key: collaboratorName }),
type: collaboratorType
} as ICollaborator,
expirationDate
})
}
)
28 changes: 27 additions & 1 deletion tests/e2e/support/objects/app-files/share/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ const pendingShareItem =
'//div[@id="files-shared-with-me-pending-section"]//tr[contains(@class,"oc-tbody-tr")]'
const passwordInput = '.oc-modal-body input.oc-text-input'
const createLinkButton = '.oc-modal-body-actions-confirm'
const showMoreOptionsButton = '#show-more-share-options-btn'
const calendarDatePickerId = 'recipient-datepicker-btn'

export interface ShareArgs {
page: Page
resource: string
recipients: ICollaborator[]
expirationDate?: string
}

export const openSharingPanel = async function (
Expand Down Expand Up @@ -67,9 +70,14 @@ export const createShare = async (args: createShareArgs): Promise<void> => {
if (via !== 'URL_NAVIGATION') {
await openSharingPanel(page, resource, via)
}
const expirationDate = recipients[0].expirationDate

if (expirationDate) {
await page.locator(showMoreOptionsButton).click()
await page.getByTestId(calendarDatePickerId).click()
await Collaborator.setExpirationDate(page, expirationDate)
}
await Collaborator.inviteCollaborators({ page, collaborators: recipients })

await sidebar.close({ page })
}

Expand Down Expand Up @@ -249,3 +257,21 @@ export const setDenyShare = async (args: setDenyShareArgs): Promise<void> => {
await openSharingPanel(page, resource)
await Collaborator.setDenyShareForCollaborator({ page, deny, collaborator })
}

export const addExpirationDate = async (args: {
page: Page
resource: string
collaborator: Omit<ICollaborator, 'role'>
expirationDate: string
}): Promise<void> => {
const { page, resource, collaborator, expirationDate } = args
await openSharingPanel(page, resource)

await Promise.all([
page.waitForResponse(
(resp) =>
resp.url().includes('shares') && resp.status() === 200 && resp.request().method() === 'PUT'
),
Collaborator.setExpirationDateForCollaborator({ page, collaborator, expirationDate })
])
}
5 changes: 5 additions & 0 deletions tests/e2e/support/objects/app-files/share/collaborator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface ICollaborator {
role?: string
type?: CollaboratorType
resourceType?: string
expirationDate?: string
}

export interface InviteCollaboratorsArgs {
Expand Down Expand Up @@ -311,6 +312,10 @@ export default class Collaborator {
.locator(util.format(Collaborator.setExpirationDateCollaboratorButton, collaboratorRow))
.click()

await Collaborator.setExpirationDate(page, expirationDate)
}

static async setExpirationDate(page: Page, expirationDate: any): Promise<void> {
const newExpiryDate = getActualExpiryDate(
expirationDate.toLowerCase().match(/[dayrmonthwek]+/)[0],
expirationDate
Expand Down
15 changes: 15 additions & 0 deletions tests/e2e/support/objects/app-files/share/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Page } from '@playwright/test'
import * as po from './actions'
import { resourceIsNotOpenable, isAcceptedSharePresent, resourceIsSynced } from './utils'
import { createLinkArgs } from '../link/actions'
import { ICollaborator } from './collaborator'
export class Share {
#page: Page

Expand Down Expand Up @@ -71,4 +72,18 @@ export class Share {
await po.setDenyShare({ ...args, page: this.#page })
await this.#page.goto(startUrl)
}

async addExpirationDate({
resource,
collaborator,
expirationDate
}: {
resource: string
collaborator: Omit<ICollaborator, 'role'>
expirationDate: string
}): Promise<void> {
const startUrl = this.#page.url()
await po.addExpirationDate({ resource, collaborator, expirationDate, page: this.#page })
await this.#page.goto(startUrl)
}
}

0 comments on commit b45047b

Please sign in to comment.