Skip to content

Commit

Permalink
put the ReactJS project within the frontend directory
Browse files Browse the repository at this point in the history
  • Loading branch information
S-e-b-a-s committed Oct 2, 2024
1 parent a53cb00 commit 97d7e43
Show file tree
Hide file tree
Showing 152 changed files with 2,083 additions and 5,023 deletions.
69 changes: 36 additions & 33 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,51 @@
name: Deploy React App

on:
push:
branches:
- dev # Adjust this to your main branch
push:
branches:
- dev # Adjust this to your main branch

jobs:
deploy:
runs-on: dev
deploy:
runs-on: dev
defaults:
run:
working-directory: ./frontend

steps:
- name: Checkout repository
uses: actions/checkout@v2
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18.17.1' # Adjust this to your required Node version
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "18.17.1" # Adjust this to your required Node version

- name: Install Pnpm
run: npm install -g pnpm
- name: Install Pnpm
run: npm install -g pnpm

- name: Install dependencies
run: pnpm install
- name: Install dependencies
run: pnpm install

- name: Format code
run: pnpm format
- name: Format code
run: pnpm format

- name: Lint code
run: pnpm oxlint
- name: Lint code
run: pnpm oxlint

- name: Run tests
run: pnpm run test
- name: Run tests
run: pnpm run test

- name: Build project
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
run: NODE_OPTIONS="--max-old-space-size=4096" pnpm run build
- name: Build project
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
run: NODE_OPTIONS="--max-old-space-size=4096" pnpm run build

- name: Postbuild project
run: pnpm run postbuild
- name: Postbuild project
run: pnpm run postbuild

