diff --git a/.github/workflows/chromatic.yaml b/.github/workflows/chromatic similarity index 100% rename from .github/workflows/chromatic.yaml rename to .github/workflows/chromatic diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..23e8223 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,50 @@ +name: "Deploy to Github Pages" + +on: + push: + branches: + - develop + - main + +permissions: + contents: read + pages: write + id-token: write + +jobs: + lint_and_test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "npm" + - run: npm ci + - run: npm run lint + - run: npm run test + + build_and_deploy: + runs-on: ubuntu-latest + needs: lint_and_test + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "npm" + - run: npm ci + - uses: actions/configure-pages@v3 + - run: npm run build + - uses: actions/upload-pages-artifact@v2 + with: + path: ./dist/ + - name: Deploy to GH pages + id: deployment + uses: actions/deploy-pages@v1 diff --git a/package.json b/package.json index 1a45654..0bdbe37 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "private": true, "version": "0.0.0", "type": "module", + "homepage": "https://calcagnoloic.github.io/ecommerce-sneakers/", "scripts": { "dev": "vite", "dev:format": "prettier --write .", diff --git a/src/components/Counter/index.spec.tsx b/src/components/Counter/index.spec.tsx deleted file mode 100644 index cd8ced2..0000000 --- a/src/components/Counter/index.spec.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { render, screen } from "@testing-library/react"; -import Counter from "."; -import userEvent from "@testing-library/user-event"; -import { vi } from "vitest"; -import { BasketProvider } from "../../context/Basket/BasketContext"; - -describe("Counter Component Suite Test", () => { - it("should be modify the counter value if user click on quantity button", async () => { - const setOnClicMock = vi.fn(); - - render( - - - , - ); - - expect(setOnClicMock()).toHaveBeenCalledWith("add"); - - const counterText = await screen.findByRole("paragraph", { name: "1" }); - expect(counterText).toBeInTheDocument(); - }); -}); diff --git a/src/components/Dropdown/BasketDropdown/index.spec.tsx b/src/components/Dropdown/BasketDropdown/index.spec.tsx index 3f8bd5b..d1cd0c8 100644 --- a/src/components/Dropdown/BasketDropdown/index.spec.tsx +++ b/src/components/Dropdown/BasketDropdown/index.spec.tsx @@ -14,22 +14,6 @@ describe("Basket Dropdown Suite Test", () => { expect(getByText("Your cart is empty.")).toBeInTheDocument(); }); - /* it("should be display the basket content with items", async () => { - const { getByTestId } = render( - - - {}} /> - , - ); - - const quantityIconsPlus = getByTestId("plus-icon"); - userEvent.click(quantityIconsPlus); - - await waitFor(() => { - expect(screen.queryByText("Your cart is empty.")).toBeNull(); - }); - }); */ - it("should close the dropdown basket if user clicks outside", () => { const setIsOpenMock = vi.fn(); diff --git a/src/data/index.ts b/src/data/index.ts index eb94256..f6548ab 100644 --- a/src/data/index.ts +++ b/src/data/index.ts @@ -14,10 +14,10 @@ type NavBar = { }; export const images: carrouselImage[] = [ - { id: 1, value: "/assets/img/product-1.jpg", key: uuidv4() }, - { id: 2, value: "/assets/img/product-2.jpg", key: uuidv4() }, - { id: 3, value: "/assets/img/product-3.jpg", key: uuidv4() }, - { id: 4, value: "/assets/img/product-4.jpg", key: uuidv4() }, + { id: 1, value: "/ecommerce-sneakers/assets/img/product-1.jpg", key: uuidv4() }, + { id: 2, value: "/ecommerce-sneakers/assets/img/product-2.jpg", key: uuidv4() }, + { id: 3, value: "/ecommerce-sneakers/assets/img/product-3.jpg", key: uuidv4() }, + { id: 4, value: "/ecommerce-sneakers/assets/img/product-4.jpg", key: uuidv4() }, ]; export const namesItems: NavBar[] = [ diff --git a/vite.config.ts b/vite.config.ts index 27c9b75..7de7ba7 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -6,7 +6,8 @@ export default defineConfig({ plugins: [react()], test: { globals: true, - environment: 'jsdom', - setupFiles: './src/setup.ts', + environment: "jsdom", + setupFiles: "./src/setup.ts", }, + base: "/ecommerce-sneakers/", });