-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb23a98
commit 5df9f2d
Showing
8 changed files
with
87 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ Feature: federation management | |
|
||
Scenario: user create federated share | ||
Given using "LOCAL" server | ||
Given "Admin" creates following user using API | ||
And "Admin" creates following user using API | ||
| id | | ||
| Alice | | ||
And "Alice" creates the following files into personal space using API | ||
|
@@ -19,11 +19,12 @@ Feature: federation management | |
| Brian | | ||
And "Brian" logs in | ||
And "Brian" opens the "open-cloud-mesh" app | ||
When "Brian" accept federation share invitation | ||
When "Brian" accepts federated share invitation by "Alice" | ||
# Then "Brian" should see the following federated connections: | ||
# | connections | | ||
# | user | email | institution | | ||
# | Alice | [email protected] | ocis:9200 | | ||
# And "Alice" shares the following resource using the sidebar panel | ||
# | resource | recipient | type | role | resourceType | share-type | | ||
# | test.odt | Carol | user | Can view | file | external | | ||
# | resource | recipient | type | role | resourceType | userType | | ||
# | test.odt | Brian | user | Can view | file | external | | ||
And "Brian" logs out | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,73 @@ | ||
import { expect, Page } from '@playwright/test' | ||
import { federatedInvitationCode } from '../../store' | ||
|
||
const generateInvitationButton = | ||
'//button[contains(@aria-label,"Generate invitation link that can be shared with one or more invitees")]' | ||
const descriptionInput = '#invite_token_description' | ||
const emailInput = '#invite_token_recipient' | ||
const generateInvitationActionConfirmButton = '.oc-modal-body-actions-confirm' | ||
const emptyInvitationToken = '#invite-tokens-empty' | ||
const acceptFederatedInvitation = '//input[starts-with(@id, "oc-textinput-")]' | ||
const institutionOptionDropdown = '.vs__open-indicator' | ||
|
||
export const generateInvitation = async (args: { page: Page }): Promise<void> => { | ||
const { page } = args | ||
export const generateInvitation = async (args: { page: Page; user: string }): Promise<void> => { | ||
const { page, user } = args | ||
await page.locator(generateInvitationButton).click() | ||
await page.locator(descriptionInput).fill('hello') | ||
await page.locator(emailInput).fill('[email protected]') | ||
await page.locator(generateInvitationActionConfirmButton).click() | ||
let inviteCode = '' | ||
await Promise.all([ | ||
page.waitForResponse(async (resp) => { | ||
if ( | ||
resp.url().endsWith('generate-invite') && | ||
resp.status() === 200 && | ||
resp.request().method() === 'POST' | ||
) { | ||
const responseBody = await resp.json() | ||
inviteCode = responseBody.token | ||
return true | ||
} | ||
return false | ||
}), | ||
page.locator(generateInvitationActionConfirmButton).click() | ||
]) | ||
await expect(page.locator(emptyInvitationToken)).not.toBeVisible() | ||
federatedInvitationCode.set(user, { code: inviteCode }) | ||
console.log(federatedInvitationCode) | ||
} | ||
|
||
export const acceptInvitation = async (args: { page: Page }): Promise<void> => { | ||
const { page } = args | ||
// todo: store federation invitation token and use that token | ||
// await page.locator(generateInvitationButton).click() | ||
// await page.locator(descriptionInput).fill('hello') | ||
// await page.locator(emailInput).fill('[email protected]') | ||
// await page.locator(generateInvitationActionConfirmButton).click() | ||
// await expect(page.locator(emptyInvitationToken)).not.toBeVisible() | ||
export const acceptInvitation = async (args: { page: Page; user: string }): Promise<Response> => { | ||
const { page, user } = args | ||
const invitation = federatedInvitationCode.get(user) | ||
await page.locator(acceptFederatedInvitation).fill(invitation.code) | ||
await page.locator(institutionOptionDropdown).click() | ||
await page.getByRole('option', { name: 'first-ocis-instance ocis-server:' }).click() | ||
await Promise.all([ | ||
page.waitForResponse( | ||
(resp) => | ||
resp.url().endsWith('accept-invite') && | ||
resp.status() === 200 && | ||
resp.request().method() === 'POST' | ||
), | ||
// async (resp) => { | ||
// if ( | ||
// resp.url().endsWith('find-accepted-users') && | ||
// resp.status() === 200 && | ||
// resp.request().method() === 'GET' | ||
// ) { | ||
// // Extract and store the API response value | ||
// return await resp.json() | ||
// } | ||
// return false | ||
// }, | ||
page.locator('button:has(span:has-text("Accept invitation"))').click() | ||
]) | ||
} | ||
|
||
// export const isConnectionVisible = async (args: { | ||
// page: Page | ||
// connectionInfo: Response | ||
// }): Promise<void> => { | ||
// const { page, connectionInfo } = args | ||
// } | ||
// first-ocis-instance ocis-server:9200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { FederatedShareInvitation } from '../types' | ||
|
||
export const federatedInvitationCode = new Map<string, FederatedShareInvitation>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters