From b8105717ec06de08dc6d69ed679463b304762dd1 Mon Sep 17 00:00:00 2001 From: Quentin AUBERT Date: Mon, 16 Dec 2024 11:09:02 +0100 Subject: [PATCH] FIX playwrights tests --- .../backoffice/apis/TeamApiSettings.tsx | 6 +++--- .../notifications/SimpleNotification.tsx | 1 - .../components/utils/sidebar/RightPanel.tsx | 10 +++++++--- .../src/components/utils/sidebar/SideBar.tsx | 1 + .../src/locales/en/translation.json | 3 ++- .../src/locales/fr/translation.json | 3 ++- .../javascript/tests/connectedUser.spec.ts | 19 ++++++++++++------- daikoku/javascript/tests/envMode.spec.ts | 4 +++- 8 files changed, 30 insertions(+), 17 deletions(-) diff --git a/daikoku/javascript/src/components/backoffice/apis/TeamApiSettings.tsx b/daikoku/javascript/src/components/backoffice/apis/TeamApiSettings.tsx index e0574b4af..26940afa8 100644 --- a/daikoku/javascript/src/components/backoffice/apis/TeamApiSettings.tsx +++ b/daikoku/javascript/src/components/backoffice/apis/TeamApiSettings.tsx @@ -20,7 +20,7 @@ export const TeamApiSettings = ({ api, currentTeam }: TeamApiSettingsProps) => { const { confirm } = useContext(ModalContext); const navigate = useNavigate(); - const transferOwnership = ({team}: any) => { + const transferOwnership = ({team}: {team: ITeamSimple}) => { Services.transferApiOwnership(team, api.team, api._id).then((r) => { if (r.notify) { @@ -41,13 +41,13 @@ export const TeamApiSettings = ({ api, currentTeam }: TeamApiSettingsProps) => { optionsFrom: Services.teams(currentTeam) .then((teams) => { if (!isError(teams)) { - return sortBy(teams.filter((team: any) => team._id !== api.team), 'name') + return sortBy(teams.filter((team) => team._id !== api.team), 'name') } else { return [] } } ), - transformer: (team: any) => ({ + transformer: (team: ITeamSimple) => ({ label: team.name, value: team._id }), diff --git a/daikoku/javascript/src/components/backoffice/notifications/SimpleNotification.tsx b/daikoku/javascript/src/components/backoffice/notifications/SimpleNotification.tsx index bc4bbf70a..2dc214799 100644 --- a/daikoku/javascript/src/components/backoffice/notifications/SimpleNotification.tsx +++ b/daikoku/javascript/src/components/backoffice/notifications/SimpleNotification.tsx @@ -409,7 +409,6 @@ export function SimpleNotification(props: ISimpleNotificationProps) { }; const fromFormatter = (action: any, sender: any) => { - console.debug({props, sender}) switch (action.__typename) { case 'ApiAccess': return `${sender.name}/${props.notification.action.team?.name ?? translate("Unknown team") }`; diff --git a/daikoku/javascript/src/components/utils/sidebar/RightPanel.tsx b/daikoku/javascript/src/components/utils/sidebar/RightPanel.tsx index 765d72ea5..ae6bd6d0f 100644 --- a/daikoku/javascript/src/components/utils/sidebar/RightPanel.tsx +++ b/daikoku/javascript/src/components/utils/sidebar/RightPanel.tsx @@ -2,11 +2,12 @@ import classNames from 'classnames'; import { useContext, useEffect } from 'react'; import ArrowRight from 'react-feather/dist/icons/arrow-right'; -import { ModalContext } from '../../../contexts'; +import { I18nContext, ModalContext } from '../../../contexts'; export const RightPanel = () => { const { rightPanelContent, closeRightPanel } = useContext(ModalContext); + const { translate } = useContext(I18nContext); useEffect(() => { @@ -37,8 +38,11 @@ export const RightPanel = () => { })} >
-
- +
+
{rightPanelContent?.title}
diff --git a/daikoku/javascript/src/components/utils/sidebar/SideBar.tsx b/daikoku/javascript/src/components/utils/sidebar/SideBar.tsx index 7956d9565..2a688dcc9 100644 --- a/daikoku/javascript/src/components/utils/sidebar/SideBar.tsx +++ b/daikoku/javascript/src/components/utils/sidebar/SideBar.tsx @@ -158,6 +158,7 @@ export const SideBar = () => { })} to="/notifications" title={translate('Access to the notifications')} + aria-label={translate('Access to the notifications')} > diff --git a/daikoku/javascript/src/locales/en/translation.json b/daikoku/javascript/src/locales/en/translation.json index 647a68856..7401b0b0d 100644 --- a/daikoku/javascript/src/locales/en/translation.json +++ b/daikoku/javascript/src/locales/en/translation.json @@ -1400,5 +1400,6 @@ "subscription.copy.token.label": "token", "subscription.copy.token.help": "Copy daikoku token, used for retrieve credentials by API", "setting.panel.reset.confirm.message": "Are you sure you want to reset your organization's data?", - "api.pricing.created.subscription.panel.title": "Your API Key is Ready" + "api.pricing.created.subscription.panel.title": "Your API Key is Ready", + "right.panel.close.aria.label": "Close the panel" } \ No newline at end of file diff --git a/daikoku/javascript/src/locales/fr/translation.json b/daikoku/javascript/src/locales/fr/translation.json index 4b7130f24..899be6044 100644 --- a/daikoku/javascript/src/locales/fr/translation.json +++ b/daikoku/javascript/src/locales/fr/translation.json @@ -1401,5 +1401,6 @@ "subscription.copy.token.label": "Jeton", "subscription.copy.token.help": "Copier le jeton Daikoku, utilisable pour récupérer les identifiants par API", "setting.panel.reset.confirm.message": "Êtes-vous sûr de vouloir réinitialiser les données de votre organisation ?", - "api.pricing.created.subscription.panel.title": "Votre clé d'API est prête" + "api.pricing.created.subscription.panel.title": "Votre clé d'API est prête", + "right.panel.close.aria.label": "Fermer le panneau latéral" } \ No newline at end of file diff --git a/daikoku/javascript/tests/connectedUser.spec.ts b/daikoku/javascript/tests/connectedUser.spec.ts index 1d9acf811..49d713065 100644 --- a/daikoku/javascript/tests/connectedUser.spec.ts +++ b/daikoku/javascript/tests/connectedUser.spec.ts @@ -276,7 +276,8 @@ test('Create & manage API', async ({ page }) => { await expect(page.getByText('Consumers')).toBeVisible(); await expect(page.locator('div').filter({ hasText: /^Testers$/ })).toBeVisible(); await page.getByText('Consumers').click(); - await expect(page.getByText('API key to plan Free with')).toBeVisible(); + await page.getByLabel('Close the panel').click(); + // await expect(page.getByText('API key to plan Free with')).toBeVisible(); await expect(page.getByText('public & manual')).toBeVisible(); await page.getByRole('button', { name: 'Request API key' }).click(); await expect(page.locator('div.team-selection').filter({ hasText: /^Consumers$/ })).toBeVisible(); @@ -294,7 +295,8 @@ test('Create & manage API', async ({ page }) => { await expect(page.locator('div.team-selection').filter({ hasText: /^Testers$/ })).toBeVisible(); await expect(page.locator('div.team-selection').filter({ hasText: /^Consumers$/ })).toBeHidden(); await page.locator('div.team-selection').filter({ hasText: /^Testers$/ }).click(); - await expect(page.getByText('API key to plan Free with')).toBeVisible(); + await page.getByLabel('Close the panel').click(); + // await expect(page.getByText('API key to plan Free with')).toBeVisible(); await page.getByRole('link', { name: 'Access to the notifications' }).click(); await expect(page.getByText('Request subscription to test API 2 for plan')).toBeVisible(); await page.getByRole('link', { name: 'Accept' }).nth(1).click(); @@ -383,6 +385,8 @@ test('aggregation mode', async ({ page, request, context }) => { await page.locator('.usage-plan__card').filter({ hasText: 'not test plan' }).getByRole('button').click(); await page.locator('div').filter({ hasText: /^Consumers$/ }).click(); // await page.getByRole('button', { name: 'Subscribe with a new api key' }).click(); + + await page.getByLabel('Close the panel').click(); await page.getByRole('link', { name: 'APIs list' }).click(); //subscribe second api with aggregation @@ -392,6 +396,7 @@ test('aggregation mode', async ({ page, request, context }) => { await page.locator('.team-selection').filter({ hasText: 'Consumer' }).click(); await page.getByRole('button', { name: ' Subscribe using an existing' }).click(); await page.getByText('test API/not test plan').click(); + await page.getByLabel('Close the panel').click(); //go to subscriptions await page.getByRole('link', { name: 'APIs list' }).click(); @@ -500,6 +505,7 @@ test('API admin can transfer his own API ownership', async ({ page }) => { await page.getByRole('heading', { name: 'test API' }).click(); await page.getByRole('link', { name: 'Configure API' }).click(); await page.getByText('Settings').click(); + await page.locator('h3').filter({ hasText: 'Transfer ownership' }).waitFor({ state: 'visible' }) await page.locator('.react-form-select__input-container').click(); await page.getByText('Consumers', { exact: true }).click(); await page.getByLabel('Please type test API to').fill('test API'); @@ -605,18 +611,17 @@ test('transfer an api subscription', async ({ page, context }) => { await page.waitForResponse(r => r.url().includes('/api/me/context') && r.status() === 200) await page.waitForSelector('.apis__pagination') await page.getByRole('heading', { name: 'test API' }).click(); - - //tester l'url pour verifier que c'est bien la v2 await page.getByText('Plans').click(); - await page.locator('div').filter({ hasText: /^fake prod plan/ }).getByRole('button').click(); await page.getByText('Consumers').click(); - await page.getByLabel('Notifications').getByRole('img').nth(1).click(); - await page.locator('.api-subscription__icon').isVisible(); + // await page.getByLabel('Notifications').getByRole('img').nth(1).click(); + // await page.locator('.api-subscription__icon').isVisible(); // await page.locator('.api-subscription__infos__value').innerText(); await page.getByRole('button', { name: 'clientId:clientToken' }).click(); const apikey = await page.evaluate(() => navigator.clipboard.readText()); + //todo: go to subscription page to have menu action + await page.goto(`http://localhost:${exposedPort}/consumers/settings/apikeys/test-api/2.0.0`) await page.locator('#dropdownMenuButton').click(); await page.getByText('Transfer subscription').click(); await page.getByText('Display link').click(); diff --git a/daikoku/javascript/tests/envMode.spec.ts b/daikoku/javascript/tests/envMode.spec.ts index 9498416c2..0ac35104e 100644 --- a/daikoku/javascript/tests/envMode.spec.ts +++ b/daikoku/javascript/tests/envMode.spec.ts @@ -71,6 +71,7 @@ test('aggregation security works', async ({ page, request }) => { await page.getByText('Environments').click(); await page.locator('.usage-plan__card').filter({ hasText: 'prod' }).getByRole('button').click(); await page.getByText('Consumers').click(); + await page.getByLabel('Close the panel').click(); await page.getByLabel('APIs list').click(); await page.getByRole('heading', { name: 'Child API' }).click(); @@ -87,9 +88,10 @@ test('aggregation security works', async ({ page, request }) => { await page.getByRole('button', { name: ' Subscribe using an existing' }).click(); await expect(page.getByText('Parent API/prod')).toBeVisible(); await page.getByText('Parent API/prod').click(); + await page.getByLabel('Close the panel').click(); // await expect(page.getByText('API key to plan Free without')).toBeVisible(); - await page.getByLabel('APIs list').click(); + await page.goto(`http://localhost:${exposedPort}/apis`); await page.getByText('Consumers', { exact: true }).click(); await page.getByText('API keys').click(); await expect(page.getByRole('cell', { name: 'Child API' })).toBeVisible();