-
Notifications
You must be signed in to change notification settings - Fork 154
feat: add Cypress e2e tests for dashboard push actions #1403
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
fabiovincenzi
wants to merge
30
commits into
finos:main
Choose a base branch
from
fabiovincenzi:feat/e2e-dashboard-tests
base: main
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
Show all changes
30 commits
Select commit
Hold shift + click to select a range
2d86cce
fix: forward disabled prop to MUI Button in CustomButton component
fabiovincenzi 3b91f8c
feat: add data-testid attributes to push detail actions
fabiovincenzi 01a7881
feat: add e2e tests for dashboard push approve, reject and cancel
fabiovincenzi 1a4bf35
ci: add Cypress e2e tests to CI workflow
fabiovincenzi 84a0046
fix: improve Cypress commands reliability for CI/Docker environment
fabiovincenzi 39ae5b2
fix: use absolute URLs for Cypress API calls and handle CSRF gracefully
fabiovincenzi 1234085
fix: ensure test config is loaded in Docker and disable CSRF for e2e
fabiovincenzi fc074b5
chore(ci): add debug logging for git-proxy config in e2e workflow
fabiovincenzi 472ff54
Merge branch 'main' into feat/e2e-dashboard-tests
fabiovincenzi 6250d6a
fix: bake test config into Docker image and add config diagnostics
fabiovincenzi b38a4de
Merge branch 'feat/e2e-dashboard-tests' of https://github.com/fabiovi…
fabiovincenzi e5d3e82
fix: bake test config into Docker image and add pre-Cypress diagnostics
fabiovincenzi 80ca649
fix: move all Cypress tests to e2e.yml
fabiovincenzi 382dec0
fix: separate local and Docker Cypress tests, restore ci.yml Cypress …
fabiovincenzi e0f5c43
fix: improve Cypress command reliability and test pattern
fabiovincenzi ec80ad8
fix: use --config to override specPattern for Docker Cypress tests
fabiovincenzi 44bb506
fix: replace clearAllSavedSessions with clearCookies in cy.logout
fabiovincenzi 39372ea
fix: raise rateLimit to 1000 in e2e test config
fabiovincenzi e36872a
Merge branch 'main' into feat/e2e-dashboard-tests
fabiovincenzi 3fc1ab3
fix: hide git credentials from Cypress logs and cap e2e timeout
fabiovincenzi 2a993e7
Merge branch 'main' of https://github.com/finos/git-proxy into feat/e…
fabiovincenzi a1bab38
Merge branch 'feat/e2e-dashboard-tests' of https://github.com/fabiovi…
fabiovincenzi 14ce0b6
Merge branch 'main' into feat/e2e-dashboard-tests
fabiovincenzi 5445793
chore: merge upstream main
fabiovincenzi 2949e9e
test(e2e): add repo cleanup commands and fix delete using _id
fabiovincenzi 95d2a8d
fix(e2e): use correct test-owner/test-repo in Cypress commands
fabiovincenzi 0c76acd
fix(e2e): logout after cleaning
fabiovincenzi 308d747
Merge branch 'main' into feat/e2e-dashboard-tests
fabiovincenzi ccef965
Merge branch 'main' into feat/e2e-dashboard-tests
jescalada 1c4ba16
chore: add missing header
fabiovincenzi 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,270 @@ | ||
| /** | ||
| * Copyright 2026 GitProxy Contributors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| describe('Push Actions (Approve, Reject, Cancel)', () => { | ||
| const testUser = { | ||
| username: 'testuser', | ||
| password: 'user123', | ||
| email: 'testuser@example.com', | ||
| gitAccount: 'testuser', | ||
| }; | ||
|
|
||
| const approverUser = { | ||
| username: 'approver', | ||
| password: 'approver123', | ||
| email: 'approver@example.com', | ||
| gitAccount: 'approver', | ||
| }; | ||
|
|
||
| before(() => { | ||
| // Setup: login as admin, create test users, assign permissions | ||
| cy.login('admin', 'admin'); | ||
|
|
||
| cy.createUser(testUser.username, testUser.password, testUser.email, testUser.gitAccount); | ||
| cy.createUser( | ||
| approverUser.username, | ||
| approverUser.password, | ||
| approverUser.email, | ||
| approverUser.gitAccount, | ||
| ); | ||
|
|
||
| cy.getTestRepoId().then((repoId) => { | ||
| cy.addUserPushPermission(repoId, testUser.username); | ||
| cy.addUserAuthorisePermission(repoId, approverUser.username); | ||
| }); | ||
|
|
||
| cy.logout(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| cy.logout(); | ||
| }); | ||
|
|
||
| describe('Approve flow', () => { | ||
| beforeEach(() => { | ||
| const suffix = `approve-${Date.now()}`; | ||
| cy.createPush(testUser.username, testUser.password, testUser.email, suffix).as('pushId'); | ||
| }); | ||
|
|
||
| it('should approve a pending push via attestation dialog', function () { | ||
| cy.login(approverUser.username, approverUser.password); | ||
| cy.visit(`/dashboard/push/${this.pushId}`); | ||
|
|
||
| // Verify push is Pending | ||
| cy.get('[data-testid="push-status"]').should('contain', 'Pending'); | ||
|
|
||
| // Action buttons should be visible | ||
| cy.get('[data-testid="push-cancel-btn"]').should('be.visible'); | ||
| cy.get('[data-testid="push-reject-btn"]').should('be.visible'); | ||
| cy.get('[data-testid="attestation-open-btn"]').should('be.visible'); | ||
|
|
||
| // Open attestation dialog | ||
| cy.get('[data-testid="attestation-open-btn"]').click(); | ||
| cy.get('[data-testid="attestation-dialog"]').should('be.visible'); | ||
|
|
||
| // Confirm button should be disabled until all checkboxes are checked | ||
| cy.get('[data-testid="attestation-confirm-btn"]').should('be.disabled'); | ||
|
|
||
| // Check all attestation checkboxes | ||
| cy.get('[data-testid="attestation-dialog"]') | ||
| .find('input[type="checkbox"]') | ||
| .each(($checkbox) => { | ||
| cy.wrap($checkbox).check({ force: true }); | ||
| }); | ||
|
|
||
| // Confirm button should now be enabled | ||
| cy.get('[data-testid="attestation-confirm-btn"]').should('not.be.disabled'); | ||
|
|
||
| // Click confirm to approve | ||
| cy.get('[data-testid="attestation-confirm-btn"]').click(); | ||
|
|
||
| // Should navigate back to push list | ||
| cy.url().should('include', '/dashboard/push'); | ||
| cy.url().should('not.include', this.pushId); | ||
|
|
||
| // Verify push is now Approved by revisiting its detail page | ||
| cy.visit(`/dashboard/push/${this.pushId}`); | ||
| cy.get('[data-testid="push-status"]').should('contain', 'Approved'); | ||
|
|
||
| // Action buttons should no longer be visible for an approved push | ||
| cy.get('[data-testid="push-cancel-btn"]').should('not.exist'); | ||
| cy.get('[data-testid="push-reject-btn"]').should('not.exist'); | ||
| cy.get('[data-testid="attestation-open-btn"]').should('not.exist'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Reject flow', () => { | ||
| beforeEach(() => { | ||
| const suffix = `reject-${Date.now()}`; | ||
| cy.createPush(testUser.username, testUser.password, testUser.email, suffix).as('pushId'); | ||
| }); | ||
|
|
||
| it('should reject a pending push', function () { | ||
| cy.login(approverUser.username, approverUser.password); | ||
| cy.visit(`/dashboard/push/${this.pushId}`); | ||
|
|
||
| // Verify push is Pending | ||
| cy.get('[data-testid="push-status"]').should('contain', 'Pending'); | ||
|
|
||
| // Open reject dialog | ||
| cy.get('[data-testid="push-reject-btn"]').click(); | ||
|
|
||
| // Confirm button should be disabled until reason is provided | ||
| cy.get('[data-testid="push-reject-confirm-btn"]').should('be.disabled'); | ||
|
|
||
| // Fill in rejection reason | ||
| cy.get('#reason').type('Rejecting for test purposes'); | ||
|
|
||
| // Confirm button should now be enabled | ||
| cy.get('[data-testid="push-reject-confirm-btn"]').should('not.be.disabled'); | ||
|
|
||
| // Confirm rejection | ||
| cy.get('[data-testid="push-reject-confirm-btn"]').click(); | ||
|
|
||
| // Should navigate back to push list | ||
| cy.url().should('include', '/dashboard/push'); | ||
| cy.url().should('not.include', this.pushId); | ||
|
|
||
| // Verify push is now Rejected | ||
| cy.visit(`/dashboard/push/${this.pushId}`); | ||
| cy.get('[data-testid="push-status"]').should('contain', 'Rejected'); | ||
|
|
||
| // Action buttons should no longer be visible | ||
| cy.get('[data-testid="push-cancel-btn"]').should('not.exist'); | ||
| cy.get('[data-testid="push-reject-btn"]').should('not.exist'); | ||
| cy.get('[data-testid="attestation-open-btn"]').should('not.exist'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Cancel flow', () => { | ||
| beforeEach(() => { | ||
| const suffix = `cancel-${Date.now()}`; | ||
| cy.createPush(testUser.username, testUser.password, testUser.email, suffix).as('pushId'); | ||
| }); | ||
|
|
||
| it('should cancel a pending push', function () { | ||
| // Cancel can be done by the push author | ||
| cy.login(testUser.username, testUser.password); | ||
| cy.visit(`/dashboard/push/${this.pushId}`); | ||
|
|
||
| // Verify push is Pending | ||
| cy.get('[data-testid="push-status"]').should('contain', 'Pending'); | ||
|
|
||
| // Click Cancel | ||
| cy.get('[data-testid="push-cancel-btn"]').click(); | ||
|
|
||
| // Should navigate back to push list | ||
| cy.url().should('include', '/dashboard/push'); | ||
|
|
||
| // Verify push is now Canceled | ||
| cy.visit(`/dashboard/push/${this.pushId}`); | ||
| cy.get('[data-testid="push-status"]').should('contain', 'Canceled'); | ||
|
|
||
| // Action buttons should no longer be visible | ||
| cy.get('[data-testid="push-cancel-btn"]').should('not.exist'); | ||
| cy.get('[data-testid="push-reject-btn"]').should('not.exist'); | ||
| cy.get('[data-testid="attestation-open-btn"]').should('not.exist'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Negative: unauthorized approve', () => { | ||
| beforeEach(() => { | ||
| const suffix = `neg-approve-${Date.now()}`; | ||
| cy.createPush(testUser.username, testUser.password, testUser.email, suffix).as('pushId'); | ||
| }); | ||
|
|
||
| it('should not change push state when user lacks canAuthorise permission', function () { | ||
| // Login as testuser (has canPush but NOT canAuthorise) | ||
| cy.login(testUser.username, testUser.password); | ||
| cy.visit(`/dashboard/push/${this.pushId}`); | ||
|
|
||
| cy.get('[data-testid="push-status"]').should('contain', 'Pending'); | ||
|
|
||
| // Open attestation dialog and attempt to approve | ||
| cy.get('[data-testid="attestation-open-btn"]').click(); | ||
| cy.get('[data-testid="attestation-dialog"]').should('be.visible'); | ||
|
|
||
| // Check all checkboxes | ||
| cy.get('[data-testid="attestation-dialog"]') | ||
| .find('input[type="checkbox"]') | ||
| .each(($checkbox) => { | ||
| cy.wrap($checkbox).check({ force: true }); | ||
| }); | ||
|
|
||
| cy.get('[data-testid="attestation-confirm-btn"]').click(); | ||
|
|
||
| // TODO: The server correctly returns 403 but the UI (src/ui/services/git-push.ts) | ||
| // only handles 401 errors in authorisePush/rejectPush. The 403 is silently | ||
| // ignored and the user is navigated away without feedback. Once the UI properly | ||
| // handles 403, this test should assert a snackbar error message is shown. | ||
| cy.visit(`/dashboard/push/${this.pushId}`); | ||
| cy.get('[data-testid="push-status"]').should('contain', 'Pending'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Negative: unauthorized reject', () => { | ||
| beforeEach(() => { | ||
| const suffix = `neg-reject-${Date.now()}`; | ||
| cy.createPush(testUser.username, testUser.password, testUser.email, suffix).as('pushId'); | ||
| }); | ||
|
|
||
| it('should not change push state when user lacks canAuthorise permission', function () { | ||
| // Login as testuser | ||
| cy.login(testUser.username, testUser.password); | ||
| cy.visit(`/dashboard/push/${this.pushId}`); | ||
|
|
||
| cy.get('[data-testid="push-status"]').should('contain', 'Pending'); | ||
|
|
||
| // Click Reject | ||
| cy.get('[data-testid="push-reject-btn"]').click(); | ||
|
|
||
| // TODO: Same issue as unauthorized approve — UI ignores 403 from server. | ||
| // Once fixed, assert snackbar error message is shown. | ||
| cy.visit(`/dashboard/push/${this.pushId}`); | ||
| cy.get('[data-testid="push-status"]').should('contain', 'Pending'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Attestation dialog cancel does not cancel the push', () => { | ||
| beforeEach(() => { | ||
| const suffix = `dialog-cancel-${Date.now()}`; | ||
| cy.createPush(testUser.username, testUser.password, testUser.email, suffix).as('pushId'); | ||
| }); | ||
|
|
||
| it('should close attestation dialog without affecting push status', function () { | ||
| cy.login(approverUser.username, approverUser.password); | ||
| cy.visit(`/dashboard/push/${this.pushId}`); | ||
|
|
||
| cy.get('[data-testid="push-status"]').should('contain', 'Pending'); | ||
|
|
||
| // Open attestation dialog | ||
| cy.get('[data-testid="attestation-open-btn"]').click(); | ||
| cy.get('[data-testid="attestation-dialog"]').should('be.visible'); | ||
|
|
||
| // Click the dialog's Cancel button (NOT the push cancel button) | ||
| cy.get('[data-testid="attestation-cancel-btn"]').click(); | ||
|
|
||
| // Dialog should close, push should still be pending | ||
| cy.get('[data-testid="attestation-dialog"]').should('not.exist'); | ||
| cy.get('[data-testid="push-status"]').should('contain', 'Pending'); | ||
|
|
||
| // Action buttons should still be visible (push is still pending) | ||
| cy.get('[data-testid="push-cancel-btn"]').should('be.visible'); | ||
| cy.get('[data-testid="push-reject-btn"]').should('be.visible'); | ||
| cy.get('[data-testid="attestation-open-btn"]').should('be.visible'); | ||
| }); | ||
| }); | ||
| }); | ||
jescalada marked this conversation as resolved.
Show resolved
Hide resolved
|
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
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.
Uh oh!
There was an error while loading. Please reload this page.