Skip to content

Commit

Permalink
public form fixed (#614)
Browse files Browse the repository at this point in the history
  • Loading branch information
abilpraju-aot authored Jul 19, 2022
1 parent 9d6ba9c commit 91f5086
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { render as rtlRender,screen } from '@testing-library/react'
import { render as rtlRender,screen,fireEvent } from '@testing-library/react'
import View from '../../../../components/Form/Item/View'
import '@testing-library/jest-dom/extend-expect';
import { Provider } from 'react-redux'
Expand All @@ -9,6 +9,7 @@ import configureStore from 'redux-mock-store';
import { mockstate } from './constatnts-edit';
import thunk from 'redux-thunk'
import * as redux from 'react-redux'
import { publicApplicationCreate } from "../../../../apiManager/services/applicationServices";

jest.mock('react-formio', () => ({
...jest.requireActual('react-formio'),
Expand Down Expand Up @@ -59,12 +60,17 @@ it("should render the public View component without breaking ",async()=>{
spy.mockImplementation((callback) => callback(
{applications:{isPublicStatusLoading:false},form:{isActive: false},formDelete:{isFormSubmissionLoading:false}}
))

const applicationCreate = jest.fn();
applicationCreate(publicApplicationCreate);
//spy.mockReturnValue({applications:{isPublicStatusLoading:false},form:{isActive: false}})
renderWithRouterMatch(View,{
path:"/public/form/:formId",
route:"/public/form/123",
}
)
expect(screen.getByText("the form title")).toBeInTheDocument();
expect(screen.getByText("Submit")).toBeInTheDocument();
expect(screen.getByText("Submit")).toBeInTheDocument();
fireEvent.click(screen.getByText("Submit"));
expect(applicationCreate).toHaveBeenCalled();
})
4 changes: 1 addition & 3 deletions forms-flow-web/src/components/Form/Item/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,7 @@ const doProcessActions = (submission, ownProps) => {
dispatch(resetSubmissions("submission"));
const data = getProcessReq(form, submission._id, "new", user);

const isPublic = window.location.href.includes("public");

if (isPublic) {
if (!IsAuth) {
// this is for anonymous
dispatch(
publicApplicationCreate(data, (err, res) => {
Expand Down

0 comments on commit 91f5086

Please sign in to comment.