Skip to content

[e2e-tests] Add partial suite of tests for 'upload' feature specification - #4929

Merged
jonathonherbert merged 18 commits into
mainfrom
jsh/add-upload-tests
Sep 16, 2026
Merged

jonathonherbert merged 18 commits into
mainfrom
jsh/add-upload-tests

Conversation

@jonathonherbert

@jonathonherbert jonathonherbert commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

co-authored-by: @claude (Opus 5) — words are mine.

What does this change?

Adds the first batch of end-to-end tests for the upload feature specified in #4900. The specs included are:

 An authorised user sees the upload tools 
 Returning to search from the upload page 
 The current uploads section only appears while an upload is running 
 Viewing all of my uploads 
 The prompt explains how to upload 
 Opening the file picker from the Upload button 
 Selecting files queues them for upload 
 Files above the size limit are skipped with a warning 

Notes

I felt that breaking the suite into chunks would make it easier to review, and there are also some changes to make to ensure later parts of the spec pass, including provisioning users in cookies for permissions, and fixing bugs, which are probably best done in specific PRs.

Nevertheless, this is a marker for the general approach, and gives us an idea of how the suite might perform as it grows to encompass the application generally. At the moment these tests are run serially, as some of them perform writes and we will run into concurrency issues running them in parallel. It may be useful to split the suite as it grows to permit parallel execution — the operation mode can only be set at the feature level (docs).

Encouragingly, the extra scaffolding in setup.ts seems fairly thin, and the approach seems sensible to me, but comments on how this looks from others with adjacent experience (@dominickendrick @waisingyiu) would be much appreciated, if only from the point of view of standardising across projects.

Who should look at this?

Tested? Documented?

  • locally by committer
  • in CI
  • locally by Guardian reviewer
  • on the Guardian's TEST environment
  • relevant documentation added or amended (if needed)

@jonathonherbert
jonathonherbert requested a review from a team as a code owner September 10, 2026 12:35
@jonathonherbert
jonathonherbert marked this pull request as draft September 10, 2026 12:35
@jonathonherbert jonathonherbert changed the title Jsh/add upload tests Add partial suite of tests for 'upload' feature specification Sep 10, 2026
@jonathonherbert jonathonherbert added the feature Departmental tracking: work on a new feature label Sep 10, 2026
@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown

@jonathonherbert
jonathonherbert force-pushed the jsh/add-upload-tests branch 2 times, most recently from 781a8bc to da74f89 Compare September 11, 2026 08:11
@jonathonherbert jonathonherbert changed the title Add partial suite of tests for 'upload' feature specification [e2e-tests] Add partial suite of tests for 'upload' feature specification Sep 11, 2026
import type { Page } from '@playwright/test';

