Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement real time suggestion #292

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ shell-frontend:

test-frontend:
@docker build -f frontend/Dockerfile.test frontend -t nest-frontend-test
@docker run nest-frontend-test npm run test
@docker run --env-file frontend/.env.example nest-frontend-test npm run test
4 changes: 1 addition & 3 deletions frontend/__tests__/src/pages/Chapters.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('ChaptersPage Component', () => {
})
})

test('renders SearchBar, data, and pagination component concurrently after data is loaded', async () => {
test('renders data, and pagination component concurrently after data is loaded', async () => {
window.scrollTo = jest.fn()
;(fetchAlgoliaData as jest.Mock).mockResolvedValue({
hits: mockChapterData.chapters,
Expand All @@ -88,12 +88,10 @@ describe('ChaptersPage Component', () => {
const loadingSpinner = screen.getAllByAltText('Loading indicator')
await waitFor(() => {
expect(loadingSpinner.length).toBeGreaterThan(0)
expect(screen.queryByPlaceholderText('Search for OWASP chapters...')).not.toBeInTheDocument()
expect(screen.queryByText('Next Page')).not.toBeInTheDocument()
})
await waitFor(() => {
expect(screen.getByPlaceholderText('Search for OWASP chapters...')).toBeInTheDocument()
expect(screen.getByPlaceholderText('Search for OWASP chapters...')).toHaveFocus()
expect(screen.getByText('Chapter 1')).toBeInTheDocument()
expect(screen.getByText('Next Page')).toBeInTheDocument()
})
Expand Down
5 changes: 1 addition & 4 deletions frontend/__tests__/src/pages/Committees.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,12 @@ describe('Committees Component', () => {
const loadingSpinner = screen.getAllByAltText('Loading indicator')
await waitFor(() => {
expect(loadingSpinner.length).toBeGreaterThan(0)
expect(
screen.queryByPlaceholderText('Search for OWASP committees...')
).not.toBeInTheDocument()

expect(screen.queryByText('Next Page')).not.toBeInTheDocument()
})

await waitFor(() => {
expect(screen.getByPlaceholderText('Search for OWASP committees...')).toBeInTheDocument()
expect(screen.getByPlaceholderText('Search for OWASP committees...')).toHaveFocus()
expect(screen.getByText('Committee 1')).toBeInTheDocument()
expect(screen.getByText('Next Page')).toBeInTheDocument()
})
Expand Down
8 changes: 0 additions & 8 deletions frontend/__tests__/src/pages/Contribute.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ jest.mock('lib/api', () => ({
fetchAlgoliaData: jest.fn(),
}))

jest.mock('lib/utils', () => ({
getFilteredIcons: jest.fn(),
}))

jest.mock('utils/credentials', () => ({
API_URL: 'https://mock-api.com',
}))

jest.mock('components/Pagination', () =>
jest.fn(({ currentPage, onPageChange, totalPages }) =>
totalPages > 1 ? (
Expand Down
2 changes: 0 additions & 2 deletions frontend/__tests__/src/pages/Projects.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,10 @@ describe('ProjectPage Component', () => {
const loadingSpinner = screen.getAllByAltText('Loading indicator')
await waitFor(() => {
expect(loadingSpinner.length).toBeGreaterThan(0)
expect(screen.queryByPlaceholderText('Search for OWASP projects...')).not.toBeInTheDocument()
expect(screen.queryByText('Next Page')).not.toBeInTheDocument()
})
await waitFor(() => {
expect(screen.getByPlaceholderText('Search for OWASP projects...')).toBeInTheDocument()
expect(screen.getByPlaceholderText('Search for OWASP projects...')).toHaveFocus()
expect(screen.getByText('Project 1')).toBeInTheDocument()
expect(screen.getByText('Next Page')).toBeInTheDocument()
})
Expand Down
1 change: 1 addition & 0 deletions frontend/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default {
moduleNameMapper: {
'^@tests/(.*)$': '<rootDir>/__tests__/src/$1',
'^@/(.*)$': '<rootDir>/src/$1',
'\\.(scss|sass|css)$': 'identity-obj-proxy',
},
moduleDirectories: ['node_modules', 'src'],
}
18 changes: 18 additions & 0 deletions frontend/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
import '@testing-library/jest-dom'
import { TextEncoder } from 'util'
import dotenv from 'dotenv'
dotenv.config()
beforeEach(() => {
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(),
removeListener: jest.fn(),
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
})
})
jest.mock('@algolia/autocomplete-theme-classic', () => ({}))

global.TextEncoder = TextEncoder
154 changes: 154 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"clsx": "^2.1.1",
"dayjs": "^1.11.13",
"dompurify": "^3.2.3",
"dotenv": "^16.4.7",
"lodash": "^4.17.21",
"lucide-react": "^0.469.0",
"markdown-it": "^14.1.0",
Expand All @@ -44,6 +45,9 @@
"tailwind-merge": "^2.5.4"
},
"devDependencies": {
"@algolia/autocomplete-js": "^1.17.8",
"@algolia/autocomplete-plugin-query-suggestions": "^1.17.8",
"@algolia/autocomplete-theme-classic": "^1.17.8",
Rajgupta36 marked this conversation as resolved.
Show resolved Hide resolved
"@eslint/js": "^9.15.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.1.0",
Expand All @@ -67,6 +71,7 @@
"eslint-plugin-react-refresh": "^0.4.14",
"globals": "^15.14.0",
"husky": "^9.1.7",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^15.2.11",
Expand Down
Loading
Loading