Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
harishmohanraj committed Sep 3, 2024
1 parent 2deabc8 commit 889dabb
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 20 deletions.
9 changes: 5 additions & 4 deletions app/src/client/app/layout/ChatLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ const ChatLayout: FC<Props> = ({
useEffect(() => {
if (!user) {
history.push('/login');
} else {
if (!user.hasPaid && user.isSignUpComplete) {
history.push('/pricing');
}
}
// else {
// if (!user.hasPaid && user.isSignUpComplete) {
// history.push('/pricing');
// }
// }
}, [user, history]);

useSocketListener('newMessageFromTeam', () => setShouldAutoScroll(true));
Expand Down
2 changes: 1 addition & 1 deletion app/src/client/auth/LoginSignupForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export const LoginSignupForm = ({
handleTocChange={handleTocChange}
marketingEmailsChecked={marketingEmailsChecked}
handleMarketingEmailsChange={handleMarketingEmailsChange}
errorMessage={errorMessage}
errorMessage={null}
/>
)}
<SocialAuth>
Expand Down
2 changes: 1 addition & 1 deletion app/src/client/components/DropdownUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AuthUser } from 'wasp/auth';

const DropdownUser = ({ user }: { user: AuthUser }) => {
const [dropdownOpen, setDropdownOpen] = useState(false);
const username = user.username || user.identities.username?.id;
const username = user.username || user.identities?.username?.id;

const trigger = useRef<any>(null);
const dropdown = useRef<any>(null);
Expand Down
4 changes: 2 additions & 2 deletions app/src/client/components/TosAndMarketingEmails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ const TosAndMarketingEmails: React.FC<TosAndMarketingEmailsProps> = ({
<span className='checkmark'></span>
</label>
</div>
{/* {errorMessage && (
{errorMessage && (
<div className='text-sm'>
<MessageError>
{errorMessage.title}
{errorMessage.description && ': '}
{errorMessage.description}
</MessageError>
</div>
)} */}
)}
</div>
);

Expand Down
3 changes: 3 additions & 0 deletions app/src/client/tests/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ function setupMocks(mockUser: any, pathName = '/') {
// Always mock useAuth with provided user data
vi.doMock('wasp/client/auth', () => ({ useAuth: () => mockUser }));

// Mock Wasp API and handleApiError functions
vi.doMock('wasp/client/api', () => ({ api: () => vi.fn(), handleApiError: () => vi.fn() }));

// Correctly mock useLocation to consistently return a pathname
vi.doMock('react-router-dom', () => ({
...vi.importActual('react-router-dom'), // Maintain other hooks and routing components
Expand Down
18 changes: 9 additions & 9 deletions app/src/server/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ export const createNewChat: CreateNewChat<any, Chat> = async (args, context) =>
throw new HttpError(401);
}

if (!context.user.hasPaid) {
throw new HttpError(500, 'No Subscription Found');
}
// if (!context.user.hasPaid) {
// throw new HttpError(500, 'No Subscription Found');
// }

const chat = await context.entities.Chat.create({
data: {
Expand Down Expand Up @@ -422,9 +422,9 @@ export const createNewAndReturnAllConversations: CreateNewAndReturnAllConversati
throw new HttpError(401);
}

if (!context.user.hasPaid) {
throw new HttpError(500, 'No Subscription Found');
}
// if (!context.user.hasPaid) {
// throw new HttpError(500, 'No Subscription Found');
// }

await context.entities.Conversation.create({
data: {
Expand Down Expand Up @@ -454,9 +454,9 @@ export const createNewAndReturnLastConversation: CreateNewAndReturnLastConversat
throw new HttpError(401);
}

if (!context.user.hasPaid) {
throw new HttpError(500, 'No Subscription Found');
}
// if (!context.user.hasPaid) {
// throw new HttpError(500, 'No Subscription Found');
// }

return await context.entities.Conversation.create({
data: {
Expand Down
2 changes: 1 addition & 1 deletion app/src/server/auth/setUsername.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const getGoogleUserFields = defineUserSignupFields({
},
email: (data: any) => data.profile.email,
isAdmin: (data: any) => adminEmails.includes(data.profile.email),
hasPaid: () => true,
// hasPaid: () => true,
isSetUpComplete: () => false,
});

Expand Down
4 changes: 2 additions & 2 deletions app/src/server/websocket/webSocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ export const socketFn = (io, context) => {
// When a new user is connected
io.on('connection', async (socket) => {
if (socket.data.user) {
const userEmail = socket.data.user.email;
const username = socket.data.user.username || socket.data.user.identities.username.id;
const userUUID = socket.data.user.uuid;
console.log('========');
console.log('a user connected: ', userEmail);
console.log('a user connected: ', username);

socket.on(
'sendMessageToTeam',
Expand Down

0 comments on commit 889dabb

Please sign in to comment.