From f7ee88be16829c11bb877792ca83e047f6a5222e Mon Sep 17 00:00:00 2001 From: Iacopo Leardini Date: Fri, 10 Nov 2023 11:20:40 +0100 Subject: [PATCH 1/5] Add prettier to generate-fixtures script in package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6cf002132..4ca597e91 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "translate": "i18next-scanner", "generate-schema": ". ./.env.development; npx openapi-typescript $REACT_APP_API_URL/reference/ --output src/utils/schema.ts ", "generate-api": ". ./.env.development; API_URL=$REACT_APP_API_URL/reference/ npx @rtk-query/codegen-openapi src/services/tryberApi/config.ts", - "generate-fixtures": ". ./.env.development; API_URL=$REACT_APP_API_URL/reference/; npx @appquality/fixture-generator -u $API_URL" + "generate-fixtures": ". ./.env.development; API_URL=$REACT_APP_API_URL/reference/; npx @appquality/fixture-generator -u $API_URL && npx prettier --write 'cypress/fixtures/**/*.json'" }, "eslintConfig": { "extends": [ From bd65ef4efb2c1b77694eaae41860af8dc41e6857 Mon Sep 17 00:00:00 2001 From: Iacopo Leardini Date: Tue, 14 Nov 2023 16:37:17 +0100 Subject: [PATCH 2/5] chore: update fixture --- .../e2e/wallet/payment_requests.spec.cy.ts | 24 +++++++++---------- ...0_user_subscriber_onboarding_complete.json | 10 ++++++++ .../_post/{200.json => 200_Example_1.json} | 0 .../me/payments/_post/403_unauthorized.json | 3 +++ 4 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 cypress/fixtures/users/me/_get/200_user_subscriber_onboarding_complete.json rename cypress/fixtures/users/me/payments/_post/{200.json => 200_Example_1.json} (100%) create mode 100644 cypress/fixtures/users/me/payments/_post/403_unauthorized.json diff --git a/cypress/e2e/wallet/payment_requests.spec.cy.ts b/cypress/e2e/wallet/payment_requests.spec.cy.ts index 5f3cc6d3b..a9fdcb1ed 100644 --- a/cypress/e2e/wallet/payment_requests.spec.cy.ts +++ b/cypress/e2e/wallet/payment_requests.spec.cy.ts @@ -198,7 +198,7 @@ describe("Payment request", () => { `${Cypress.env("REACT_APP_API_URL")}/users/me/payments`, { statusCode: 200, - fixture: "users/me/payments/_post/200", + fixture: "users/me/payments/_post/200_Example_1", } ).as("postUserMePayment"); @@ -244,7 +244,7 @@ describe("Payment request", () => { { delayMs: 4000, statusCode: 200, - fixture: "users/me/payments/_post/200", + fixture: "users/me/payments/_post/200_Example_1", } ).as("postUserMePayment"); }); @@ -263,7 +263,7 @@ describe("Payment request", () => { `${Cypress.env("REACT_APP_API_URL")}/users/me/payments`, { statusCode: 200, - fixture: "users/me/payments/_post/200", + fixture: "users/me/payments/_post/200_Example_1", } ).as("postUserMePayment"); }); @@ -328,7 +328,7 @@ describe("Payment request", () => { `${Cypress.env("REACT_APP_API_URL")}/users/me/payments`, { statusCode: 403, - fixture: "users/me/payments/_post/200", + fixture: "users/me/payments/_post/200_Example_1", } ).as("postUserMePayment"); }); @@ -349,7 +349,7 @@ describe("Payment request", () => { `${Cypress.env("REACT_APP_API_URL")}/users/me/payments`, { statusCode: 200, - fixture: "users/me/payments/_post/200", + fixture: "users/me/payments/_post/200_Example_1", } ).as("postUserMePayment"); @@ -617,7 +617,7 @@ describe("Payment request", () => { `${Cypress.env("REACT_APP_API_URL")}/users/me/payments`, { statusCode: 200, - fixture: "users/me/payments/_post/200", + fixture: "users/me/payments/_post/200_Example_1", } ).as("postUserMePayment"); cy.dataQa("request-payment-cta").click(); @@ -681,7 +681,7 @@ describe("Payment request", () => { { delayMs: 4000, statusCode: 200, - fixture: "users/me/payments/_post/200", + fixture: "users/me/payments/_post/200_Example_1", } ).as("postUserMePayment"); }); @@ -700,7 +700,7 @@ describe("Payment request", () => { `${Cypress.env("REACT_APP_API_URL")}/users/me/payments`, { statusCode: 200, - fixture: "users/me/payments/_post/200", + fixture: "users/me/payments/_post/200_Example_1", } ).as("postUserMePayment"); }); @@ -766,7 +766,7 @@ describe("Payment request", () => { `${Cypress.env("REACT_APP_API_URL")}/users/me/payments`, { statusCode: 403, - fixture: "users/me/payments/_post/200", + fixture: "users/me/payments/_post/200_Example_1", } ).as("postUserMePayment"); }); @@ -830,7 +830,7 @@ describe("Payment request", () => { { delayMs: 4000, statusCode: 200, - fixture: "users/me/payments/_post/200", + fixture: "users/me/payments/_post/200_Example_1", } ).as("postUserMePayment"); }); @@ -849,7 +849,7 @@ describe("Payment request", () => { `${Cypress.env("REACT_APP_API_URL")}/users/me/payments`, { statusCode: 200, - fixture: "users/me/payments/_post/200", + fixture: "users/me/payments/_post/200_Example_1", } ).as("postUserMePayment"); }); @@ -915,7 +915,7 @@ describe("Payment request", () => { `${Cypress.env("REACT_APP_API_URL")}/users/me/payments`, { statusCode: 403, - fixture: "users/me/payments/_post/200", + fixture: "users/me/payments/_post/200_Example_1", } ).as("postUserMePayment"); }); diff --git a/cypress/fixtures/users/me/_get/200_user_subscriber_onboarding_complete.json b/cypress/fixtures/users/me/_get/200_user_subscriber_onboarding_complete.json new file mode 100644 index 000000000..2d33aa1b1 --- /dev/null +++ b/cypress/fixtures/users/me/_get/200_user_subscriber_onboarding_complete.json @@ -0,0 +1,10 @@ +{ + "id": 11110, + "name": "Name", + "surname": "Surname", + "email": "name.surname@mail.com", + "wp_user_id": 11111, + "onboarding_completed": true, + "image": "https://secure.gravatar.com/avatar/087ada6e86cf8ec31a49217dd05b7151?s=132&d=https%3A%2F%2Feu.ui-avatars.com%2Fapi%2Fi%2Bl%2F132&r=x", + "role": "subscriber" +} diff --git a/cypress/fixtures/users/me/payments/_post/200.json b/cypress/fixtures/users/me/payments/_post/200_Example_1.json similarity index 100% rename from cypress/fixtures/users/me/payments/_post/200.json rename to cypress/fixtures/users/me/payments/_post/200_Example_1.json diff --git a/cypress/fixtures/users/me/payments/_post/403_unauthorized.json b/cypress/fixtures/users/me/payments/_post/403_unauthorized.json new file mode 100644 index 000000000..f98251d15 --- /dev/null +++ b/cypress/fixtures/users/me/payments/_post/403_unauthorized.json @@ -0,0 +1,3 @@ +{ + "message": "Not Authorized." +} From 80473b7a0508cf1bebffccc0c300a2be8aa72f63 Mon Sep 17 00:00:00 2001 From: Iacopo Leardini Date: Tue, 14 Nov 2023 17:50:52 +0100 Subject: [PATCH 3/5] Fix route names in TesterSidebar --- src/features/TesterSidebar/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/features/TesterSidebar/index.tsx b/src/features/TesterSidebar/index.tsx index 6a189f11a..1d4050963 100644 --- a/src/features/TesterSidebar/index.tsx +++ b/src/features/TesterSidebar/index.tsx @@ -109,7 +109,7 @@ const TesterSidebar = ({ route, children }: TesterSidebarProps) => { i18next.language === "en" ? "" : "/" + i18next.language }/personal-equipment/`, icon: , - active: route === "personal-equipments", + active: route === "personal-equipment", text: t("Devices"), last: true, }, @@ -118,7 +118,7 @@ const TesterSidebar = ({ route, children }: TesterSidebarProps) => { i18next.language === "en" ? "" : "/" + i18next.language }/payments/`, icon: , - active: route === "Payments", + active: route === "payments", text: t("Payments"), }, { From 2c9ddbb0d9ce40bdbd7f8a08e9904271156ace40 Mon Sep 17 00:00:00 2001 From: Iacopo Leardini Date: Mon, 20 Nov 2023 16:46:04 +0100 Subject: [PATCH 4/5] playwright github action --- .github/workflows/e2e.yml | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 8026fc6d2..49087ca6d 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -1,20 +1,30 @@ -name: "Run tests" +name: Run Tests on: + push: + branches: [main, master] pull_request: workflow_dispatch: jobs: - install: + test: + timeout-minutes: 60 runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: "Install Node" - uses: actions/setup-node@v3 + - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 18 - name: Install dependencies run: | echo //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} > .npmrc - yarn - - name: "Run Test" - run: yarn test:e2e + npm install -g yarn && yarn + - name: Install Playwright Browsers + run: yarn playwright install --with-deps + - name: Run Playwright tests + run: yarn playwright test + - uses: actions/upload-artifact@v3 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 From 49536384a792800bdd8422d88fe752e27da28ad8 Mon Sep 17 00:00:00 2001 From: Davide Bizzi Date: Thu, 23 Nov 2023 15:46:36 +0100 Subject: [PATCH 5/5] fix: Use rtk instead of selectors for leaderboard --- .../RankingTables/MyRankingTable/index.tsx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/pages/Ranking/RankingTables/MyRankingTable/index.tsx b/src/pages/Ranking/RankingTables/MyRankingTable/index.tsx index aa662bebc..622d287ba 100644 --- a/src/pages/Ranking/RankingTables/MyRankingTable/index.tsx +++ b/src/pages/Ranking/RankingTables/MyRankingTable/index.tsx @@ -5,17 +5,19 @@ import { } from "@appquality/appquality-design-system"; import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; -import { RankingColumns } from "../columns"; -import starIcon from "src/pages/Ranking/assets/star.svg"; import { shallowEqual, useSelector } from "react-redux"; +import starIcon from "src/pages/Ranking/assets/star.svg"; +import { useGetUsersMeQuery } from "src/services/tryberApi"; import getGravatarUrlWithColoredFallbackInitials from "../../../../utils/getGravatarUrlWithThemedFallbackInitials"; import { rankingTheme } from "../../rankingTheme"; -import { TopTitle } from "../TopTitle"; +import { RankingColumns } from "../columns"; import { StyledAvatar, StyledExp, StyledRanking } from "../style"; +import { TopTitle } from "../TopTitle"; export const MyRankingTable = () => { const { t } = useTranslation(); - const [columns, setcolumns] = useState(RankingColumns(t)); + const { data: user } = useGetUsersMeQuery({}); + const [columns] = useState(RankingColumns(t)); const [rows, setRows] = useState([]); const peers = useSelector( @@ -27,10 +29,7 @@ export const MyRankingTable = () => { shallowEqual ); - const userId = useSelector( - (state: GeneralState) => state.user.user.id, - shallowEqual - ); + const userId = user ? user.id : undefined; const level = useSelector( (state: GeneralState) => state.ranking.summary?.level, @@ -80,7 +79,7 @@ export const MyRankingTable = () => { }; }) ); - }, [peers]); + }, [peers, level?.id, userId]); return (