From 541068941b201d329c73508591c645ea46e794af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Calcagno=20Lo=C3=AFc?= <98493858+CalcagnoLoic@users.noreply.github.com> Date: Sat, 27 Jan 2024 11:55:50 +0100 Subject: [PATCH 1/6] writing workflow --- .../workflows/{chromatic.yaml => chromatic} | 0 .github/workflows/deploy.yaml | 21 ++++++++++++++++++ src/components/Counter/index.spec.tsx | 22 ------------------- .../Dropdown/BasketDropdown/index.spec.tsx | 16 -------------- 4 files changed, 21 insertions(+), 38 deletions(-) rename .github/workflows/{chromatic.yaml => chromatic} (100%) create mode 100644 .github/workflows/deploy.yaml delete mode 100644 src/components/Counter/index.spec.tsx 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..4997a91 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,21 @@ +name: "Deploy to Github Pages" + +on: + push: + branches: + - develop + - main + +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 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(); From 348c61a6189ea0e6362631580682eaa0425cecfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Calcagno=20Lo=C3=AFc?= <98493858+CalcagnoLoic@users.noreply.github.com> Date: Sat, 27 Jan 2024 12:02:24 +0100 Subject: [PATCH 2/6] writing workflow --- .github/workflows/deploy.yaml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 4997a91..23e8223 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -6,6 +6,11 @@ on: - develop - main +permissions: + contents: read + pages: write + id-token: write + jobs: lint_and_test: runs-on: ubuntu-latest @@ -19,3 +24,27 @@ jobs: - 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 From cb4068efb8543628121db8359cfa9e7118755f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Calcagno=20Lo=C3=AFc?= <98493858+CalcagnoLoic@users.noreply.github.com> Date: Sat, 27 Jan 2024 12:09:05 +0100 Subject: [PATCH 3/6] fix vite config --- package.json | 1 + vite.config.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) 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/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/", }); From 698bd94813696aa5c14461be98ab9facf0d3bf32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Calcagno=20Lo=C3=AFc?= <98493858+CalcagnoLoic@users.noreply.github.com> Date: Sat, 27 Jan 2024 12:23:55 +0100 Subject: [PATCH 4/6] fix workflow --- .github/workflows/deploy.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 23e8223..010ec4b 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -40,11 +40,11 @@ jobs: node-version: 20 cache: "npm" - run: npm ci - - uses: actions/configure-pages@v3 + - uses: actions/configure-pages@v4 - run: npm run build - - uses: actions/upload-pages-artifact@v2 + - uses: actions/upload-pages-artifact@v3 with: path: ./dist/ - name: Deploy to GH pages id: deployment - uses: actions/deploy-pages@v1 + uses: actions/deploy-pages@v3 From 174abff2f4b66131383ccc79da945d72b280af51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Calcagno=20Lo=C3=AFc?= <98493858+CalcagnoLoic@users.noreply.github.com> Date: Sat, 27 Jan 2024 12:26:22 +0100 Subject: [PATCH 5/6] fix data --- src/data/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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[] = [ From 0e6fa13abc7b6296fb2541c786213ecd1ca47882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Calcagno=20Lo=C3=AFc?= <98493858+CalcagnoLoic@users.noreply.github.com> Date: Sat, 27 Jan 2024 12:28:44 +0100 Subject: [PATCH 6/6] fix worfklow --- .github/workflows/deploy.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 010ec4b..23e8223 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -40,11 +40,11 @@ jobs: node-version: 20 cache: "npm" - run: npm ci - - uses: actions/configure-pages@v4 + - uses: actions/configure-pages@v3 - run: npm run build - - uses: actions/upload-pages-artifact@v3 + - uses: actions/upload-pages-artifact@v2 with: path: ./dist/ - name: Deploy to GH pages id: deployment - uses: actions/deploy-pages@v3 + uses: actions/deploy-pages@v1