1
0
mirror of https://github.com/quay/quay.git synced 2026-01-26 06:21:37 +03:00
Files
quay/web/cypress/e2e/proxy-cache.cy.ts
jbpratt 6c448cc915 ui: Add account settings to the new UI (PROJQUAY-9209) (#4367)
* ui: Add account settings to the new UI (PROJQUAY-9209)

- avatar functionality
- handle current logged in user avatar
- change pw
- change account type
- enable notifications
- delete account
- CLI config
- use react-hook-form
- fix checkbox state with modal
- fixes user save and lazy loads settings tab
- add e2e tests
- fix other tests failing on CI

* fix(web): address PR review feedback for user settings

- Add success alert and redirect after account conversion
- Fix error handling in ChangeAccountTypeModal
- Remove duplicate account conversion UI from BillingInformation
- Add conditional rendering for CLI auth types in CLIConfiguration
- Fix AlertVariant import in ChangeAccountTypeModal

Co-authored-by: Claude <noreply@anthropic.com>

* feat(web): add account settings link to user dropdown menu

Add a new "Account Settings" menu item to the user dropdown in the
header toolbar, making it easier for users to access their settings.

- Import UserCogIcon for the settings icon
- Add navigation handler for account-settings itemId
- Add Account Settings MenuItem before Logout in Actions menu group
- Navigate to /organization/{username}?tab=Settings when clicked

Co-authored-by: Claude <noreply@anthropic.com>

* fix(web): restore data-testid and fix Quota tab content in Settings

Recent account settings changes (7e864bbc) broke all quota.cy.ts tests by:
1. Removing data-testid attribute from Tab components
2. Using JSX instead of function for Quota tab content

This restores data-testid={tab.name} to enable test selectors and wraps
the Quota content in an arrow function to match other tabs.

Co-authored-by: Claude <noreply@anthropic.com>

---------

Co-authored-by: mfrances <mfrances@redhat.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-10-17 13:01:39 +00:00

117 lines
4.2 KiB
TypeScript

/// <reference types="cypress" />
describe('Organization settings - Proxy-cache configuration', () => {
beforeEach(() => {
cy.exec('npm run quay:seed');
cy.request('GET', `${Cypress.env('REACT_QUAY_APP_API_URL')}/csrf_token`)
.then((response) => response.body.csrf_token)
.then((token) => {
cy.loginByCSRF(token);
});
cy.fixture('config.json').then((config) => {
config.features.PROXY_CACHE = true;
cy.intercept('GET', '/config', config).as('getConfigWithProxyCache');
});
// Intercept the /validateproxycache API call
cy.intercept('POST', '/api/v1/organization/*/validateproxycache', (req) => {
const {upstream_registry_username, upstream_registry_password} = req.body;
if (upstream_registry_username && upstream_registry_password) {
req.reply({
statusCode: 202,
body: 'Valid',
});
} else {
req.reply({
statusCode: 202,
body: 'Anonymous',
});
}
}).as('validateProxyCache');
// Intercept the /proxycache API call
cy.intercept('POST', '/api/v1/organization/*/proxycache', {
statusCode: 201,
body: 'Created',
}).as('createProxyCache');
});
const createAnonymousProxyCacheConfig = (cy) => {
cy.get('[data-testid="remote-registry-input"]').type('docker.io');
cy.get('[data-testid="save-proxy-cache-btn"]').click();
};
it('can create anonymous proxy cache configuration for an organization', () => {
cy.visit('/organization/projectquay?tab=Settings');
cy.wait('@getConfigWithProxyCache');
cy.contains('Proxy Cache').click();
createAnonymousProxyCacheConfig(cy);
// Wait for the validateproxycache API call and assert the response
cy.wait('@validateProxyCache').then((interception) => {
expect(interception.response?.statusCode).to.eq(202);
expect(interception.response?.body).to.eq('Anonymous');
});
// Wait for the proxycache API call and assert the response
cy.wait('@createProxyCache').then((interception) => {
expect(interception.response?.statusCode).to.eq(201);
expect(interception.response?.body).to.eq('Created');
});
// verify success alert
cy.get('.pf-v5-c-alert.pf-m-success')
.contains('Successfully configured proxy cache')
.should('exist');
});
it('can create proxy cache configuration with registry credentials for an organization', () => {
cy.visit('/organization/projectquay?tab=Settings');
cy.wait('@getConfigWithProxyCache');
cy.contains('Proxy Cache').click();
cy.get('[data-testid="remote-registry-input"]').type('docker.io');
cy.get('[data-testid="remote-registry-username"]').type('testuser1');
cy.get('[data-testid="remote-registry-password"]').type('testpass');
cy.get('[data-testid="remote-registry-expiration"]').clear().type('76400');
cy.get('[data-testid="remote-registry-insecure"]').check();
cy.get('[data-testid="save-proxy-cache-btn"]').click();
// Wait for the validateproxycache API call and assert the response
cy.wait('@validateProxyCache').then((interception) => {
expect(interception.response?.statusCode).to.eq(202);
expect(interception.response?.body).to.eq('Valid');
});
// Wait for the proxycache API call and assert the response
cy.wait('@createProxyCache').then((interception) => {
expect(interception.response?.statusCode).to.eq(201);
expect(interception.response?.body).to.eq('Created');
});
// verify success alert
cy.get('.pf-v5-c-alert.pf-m-success')
.contains('Successfully configured proxy cache')
.should('exist');
});
it('can delete proxy cache configuration for an organization', () => {
cy.visit('/organization/prometheus?tab=Settings');
cy.wait('@getConfigWithProxyCache');
cy.contains('Proxy Cache').click();
cy.get('[data-testid="delete-proxy-cache-btn"]').click();
// verify success alert
cy.get('.pf-v5-c-alert.pf-m-success')
.contains('Successfully deleted proxy cache configuration')
.should('exist');
});
it('proxy cache config is not shown for user organization', () => {
cy.visit('/organization/user1?tab=Settings');
cy.wait('@getConfigWithProxyCache');
cy.contains('Proxy Cache').should('not.exist');
});
});