Skip to content

Commit

Permalink
[frontend] Impossible to create a relationship from an entity "knowle…
Browse files Browse the repository at this point in the history
…dge" view (#6343)
  • Loading branch information
SarahBocognano committed Mar 14, 2024
1 parent 373c14e commit ac241d0
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ const StixCoreRelationshipCreationFromEntity: FunctionComponent<StixCoreRelation
);
const [selectedElements, setSelectedElements] = useState<Record<string, StixCoreRelationshipCreationFromEntityStixCoreObjectsLine_node$data>>({});
useEffect(() => {
if (targetEntitiesProps !== targetEntities) {
if (!R.equals(targetEntitiesProps, targetEntities) && targetEntitiesProps.length > targetEntities.length) {
setTargetEntities(targetEntitiesProps);
setStep(targetEntitiesProps.length === 0 ? 0 : 1);
setOpen(targetEntitiesProps.length !== 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class RootIntrusionSet extends Component {
? 200
: 0,
}}
data-testid="intrusionSet-details-page"
>
<Breadcrumbs variant="object" elements={[
{ label: t('Threats') },
Expand Down Expand Up @@ -214,10 +215,12 @@ class RootIntrusionSet extends Component {
<Route
path="/dashboard/threats/intrusion_sets/:intrusionSetId/knowledge"
render={(routeProps) => (
<IntrusionSetKnowledge
{...routeProps}
intrusionSet={props.intrusionSet}
/>
<div data-testid="instrusionSet-knowledge">
<IntrusionSetKnowledge
{...routeProps}
intrusionSet={props.intrusionSet}
/>
</div>
)}
/>
<Route
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ test('Create a new dashboard page', async ({ page }) => {
await dashboardDetailsPage.getDeleteButton().click();
await dashboardDetailsPage.getDelete().click();
await page.goto('/dashboard/workspaces/dashboards');
await expect(page.getByRole('link', {name: 'Test e2e'})).toBeHidden();
await expect(page.getByRole('link', { name: 'Test e2e' })).toBeHidden();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { expect, test } from '../fixtures/baseFixtures';
import IntrusionSetPage from '../model/intrusionSet.pageModel';
import IntrusionSetFormPage from '../model/intrusionSetForm.pageModel';
import IntrusionSetDetailsPage from '../model/intrusionSetDetails.pageModel';

test('Create a new relationship in intrusion set knowledge', async ({ page }) => {
const intrusionSetPage = new IntrusionSetPage(page);
const intrusionSetForm = new IntrusionSetFormPage(page);
const intrusionSetDetailsPage = new IntrusionSetDetailsPage(page);
await page.goto('/dashboard/threats/intrusion_sets');
await intrusionSetPage.addNewIntrusionSet();
await intrusionSetForm.fillNameInput('Test e2e');
await intrusionSetPage.getCreateIntrusionSetButton().click();
await intrusionSetPage.getItemFromList('Test e2e').click();
await expect(intrusionSetDetailsPage.getIntrusionSetDetailsPage()).toBeVisible();
await intrusionSetDetailsPage.getKnowledgeTab();
await intrusionSetDetailsPage.getVictimologyTab();
await intrusionSetDetailsPage.getCreateRelationshipButton().click();
await expect(intrusionSetDetailsPage.getStixCoreRelationshipCreationFromEntityComponent()).toBeVisible();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { Page } from '@playwright/test';

export default class IntrusionSetPage {
constructor(private page: Page) {}

getPage() {
return this.page.getByTestId('instrusionSet-knowledge');
}

addNewIntrusionSet() {
return this.page.getByLabel('Add', { exact: true }).click();
}

getCreateIntrusionSetButton() {
return this.page.getByRole('button', { name: 'Create', exact: true });
}

getItemFromList(name: string) {
return this.page.getByRole('link', { name }).first();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { Page } from '@playwright/test';

export default class IntrusionSetDetailsPage {
constructor(private page: Page) {}

getIntrusionSetDetailsPage() {
return this.page.getByTestId('intrusionSet-details-page');
}

getTitle(name: string) {
return this.page.getByRole('heading', { name });
}

getKnowledgeTab() {
return this.page.getByRole('tab', { name: 'Knowledge' }).click();
}

getVictimologyTab() {
return this.page.getByRole('menuitem', { name: 'Victimology' }).click();
}

getCreateRelationshipButton() {
return this.page.getByLabel('Add', { exact: true });
}

getStixCoreRelationshipCreationFromEntityComponent() {
return this.page.getByRole('heading', { name: 'Create a relationship' });
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { Page } from '@playwright/test';

export default class IntrusionSetFormPage {
constructor(private page: Page) {}

getNameInput() {
return this.page.getByRole('textbox', { name: 'Name' });
}

async fillNameInput(input: string) {
await this.getNameInput().click();
return this.getNameInput().fill(input);
}
}

0 comments on commit ac241d0

Please sign in to comment.