Skip to content

Commit

Permalink
chore: Setting test frontend URL globally
Browse files Browse the repository at this point in the history
  • Loading branch information
StaNov committed Feb 3, 2025
1 parent 397dd7b commit 7825a4c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class V2InvitationControllerTest : AuthorizedControllerTest() {
fun `deletes translate invitation with languages`() {
val base = dbPopulator.createBase()
val project = base.project
tolgeeProperties.frontEndUrl = "https://dummyUrl.com"
val invitation = createTranslateInvitation(project)

performAuthDelete("/v2/invitations/${invitation.id}").andIsOk
Expand All @@ -54,23 +53,20 @@ class V2InvitationControllerTest : AuthorizedControllerTest() {
fun `project invitation contains creator info`() {
val base = dbPopulator.createBase()
val project = base.project
tolgeeProperties.frontEndUrl = "https://dummyUrl.com"
val invitation = createTranslateInvitation(project)
assertThat(invitation.createdBy?.name).isEqualTo("admin")
}

@Test
fun `organization invitation contains creator info`() {
val base = dbPopulator.createBase()
tolgeeProperties.frontEndUrl = "https://dummyUrl.com"
val invitation = createOrganizationInvitation(base.organization)
assertThat(invitation.createdBy?.name).isEqualTo("admin")
}

@Test
fun `deletes invitations created by deleted user`() {
val base = dbPopulator.createBase()
tolgeeProperties.frontEndUrl = "https://dummyUrl.com"
val newUser = dbPopulator.createUserIfNotExists("manager")
permissionService.grantFullAccessToProject(newUser, base.project)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ import io.tolgee.development.testDataBuilder.data.BaseTestData
import io.tolgee.dtos.misc.CreateProjectInvitationParams
import io.tolgee.dtos.request.project.LanguagePermissions
import io.tolgee.dtos.request.project.ProjectInviteUserDto
import io.tolgee.fixtures.EmailTestUtil
import io.tolgee.fixtures.andAssertThatJson
import io.tolgee.fixtures.andGetContentAsString
import io.tolgee.fixtures.andHasErrorMessage
import io.tolgee.fixtures.andIsBadRequest
import io.tolgee.fixtures.andIsOk
import io.tolgee.fixtures.node
import io.tolgee.fixtures.*
import io.tolgee.model.Invitation
import io.tolgee.model.Permission
import io.tolgee.model.Project
Expand Down Expand Up @@ -56,7 +50,6 @@ class ProjectsControllerInvitationTest : ProjectAuthControllerTest("/v2/projects
fun `returns project invitations`() {
val base = dbPopulator.createBase()
val project = base.project
tolgeeProperties.frontEndUrl = "https://dummyUrl.com"
createTranslateInvitation(project)
performAuthGet("/v2/projects/${project.id}/invitations").andIsOk.andAssertThatJson {
node("_embedded.invitations[0]") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class MarketingEmailingTest : AuthorizedControllerTest() {
@BeforeEach
fun setup() {
Mockito.clearInvocations(mailjetEmailServiceManager)
tolgeeProperties.frontEndUrl = "https://aaa"
tolgeeProperties.smtp.from = "[email protected]"
emailTestUtil.initMocks()
}
Expand All @@ -98,7 +97,6 @@ class MarketingEmailingTest : AuthorizedControllerTest() {

@Test
fun `adds contact after verification when needs-verification is on`() {
tolgeeProperties.frontEndUrl = "https://aaa"
tolgeeProperties.authentication.needsEmailVerification = true
val dto = SignUpDto(name = testName, password = "aaaaaaaaaa", email = testMail)
performPost("/api/public/sign_up", dto)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package io.tolgee.controllers.resetPassword
import com.posthog.java.PostHog
import io.tolgee.development.testDataBuilder.data.BaseTestData
import io.tolgee.dtos.request.auth.ResetPasswordRequest
import io.tolgee.fixtures.*
import io.tolgee.fixtures.EmailTestUtil
import io.tolgee.fixtures.andIsOk
import io.tolgee.testing.AbstractControllerTest
import io.tolgee.testing.assert
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.kotlin.times
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
import org.springframework.boot.test.mock.mockito.MockBean
Expand Down Expand Up @@ -43,7 +43,6 @@ class ResetPasswordControllerTest :

@Test
fun `email contains correct callback url with frontend url provided`() {
tolgeeProperties.frontEndUrl = "http://dummy-url.com/"
executePasswordChangeRequest()
emailTestUtil.firstMessageContent.assert.contains("http://dummy-url.com/reset_password/")
// We don't want double slashes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class EmailVerificationTest : AbstractControllerTest() {

private fun resetProperties() {
tolgeeProperties.authentication.needsEmailVerification = false
tolgeeProperties.frontEndUrl = "dummy_frontend_url"
tolgeeProperties.smtp.from = "[email protected]"
}

Expand Down
26 changes: 8 additions & 18 deletions backend/testing/src/main/kotlin/io/tolgee/AbstractSpringTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,11 @@ import io.tolgee.component.machineTranslation.MtServiceManager
import io.tolgee.configuration.tolgee.AuthenticationProperties
import io.tolgee.configuration.tolgee.InternalProperties
import io.tolgee.configuration.tolgee.TolgeeProperties
import io.tolgee.configuration.tolgee.machineTranslation.AwsMachineTranslationProperties
import io.tolgee.configuration.tolgee.machineTranslation.AzureCognitiveTranslationProperties
import io.tolgee.configuration.tolgee.machineTranslation.BaiduMachineTranslationProperties
import io.tolgee.configuration.tolgee.machineTranslation.DeeplMachineTranslationProperties
import io.tolgee.configuration.tolgee.machineTranslation.GoogleMachineTranslationProperties
import io.tolgee.configuration.tolgee.machineTranslation.MachineTranslationProperties
import io.tolgee.configuration.tolgee.machineTranslation.TolgeeMachineTranslationProperties
import io.tolgee.configuration.tolgee.machineTranslation.*
import io.tolgee.constants.MtServiceType
import io.tolgee.development.DbPopulatorReal
import io.tolgee.development.testDataBuilder.TestDataService
import io.tolgee.repository.EmailVerificationRepository
import io.tolgee.repository.KeyRepository
import io.tolgee.repository.OrganizationRepository
import io.tolgee.repository.OrganizationRoleRepository
import io.tolgee.repository.ProjectRepository
import io.tolgee.repository.*
import io.tolgee.security.InitialPasswordManager
import io.tolgee.service.EmailVerificationService
import io.tolgee.service.ImageUploadService
Expand All @@ -41,12 +31,7 @@ import io.tolgee.service.organization.OrganizationRoleService
import io.tolgee.service.organization.OrganizationService
import io.tolgee.service.project.LanguageStatsService
import io.tolgee.service.project.ProjectService
import io.tolgee.service.security.ApiKeyService
import io.tolgee.service.security.MfaService
import io.tolgee.service.security.PatService
import io.tolgee.service.security.PermissionService
import io.tolgee.service.security.UserAccountService
import io.tolgee.service.security.UserPreferencesService
import io.tolgee.service.security.*
import io.tolgee.service.translation.TranslationCommentService
import io.tolgee.service.translation.TranslationService
import io.tolgee.testing.AbstractTransactionalTest
Expand Down Expand Up @@ -230,6 +215,11 @@ abstract class AbstractSpringTest : AbstractTransactionalTest() {
}
}

@BeforeEach
fun setTestingProperties() {
tolgeeProperties.frontEndUrl = "https://dummyFrontEndUrl.com"
}

@Autowired
private fun initInitialUser(authenticationProperties: AuthenticationProperties) {
initialUsername = authenticationProperties.initialUsername
Expand Down

0 comments on commit 7825a4c

Please sign in to comment.