declare global {
interface Window {

Copy link
Copy Markdown
Contributor Author

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 🤔

Comment thread e2e-tests/features/upload.feature Outdated

@todo
Scenario: Metadata editing is disabled without edit permission
Given I am not permitted to edit the image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On an Upload page, this situation can only occur if user without edit_metadata permission uploads an image previously uploaded by someone else. Everyone is allowed to edit metadata for any images genuinely uploaded by them, even if they have no edit_metadata permission to edit uploads made by other users.

No idea how useful is it to review those scenarios. But somehow it’s very, very, cool to be reading them!

@jonathonherbert jonathonherbert Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good shout, I've updated the description to look like Given I am not permitted to edit the image, as it has been uploaded by another user and I do not have edit_metadata permission in 208587b

@jonathonherbert
jonathonherbert force-pushed the jsh/add-upload-features branch 2 times, most recently from e4e2f39 to 465256b Compare September 11, 2026 12:56
jonathonherbert added a commit that referenced this pull request Sep 11, 2026
jonathonherbert added a commit that referenced this pull request Sep 14, 2026
jonathonherbert added a commit that referenced this pull request Sep 14, 2026
@jonathonherbert
jonathonherbert force-pushed the jsh/add-upload-features branch 2 times, most recently from cb6b403 to f11c22f Compare September 15, 2026 09:15
The upload feature file specifies far more than we are wiring up in the first
pass. Tag everything we are not implementing yet with @todo and exclude those
tags from bddgen, so its "undefined step" errors stay meaningful for the
scenarios we do implement.

Gherkin tags cannot contain whitespace, so the pre-existing @todo annotations
were failing to parse; their notes move to comments.

Uploads mutate the single shared e2e user's upload history, so the feature runs
@mode:serial.
Wires up the upload page shell, prompt and select-files scenarios against the
real stack: eight scenarios covering the upload tools rendering, navigation to
search and to a filtered search, the current-uploads section, the prompt copy,
the file picker, queueing selected files, and the upload size limit.

Locators live in one place (steps/support/upload-page.ts) and prefer roles and
accessible names. `<dnd-uploader>` gains a region role so "the drag-and-drop
uploader should be active" has a hook.

Two things needed handling to make the page testable at all:

  * Kahuna's first-run graphic-image blur explainer covers the top bar, so the
    background accepts the default via its cookie.
  * An upload reaches a terminal state within about a second, so the scenario
    that needs one in flight holds the transfer to the ingest bucket open.

Two more scenarios are tagged @todo because the app cannot currently satisfy
them, with the reason recorded against each: the "uploads in progress" leave
confirmation never fires (ui-router destroys the controller scope before
$locationChangeStart), and the prompt's example label is guarded by a `ctrl`
that does not exist in filePrompt's isolated scope.
The warning does fire, but only for history navigations. On a ui-sref click
ui-router destroys the UploadCtrl scope before broadcasting
$locationChangeStart, so the listener registered on that scope never runs;
pressing back reaches it. The step now goes back rather than clicking the top
bar link.

For back to have somewhere to return to within the same document, the
background arrives at the upload page from search the way a user does, instead
of deep-linking to /upload.
prompt.html guarded the hint with `ctrl.presetLabels` and `ctrl.active`, neither
of which filePrompt provided. That name was not simply unset: the nested
<file-uploader> has no scope of its own, so its `controllerAs: 'ctrl'` publishes
FileUploaderCtrl onto the prompt's scope, and the guard read properties off that.

Expose the check on the prompt's own scope instead, sourced from
presetLabelService so it follows labels being added and removed in
gr-preset-labels' isolated scope.

The `!active` part of the guard is dropped: while the add-label form is open its
input already shows the same example as a placeholder.
@gu-prout

gu-prout Bot commented Sep 16, 2026

Copy link
Copy Markdown

Seen on auth, usage, image-loader, metadata-editor, thrall, leases, media-api, kahuna (merged by @jonathonherbert 10 minutes and 6 seconds ago) Please check your changes!

@gu-prout

gu-prout Bot commented Sep 16, 2026

Copy link
Copy Markdown

Seen on cropper (merged by @jonathonherbert 10 minutes and 41 seconds ago) Please check your changes!

@gu-prout

gu-prout Bot commented Sep 16, 2026

Copy link
Copy Markdown

Seen on collections (merged by @jonathonherbert 10 minutes and 41 seconds ago) Please check your changes!

@gu-prout

gu-prout Bot commented Sep 16, 2026

Copy link
Copy Markdown

Seen on collections, cropper (merged by @jonathonherbert 10 minutes and 41 seconds ago) Please check your changes!

@gu-prout

gu-prout Bot commented Sep 16, 2026

Copy link
Copy Markdown

Seen on collections (merged by @jonathonherbert 10 minutes and 41 seconds ago) Please check your changes!

@gu-prout

gu-prout Bot commented Sep 16, 2026

Copy link
Copy Markdown

Seen on collections, cropper (merged by @jonathonherbert 10 minutes and 44 seconds ago) Please check your changes!

1 similar comment
@gu-prout

gu-prout Bot commented Sep 16, 2026

Copy link
Copy Markdown

Seen on collections, cropper (merged by @jonathonherbert 10 minutes and 44 seconds ago) Please check your changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants