-
Notifications
You must be signed in to change notification settings - Fork 186
[POC][tests-only] e2e tests with Playwright only #12941
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
Open
Ashim-Stha
wants to merge
1
commit into
master
Choose a base branch
from
replaceCucumberWithPlaywright
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,10 @@ | ||
import { config } from '../../e2e/config.js' | ||
import { api } from '../../e2e/support' | ||
import { UsersEnvironment } from '../../e2e/support/environment' | ||
|
||
export async function setAccessAndRefreshToken(usersEnvironment: UsersEnvironment) { | ||
if (!config.basicAuth && !config.predefinedUsers) { | ||
let user = usersEnvironment.getUser({ key: config.adminUsername }) | ||
await api.token.setAccessAndRefreshToken(user) | ||
} | ||
} |
This file contains hidden or 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,46 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
// Look for test files in the "tests" directory, relative to this configuration file. | ||
testDir: 'specs', | ||
|
||
// Run all tests in parallel. | ||
fullyParallel: false, | ||
|
||
// Fail the build on CI if you accidentally left test.only in the source code. | ||
forbidOnly: !!process.env.CI, | ||
|
||
// Retry on CI only. | ||
retries: process.env.CI ? 1 : 0, | ||
|
||
// Opt out of parallel tests on CI. | ||
workers: process.env.CI ? 1 : undefined, | ||
|
||
// Reporter to use | ||
reporter: 'html', | ||
|
||
use: { | ||
ignoreHTTPSErrors: true, | ||
|
||
// Collect trace when retrying the failed test. | ||
trace: 'on-first-retry' | ||
Ashim-Stha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
// Configure projects for major browsers. | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] } | ||
}, | ||
{ | ||
name: 'firefox', | ||
use: { ...devices['Desktop Firefox'] } | ||
}, | ||
{ | ||
name: 'webkit', | ||
use: { ...devices['Desktop Safari'] } | ||
} | ||
] | ||
}) |
This file contains hidden or 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,88 @@ | ||
import { expect, test } from '@playwright/test' | ||
import { config } from '../../e2e/config.js' | ||
import { | ||
ActorsEnvironment, | ||
UsersEnvironment, | ||
LinksEnvironment, | ||
FilesEnvironment | ||
} from '../../e2e/support/environment' | ||
import { | ||
userHasBeenCreated, | ||
userHasCreatedFolder, | ||
userHasSharedResource, | ||
userHasCreatedPublicLinkOfResource | ||
} from '../steps/api/api' | ||
import { setAccessAndRefreshToken } from '../helpers/setAccessAndRefreshToken' | ||
import { openPublicLink } from '../steps/ui/public' | ||
import { navigateToSharedWithMePage, updateShareeRole } from '../steps/ui/shares' | ||
import { uploadResource, isAbleToEditFileOrFolder } from '../steps/ui/resources' | ||
import { LogInUser, LogOutUser } from '../steps/ui/session' | ||
|
||
test.describe('internal link share', () => { | ||
let actorsEnvironment | ||
const usersEnvironment = new UsersEnvironment() | ||
const linksEnvironment = new LinksEnvironment() | ||
const filesEnvironment = new FilesEnvironment() | ||
|
||
test.beforeEach(async ({ browser }) => { | ||
actorsEnvironment = new ActorsEnvironment({ | ||
context: { | ||
acceptDownloads: config.acceptDownloads, | ||
reportDir: config.reportDir, | ||
tracingReportDir: config.tracingReportDir, | ||
reportHar: config.reportHar, | ||
reportTracing: config.reportTracing, | ||
reportVideo: config.reportVideo, | ||
failOnUncaughtConsoleError: config.failOnUncaughtConsoleError | ||
}, | ||
browser: browser | ||
}) | ||
|
||
await setAccessAndRefreshToken(usersEnvironment) | ||
|
||
await userHasBeenCreated(usersEnvironment, 'Admin', 'Alice') | ||
await userHasBeenCreated(usersEnvironment, 'Admin', 'Brian') | ||
|
||
await LogInUser(usersEnvironment, actorsEnvironment, 'Alice') | ||
await LogInUser(usersEnvironment, actorsEnvironment, 'Brian') | ||
|
||
await userHasCreatedFolder(usersEnvironment, 'Alice', 'myfolder') | ||
|
||
await userHasSharedResource( | ||
usersEnvironment, | ||
'Alice', | ||
'myfolder', | ||
'Brian', | ||
'user', | ||
'Can edit', | ||
'folder' | ||
) | ||
|
||
await userHasCreatedPublicLinkOfResource( | ||
usersEnvironment, | ||
'Alice', | ||
'myfolder', | ||
'Invited people' | ||
) | ||
}) | ||
|
||
test('opening a link with internal role', async () => { | ||
await openPublicLink(actorsEnvironment, linksEnvironment, 'Brian', 'Unnamed link') | ||
await navigateToSharedWithMePage(actorsEnvironment, 'Brian') | ||
await uploadResource(actorsEnvironment, filesEnvironment, 'Brian', 'simple.pdf', 'myfolder') | ||
await updateShareeRole( | ||
usersEnvironment, | ||
actorsEnvironment, | ||
'Alice', | ||
'myfolder', | ||
'Brian', | ||
'user', | ||
'Can view', | ||
'folder' | ||
) | ||
await LogOutUser(actorsEnvironment, 'Alice') | ||
|
||
expect(await isAbleToEditFileOrFolder(actorsEnvironment, 'Brian', 'myfolder')).toBeFalsy() | ||
await LogOutUser(actorsEnvironment, 'Brian') | ||
}) | ||
}) |
This file contains hidden or 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,67 @@ | ||
import { config } from '../../../e2e/config.js' | ||
import { UsersEnvironment } from '../../../e2e/support/environment' | ||
import { api } from '../../../e2e/support' | ||
import { ResourceType } from '../../../e2e/support/api/share/share' | ||
|
||
export async function userHasBeenCreated( | ||
usersEnvironment: UsersEnvironment, | ||
stepUser: string, | ||
userToBeCreated: string | ||
): Promise<void> { | ||
const admin = usersEnvironment.getUser({ key: stepUser }) | ||
const user = usersEnvironment.getUser({ key: userToBeCreated }) | ||
// do not try to create users when using predefined users | ||
if (!config.predefinedUsers) { | ||
await api.provision.createUser({ user, admin }) | ||
} | ||
} | ||
|
||
export async function userHasCreatedFolder( | ||
usersEnvironment: UsersEnvironment, | ||
stepUser: string, | ||
folderName: string | ||
): Promise<void> { | ||
const user = usersEnvironment.getUser({ key: stepUser }) | ||
await api.dav.createFolderInsidePersonalSpace({ user, folder: folderName }) | ||
} | ||
|
||
export async function userHasSharedResource( | ||
usersEnvironment: UsersEnvironment, | ||
stepUser: string, | ||
resource: string, | ||
recipient: string, | ||
type: string, | ||
role: string, | ||
resourceType: ResourceType | ||
): Promise<void> { | ||
const user = usersEnvironment.getUser({ key: stepUser }) | ||
await api.share.createShare({ | ||
user, | ||
path: resource, | ||
shareType: type, | ||
shareWith: recipient, | ||
role: role, | ||
resourceType: resourceType as ResourceType | ||
}) | ||
} | ||
|
||
export async function userHasCreatedPublicLinkOfResource( | ||
usersEnvironment: UsersEnvironment, | ||
stepUser: string, | ||
resource: string, | ||
role: string, | ||
name?: string, | ||
password?: undefined, | ||
space?: 'Personal' | ||
) { | ||
const user = usersEnvironment.getUser({ key: stepUser }) | ||
|
||
await api.share.createLinkShare({ | ||
user, | ||
path: resource, | ||
password: password, | ||
name: name ? name : 'Unnamed link', | ||
role: role, | ||
spaceName: space | ||
}) | ||
} |
This file contains hidden or 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,18 @@ | ||
import { objects } from '../../../e2e/support' | ||
import { ActorsEnvironment, LinksEnvironment } from '../../../e2e/support/environment' | ||
|
||
export async function openPublicLink( | ||
actorsEnvironment: ActorsEnvironment, | ||
linksEnvironment: LinksEnvironment, | ||
stepUser: string, | ||
name: string | ||
): Promise<void> { | ||
const { page } = await actorsEnvironment.createActor({ | ||
key: stepUser, | ||
namespace: actorsEnvironment.generateNamespace(stepUser, stepUser) | ||
}) | ||
|
||
const { url } = linksEnvironment.getLink({ name }) | ||
const pageObject = new objects.applicationFiles.page.Public({ page }) | ||
await pageObject.open({ url }) | ||
} |
This file contains hidden or 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,32 @@ | ||
import { objects } from '../../../e2e/support' | ||
import { ActorsEnvironment, FilesEnvironment } from '../../../e2e/support/environment' | ||
|
||
export async function uploadResource( | ||
actorsEnvironment: ActorsEnvironment, | ||
filesEnvironment: FilesEnvironment, | ||
stepUser: string, | ||
resource: string, | ||
to: string, | ||
type?: string, | ||
option?: string | ||
): Promise<void> { | ||
const { page } = actorsEnvironment.getActor({ key: stepUser }) | ||
const resourceObject = new objects.applicationFiles.Resource({ page }) | ||
await resourceObject.upload({ | ||
to: to, | ||
resources: [filesEnvironment.getFile({ name: resource })], | ||
option: option, | ||
type: type | ||
}) | ||
} | ||
|
||
export async function isAbleToEditFileOrFolder( | ||
actorsEnvironment: ActorsEnvironment, | ||
stepUser: string, | ||
resource: string | ||
): Promise<boolean> { | ||
const { page } = actorsEnvironment.getActor({ key: stepUser }) | ||
const resourceObject = new objects.applicationFiles.Resource({ page }) | ||
const userCanEdit = await resourceObject.canManageResource({ resource }) | ||
return userCanEdit | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.