Compare commits
3 Commits
main
...
codex/add-
| Author | SHA1 | Date |
|---|---|---|
|
|
4172da6911 | |
|
|
fae70abd29 | |
|
|
8d026821e5 |
|
|
@ -0,0 +1,46 @@
|
|||
import { UserFactory, type UserAttributes } from '../../factories/user'
|
||||
import { login } from '../../support/authenticateUser'
|
||||
|
||||
const avatarProviders = [
|
||||
'initials',
|
||||
'gravatar',
|
||||
'marble',
|
||||
'upload',
|
||||
'ldap',
|
||||
] as const
|
||||
|
||||
function createFakeUserWithAvatar(provider: string) {
|
||||
const overrides: Partial<UserAttributes & {
|
||||
avatar_provider?: string;
|
||||
avatar_file_id?: number;
|
||||
email?: string
|
||||
}> = {
|
||||
username: `user_${provider}`,
|
||||
avatar_provider: provider,
|
||||
}
|
||||
|
||||
if (provider === 'gravatar') {
|
||||
overrides.email = `user_${provider}@example.com`
|
||||
}
|
||||
if (provider === 'upload' || provider === 'ldap') {
|
||||
overrides.avatar_file_id = 1
|
||||
}
|
||||
|
||||
return UserFactory.create(1, overrides)[0] as UserAttributes
|
||||
}
|
||||
|
||||
describe('User avatars', () => {
|
||||
avatarProviders.forEach(provider => {
|
||||
it(`Shows the avatar image for ${provider}`, () => {
|
||||
|
||||
login(createFakeUserWithAvatar(provider))
|
||||
|
||||
cy.visit('/')
|
||||
cy.get('.username-dropdown-trigger img.avatar')
|
||||
.should('be.visible')
|
||||
.and(($img) => {
|
||||
expect($img[0].naturalWidth).to.be.greaterThan(0)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
@ -2,6 +2,18 @@
|
|||
import './commands'
|
||||
import '@4tw/cypress-drag-drop'
|
||||
|
||||
beforeEach(() => {
|
||||
// More comprehensive intercept for all API requests to dev server
|
||||
cy.intercept('GET', '**/api/v1/**', (req) => {
|
||||
// If the request is going to the dev server, redirect to API server
|
||||
if (req.url.includes('127.0.0.1:4173') || req.url.includes('localhost:4173')) {
|
||||
const newUrl = req.url.replace(/https?:\/\/(127\.0\.0\.1|localhost):4173\/api\/v1/, Cypress.env('API_URL'))
|
||||
console.log('Redirecting request from', req.url, 'to', newUrl)
|
||||
req.url = newUrl
|
||||
}
|
||||
}).as('apiRequest')
|
||||
})
|
||||
|
||||
// see https://github.com/cypress-io/cypress/issues/702#issuecomment-587127275
|
||||
Cypress.on('window:before:load', (win) => {
|
||||
// disable service workers
|
||||
|
|
|
|||
Loading…
Reference in New Issue