-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable playwright on the CI (#1109)
* feat: enable playwright on the CI * fix: remove syntax error * feat: write first playwright test * fix: add unit test and remove scss file * fix: migrate to typescript and CSS * fix: remove .only * feat: add unit test * feat: migrate scss * fix: solve stylelint issue * fix: migrate scss * fix: remove some SCSS, add unit test, remove unused props, and migrate component to typescript * fix: remove screen.debug
- Loading branch information
1 parent
7166818
commit 2d8670c
Showing
62 changed files
with
711 additions
and
380 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,23 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test('Should create a new family', async ({ page }) => { | ||
await page.goto('/'); | ||
await page.getByRole('link', { name: 'Operations' }).click(); | ||
await page.getByRole('link', { name: 'Families' }).click(); | ||
await page.getByRole('link', { name: 'New' }).click(); | ||
await page.getByLabel('Intitulé*').click(); | ||
await page.getByLabel('Intitulé*').fill('Familie 1'); | ||
await page.getByLabel('Title*').click(); | ||
await page.getByLabel('Title*').fill('Familie 2'); | ||
await page.getByLabel('Thème').click(); | ||
await page.getByLabel('Thème').fill('Theme 1'); | ||
await page.getByLabel('Theme').click(); | ||
await page.getByLabel('Theme').fill('Theme 2'); | ||
await page.getByRole('button', { name: 'Save' }).click(); | ||
await expect(page.locator('h2')).toContainText('Familie 1'); | ||
await page.getByText('Display second language').click(); | ||
await expect(page.locator('h2')).toContainText('" Familie 2 "'); | ||
await page.getByRole('link', { name: 'Families' }).click(); | ||
await expect(page.locator('#root-app')).toContainText('1 result'); | ||
await expect(page.getByRole('link', { name: 'Familie 1' })).toBeVisible(); | ||
}); |
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,31 @@ | ||
.application-title { | ||
background: #45374e; | ||
padding-bottom: 0.5em; | ||
padding-top: 0.5em; | ||
} | ||
|
||
.application-title .application-title-container { | ||
width: 50%; | ||
margin: auto; | ||
} | ||
|
||
.application-title .application-title-wrapper { | ||
display: flex; | ||
margin: auto; | ||
} | ||
|
||
.application-title img { | ||
width: 25%; | ||
} | ||
|
||
.application-title h1 { | ||
color: white; | ||
font-size: 15.3pt; | ||
float: right; | ||
margin: 0; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
text-align: center; | ||
flex-grow: 1; | ||
} |
This file was deleted.
Oops, something went wrong.
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
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,16 @@ | ||
.bauhaus-btn { | ||
background-color: var(--color-3); | ||
color: white; | ||
width: 100%; | ||
margin-bottom: 0.5em; | ||
} | ||
|
||
.bauhaus-btn:hover { | ||
color: white; | ||
} | ||
|
||
.bauhaus-btn:focus, | ||
.bauhaus-btn:hover:not([disabled]) { | ||
background-color: var(--color-2); | ||
color: white; | ||
} |
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
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
7 changes: 7 additions & 0 deletions
7
src/packages/components/filter-toggle-buttons/filter-toggle-buttons.css
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,7 @@ | ||
.bauhaus-filter-toggle-buttons { | ||
margin-bottom: 1em; | ||
} | ||
|
||
.bauhaus-filter-toggle-buttons-btn-active { | ||
border: 2px var(--color-3) solid; | ||
} |
6 changes: 0 additions & 6 deletions
6
src/packages/components/filter-toggle-buttons/filter-toggle-buttons.scss
This file was deleted.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
src/packages/components/filter-toggle-buttons/filter-toggle-buttons.spec.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,78 @@ | ||
import { fireEvent, render, screen } from '@testing-library/react'; | ||
import { describe, expect, it, vi } from 'vitest'; | ||
|
||
import FilterToggleButtons from '.'; | ||
import { BOTH, DOCUMENT, LINK } from '../../modules-operations/document/utils'; | ||
|
||
describe('FilterToggleButtons Component', () => { | ||
const mockHandleSelection = vi.fn(); | ||
|
||
const setup = (currentValue: string) => { | ||
const options = [ | ||
[BOTH, 'Both'], | ||
[DOCUMENT, 'Document'], | ||
[LINK, 'Link'], | ||
] as [typeof BOTH | typeof DOCUMENT | typeof LINK, string][]; | ||
|
||
render( | ||
<FilterToggleButtons | ||
options={options} | ||
currentValue={currentValue} | ||
handleSelection={mockHandleSelection} | ||
/>, | ||
); | ||
}; | ||
|
||
afterEach(() => { | ||
vi.restoreAllMocks(); | ||
mockHandleSelection.mockClear(); | ||
}); | ||
|
||
it('should render the correct number of buttons', () => { | ||
setup(BOTH); | ||
const buttons = screen.getAllByRole('button'); | ||
expect(buttons).toHaveLength(3); | ||
}); | ||
|
||
it('should apply the active class to the selected button', () => { | ||
setup(DOCUMENT); | ||
const activeButton = screen.getByText('Document'); | ||
expect(activeButton).toHaveClass( | ||
'bauhaus-filter-toggle-buttons-btn-active', | ||
); | ||
}); | ||
|
||
it('should not apply the active class to unselected buttons', () => { | ||
setup(DOCUMENT); | ||
const unselectedButton = screen.getByText('Both'); | ||
expect(unselectedButton).not.toHaveClass( | ||
'bauhaus-filter-toggle-buttons-btn-active', | ||
); | ||
}); | ||
|
||
it('should call handleSelection with the correct value when a button is clicked', () => { | ||
setup(BOTH); | ||
const button = screen.getByText('Link'); | ||
fireEvent.click(button); | ||
expect(mockHandleSelection).toHaveBeenCalledWith(LINK); | ||
}); | ||
|
||
it('should render button labels correctly', () => { | ||
setup(BOTH); | ||
expect(screen.getByText('Both')).toBeDefined(); | ||
expect(screen.getByText('Document')).toBeDefined(); | ||
expect(screen.getByText('Link')).toBeDefined(); | ||
}); | ||
|
||
it('should handle empty options gracefully', () => { | ||
render( | ||
<FilterToggleButtons | ||
options={[]} | ||
currentValue={BOTH} | ||
handleSelection={mockHandleSelection} | ||
/>, | ||
); | ||
const buttons = screen.queryAllByRole('button'); | ||
expect(buttons).toHaveLength(0); | ||
}); | ||
}); |
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
Oops, something went wrong.