-
Notifications
You must be signed in to change notification settings - Fork 121
[e2e-tests] Add partial suite of tests for 'upload' feature specification #4929
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ac5e036
Remove redundant spec
jonathonherbert f6b1db7
Tag unimplemented upload scenarios @todo and skip them
jonathonherbert 6520661
Implement the runnable upload e2e scenarios
jonathonherbert 7b371f0
Restore the uploads-in-progress leave warning scenario
jonathonherbert 8b5af0b
Show the upload prompt's example label when no labels are applied
jonathonherbert 1eda379
Minor scenario changes to accommodate testing requirements
jonathonherbert f361d4f
Adapt tests to feature changes
jonathonherbert e1dd82d
Move comments out of todo directives
jonathonherbert e94a877
Move uploads steps to own folder
jonathonherbert 208587b
Add detail to metadata w/o edito permission scenario
jonathonherbert fb208b2
Colocate variable definitions with usage, and use lower camel case
jonathonherbert 7aa175c
Shorter comments
jonathonherbert 67f7d42
Remove the prompt test and changes, which can be another PR
jonathonherbert 606337c
Use list reporter to view timings in CI
jonathonherbert 26c803b
Potential fix for pull request finding
jonathonherbert 7617a06
Add assertion that the current uploads UI is not visible if no upload…
jonathonherbert 4c3c1cc
Test for specific user in query params
jonathonherbert acaaad6
Always start caddy, which is necessary for Playwright to run tests lo…
jonathonherbert 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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 { Given, KAHUNA_APP_URL, expect } from './fixtures.ts'; | ||
|
|
||
| Given('the application stack is running', async ({ request }) => { | ||
| const response = await request.get('/management/healthcheck'); | ||
| expect(response.ok()).toBeTruthy(); | ||
| }); | ||
|
|
||
| Given('I have opened the image upload page', async ({ page, testContext }) => { | ||
| // An unhandled dialog blocks the page, so record every one and answer it. Dismissing a | ||
| // confirm answers "no", which keeps us on the page under test. | ||
| page.on('dialog', (dialog) => { | ||
| testContext.dialogs.push(dialog.message()); | ||
| void dialog.dismiss(); | ||
| }); | ||
|
|
||
| // Accept the default of blurring graphic images up front. Kahuna otherwise shows a | ||
| // first-run explainer overlay that covers the top bar (see services/graphic-image-blur.js). | ||
| await page.context().addCookies([ | ||
| { | ||
| name: 'SHOULD_BLUR_GRAPHIC_IMAGES', | ||
| value: 'true', | ||
| domain: `.${new URL(KAHUNA_APP_URL).hostname}`, | ||
| path: '/', | ||
| }, | ||
| ]); | ||
|
|
||
| // Arrive from search rather than deep-linking, so the upload page has a same-document | ||
| // history entry behind it and back-navigation behaves as it does for a real user. | ||
| await page.goto(KAHUNA_APP_URL); | ||
| await page.getByRole('banner').getByRole('link', { name: 'My recent uploads' }).click(); | ||
| await page.waitForURL('**/upload'); | ||
| }); |
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 was deleted.
Oops, something went wrong.
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,52 @@ | ||
| import { statSync } from 'node:fs'; | ||
| import * as path from 'node:path'; | ||
| import type { Page } from '@playwright/test'; | ||
|
|
||
| declare global { | ||
| interface Window { | ||
| _clientConfig: { | ||
| systemName: string; | ||
| maybeUploadLimitInBytes: number; | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| const FIXTURE_IMAGES = path.join(import.meta.dirname, '..', '..', 'fixtures', 'images'); | ||
|
|
||
| export interface TestImage { | ||
| fileName: string; | ||
| path: string; | ||
| bytes: number; | ||
| } | ||
|
|
||
| const testImage = (fileName: string): TestImage => { | ||
| const filePath = path.join(FIXTURE_IMAGES, fileName); | ||
| return { fileName, path: filePath, bytes: statSync(filePath).size }; | ||
| }; | ||
|
|
||
| /** Sizes are read from disk so the size-limit scenario can pick a threshold between them. */ | ||
| export const testImages = { | ||
| smaller: testImage('test-card-f.jpg'), | ||
| larger: testImage('test.jpg'), | ||
| }; | ||
|
|
||
| export const uploadPage = (page: Page) => { | ||
| const prompt = page.getByRole('region', { name: 'File upload' }); | ||
|
|
||
| return { | ||
| prompt, | ||
| main: page.getByRole('main', { name: 'Image uploads' }), | ||
| currentUploads: page.getByRole('region', { name: 'Your current uploads' }), | ||
| pastUploads: page.getByRole('region', { name: 'Your past 50 uploads' }), | ||
| dragAndDropUploader: page.getByRole('region', { name: 'Drag and drop uploader' }), | ||
| fileInput: prompt.locator('input[name="files"]'), | ||
| /* The upload and back-to-search controls carry aria-labels that override their visible | ||
| text, so filter on the text the feature file names rather than the accessible name. */ | ||
| uploadButton: (label: string) => prompt.getByRole('button').filter({ hasText: label }), | ||
| topBarLink: (label: string) => page.getByRole('banner').getByRole('link').filter({ hasText: label }), | ||
| /** Any control that takes you off the upload page, wherever it sits on it. */ | ||
| leaveLink: (label: string) => page.getByRole('link').filter({ hasText: label }), | ||
| /** A queued or in-flight upload, before it becomes an editable image. */ | ||
| job: (fileName: string) => page.getByRole('region', { name: `${fileName} upload` }), | ||
| }; | ||
| }; | ||
Oops, something went wrong.
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.
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.
Perhaps this could come from the application definition 🤔