diff --git a/src/sections/account/api-token-section/useGetCurrentApiToken.tsx b/src/sections/account/api-token-section/useGetCurrentApiToken.tsx index 78dfd2ea0..ecf66aacc 100644 --- a/src/sections/account/api-token-section/useGetCurrentApiToken.tsx +++ b/src/sections/account/api-token-section/useGetCurrentApiToken.tsx @@ -39,5 +39,5 @@ export const useGetApiToken = (repository: ApiTokenInfoRepository): UseGetApiTok void fetchTokenInfo() }, [fetchTokenInfo]) - return { error, apiTokenInfo, isLoading } + return { isLoading, error, apiTokenInfo } } diff --git a/src/sections/account/api-token-section/useRecreateApiToken.tsx b/src/sections/account/api-token-section/useRecreateApiToken.tsx index eb0711597..bf48ce54d 100644 --- a/src/sections/account/api-token-section/useRecreateApiToken.tsx +++ b/src/sections/account/api-token-section/useRecreateApiToken.tsx @@ -38,6 +38,7 @@ export const useRecreateApiToken = ( setShouldRecreate(false) } } + if (shouldRecreate) { void recreateToken() } diff --git a/tests/component/sections/account/ApiTokenSection.spec.tsx b/tests/component/sections/account/ApiTokenSection.spec.tsx index 0116a392a..5b10d781e 100644 --- a/tests/component/sections/account/ApiTokenSection.spec.tsx +++ b/tests/component/sections/account/ApiTokenSection.spec.tsx @@ -18,20 +18,20 @@ describe('ApiTokenSection', () => { recreateApiToken: cy.stub().resolves(mockApiTokenInfo), deleteApiToken: cy.stub().resolves() } + cy.mountAuthenticated() }) it('should show the loading skeleton while fetching the token', () => { - // Simulate a delayed API response apiTokenRepository.getCurrentApiToken = cy.stub().callsFake(() => { return Cypress.Promise.delay(500).then(() => mockApiTokenInfo) }) cy.mount() - cy.get('[data-testid="loadingSkeleton"]').should('exist') // Verify loading skeleton exists + cy.get('[data-testid="loadingSkeleton"]').should('exist') - cy.wait(500) // Wait for the delay to finish - cy.get('[data-testid="loadingSkeleton"]').should('not.exist') // Verify skeleton is gone + cy.wait(500) + cy.get('[data-testid="loadingSkeleton"]').should('not.exist') }) it('should copy the api token to the clipboard', () => {