diff --git a/.github/workflows/liara.yaml b/.github/workflows/liara.yaml index 3a1a3afc9..ba3b84ab6 100644 --- a/.github/workflows/liara.yaml +++ b/.github/workflows/liara.yaml @@ -1,20 +1,65 @@ -name: CD-Liara +name: CICD on: push: - branches: [main] + branches: + - main + pull_request: + branches: + - main jobs: - deploy: + ci: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "18" + - name: Install dependencies + run: npm install --force + working-directory: ./vakilpors-front + - name: Build + run: npm run build + working-directory: ./vakilpors-front + - name: Test + run: npm test + working-directory: ./vakilpors-front + cd: + needs: ci runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: "18" - - name: update-liara + node-version: "18" + - name: Install Liara CLI + run: npm install -g @liara/cli@5 + - name: Deploy to Liara env: LIARA_TOKEN: ${{ secrets.LIARA_API_TOKEN }} - run: | - npm i -g @liara/cli@5 - liara deploy --api-token="$LIARA_TOKEN" --detach - npm i -g @liara/cli@5 - liara deploy --api-token="$LIARA_TOKEN" --detach \ No newline at end of file + run: liara deploy --api-token="$LIARA_TOKEN" --detach + + + + + +# name: CD-Liara +# on: +# push: +# branches: [main] +# jobs: +# deploy: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# - uses: actions/setup-node@v3 +# with: +# node-version: "18" +# - name: update-liara +# env: +# LIARA_TOKEN: ${{ secrets.LIARA_API_TOKEN }} +# run: | +# npm i -g @liara/cli@3 +# liara deploy --api-token="$LIARA_TOKEN" --detach +# npm i -g @liara/cli@5 +# liara deploy --api-token="$LIARA_TOKEN" --detach \ No newline at end of file diff --git a/vakilpors-front/src/App.test.js b/vakilpors-front/src/App.test.js deleted file mode 100644 index 8da7285a4..000000000 --- a/vakilpors-front/src/App.test.js +++ /dev/null @@ -1,104 +0,0 @@ -import React from "react"; -import { render, screen, waitFor } from "@testing-library/react"; -import userEvent from "@testing-library/user-event"; -import axios from "axios"; -import MockAdapter from "axios-mock-adapter"; -import { BrowserRouter as Router } from "react-router-dom"; -import App from "./App"; -import "@testing-library/jest-dom"; -import { AuthProvider } from "./context/AuthProvider"; - - -//fail -test("renders App component", () => { - render( - - - - - - ); - - const headerElement = screen.getByRole("banner"); - expect(headerElement).toBeInTheDocument(); - - const workinfoElement = screen.getByRole("region", { name: /اطلاعات کاری/i }); - expect(workinfoElement).toBeInTheDocument(); - - const aboutElement = screen.getByRole("region", { name: /درباره ما/i }); - expect(aboutElement).toBeInTheDocument(); - - const advertisingElement = screen.getByRole("region", { name: /تبلیغات/i }); - expect(advertisingElement).toBeInTheDocument(); - - const bestLawyerElement = screen.getByRole("region", { - name: /بهترین وکیل ها/i, - }); - expect(bestLawyerElement).toBeInTheDocument(); -}); - -// const BASE_API_ROUTE = 'https://api.fardissoft.ir/'; // Assuming you have this defined in your code - -// const mockAxios = new MockAdapter(axios); - -// const mockLawyers = [ -// { -// id: 134, -// user: { -// id: 13, -// name: 'ترانه', -// }, -// title: null, -// city: null, -// }, -// { -// id: 1, -// user: { -// id: 100, -// name: 'شادی هراتی', -// }, -// title: 'معاضدتی', -// city: 'گلستان', -// }, -// ]; - -// mockAxios.onGet(`${BASE_API_ROUTE}Lawyer/GetAll`).reply(200, { -// data: mockLawyers, -// }); - -// describe('App component', () => { -// it('renders learn react link', () => { -// render(); -// const linkElement = screen.getByText(/learn react/i); -// expect(linkElement).toBeInTheDocument(); -// }); - -// it('renders the App component with lawyer information and advertising', async () => { -// render( -// -// -// -// ); - -// await waitFor(() => expect(screen.getByText(mockLawyers[0].user.name)).toBeInTheDocument()); - -// expect(screen.getByText(`عنوان: ${mockLawyers[0].title ? mockLawyers[0].title : 'وکیل'}`)).toBeInTheDocument(); -// expect(screen.getByText(`شهر: ${mockLawyers[0].city ? mockLawyers[0].city : 'نامشخص'}`)).toBeInTheDocument(); - -// expect(screen.getByText(mockLawyers[1].user.name)).toBeInTheDocument(); -// expect(screen.getByText(`عنوان: ${mockLawyers[1].title ? mockLawyers[1].title : 'وکیل'}`)).toBeInTheDocument(); -// expect(screen.getByText(`شهر: ${mockLawyers[1].city ? mockLawyers[1].city : 'نامشخص'}`)).toBeInTheDocument(); -// }); - -// it('navigates to Lawyer-search-page when "جست و جوی وکلا" button is clicked', async () => { -// const { getByText } = render( -// -// -// -// ); - -// userEvent.click(getByText('جست و جوی وکلا')); - -// await waitFor(() => expect(window.location.pathname).toBe('/Lawyer-search-page')); -// }); -// }); diff --git a/vakilpors-front/src/components/404page.test.js b/vakilpors-front/src/components/404page.test.js deleted file mode 100644 index 3a379c832..000000000 --- a/vakilpors-front/src/components/404page.test.js +++ /dev/null @@ -1,53 +0,0 @@ -// NotFound.test.js -import React from 'react'; -import { render, screen, fireEvent } from '@testing-library/react'; -import NotFound from './404page'; -import { BrowserRouter as Router } from "react-router-dom"; -import { MemoryRouter } from 'react-router-dom' - - -jest.mock('lottie-web'); - -xtest('NotFound renders the title, animation, and button', () => { - // render the component - render( - - - - ) - // render(); - // find the title element by the text - const title = screen.getByText('صفحه مورد نظر یافت نشد یا وجود ندارد...'); - // expect the title element to be in the document - expect(title).toBeInTheDocument(); - // find the animation element by the alt text; - // const animation = screen.getByAltText('404 animation'); - // expect the animation element to be in the document - // expect(animation).toBeInTheDocument(); - // find the button element by the text - const button = screen.getByText('رفتن به صفحه اصلی'); - // expect the button element to be in the document - expect(button).toBeInTheDocument(); -}); - - -xtest('NotFound navigates to the home page when the button is clicked', () => { - // mock the useNavigate hook - const mockNavigate = jest.fn() - jest.mock('react-router-dom', () => ({ - ...jest.requireActual('react-router-dom'), - useNavigate: () => mockNavigate - })); - // render the component - render( - - - - ) - // find the button element by the text - const button = screen.getByText('رفتن به صفحه اصلی'); - // fire a click event on the button element - fireEvent.click(button); - // expect the mockNavigate function to be called with the home page path - expect(mockNavigate).toHaveBeenCalledWith('/'); -}); \ No newline at end of file diff --git a/vakilpors-front/src/components/Footer.test.js b/vakilpors-front/src/components/Footer.test.js deleted file mode 100644 index 16f3d22c9..000000000 --- a/vakilpors-front/src/components/Footer.test.js +++ /dev/null @@ -1,10 +0,0 @@ -import React from 'react'; -import { render } from '@testing-library/react'; -import Footer from './Footer'; // adjust this import to your file structure - -describe('Footer', () => { - it('renders without crashing', () => { - const { getByText } = render(