- name: Deploy to server
run: |
rm -rf /var/www/INSIGHTS/dist/*
cp -r ./dist/* /var/www/INSIGHTS/dist
sudo systemctl restart nginx
- name: Deploy to server
run: |
rm -rf /var/www/INSIGHTS/frontend/dist/*
cp -r ./frontend/dist/* /var/www/INSIGHTS/frontend/dist
sudo systemctl restart nginx
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@ backup*

# Coverage files
.coverage

stats.html
start.sh
1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

Binary file added INSIGHTSAPI/static/test/Test_banner.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
2 changes: 2 additions & 0 deletions frontend/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions package.json → frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@testing-library/user-event": "^14.5.2",
"@types/react": "^18.3.5",
"@vitejs/plugin-react": "^4.3.1",
"@vitest/ui": "^2.1.1",
"jsdom": "^25.0.0",
"oxlint": "^0.9.5",
"prettier": "^3.3.3",
Expand Down
83 changes: 81 additions & 2 deletions pnpm-lock.yaml → frontend/pnpm-lock.yaml

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

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,42 @@ describe('AddImagesCarouselDialog Component', () => {
expect(screen.getByText('Actualizar')).toBeInTheDocument();
});

it('handles form submission with valid data', async () => {
it('handles form submission with valid data using mocked FilePond', async () => {
getApiUrl.mockReturnValue({ apiUrl: 'http://localhost/' });
handleError.mockResolvedValue();

screen.debug();
// Render your component
render(<AddImagesCarouselDialog {...defaultProps} />);

// Simulate opening the dropdown
// Simulate opening the dropdown (for "position" field)
const positionInput = screen.getByLabelText(/Posición/i);
fireEvent.mouseDown(positionInput);

fireEvent.mouseDown(positionInput); // Open the dropdown

// Find the dropdown list within the document
const listbox = within(screen.getByRole('listbox'));

// Select the first option (e.g., value "1")
const firstOption = listbox.getByText('1');
fireEvent.click(firstOption);

// Directly access the input using container.querySelector
const fileInput = screen.getByTestId('filepond-input'); // Use testid from the mock
fireEvent.click(firstOption);

// Now, add the file using the mocked FilePond input
const fileInput = screen.getByTestId('filepond-input');
const file = new File(['dummy content'], 'example.png', {
type: 'image/png',
});

fireEvent.change(fileInput, { target: { files: [file] } });

// Add a console log to inspect the form elements
const form = screen.getByRole('form');

Check failure on line 84 in frontend/src/__test__/AddImagesCarouselDialog.test.jsx

View workflow job for this annotation

GitHub Actions / deploy

src/__test__/AddImagesCarouselDialog.test.jsx > AddImagesCarouselDialog Component > handles form submission with valid data using mocked FilePond

TestingLibraryElementError: Unable to find an accessible element with the role "form" Here are the accessible roles: presentation: Name "": <form class="MuiDialog-root MuiModal-root css-zw3mfo-MuiModal-root-MuiDialog-root" role="presentation" /> Name "": <div class="MuiDialog-container MuiDialog-scrollPaper css-hz1bth-MuiDialog-container" role="presentation" style="opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;" tabindex="-1" /> -------------------------------------------------- dialog: Name "": <div aria-labelledby=":r4:" class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation24 MuiDialog-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthMd MuiDialog-paperFullWidth css-rnmm7m-MuiPaper-root-MuiDialog-paper" role="dialog" /> -------------------------------------------------- heading: Name "Actualizar imagenes": <h4 class="MuiTypography-root MuiTypography-h4 css-5lbw0b-MuiTypography-root" /> -------------------------------------------------- paragraph: Name "": <p class="MuiTypography-root MuiDialogContentText-root MuiTypography-body1 MuiDialogContentText-root css-x9qjxg-MuiTypography-root-MuiDialogContentText-root" id="alert-dialog-slide-description" /> -------------------------------------------------- checkbox: Name "¿La imagen debería redireccionar a un link?": <input class="PrivateSwitchBase-input css-1m9pwf3" data-indeterminate="false" type="checkbox" /> -------------------------------------------------- combobox: Name "Posición": <div aria-controls=":r7:" aria-expanded="false" aria-haspopup="listbox" aria-labelledby="position-label position" class="MuiSelect-select MuiSelect-outlined MuiInputBase-input MuiOutlinedInput-input css-11u53oe-MuiSelect-select-MuiInputBase-input-MuiOutlinedInput-input" id="position" role="combobox" tabindex="0" /> -------------------------------------------------- button: Name "Cancelar": <button class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary css-sghohy-MuiButtonBase-root-MuiButton-root" tabindex="0" type="button" /> Name "Actualizar": <button class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary css-sghohy-MuiButtonBase-root-MuiButton-root" tabindex="0" type="submit" /> --------------------------------------------------presentation: Name "": <div class="MuiPopover-root MuiMenu-root MuiModal-root css-10nakn3-MuiModal-root-MuiPopover-root-MuiMenu-root" id="menu-position" role="presentation" /> -------------------------------------------------- listbox: Name "Posición": <ul aria-labelledby="position-label" class="MuiList-root MuiList-padding MuiMenu-list css-6hp17o-MuiList-root-MuiMenu-list" id=":r7:" role="listbox" tabindex="-1" /> -------------------------------------------------- option: Name "1": <li aria-selected="true" class="MuiButtonBase-root MuiMenuItem-root MuiMenuItem-gutters Mui-selected MuiMenuItem-root MuiMenuItem-gutters Mui-selected css-kk1bwy-MuiButtonBase-root-MuiMenuItem-root" data-value="1" role="option" tabindex="0" /> Name "2": <li aria-selected="false" class="MuiButtonBase-root MuiMenuItem-root MuiMenuItem-gutters MuiMenuItem-root MuiMenuItem-gutters css-kk1bwy-MuiButtonBase-root-MuiMenuItem-root" data-value="2" role="option" tabindex="-1" /> Name
console.log(form);

// Submit the form
const submitButton = screen.getByText('Actualizar');
fireEvent.click(submitButton);

// Assert form submission behavior
expect(mockSetOpenAddDialog).toHaveBeenCalledWith(false);
});

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 97d7e43

Please sign in to comment.