Skip to content

Commit

Permalink
FIX playwrights tests
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinovega committed Dec 16, 2024
1 parent f312d7b commit b810571
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") }`;
Expand Down
10 changes: 7 additions & 3 deletions daikoku/javascript/src/components/utils/sidebar/RightPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -37,8 +38,11 @@ export const RightPanel = () => {
})}
>
<div className="m-2 p-2 ">
<div className="cursor-pointer right-panel__back d-flex align-items-center justify-content-center companion-link">
<ArrowRight className="" onClick={closeRightPanel} />
<div
className="cursor-pointer right-panel__back d-flex align-items-center justify-content-center companion-link"
onClick={closeRightPanel}
aria-label={translate("right.panel.close.aria.label")} >
<ArrowRight />
</div>
{rightPanelContent?.title}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export const SideBar = () => {
})}
to="/notifications"
title={translate('Access to the notifications')}
aria-label={translate('Access to the notifications')}
>
<Bell />
</Link>
Expand Down
3 changes: 2 additions & 1 deletion daikoku/javascript/src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
3 changes: 2 additions & 1 deletion daikoku/javascript/src/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
19 changes: 12 additions & 7 deletions daikoku/javascript/tests/connectedUser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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
Expand All @@ -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();
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion daikoku/javascript/tests/envMode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit b810571

Please sign in to comment.