Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[frontend] Impossible to create a relationship from an entity "knowledge" view (#6343) #6356

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
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();
});
@@ -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();
});
@@ -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();
}
}
@@ -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' });
}
}
@@ -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);
}
}