diff --git a/apps/admin-x-demo/.gitignore b/apps/admin-x-demo/.gitignore index 1521c8b765..68565785a7 100644 --- a/apps/admin-x-demo/.gitignore +++ b/apps/admin-x-demo/.gitignore @@ -1 +1,3 @@ dist +playwright-report +test-results diff --git a/apps/admin-x-demo/index.html b/apps/admin-x-demo/index.html new file mode 100644 index 0000000000..60bd860b4a --- /dev/null +++ b/apps/admin-x-demo/index.html @@ -0,0 +1,13 @@ + + + + + + + AdminX Standalone + + +
+ + + diff --git a/apps/admin-x-demo/package.json b/apps/admin-x-demo/package.json index e686015eed..f4db53a8bc 100644 --- a/apps/admin-x-demo/package.json +++ b/apps/admin-x-demo/package.json @@ -12,7 +12,6 @@ "README.md", "dist/" ], - "type": "module", "main": "./dist/admin-x-demo.umd.cjs", "module": "./dist/admin-x-demo.js", "publishConfig": { @@ -23,11 +22,17 @@ "dev": "vite build --watch", "dev:start": "vite", "build": "tsc && vite build", - "lint": "yarn run lint:js", - "lint:js": "eslint --ext .js,.ts,.cjs,.tsx --cache src", + "lint": "yarn run lint:code && yarn run lint:test", + "lint:code": "eslint --ext .js,.ts,.cjs,.tsx --cache src", + "lint:test": "eslint -c test/.eslintrc.cjs --ext .js,.ts,.cjs,.tsx --cache test", + "test:unit": "yarn nx build && vitest run", + "test:acceptance": "NODE_OPTIONS='--experimental-specifier-resolution=node --no-warnings' VITE_TEST=true playwright test", + "test:acceptance:slowmo": "TIMEOUT=100000 PLAYWRIGHT_SLOWMO=100 yarn test:acceptance --headed", + "test:acceptance:full": "ALL_BROWSERS=1 yarn test:acceptance", "preview": "vite preview" }, "devDependencies": { + "@testing-library/react": "14.1.0", "@tryghost/admin-x-design-system": "0.0.0", "@tryghost/admin-x-framework": "0.0.0", "@types/react": "18.2.38", @@ -40,13 +45,25 @@ "build": { "dependsOn": [ "build", - {"projects": ["@tryghost/admin-x-design-system", "@tryghost/admin-x-framework"], "target": "build"} + { + "projects": [ + "@tryghost/admin-x-design-system", + "@tryghost/admin-x-framework" + ], + "target": "build" + } ] }, "test:acceptance": { "dependsOn": [ "test:acceptance", - {"projects": ["@tryghost/admin-x-design-system", "@tryghost/admin-x-framework"], "target": "build"} + { + "projects": [ + "@tryghost/admin-x-design-system", + "@tryghost/admin-x-framework" + ], + "target": "build" + } ] } } diff --git a/apps/admin-x-demo/playwright.config.mjs b/apps/admin-x-demo/playwright.config.mjs new file mode 100644 index 0000000000..04367c1d9e --- /dev/null +++ b/apps/admin-x-demo/playwright.config.mjs @@ -0,0 +1,3 @@ +import adminXPlaywrightConfig from '@tryghost/admin-x-framework/playwright'; + +export default adminXPlaywrightConfig(); diff --git a/apps/admin-x-demo/src/standalone.tsx b/apps/admin-x-demo/src/standalone.tsx new file mode 100644 index 0000000000..dd723c833c --- /dev/null +++ b/apps/admin-x-demo/src/standalone.tsx @@ -0,0 +1,5 @@ +import './styles/index.css'; +import App from './App.tsx'; +import renderStandaloneApp from '@tryghost/admin-x-framework/test/render'; + +renderStandaloneApp(App, {}); diff --git a/apps/admin-x-demo/test/.eslintrc.cjs b/apps/admin-x-demo/test/.eslintrc.cjs new file mode 100644 index 0000000000..42f8e77355 --- /dev/null +++ b/apps/admin-x-demo/test/.eslintrc.cjs @@ -0,0 +1,6 @@ +module.exports = { + plugins: ['ghost'], + extends: [ + 'plugin:ghost/ts-test' + ] +}; diff --git a/apps/admin-x-demo/test/acceptance/example.test.ts b/apps/admin-x-demo/test/acceptance/example.test.ts new file mode 100644 index 0000000000..a3b454c793 --- /dev/null +++ b/apps/admin-x-demo/test/acceptance/example.test.ts @@ -0,0 +1,18 @@ +import {expect, test} from '@playwright/test'; +import {mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; + +test.describe('Demo', async () => { + test('Renders the list page', async ({page}) => { + await mockApi({page, requests: { + browseSettings: { + method: 'GET', + path: /^\/settings\/\?group=/, + response: responseFixtures.settings + } + }}); + + await page.goto('/'); + + await expect(page.locator('body')).toContainText('AdminX Demo App'); + }); +}); diff --git a/apps/admin-x-demo/test/unit/example.test.tsx b/apps/admin-x-demo/test/unit/example.test.tsx new file mode 100644 index 0000000000..e84c756265 --- /dev/null +++ b/apps/admin-x-demo/test/unit/example.test.tsx @@ -0,0 +1,10 @@ +import ListPage from '../../src/ListPage'; +import {render, screen} from '@testing-library/react'; + +describe('Demo', function () { + it('renders a component', async function () { + render(); + + expect(screen.getAllByRole('heading')[0].textContent).toEqual('AdminX Demo App'); + }); +}); diff --git a/apps/admin-x-demo/tsconfig.json b/apps/admin-x-demo/tsconfig.json index 1ebb01c0f4..621d5ec558 100644 --- a/apps/admin-x-demo/tsconfig.json +++ b/apps/admin-x-demo/tsconfig.json @@ -19,5 +19,5 @@ "noUnusedParameters": true, "noFallthroughCasesInSwitch": true }, - "include": ["src"] + "include": ["src", "test"] } diff --git a/apps/admin-x-design-system/package.json b/apps/admin-x-design-system/package.json index 4fa649c4af..d8832c8be8 100644 --- a/apps/admin-x-design-system/package.json +++ b/apps/admin-x-design-system/package.json @@ -35,18 +35,19 @@ "@storybook/react": "7.5.3", "@storybook/react-vite": "7.5.3", "@storybook/testing-library": "0.2.2", + "@testing-library/react": "14.1.0", "@vitejs/plugin-react": "4.2.0", "c8": "8.0.1", "eslint-plugin-react-hooks": "4.6.0", "eslint-plugin-react-refresh": "0.4.3", "eslint-plugin-tailwindcss": "3.13.0", "mocha": "10.2.0", - "rollup-plugin-node-builtins": "2.1.2", - "sinon": "17.0.0", - "ts-node": "10.9.1", "react": "^18.2.0", "react-dom": "^18.2.0", + "rollup-plugin-node-builtins": "2.1.2", + "sinon": "17.0.0", "storybook": "7.5.3", + "ts-node": "10.9.1", "typescript": "5.3.2", "vite": "4.5.0", "vite-plugin-svgr": "3.3.0" diff --git a/apps/admin-x-framework/src/test/acceptance.ts b/apps/admin-x-framework/src/test/acceptance.ts index 1cd9848dbb..ab107c2a10 100644 --- a/apps/admin-x-framework/src/test/acceptance.ts +++ b/apps/admin-x-framework/src/test/acceptance.ts @@ -130,13 +130,6 @@ export function toggleLabsFlag(flag: string, value: boolean) { } } -export const globalDataRequests = { - browseSettings: {method: 'GET', path: /^\/settings\/\?group=/, response: responseFixtures.settings}, - browseConfig: {method: 'GET', path: '/config/', response: responseFixtures.config}, - browseSite: {method: 'GET', path: '/site/', response: responseFixtures.site}, - browseMe: {method: 'GET', path: '/users/me/?include=roles', response: responseFixtures.me} -}; - export const settingsWithStripe = updatedSettingsResponse([ {key: 'stripe_connect_publishable_key', value: 'pk_test_123'}, {key: 'stripe_connect_secret_key', value: 'sk_test_123'}, diff --git a/apps/admin-x-framework/src/test/render.tsx b/apps/admin-x-framework/src/test/render.tsx new file mode 100644 index 0000000000..e949ef6195 --- /dev/null +++ b/apps/admin-x-framework/src/test/render.tsx @@ -0,0 +1,59 @@ +import {DesignSystemAppProps} from '@tryghost/admin-x-design-system'; +import React from 'react'; +import ReactDOM from 'react-dom/client'; +import {TopLevelFrameworkProps} from '../providers/FrameworkProvider'; + +export default function renderStandaloneApp>( + App: React.ComponentType, + props: Props +) { + const style = document.createElement('style'); + style.appendChild(document.createTextNode(` + :root { + font-size: 62.5%; + line-height: 1.5; + -ms-text-size-adjust: 100%; + -webkit-text-size-adjust: 100%; + + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + -webkit-text-size-adjust: 100%; + } + + html, body, #root { + width: 100%; + height: 100%; + margin: 0; + letter-spacing: unset; + } + `)); + document.head.appendChild(style); + + ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( + + {}}} + framework={{ + externalNavigate: () => {}, + ghostVersion: '5.x', + sentryDSN: null, + unsplashConfig: { + Authorization: '', + 'Accept-Version': '', + 'Content-Type': '', + 'App-Pragma': '', + 'X-Unsplash-Cache': false + }, + onDelete: () => {}, + onInvalidate: () => {}, + onUpdate: () => {} + }} + {...props} + /> + + ); +} diff --git a/apps/admin-x-framework/test/unit/utils/api/hooks.test.tsx b/apps/admin-x-framework/test/unit/utils/api/hooks.test.tsx index 005f48165f..a94da1bbc4 100644 --- a/apps/admin-x-framework/test/unit/utils/api/hooks.test.tsx +++ b/apps/admin-x-framework/test/unit/utils/api/hooks.test.tsx @@ -15,7 +15,6 @@ const queryClient = new QueryClient({ const wrapper: React.FC<{ children: ReactNode }> = ({children}) => ( {}} ghostVersion='5.x' sentryDSN='' diff --git a/apps/admin-x-settings/package.json b/apps/admin-x-settings/package.json index a0c76c2090..eb66cb42eb 100644 --- a/apps/admin-x-settings/package.json +++ b/apps/admin-x-settings/package.json @@ -48,6 +48,7 @@ }, "devDependencies": { "@playwright/test": "1.38.1", + "@testing-library/react": "14.1.0", "@tryghost/admin-x-design-system": "0.0.0", "@tryghost/admin-x-framework": "0.0.0", "@types/react": "18.2.38", @@ -68,13 +69,25 @@ "build": { "dependsOn": [ "build", - {"projects": ["@tryghost/admin-x-design-system", "@tryghost/admin-x-framework"], "target": "build"} + { + "projects": [ + "@tryghost/admin-x-design-system", + "@tryghost/admin-x-framework" + ], + "target": "build" + } ] }, "test:acceptance": { "dependsOn": [ "test:acceptance", - {"projects": ["@tryghost/admin-x-design-system", "@tryghost/admin-x-framework"], "target": "build"} + { + "projects": [ + "@tryghost/admin-x-design-system", + "@tryghost/admin-x-framework" + ], + "target": "build" + } ] } } diff --git a/apps/admin-x-settings/test/acceptance/advanced/codeInjection.test.ts b/apps/admin-x-settings/test/acceptance/advanced/codeInjection.test.ts index d852f7e726..f20f844523 100644 --- a/apps/admin-x-settings/test/acceptance/advanced/codeInjection.test.ts +++ b/apps/admin-x-settings/test/acceptance/advanced/codeInjection.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; // CodeMirror takes some time to load in Playwright meaning the first few characters typed don't always // show up in the input. Since that lag is not consistent, this workaround ensures we type enough diff --git a/apps/admin-x-settings/test/acceptance/advanced/history.test.ts b/apps/admin-x-settings/test/acceptance/advanced/history.test.ts index e4d73794ff..d8e57c1ba5 100644 --- a/apps/admin-x-settings/test/acceptance/advanced/history.test.ts +++ b/apps/admin-x-settings/test/acceptance/advanced/history.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('History', async () => { test('Browsing history', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/advanced/integrations/amp.test.ts b/apps/admin-x-settings/test/acceptance/advanced/integrations/amp.test.ts index 7af6ad8f8f..d08eb1a7d2 100644 --- a/apps/admin-x-settings/test/acceptance/advanced/integrations/amp.test.ts +++ b/apps/admin-x-settings/test/acceptance/advanced/integrations/amp.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, responseFixtures, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../../utils/acceptance'; +import {mockApi, responseFixtures, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('AMP integration', async () => { test('Supports toggling and filling in AMP integration', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/advanced/integrations/custom.test.ts b/apps/admin-x-settings/test/acceptance/advanced/integrations/custom.test.ts index bec0f2677c..190eda04b3 100644 --- a/apps/admin-x-settings/test/acceptance/advanced/integrations/custom.test.ts +++ b/apps/admin-x-settings/test/acceptance/advanced/integrations/custom.test.ts @@ -1,7 +1,8 @@ import {Integration, IntegrationsResponseType} from '@tryghost/admin-x-framework/api/integrations'; import {Webhook, WebhooksResponseType} from '@tryghost/admin-x-framework/api/webhooks'; -import {chooseOptionInSelect, globalDataRequests, limitRequests, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; +import {chooseOptionInSelect, limitRequests, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; import {expect, test} from '@playwright/test'; +import {globalDataRequests} from '../../../utils/acceptance'; test.describe('Custom integrations', async () => { test('Supports creating an integration and adding webhooks', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/advanced/integrations/firstPromoter.test.ts b/apps/admin-x-settings/test/acceptance/advanced/integrations/firstPromoter.test.ts index 55e273d68b..ea216d6ac9 100644 --- a/apps/admin-x-settings/test/acceptance/advanced/integrations/firstPromoter.test.ts +++ b/apps/admin-x-settings/test/acceptance/advanced/integrations/firstPromoter.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, responseFixtures, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../../utils/acceptance'; +import {mockApi, responseFixtures, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('First Promoter integration', async () => { test('Supports toggling and filling in First Promoter integration', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/advanced/integrations/pintura.test.ts b/apps/admin-x-settings/test/acceptance/advanced/integrations/pintura.test.ts index 06f4f3645f..7bfd429384 100644 --- a/apps/admin-x-settings/test/acceptance/advanced/integrations/pintura.test.ts +++ b/apps/admin-x-settings/test/acceptance/advanced/integrations/pintura.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../../utils/acceptance'; +import {mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Pintura integration', async () => { test('Can toggle Pintura', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/advanced/integrations/slack.test.ts b/apps/admin-x-settings/test/acceptance/advanced/integrations/slack.test.ts index 05ea0faf67..420a9f5ee2 100644 --- a/apps/admin-x-settings/test/acceptance/advanced/integrations/slack.test.ts +++ b/apps/admin-x-settings/test/acceptance/advanced/integrations/slack.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, responseFixtures, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../../utils/acceptance'; +import {mockApi, responseFixtures, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Slack integration', async () => { test('Supports updating Slack settings', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/advanced/integrations/unsplash.test.ts b/apps/admin-x-settings/test/acceptance/advanced/integrations/unsplash.test.ts index bf05860913..21bf9ef5ba 100644 --- a/apps/admin-x-settings/test/acceptance/advanced/integrations/unsplash.test.ts +++ b/apps/admin-x-settings/test/acceptance/advanced/integrations/unsplash.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../../utils/acceptance'; +import {mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Unsplash integration', async () => { test('Supports toggling unsplash integration', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/advanced/integrations/zapier.test.ts b/apps/admin-x-settings/test/acceptance/advanced/integrations/zapier.test.ts index b3f1f584f2..d4215389b3 100644 --- a/apps/admin-x-settings/test/acceptance/advanced/integrations/zapier.test.ts +++ b/apps/admin-x-settings/test/acceptance/advanced/integrations/zapier.test.ts @@ -1,6 +1,7 @@ import {Integration, IntegrationsResponseType} from '@tryghost/admin-x-framework/api/integrations'; import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../../utils/acceptance'; +import {mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Zapier integration settings', async () => { test('Showing and regenerating API keys', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/advanced/labs.test.ts b/apps/admin-x-settings/test/acceptance/advanced/labs.test.ts index dc4bc0f0c4..daf98413ad 100644 --- a/apps/admin-x-settings/test/acceptance/advanced/labs.test.ts +++ b/apps/admin-x-settings/test/acceptance/advanced/labs.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {mockApi} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Labs', async () => { test('Delete all content', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/email/defaultRecipients.test.ts b/apps/admin-x-settings/test/acceptance/email/defaultRecipients.test.ts index 0225f691f2..26751488e2 100644 --- a/apps/admin-x-settings/test/acceptance/email/defaultRecipients.test.ts +++ b/apps/admin-x-settings/test/acceptance/email/defaultRecipients.test.ts @@ -1,5 +1,6 @@ -import {chooseOptionInSelect, globalDataRequests, mockApi, responseFixtures, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; +import {chooseOptionInSelect, mockApi, responseFixtures, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; import {expect, test} from '@playwright/test'; +import {globalDataRequests} from '../../utils/acceptance'; test.describe('Default recipient settings', async () => { test('Supports editing default recipients', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/email/mailgun.test.ts b/apps/admin-x-settings/test/acceptance/email/mailgun.test.ts index 04b1c6415b..a34024cfdf 100644 --- a/apps/admin-x-settings/test/acceptance/email/mailgun.test.ts +++ b/apps/admin-x-settings/test/acceptance/email/mailgun.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Mailgun settings', async () => { test('Supports setting up mailgun', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/email/newsletters.test.ts b/apps/admin-x-settings/test/acceptance/email/newsletters.test.ts index 4dbd3316aa..6416c86536 100644 --- a/apps/admin-x-settings/test/acceptance/email/newsletters.test.ts +++ b/apps/admin-x-settings/test/acceptance/email/newsletters.test.ts @@ -1,6 +1,7 @@ import {NewslettersResponseType} from '@tryghost/admin-x-framework/api/newsletters'; -import {chooseOptionInSelect, globalDataRequests, limitRequests, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; +import {chooseOptionInSelect, limitRequests, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; import {expect, test} from '@playwright/test'; +import {globalDataRequests} from '../../utils/acceptance'; test.describe('Newsletter settings', async () => { test('Supports creating a new newsletter', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/general/facebook.test.ts b/apps/admin-x-settings/test/acceptance/general/facebook.test.ts index a4ee8b4bc4..e60283bbb0 100644 --- a/apps/admin-x-settings/test/acceptance/general/facebook.test.ts +++ b/apps/admin-x-settings/test/acceptance/general/facebook.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Facebook settings', async () => { test('Supports editing the facebook card', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/general/lockSite.test.ts b/apps/admin-x-settings/test/acceptance/general/lockSite.test.ts index ac6eaac878..0523a31374 100644 --- a/apps/admin-x-settings/test/acceptance/general/lockSite.test.ts +++ b/apps/admin-x-settings/test/acceptance/general/lockSite.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Site password settings', async () => { test('Supports locking and unlocking the site', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/general/metadata.test.ts b/apps/admin-x-settings/test/acceptance/general/metadata.test.ts index 25683f1f38..4240f3a83c 100644 --- a/apps/admin-x-settings/test/acceptance/general/metadata.test.ts +++ b/apps/admin-x-settings/test/acceptance/general/metadata.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Metadata settings', async () => { test('Supports editing metadata', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/general/publicationLanguage.test.ts b/apps/admin-x-settings/test/acceptance/general/publicationLanguage.test.ts index e873eeb9c3..16e0e89fc8 100644 --- a/apps/admin-x-settings/test/acceptance/general/publicationLanguage.test.ts +++ b/apps/admin-x-settings/test/acceptance/general/publicationLanguage.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Publication language settings', async () => { test('Supports editing the locale', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/general/socialAccounts.test.ts b/apps/admin-x-settings/test/acceptance/general/socialAccounts.test.ts index cfcf6bfbbe..f5041c7e93 100644 --- a/apps/admin-x-settings/test/acceptance/general/socialAccounts.test.ts +++ b/apps/admin-x-settings/test/acceptance/general/socialAccounts.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, testUrlValidation, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {mockApi, testUrlValidation, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Social account settings', async () => { test('Supports editing social URLs', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/general/timeZone.test.ts b/apps/admin-x-settings/test/acceptance/general/timeZone.test.ts index afb4f11f24..23212b4f68 100644 --- a/apps/admin-x-settings/test/acceptance/general/timeZone.test.ts +++ b/apps/admin-x-settings/test/acceptance/general/timeZone.test.ts @@ -1,5 +1,6 @@ -import {chooseOptionInSelect, globalDataRequests, mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; +import {chooseOptionInSelect, mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; import {expect, test} from '@playwright/test'; +import {globalDataRequests} from '../../utils/acceptance'; test.describe('Time zone settings', async () => { test('Supports editing the time zone', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/general/titleAndDescription.test.ts b/apps/admin-x-settings/test/acceptance/general/titleAndDescription.test.ts index 2950e685c6..9dcd118d8d 100644 --- a/apps/admin-x-settings/test/acceptance/general/titleAndDescription.test.ts +++ b/apps/admin-x-settings/test/acceptance/general/titleAndDescription.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Title and description settings', async () => { test('Supports editing the title and description', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/general/twitter.test.ts b/apps/admin-x-settings/test/acceptance/general/twitter.test.ts index 6622bdf0af..cc0e3caef9 100644 --- a/apps/admin-x-settings/test/acceptance/general/twitter.test.ts +++ b/apps/admin-x-settings/test/acceptance/general/twitter.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Twitter settings', async () => { test('Supports editing the twitter card', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/general/users/actions.test.ts b/apps/admin-x-settings/test/acceptance/general/users/actions.test.ts index a67012203e..171a31840b 100644 --- a/apps/admin-x-settings/test/acceptance/general/users/actions.test.ts +++ b/apps/admin-x-settings/test/acceptance/general/users/actions.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, limitRequests, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../../utils/acceptance'; +import {limitRequests, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('User actions', async () => { test('Supports suspending a user', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/general/users/invite.test.ts b/apps/admin-x-settings/test/acceptance/general/users/invite.test.ts index 9a183e3102..201e3fa709 100644 --- a/apps/admin-x-settings/test/acceptance/general/users/invite.test.ts +++ b/apps/admin-x-settings/test/acceptance/general/users/invite.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, limitRequests, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../../utils/acceptance'; +import {limitRequests, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('User invitations', async () => { test('Supports inviting a user', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/general/users/password.test.ts b/apps/admin-x-settings/test/acceptance/general/users/password.test.ts index d0e728161e..0f42790fe0 100644 --- a/apps/admin-x-settings/test/acceptance/general/users/password.test.ts +++ b/apps/admin-x-settings/test/acceptance/general/users/password.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../../utils/acceptance'; +import {mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('User passwords', async () => { test('Supports changing password', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/general/users/profile.test.ts b/apps/admin-x-settings/test/acceptance/general/users/profile.test.ts index 5aa3ae8ee1..1511eb6ce4 100644 --- a/apps/admin-x-settings/test/acceptance/general/users/profile.test.ts +++ b/apps/admin-x-settings/test/acceptance/general/users/profile.test.ts @@ -1,6 +1,7 @@ import {StaffTokenResponseType} from '@tryghost/admin-x-framework/api/staffToken'; import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, responseFixtures, testUrlValidation} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../../utils/acceptance'; +import {mockApi, responseFixtures, testUrlValidation} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('User profile', async () => { test('Supports editing user profiles', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/general/users/roles.test.ts b/apps/admin-x-settings/test/acceptance/general/users/roles.test.ts index 612d488794..383e6676ec 100644 --- a/apps/admin-x-settings/test/acceptance/general/users/roles.test.ts +++ b/apps/admin-x-settings/test/acceptance/general/users/roles.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, meWithRole, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../../utils/acceptance'; +import {meWithRole, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('User roles', async () => { test('Shows users under their role', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/layout.test.ts b/apps/admin-x-settings/test/acceptance/layout.test.ts index 1966ec0f2c..0f5d7ea59c 100644 --- a/apps/admin-x-settings/test/acceptance/layout.test.ts +++ b/apps/admin-x-settings/test/acceptance/layout.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../utils/acceptance'; +import {mockApi} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Layout', async () => { test('Confirms when leaving if a section is dirty', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/membership/access.test.ts b/apps/admin-x-settings/test/acceptance/membership/access.test.ts index 13d05556f8..7d53b508cd 100644 --- a/apps/admin-x-settings/test/acceptance/membership/access.test.ts +++ b/apps/admin-x-settings/test/acceptance/membership/access.test.ts @@ -1,5 +1,6 @@ -import {chooseOptionInSelect, globalDataRequests, mockApi, responseFixtures, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; +import {chooseOptionInSelect, mockApi, responseFixtures, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; import {expect, test} from '@playwright/test'; +import {globalDataRequests} from '../../utils/acceptance'; test.describe('Access settings', async () => { test('Supports editing access', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/membership/analytics.test.ts b/apps/admin-x-settings/test/acceptance/membership/analytics.test.ts index ac6570caf1..a334ccdad3 100644 --- a/apps/admin-x-settings/test/acceptance/membership/analytics.test.ts +++ b/apps/admin-x-settings/test/acceptance/membership/analytics.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {mockApi, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Analytics settings', async () => { test('Supports toggling analytics settings', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/membership/offers.test.ts b/apps/admin-x-settings/test/acceptance/membership/offers.test.ts index 879a44ad25..d65fa8a850 100644 --- a/apps/admin-x-settings/test/acceptance/membership/offers.test.ts +++ b/apps/admin-x-settings/test/acceptance/membership/offers.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, responseFixtures, settingsWithStripe, toggleLabsFlag} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {mockApi, responseFixtures, settingsWithStripe, toggleLabsFlag} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Offers Modal', () => { test.beforeEach(async () => { diff --git a/apps/admin-x-settings/test/acceptance/membership/portal.test.ts b/apps/admin-x-settings/test/acceptance/membership/portal.test.ts index bb4c38e549..08d35b233b 100644 --- a/apps/admin-x-settings/test/acceptance/membership/portal.test.ts +++ b/apps/admin-x-settings/test/acceptance/membership/portal.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, mockSitePreview, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {mockApi, mockSitePreview, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Portal Settings', async () => { test('Loads Portal Preview Modal', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/membership/recommendations.test.ts b/apps/admin-x-settings/test/acceptance/membership/recommendations.test.ts index 87f1bc4c89..07cf0ee540 100644 --- a/apps/admin-x-settings/test/acceptance/membership/recommendations.test.ts +++ b/apps/admin-x-settings/test/acceptance/membership/recommendations.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, responseFixtures, toggleLabsFlag} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {mockApi, responseFixtures, toggleLabsFlag} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Recommendations', async () => { test.beforeEach(async () => { diff --git a/apps/admin-x-settings/test/acceptance/membership/signupEmbed.test.ts b/apps/admin-x-settings/test/acceptance/membership/signupEmbed.test.ts index 9b73617523..4deb5250d0 100644 --- a/apps/admin-x-settings/test/acceptance/membership/signupEmbed.test.ts +++ b/apps/admin-x-settings/test/acceptance/membership/signupEmbed.test.ts @@ -1,5 +1,5 @@ import {test} from '@playwright/test'; -// import {globalDataRequests, mockApi, responseFixtures} from '../../utils/e2e'; +// import {globalDataRequests} from '../../utils/acceptance'; test.describe('Signup Embed', async () => { // TODO - currently having difficulty rendering the iframe in the test diff --git a/apps/admin-x-settings/test/acceptance/membership/stripe.test.ts b/apps/admin-x-settings/test/acceptance/membership/stripe.test.ts index a7644485e9..7f0f26ef91 100644 --- a/apps/admin-x-settings/test/acceptance/membership/stripe.test.ts +++ b/apps/admin-x-settings/test/acceptance/membership/stripe.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, responseFixtures, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {mockApi, responseFixtures, updatedSettingsResponse} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Stripe settings', async () => { test('Supports the Stripe Connect flow', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/membership/tiers.test.ts b/apps/admin-x-settings/test/acceptance/membership/tiers.test.ts index 58abefbb69..73d73cfd03 100644 --- a/apps/admin-x-settings/test/acceptance/membership/tiers.test.ts +++ b/apps/admin-x-settings/test/acceptance/membership/tiers.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, responseFixtures, settingsWithStripe} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {mockApi, responseFixtures, settingsWithStripe} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Tier settings', async () => { test('Supports creating a new tier', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/permissions.test.ts b/apps/admin-x-settings/test/acceptance/permissions.test.ts index be656a0428..d2f4a91a4e 100644 --- a/apps/admin-x-settings/test/acceptance/permissions.test.ts +++ b/apps/admin-x-settings/test/acceptance/permissions.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, meWithRole, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../utils/acceptance'; +import {meWithRole, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('User permissions', async () => { test('Editors can only see users', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/routing.test.ts b/apps/admin-x-settings/test/acceptance/routing.test.ts index 4bcc3ce5ab..c332d117a7 100644 --- a/apps/admin-x-settings/test/acceptance/routing.test.ts +++ b/apps/admin-x-settings/test/acceptance/routing.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../utils/acceptance'; +import {mockApi} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Routing', async () => { test('Reopens the opened modal when refreshing the page', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/search.test.ts b/apps/admin-x-settings/test/acceptance/search.test.ts index f08abd2858..1b0f0ac1b2 100644 --- a/apps/admin-x-settings/test/acceptance/search.test.ts +++ b/apps/admin-x-settings/test/acceptance/search.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../utils/acceptance'; +import {mockApi} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Search', async () => { test('Hiding and showing groups based on the search term', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/site/announcementbar.test.ts b/apps/admin-x-settings/test/acceptance/site/announcementbar.test.ts index e66d44af03..e0f0f0c798 100644 --- a/apps/admin-x-settings/test/acceptance/site/announcementbar.test.ts +++ b/apps/admin-x-settings/test/acceptance/site/announcementbar.test.ts @@ -1,5 +1,6 @@ import {ElementHandle, expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, mockSitePreview, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {mockApi, mockSitePreview, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Announcement Bar', async () => { test('Working with the announcement bar preview', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/site/design.test.ts b/apps/admin-x-settings/test/acceptance/site/design.test.ts index 693a4d8298..9f062e7443 100644 --- a/apps/admin-x-settings/test/acceptance/site/design.test.ts +++ b/apps/admin-x-settings/test/acceptance/site/design.test.ts @@ -1,5 +1,6 @@ -import {chooseOptionInSelect, globalDataRequests, mockApi, mockSitePreview, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; +import {chooseOptionInSelect, mockApi, mockSitePreview, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; import {expect, test} from '@playwright/test'; +import {globalDataRequests} from '../../utils/acceptance'; test.describe('Design settings', async () => { test('Working with the preview', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/site/navigation.test.ts b/apps/admin-x-settings/test/acceptance/site/navigation.test.ts index 8961957f6f..ac1ae2bb44 100644 --- a/apps/admin-x-settings/test/acceptance/site/navigation.test.ts +++ b/apps/admin-x-settings/test/acceptance/site/navigation.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Navigation settings', async () => { test('Editing primary and secondary navigation', async ({page}) => { diff --git a/apps/admin-x-settings/test/acceptance/site/theme.test.ts b/apps/admin-x-settings/test/acceptance/site/theme.test.ts index 3e167ac464..2580a766d3 100644 --- a/apps/admin-x-settings/test/acceptance/site/theme.test.ts +++ b/apps/admin-x-settings/test/acceptance/site/theme.test.ts @@ -1,5 +1,6 @@ import {expect, test} from '@playwright/test'; -import {globalDataRequests, limitRequests, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; +import {globalDataRequests} from '../../utils/acceptance'; +import {limitRequests, mockApi, responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; test.describe('Theme settings', async () => { test('Browsing and installing default themes', async ({page}) => { diff --git a/apps/admin-x-settings/test/utils/acceptance.ts b/apps/admin-x-settings/test/utils/acceptance.ts new file mode 100644 index 0000000000..2a2a168a4b --- /dev/null +++ b/apps/admin-x-settings/test/utils/acceptance.ts @@ -0,0 +1,8 @@ +import {responseFixtures} from '@tryghost/admin-x-framework/test/acceptance'; + +export const globalDataRequests = { + browseSettings: {method: 'GET', path: /^\/settings\/\?group=/, response: responseFixtures.settings}, + browseConfig: {method: 'GET', path: '/config/', response: responseFixtures.config}, + browseSite: {method: 'GET', path: '/site/', response: responseFixtures.site}, + browseMe: {method: 'GET', path: '/users/me/?include=roles', response: responseFixtures.me} +}; diff --git a/package.json b/package.json index c17d944566..1773454d1d 100644 --- a/package.json +++ b/package.json @@ -6,13 +6,10 @@ "repository": "https://github.com/TryGhost/Ghost", "author": "Ghost Foundation", "license": "MIT", - "workspaces": { - "packages": [ - "ghost/*", - "apps/*" - ], - "nohoist": ["**/@testing-library/react"] - }, + "workspaces": [ + "ghost/*", + "apps/*" + ], "monorepo": { "public": false, "internalPackages": true,