generated from muratkeremozcan/react-cypress-ts-vite-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from cesarhenrq/4091-feat--filter-card-container
4091 feat filter card container
- Loading branch information
Showing
16 changed files
with
284 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/components/FilterCardContainer/FilterCardContainer.cy.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import FilterCardContainer from './FilterCardContainer'; | ||
import GlobalStyle from '@styles/global'; | ||
|
||
const Sut = () => ( | ||
<> | ||
<GlobalStyle /> | ||
<FilterCardContainer /> | ||
</> | ||
); | ||
|
||
describe('<FilterCardContainer />', () => { | ||
beforeEach(() => { | ||
cy.mount(<Sut />); | ||
}); | ||
|
||
it('should has background-color: var(--purple-dark)', () => { | ||
cy.getByCy('filter-card-container').should( | ||
'have.css', | ||
'background-color', | ||
'rgb(26, 16, 51)', | ||
); | ||
}); | ||
|
||
it('should has padding: 26px 135px 64px', () => { | ||
cy.getByCy('filter-card-container').should( | ||
'have.css', | ||
'padding', | ||
'26px 135px 64px', | ||
); | ||
}); | ||
|
||
it('should base-card has box-shadow: none', () => { | ||
cy.getByCy('base-card').should('have.css', 'box-shadow', 'none'); | ||
}); | ||
|
||
it('should navigation and card wrapper has display: flex', () => { | ||
cy.getByCy('navigation-and-card').should('have.css', 'display', 'flex'); | ||
}); | ||
|
||
it('should navigation and card wrapper has justify-content: space-between', () => { | ||
cy.getByCy('navigation-and-card').should( | ||
'have.css', | ||
'justify-content', | ||
'space-between', | ||
); | ||
}); | ||
|
||
it('should text "Vagas de emprego em todo Brasil" has justify-content: flex-start', () => { | ||
cy.contains('Vagas de emprego em todo Brasil').should( | ||
'have.css', | ||
'justify-content', | ||
'flex-start', | ||
); | ||
}); | ||
|
||
it('should filter cards wrapper has display: flex', () => { | ||
cy.getByClassLike('filter-cards').should('have.css', 'display', 'flex'); | ||
}); | ||
|
||
it('should filter cards wrapper has gap: 1.5rem', () => { | ||
cy.getByClassLike('filter-cards').should('have.css', 'gap', '24px'); | ||
}); | ||
|
||
it('should filter cards wrapper has flex-wrap: wrap', () => { | ||
cy.getByClassLike('filter-cards').should('have.css', 'flex-wrap', 'wrap'); | ||
}); | ||
|
||
it('should filter cards wrapper has margin-top: 1.875rem', () => { | ||
cy.getByClassLike('filter-cards').should('have.css', 'margin-top', '30px'); | ||
}); | ||
}); |
37 changes: 37 additions & 0 deletions
37
src/components/FilterCardContainer/FilterCardContainer.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import FilterCardContainer from './FilterCardContainer'; | ||
|
||
describe('<FilterCardContainer />', () => { | ||
beforeEach(() => { | ||
render(<FilterCardContainer />); | ||
}); | ||
|
||
it('should be defined', () => { | ||
screen.getByTestId('filter-card-container'); | ||
}); | ||
|
||
it('should render navigation-and-card wrapper', () => { | ||
screen.getByTestId('navigation-and-card'); | ||
}); | ||
|
||
it('should render text-and-navigation wrapper', () => { | ||
screen.getByTestId('text-and-navigation'); | ||
}); | ||
|
||
it('should render filter navigation component', () => { | ||
screen.getByTestId('filter-navigation'); | ||
}); | ||
|
||
it('should render register card component', () => { | ||
screen.getByTestId('register-card'); | ||
}); | ||
|
||
it('should render filter card component', () => { | ||
screen.getAllByTestId('filter-card'); | ||
}); | ||
|
||
it('should render text "Vagas de emprego em todo Brasil"', () => { | ||
screen.getByText('Vagas de emprego em todo Brasil'); | ||
}); | ||
}); |
88 changes: 88 additions & 0 deletions
88
src/components/FilterCardContainer/FilterCardContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { useState } from 'react'; | ||
|
||
import Text from '@components/Text'; | ||
import FilterNavigation from '@components/FilterNavigation'; | ||
import RegisterCard from '@components/RegisterCard'; | ||
import FilterCard from '@components/FilterCard'; | ||
|
||
import useResource from '@hooks/useResource'; | ||
import useFetchResource from '@hooks/useFetchResource'; | ||
|
||
import * as S from './styles'; | ||
|
||
const technologies = [ | ||
'JavaScript', | ||
'Python', | ||
'Java', | ||
'C#', | ||
'Ruby', | ||
'PHP', | ||
'TypeScript', | ||
'Swift', | ||
'Go', | ||
'Kotlin', | ||
'Rust', | ||
]; | ||
|
||
const FilterCardContainer = () => { | ||
const [activeTab, setActiveTab] = useState('technology'); | ||
|
||
const [vacancies, vacancyService] = useResource<Vacancy>('vacancies'); | ||
/* const [technologies, technologyService] = | ||
useResource<Technology>('technologies'); */ | ||
|
||
const roles = [...new Set(vacancies?.map(vacancy => vacancy.vacancyRole))]; | ||
const locations = [...new Set(vacancies?.map(vacancy => vacancy.location))]; | ||
|
||
useFetchResource(vacancyService); | ||
//useFetchResource(technologyService); | ||
|
||
const handleCLick = (event: React.MouseEvent<HTMLDivElement>) => { | ||
const { id } = event.currentTarget; | ||
setActiveTab(id); | ||
}; | ||
|
||
let dataToRender = []; | ||
|
||
switch (activeTab) { | ||
case 'technology': | ||
dataToRender = technologies; | ||
break; | ||
case 'location': | ||
dataToRender = locations; | ||
break; | ||
case 'roles': | ||
dataToRender = roles; | ||
break; | ||
default: | ||
dataToRender = technologies; | ||
} | ||
|
||
return ( | ||
<S.FilterCardContainer data-cy="filter-card-container"> | ||
<div className="navigation-and-card" data-cy="navigation-and-card"> | ||
<div className="text-and-navigation" data-cy="text-and-navigation"> | ||
<Text | ||
label="Vagas de emprego em todo Brasil" | ||
fontColor="yellow" | ||
fontSize="large" | ||
fontWeight="600" | ||
/> | ||
<FilterNavigation activeTab={activeTab} onClick={handleCLick} /> | ||
</div> | ||
<RegisterCard /> | ||
</div> | ||
<div className="filter-cards" data-cy={`filter-cards-${activeTab}`}> | ||
{dataToRender.map(data => ( | ||
<FilterCard | ||
key={data} | ||
filter={data} | ||
onClick={() => console.log('clicked')} | ||
/> | ||
))} | ||
</div> | ||
</S.FilterCardContainer> | ||
); | ||
}; | ||
|
||
export default FilterCardContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './FilterCardContainer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const FilterCardContainer = styled.div` | ||
background-color: var(--purple-dark); | ||
padding: 1.625rem 8.4375rem; | ||
padding-bottom: 4rem; | ||
.base-card { | ||
box-shadow: none; | ||
} | ||
.navigation-and-card { | ||
display: flex; | ||
justify-content: space-between; | ||
.text-and-navigation { | ||
.text { | ||
justify-content: flex-start; | ||
} | ||
} | ||
} | ||
.filter-cards { | ||
display: flex; | ||
gap: 1.5rem; | ||
flex-wrap: wrap; | ||
margin-top: 1.875rem; | ||
.filter-card { | ||
width: 16.875rem; | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { useEffect } from 'react'; | ||
|
||
const useFetchResouce = (service: Service) => { | ||
const useFetchResource = (service: Service) => { | ||
useEffect(() => { | ||
service.get(); | ||
}, []); | ||
}; | ||
|
||
export default useFetchResouce; | ||
export default useFetchResource; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import axios from 'axios'; | ||
|
||
const httpClient = axios.create({ | ||
baseURL: import.meta.env.VITE_BASE_URL, | ||
baseURL: 'https://metavagasapi.onrender.com/', | ||
}); | ||
|
||
export default httpClient; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
type Company = { | ||
id: string; | ||
name: string; | ||
description: string; | ||
foundedAt: Date; | ||
adress: string; | ||
city: string; | ||
state: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
type Technology = { | ||
id: string; | ||
tecName: string; | ||
creatorsName: string; | ||
vacancies: Vacancy[]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
type Vacancy = { | ||
id: string; | ||
level: string; | ||
location: string; | ||
company: Company; | ||
vacancyDescription: string; | ||
vacancyRole: string; | ||
vacancyType: string; | ||
wage: number; | ||
createdAt: Date; | ||
updatedAt: Date; | ||
}; |
Oops, something went wrong.