Skip to content

Commit

Permalink
chore: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengShi-1 committed Oct 30, 2024
1 parent c60e345 commit 6eff4e0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ export const useGetApiToken = (repository: ApiTokenInfoRepository): UseGetApiTok
void fetchTokenInfo()
}, [fetchTokenInfo])

return { error, apiTokenInfo, isLoading }
return { isLoading, error, apiTokenInfo }
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const useRecreateApiToken = (
setShouldRecreate(false)
}
}

if (shouldRecreate) {
void recreateToken()
}
Expand Down
8 changes: 4 additions & 4 deletions tests/component/sections/account/ApiTokenSection.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ describe('ApiTokenSection', () => {
recreateApiToken: cy.stub().resolves(mockApiTokenInfo),
deleteApiToken: cy.stub().resolves()
}

cy.mountAuthenticated(<ApiTokenSection repository={apiTokenRepository} />)
})

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(<ApiTokenSection repository={apiTokenRepository} />)
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', () => {
Expand Down

0 comments on commit 6eff4e0

Please sign in to comment.