diff --git a/packages/login/__tests__/example.spec.ts b/packages/login/__tests__/example.spec.ts index abbc03b69f..2d25561473 100644 --- a/packages/login/__tests__/example.spec.ts +++ b/packages/login/__tests__/example.spec.ts @@ -1,7 +1,7 @@ -import { expect, test } from "@docspace/shared/__mocks__/e2e"; +import { expect, test } from "@playwright/test"; test("has title", async ({ page }) => { - await page.goto("http://192.168.0.16/login"); + await page.goto("http://192.168.0.16:5011/login"); // // Expect a title "to contain" a substring. // await expect(page).toHaveTitle(/Playwright/); diff --git a/packages/login/package.json b/packages/login/package.json index 744fb2849b..86d25203d1 100644 --- a/packages/login/package.json +++ b/packages/login/package.json @@ -11,6 +11,8 @@ "lint": "next lint", "clean": "shx rm -rf .next", "deploy": "shx --silent mkdir -p ../../../publish/web/login && shx --silent mkdir -p ../../../publish/web/login/.next && shx --silent mkdir -p ../../../publish/web/login/node_modules && shx --silent mkdir -p ../../../publish/web/login/.next/static && shx cp -r .next/standalone/node_modules/* ../../../publish/web/login/node_modules && shx cp -r .next/static/* ../../../publish/web/login/.next/static && shx cp -r .next/standalone/packages/login/.next/* ../../../publish/web/login/.next && shx cp -f server.prod.js ../../../publish/web/login/server.js", + "test:build": "node ./scripts/buildTranslations.js && TEST=true next build", + "test:start": "NODE_ENV=production TEST=true node server.js", "test:e2e": "npx playwright test", "test:e2e:ui": "npx playwright test --ui" }, diff --git a/packages/login/playwright.config.ts b/packages/login/playwright.config.ts index 3629bef19d..25d8ef93f8 100644 --- a/packages/login/playwright.config.ts +++ b/packages/login/playwright.config.ts @@ -70,9 +70,8 @@ export default defineConfig({ ], /* Run your local dev server before starting the tests */ - // webServer: { - // command: 'npm run start', - // url: 'http://127.0.0.1:3000', - // reuseExistingServer: !process.env.CI, - // }, + webServer: { + command: "yarn test:build && yarn test:start", + port: 5011, + }, }); diff --git a/packages/login/src/utils/actions.ts b/packages/login/src/utils/actions.ts index 126d3004b0..a0356dc362 100644 --- a/packages/login/src/utils/actions.ts +++ b/packages/login/src/utils/actions.ts @@ -53,6 +53,9 @@ import { } from "@/types"; import { TScope } from "@docspace/shared/utils/oauth/types"; import { transformToClientProps } from "@docspace/shared/utils/oauth"; +import { getMockSettingsResponse } from "@docspace/shared/__mocks__/e2e"; + +const IS_TEST = process.env.TEST; export const checkIsAuthenticated = async () => { const [request] = createRequest(["/authentication"], [["", ""]], "GET"); @@ -73,7 +76,9 @@ export async function getSettings() { "GET", ); - const settingsRes = await fetch(getSettings); + const settingsRes = IS_TEST + ? getMockSettingsResponse(true) + : await fetch(getSettings); if (settingsRes.status === 403) return `access-restricted`;