Skip to content

Commit

Permalink
Fix CI (#8862)
Browse files Browse the repository at this point in the history
  • Loading branch information
Weiko authored Dec 3, 2024
1 parent 7943141 commit 5e891a1
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 38 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"bcrypt": "^5.1.1",
"better-sqlite3": "^9.2.2",
"body-parser": "^1.20.2",
"bullmq": "^4.14.0",
"bullmq": "^4.15.0",
"bytes": "^3.1.2",
"class-transformer": "^0.5.1",
"clsx": "^2.1.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { zodResolver } from '@hookform/resolvers/zod';
import { useEffect } from 'react';
import { useForm } from 'react-hook-form';
import { useLocation, useSearchParams } from 'react-router-dom';
import { useRecoilValue } from 'recoil';
import { z } from 'zod';
import { useLocation } from 'react-router-dom';

import { PASSWORD_REGEX } from '@/auth/utils/passwordRegex';
import { isDeveloperDefaultSignInPrefilledState } from '@/client-config/states/isDeveloperDefaultSignInPrefilledState';
import { useSearchParams } from 'react-router-dom';
import { isDefined } from '~/utils/isDefined';
import {
SignInUpStep,
signInUpStepState,
} from '@/auth/states/signInUpStepState';
import { PASSWORD_REGEX } from '@/auth/utils/passwordRegex';
import { isDeveloperDefaultSignInPrefilledState } from '@/client-config/states/isDeveloperDefaultSignInPrefilledState';
import { isDefined } from '~/utils/isDefined';

const makeValidationSchema = (signInUpStep: SignInUpStep) =>
z
Expand Down Expand Up @@ -63,6 +62,11 @@ export const useSignInUpForm = () => {
form.setValue('email', '[email protected]');
form.setValue('password', 'Applecar2025');
}
}, [form, isDeveloperDefaultSignInPrefilled, prefilledEmail, location.search]);
return { form: form };
}, [
form,
isDeveloperDefaultSignInPrefilled,
prefilledEmail,
location.search,
]);
return { form, validationSchema };
};
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ export const queries = {
allowImpersonation
activationStatus
isPublicInviteLinkEnabled
isGoogleAuthEnabled
isMicrosoftAuthEnabled
isPasswordAuthEnabled
subdomain
hasValidEntrepriseKey
featureFlags {
id
Expand All @@ -164,6 +168,7 @@ export const queries = {
logo
displayName
domainName
subdomain
}
}
userVars
Expand Down Expand Up @@ -286,6 +291,10 @@ export const responseData = {
activationStatus: 'active',
isPublicInviteLinkEnabled: false,
hasValidEntrepriseKey: false,
isGoogleAuthEnabled: true,
isMicrosoftAuthEnabled: false,
isPasswordAuthEnabled: true,
subdomain: 'test',
featureFlags: [],
metadataVersion: 1,
currentBillingSubscription: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@ import { HttpService } from '@nestjs/axios';
import { Test, TestingModule } from '@nestjs/testing';
import { getRepositoryToken } from '@nestjs/typeorm';

import bcrypt from 'bcrypt';
import { expect, jest } from '@jest/globals';
import bcrypt from 'bcrypt';

import { AppToken } from 'src/engine/core-modules/app-token/app-token.entity';
import { SignInUpService } from 'src/engine/core-modules/auth/services/sign-in-up.service';
import { DomainManagerService } from 'src/engine/core-modules/domain-manager/service/domain-manager.service';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { FileUploadService } from 'src/engine/core-modules/file/file-upload/services/file-upload.service';
import { OnboardingService } from 'src/engine/core-modules/onboarding/onboarding.service';
import { UserWorkspaceService } from 'src/engine/core-modules/user-workspace/user-workspace.service';
import { User } from 'src/engine/core-modules/user/user.entity';
import { WorkspaceInvitationService } from 'src/engine/core-modules/workspace-invitation/services/workspace-invitation.service';
import { WorkspaceService } from 'src/engine/core-modules/workspace/services/workspace.service';
import {
Workspace,
WorkspaceActivationStatus,
} from 'src/engine/core-modules/workspace/workspace.entity';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { AppToken } from 'src/engine/core-modules/app-token/app-token.entity';
import { WorkspaceInvitationService } from 'src/engine/core-modules/workspace-invitation/services/workspace-invitation.service';
import { WorkspaceService } from 'src/engine/core-modules/workspace/services/workspace.service';

jest.mock('bcrypt');

Expand Down Expand Up @@ -75,9 +76,7 @@ describe('SignInUpService', () => {
},
{
provide: WorkspaceService,
useValue: {
generateSubdomain: jest.fn().mockReturnValue('tartanpion'),
},
useValue: {},
},
{
provide: UserWorkspaceService,
Expand Down Expand Up @@ -114,6 +113,12 @@ describe('SignInUpService', () => {
workspaceInvitationFindInvitationByWorkspaceSubdomainAndUserEmailMock,
},
},
{
provide: DomainManagerService,
useValue: {
generateSubdomain: jest.fn().mockReturnValue('testSubDomain'),
},
},
],
}).compile();

Expand All @@ -139,7 +144,7 @@ describe('SignInUpService', () => {
await service.signInUp({
email: '[email protected]',
fromSSO: true,
targetWorkspaceSubdomain: 'tartanpion',
targetWorkspaceSubdomain: 'testSubDomain',
});

expect(spy).toHaveBeenCalledWith(
Expand Down Expand Up @@ -169,7 +174,7 @@ describe('SignInUpService', () => {
const result = await service.signInUp({
email,
fromSSO: true,
targetWorkspaceSubdomain: 'tartanpion',
targetWorkspaceSubdomain: 'testSubDomain',
});

expect(result).toEqual(existingUser);
Expand Down Expand Up @@ -204,7 +209,7 @@ describe('SignInUpService', () => {
await service.signInUp({
email,
fromSSO: true,
targetWorkspaceSubdomain: 'tartanpion',
targetWorkspaceSubdomain: 'testSubDomain',
});

expect(spySignInUpOnExistingWorkspace).toHaveBeenCalledWith(
Expand Down Expand Up @@ -257,7 +262,7 @@ describe('SignInUpService', () => {
const result = await service.signInUp({
email,
fromSSO: true,
targetWorkspaceSubdomain: 'tartanpion',
targetWorkspaceSubdomain: 'testSubDomain',
});

expect(result).toEqual(existingUser);
Expand Down Expand Up @@ -297,7 +302,7 @@ describe('SignInUpService', () => {
email,
fromSSO: true,
workspacePersonalInviteToken,
targetWorkspaceSubdomain: 'tartanpion',
targetWorkspaceSubdomain: 'testSubDomain',
});

expect(spySignInUpOnExistingWorkspace).toHaveBeenCalledWith(
Expand Down Expand Up @@ -348,7 +353,7 @@ describe('SignInUpService', () => {
email,
fromSSO: true,
workspacePersonalInviteToken,
targetWorkspaceSubdomain: 'tartanpion',
targetWorkspaceSubdomain: 'testSubDomain',
});

expect(
Expand All @@ -375,7 +380,7 @@ describe('SignInUpService', () => {
email,
password,
fromSSO: false,
targetWorkspaceSubdomain: 'tartanpion',
targetWorkspaceSubdomain: 'testSubDomain',
});

expect(
Expand All @@ -400,7 +405,7 @@ describe('SignInUpService', () => {
email,
password,
fromSSO: false,
targetWorkspaceSubdomain: 'tartanpion',
targetWorkspaceSubdomain: 'testSubDomain',
});

expect(UserCreateMock).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -436,7 +441,7 @@ describe('SignInUpService', () => {
password,
fromSSO: false,
workspacePersonalInviteToken,
targetWorkspaceSubdomain: 'tartanpion',
targetWorkspaceSubdomain: 'testSubDomain',
});

expect(UserCreateMock).toHaveBeenCalledTimes(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';

import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { isDefined } from 'src/utils/is-defined';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import {
WorkspaceException,
WorkspaceExceptionCode,
} from 'src/engine/core-modules/workspace/workspace.exception';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { isWorkEmail } from 'src/utils/is-work-email';
import { getDomainNameByEmail } from 'src/utils/get-domain-name-by-email';
import { isDefined } from 'src/utils/is-defined';
import { isWorkEmail } from 'src/utils/is-work-email';

@Injectable()
// eslint-disable-next-line @nx/workspace-inject-workspace-repository
export class DomainManagerService {
constructor(
@InjectRepository(Workspace, 'core')
Expand Down Expand Up @@ -126,6 +125,7 @@ export class DomainManagerService {
order: {
createdAt: 'DESC',
},
relations: ['workspaceSSOIdentityProviders'],
});

if (workspaces.length > 1) {
Expand Down Expand Up @@ -153,7 +153,12 @@ export class DomainManagerService {

if (!isDefined(subdomain)) return;

return this.workspaceRepository.findOneBy({ subdomain });
const workspace = await this.workspaceRepository.findOne({
where: { subdomain },
relations: ['workspaceSSOIdentityProviders'],
});

return workspace;
} catch (e) {
throw new WorkspaceException(
'Workspace not found',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ import {
AuthException,
AuthExceptionCode,
} from 'src/engine/core-modules/auth/auth.exception';
import { DomainManagerService } from 'src/engine/core-modules/domain-manager/service/domain-manager.service';
import { EmailService } from 'src/engine/core-modules/email/email.service';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { OnboardingService } from 'src/engine/core-modules/onboarding/onboarding.service';
import { UserWorkspace } from 'src/engine/core-modules/user-workspace/user-workspace.entity';
import { User } from 'src/engine/core-modules/user/user.entity';
import { SendInvitationsOutput } from 'src/engine/core-modules/workspace-invitation/dtos/send-invitations.output';
import { castAppTokenToWorkspaceInvitationUtil } from 'src/engine/core-modules/workspace-invitation/utils/cast-app-token-to-workspace-invitation.util';
import {
WorkspaceInvitationException,
WorkspaceInvitationExceptionCode,
} from 'src/engine/core-modules/workspace-invitation/workspace-invitation.exception';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { DomainManagerService } from 'src/engine/core-modules/domain-manager/service/domain-manager.service';
import { castAppTokenToWorkspaceInvitationUtil } from 'src/engine/core-modules/workspace-invitation/utils/cast-app-token-to-workspace-invitation.util';

@Injectable()
// eslint-disable-next-line @nx/workspace-inject-workspace-repository
Expand Down Expand Up @@ -338,7 +338,7 @@ export class WorkspaceInvitationService {
? {
inviteToken: invitation.value.appToken.value,
email: invitation.value.email,
}
}
: {},
});
const emailData = {
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21176,9 +21176,9 @@ __metadata:
languageName: node
linkType: hard

"bullmq@npm:^4.14.0":
version: 4.17.0
resolution: "bullmq@npm:4.17.0"
"bullmq@npm:^4.15.0":
version: 4.18.2
resolution: "bullmq@npm:4.18.2"
dependencies:
cron-parser: "npm:^4.6.0"
glob: "npm:^8.0.3"
Expand All @@ -21189,7 +21189,7 @@ __metadata:
semver: "npm:^7.5.4"
tslib: "npm:^2.0.0"
uuid: "npm:^9.0.0"
checksum: 10c0/7dde2fcc2a6432aa52fb255ac470fbc6c01530d2825bad1b48549706de2d3af90b1895954db16a753f60a3e6f2755d9e9987b422597dbf74762932e98bc8fbd2
checksum: 10c0/09371a6d53377e556a37e3e046576bb20056a14ac26d29528bd0a4054c33f458f1764ae696ae6a39fda688e8215ef34f1ba94fe56ba89db5b9ad2c9aa0082f2f
languageName: node
linkType: hard

Expand Down Expand Up @@ -44483,7 +44483,7 @@ __metadata:
bcrypt: "npm:^5.1.1"
better-sqlite3: "npm:^9.2.2"
body-parser: "npm:^1.20.2"
bullmq: "npm:^4.14.0"
bullmq: "npm:^4.15.0"
bytes: "npm:^3.1.2"
chromatic: "npm:^6.18.0"
class-transformer: "npm:^0.5.1"
Expand Down

0 comments on commit 5e891a1

Please sign in to comment.