From 06887c7eeceb7e59206e24dd9a55e6b2cfc5283d Mon Sep 17 00:00:00 2001 From: Kim Lan Phan Hoang Date: Thu, 9 Nov 2023 17:27:38 +0100 Subject: [PATCH] feat: redirects to account for profile (#403) --- .github/workflows/deploy-dev.yml | 3 ++- .github/workflows/deploy-prod.yml | 3 ++- .github/workflows/deploy-stage.yml | 3 ++- cypress.config.ts | 2 ++ cypress/e2e/header.cy.ts | 4 ++-- cypress/support/constants.ts | 4 ---- cypress/support/server.ts | 6 +----- src/config/constants.ts | 2 -- src/config/env.ts | 3 +++ src/env.d.ts | 4 ++++ src/modules/userSwitch/UserSwitchWrapper.tsx | 5 +++-- 11 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 9eaa3d05..edcef3e0 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -29,10 +29,11 @@ jobs: VITE_VERSION: ${{ github.sha }} VITE_GRAASP_DOMAIN: ${{ vars.VITE_GRAASP_DOMAIN }} VITE_GRAASP_API_HOST: ${{ vars.VITE_GRAASP_API_HOST }} + VITE_GRAASP_ACCOUNT_HOST: ${{ vars.VITE_GRAASP_ACCOUNT_HOST }} + VITE_GRAASP_ANALYTICS_HOST: ${{ vars.VITE_GRAASP_ANALYTICS_HOST }} VITE_GRAASP_AUTH_HOST: ${{ vars.VITE_GRAASP_AUTH_HOST }} VITE_GRAASP_BUILDER_HOST: ${{ vars.VITE_GRAASP_BUILDER_HOST }} VITE_GRAASP_LIBRARY_HOST: ${{ vars.VITE_GRAASP_LIBRARY_HOST }} - VITE_GRAASP_ANALYTICS_HOST: ${{ vars.VITE_GRAASP_ANALYTICS_HOST }} VITE_GRAASP_ASSETS_URL: ${{ vars.VITE_GRAASP_ASSETS_URL }} VITE_GRAASP_H5P_INTEGRATION_URL: ${{ secrets.VITE_GRAASP_H5P_INTEGRATION_URL }} VITE_SENTRY_ENV: ${{ vars.VITE_SENTRY_ENV }} diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index 33fd3c85..7ef5ae0a 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -32,10 +32,11 @@ jobs: VITE_VERSION: ${{ github.event.client_payload.tag }} VITE_GRAASP_DOMAIN: ${{ vars.VITE_GRAASP_DOMAIN }} VITE_GRAASP_API_HOST: ${{ vars.VITE_GRAASP_API_HOST }} + VITE_GRAASP_ACCOUNT_HOST: ${{ vars.VITE_GRAASP_ACCOUNT_HOST }} + VITE_GRAASP_ANALYTICS_HOST: ${{ vars.VITE_GRAASP_ANALYTICS_HOST }} VITE_GRAASP_AUTH_HOST: ${{ vars.VITE_GRAASP_AUTH_HOST }} VITE_GRAASP_BUILDER_HOST: ${{ vars.VITE_GRAASP_BUILDER_HOST }} VITE_GRAASP_LIBRARY_HOST: ${{ vars.VITE_GRAASP_LIBRARY_HOST }} - VITE_GRAASP_ANALYTICS_HOST: ${{ vars.VITE_GRAASP_ANALYTICS_HOST }} VITE_GRAASP_ASSETS_URL: ${{ vars.VITE_GRAASP_ASSETS_URL }} VITE_GRAASP_H5P_INTEGRATION_URL: ${{ secrets.VITE_GRAASP_H5P_INTEGRATION_URL }} VITE_SENTRY_ENV: ${{ vars.VITE_SENTRY_ENV }} diff --git a/.github/workflows/deploy-stage.yml b/.github/workflows/deploy-stage.yml index 0878281d..d0eec627 100644 --- a/.github/workflows/deploy-stage.yml +++ b/.github/workflows/deploy-stage.yml @@ -32,10 +32,11 @@ jobs: VITE_VERSION: ${{ github.event.client_payload.tag }} VITE_GRAASP_DOMAIN: ${{ vars.VITE_GRAASP_DOMAIN }} VITE_GRAASP_API_HOST: ${{ vars.VITE_GRAASP_API_HOST }} + VITE_GRAASP_ACCOUNT_HOST: ${{ vars.VITE_GRAASP_ACCOUNT_HOST }} + VITE_GRAASP_ANALYTICS_HOST: ${{ vars.VITE_GRAASP_ANALYTICS_HOST }} VITE_GRAASP_AUTH_HOST: ${{ vars.VITE_GRAASP_AUTH_HOST }} VITE_GRAASP_BUILDER_HOST: ${{ vars.VITE_GRAASP_BUILDER_HOST }} VITE_GRAASP_LIBRARY_HOST: ${{ vars.VITE_GRAASP_LIBRARY_HOST }} - VITE_GRAASP_ANALYTICS_HOST: ${{ vars.VITE_GRAASP_ANALYTICS_HOST }} VITE_GRAASP_ASSETS_URL: ${{ vars.VITE_GRAASP_ASSETS_URL }} VITE_GRAASP_H5P_INTEGRATION_URL: ${{ secrets.VITE_GRAASP_H5P_INTEGRATION_URL }} VITE_SENTRY_ENV: ${{ vars.VITE_SENTRY_ENV }} diff --git a/cypress.config.ts b/cypress.config.ts index d057b5bc..c538b499 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -16,6 +16,8 @@ export default defineConfig({ API_HOST: process.env.VITE_GRAASP_API_HOST || 'http://localhost:3000', AUTHENTICATION_HOST: process.env.VITE_GRAASP_AUTH_HOST || 'http://localhost:3001', + ACCOUNT_HOST: + process.env.VITE_GRAASP_ACCOUNT_HOST || 'http://localhost:3114', }, e2e: { baseUrl: `http://localhost:${process.env.VITE_PORT || 3112}`, diff --git a/cypress/e2e/header.cy.ts b/cypress/e2e/header.cy.ts index c87ae037..023e7b02 100644 --- a/cypress/e2e/header.cy.ts +++ b/cypress/e2e/header.cy.ts @@ -4,7 +4,7 @@ import { HEADER_MEMBER_MENU_SEE_PROFILE_BUTTON_ID, HEADER_MEMBER_MENU_SIGN_OUT_BUTTON_ID, } from '../../src/config/selectors'; -import { MEMBER_PROFILE_PATH, SIGN_IN_PATH } from '../support/constants'; +import { SIGN_IN_PATH } from '../support/constants'; // catch hook warning from react Cypress.on('uncaught:exception', (err) => { @@ -25,7 +25,7 @@ describe('Header', () => { cy.get(`#${HEADER_MEMBER_MENU_BUTTON_ID}`).click(); cy.get(`#${HEADER_MEMBER_MENU_SEE_PROFILE_BUTTON_ID}`).click(); cy.wait('@goToMemberProfile'); - cy.url().should('equal', MEMBER_PROFILE_PATH); + cy.url().should('contain', Cypress.env('ACCOUNT_HOST')); }); // todo: not available currently because cookie is httpOnly diff --git a/cypress/support/constants.ts b/cypress/support/constants.ts index db9b6b5f..2d61dfca 100644 --- a/cypress/support/constants.ts +++ b/cypress/support/constants.ts @@ -3,10 +3,6 @@ import { buildSignInPath } from '@graasp/sdk'; // eslint-disable-next-line import/prefer-default-export export const LOAD_FOLDER_CONTENT_PAUSE = 2000; -export const MEMBER_PROFILE_PATH = `${Cypress.env( - 'GRAASP_COMPOSE_HOST', -)}/profile`; - export const SIGN_IN_PATH = buildSignInPath({ host: Cypress.env('AUTHENTICATION_HOST'), }); diff --git a/cypress/support/server.ts b/cypress/support/server.ts index d83bc0a1..d322b599 100644 --- a/cypress/support/server.ts +++ b/cypress/support/server.ts @@ -34,10 +34,6 @@ import { parseStringToRegExp, } from './utils'; -export const MEMBER_PROFILE_PATH = `${Cypress.env( - 'GRAASP_COMPOSE_HOST', -)}/profile`; - const { buildDownloadFilesRoute, buildGetItemChatRoute, @@ -577,7 +573,7 @@ export const mockProfilePage = (): void => { cy.intercept( { method: DEFAULT_GET.method, - url: MEMBER_PROFILE_PATH, + url: Cypress.env('ACCOUNT_HOST'), }, ({ reply }) => { reply(redirectionReply); diff --git a/src/config/constants.ts b/src/config/constants.ts index ebb499e4..d37dcdd3 100644 --- a/src/config/constants.ts +++ b/src/config/constants.ts @@ -33,8 +33,6 @@ export const DESCRIPTION_MAX_LENGTH = 130; // TODO: SIGN_IN_PATH should be clearly typed as an URL object to avoid confusion with routes export const SIGN_IN_PATH = buildSignInPath({ host: AUTHENTICATION_HOST }); -export const MEMBER_PROFILE_PATH = `${GRAASP_BUILDER_HOST}/profile`; - export const HOST_MAP = { [Context.Builder]: GRAASP_BUILDER_HOST, [Context.Library]: GRAASP_LIBRARY_HOST, diff --git a/src/config/env.ts b/src/config/env.ts index b5bde157..bba7a4ef 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -17,6 +17,9 @@ export const GRAASP_BUILDER_HOST = export const GRAASP_LIBRARY_HOST = import.meta.env.VITE_GRAASP_LIBRARY_HOST || 'http://localhost:3005'; +export const GRAASP_ACCOUNT_HOST = + import.meta.env.VITE_GRAASP_ACCOUNT_HOST || 'http://localhost:3114'; + export const GRAASP_ANALYTICS_HOST = import.meta.env.VITE_GRAASP_ANALYTICS_HOST || 'http://localhost:3012'; diff --git a/src/env.d.ts b/src/env.d.ts index 2cb8ac6c..9bb011dc 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -5,6 +5,10 @@ interface ImportMetaEnv { readonly VITE_PORT: number; readonly VITE_SHOW_NOTIFICATIONS: string; readonly VITE_GRAASP_AUTH_HOST: string; + readonly VITE_GRAASP_BUILDER_HOST: string; + readonly VITE_GRAASP_LIBRARY_HOST: string; + readonly VITE_GRAASP_ACCOUNT_HOST: string; + readonly VITE_GRAASP_AUTH_HOST: string; readonly VITE_GRAASP_H5P_INTEGRATION_URL: string; readonly VITE_SENTRY_ENV: string; readonly VITE_SENTRY_DSN: string; diff --git a/src/modules/userSwitch/UserSwitchWrapper.tsx b/src/modules/userSwitch/UserSwitchWrapper.tsx index 1fec22cf..c767b9ab 100644 --- a/src/modules/userSwitch/UserSwitchWrapper.tsx +++ b/src/modules/userSwitch/UserSwitchWrapper.tsx @@ -1,7 +1,8 @@ import { CompleteMember } from '@graasp/sdk'; import { UserSwitchWrapper as GraaspUserSwitch } from '@graasp/ui'; -import { MEMBER_PROFILE_PATH, SIGN_IN_PATH } from '@/config/constants'; +import { SIGN_IN_PATH } from '@/config/constants'; +import { GRAASP_ACCOUNT_HOST } from '@/config/env'; import { mutations } from '@/config/queryClient'; import { HEADER_MEMBER_MENU_BUTTON_ID, @@ -44,7 +45,7 @@ const UserSwitchWrapper = ({ currentMember={member} userMenuItems={[]} isCurrentMemberLoading={isLoading} - profilePath={MEMBER_PROFILE_PATH} + profilePath={GRAASP_ACCOUNT_HOST} redirectPath={redirectUrl.toString()} buttonId={HEADER_MEMBER_MENU_BUTTON_ID} signInMenuItemId={HEADER_MEMBER_MENU_SIGN_IN_BUTTON_ID}