Skip to content

Commit

Permalink
Refactor test and story
Browse files Browse the repository at this point in the history
  • Loading branch information
EMaksy committed Jul 30, 2024
1 parent f7e322a commit a6e15b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@ const sapSystemTypes = [
'SOME_SAP_SYSTEM_FEATURE|NOT_A_REAL_SYSTEM',
];

const sapSystemIDList = sapSystemTypes.map((_) => faker.string.uuid());
const sapSystemsWithCustomTypes = sapSystemTypes.map((type, index) =>
sapSystemFactory.build({
id: sapSystemIDList[index],
const sapSystemsWithCustomTypes = sapSystemTypes.map((type) => {
const sapSystemID = faker.string.uuid();
return sapSystemFactory.build({
id: sapSystemID,
application_instances: sapSystemApplicationInstanceFactory.buildList(2, {
sap_system_id: sapSystemIDList[index],
sap_system_id: sapSystemID,
features: type,
}),
})
);
});
});
const sapSystemApplicationInstances = sapSystemsWithCustomTypes
.map((sapSystem) => sapSystem.application_instances)
.flat();
Expand Down
35 changes: 13 additions & 22 deletions assets/js/pages/SapSystemsOverviewPage/SapSystemsOverview.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ describe('SapSystemsOverviews component', () => {
it('should display the correct content for a SAP system main row', () => {
const sapSystemType = 'ABAP';
const sapSystemID = faker.string.uuid();
const sapSystemSID = faker.string.uuid();

const sapSystem = sapSystemFactory.build({
id: sapSystemID,
sid: sapSystemSID,
ensa_version: 'ensa1',
application_instances: sapSystemApplicationInstanceFactory.buildList(
2,
Expand All @@ -61,6 +60,7 @@ describe('SapSystemsOverviews component', () => {
database_instances: databaseInstances,
database_id: databaseID,
database_sid: attachedRdbms,
sid,
} = sapSystem;

renderWithRouter(
Expand All @@ -74,9 +74,7 @@ describe('SapSystemsOverviews component', () => {
const rows = screen.getByRole('table').querySelectorAll('tbody > tr');
const mainRow = rows[0];

expect(mainRow.querySelector('td:nth-child(2)')).toHaveTextContent(
sapSystemSID
);
expect(mainRow.querySelector('td:nth-child(2)')).toHaveTextContent(sid);
expect(mainRow.querySelector('td:nth-child(2) > a')).toHaveAttribute(
'href',
`/sap_systems/${sapSystemID}`
Expand Down Expand Up @@ -111,16 +109,16 @@ describe('SapSystemsOverviews component', () => {

const expectedSapSystemTypes = ['ABAP', 'JAVA', ''];

const sapSystemIDList = sapSystemTypes.map((_) => faker.string.uuid());
const sapSystems = sapSystemTypes.map((type, index) =>
sapSystemFactory.build({
id: sapSystemIDList[index],
const sapSystems = sapSystemTypes.map((type) => {
const sapSystemID = faker.string.uuid();
return sapSystemFactory.build({
id: sapSystemID,
application_instances: sapSystemApplicationInstanceFactory.buildList(
2,
{ sap_system_id: sapSystemIDList[index], features: type }
{ sap_system_id: sapSystemID, features: type }
),
})
);
});
});

const sapSystemApplicationInstances = sapSystems
.map((sapSystem) => sapSystem.application_instances)
Expand All @@ -145,29 +143,22 @@ describe('SapSystemsOverviews component', () => {
});

it('should display the correct SAP system type JAVA and ABAP', () => {
const sapSystemTypes = [
'ABAP',
'J2EE',
'SOME_SAP_SYSTEM_FEATURE|OTHER_SAP_APP',
];
const expectedSapSystemTypes = 'ABAP/JAVA';
const sapSystemID = faker.string.uuid();
const sapSystemSID = faker.string.uuid();
const sapSystem = sapSystemFactory.build({
id: sapSystemID,
sid: sapSystemSID,
application_instances: [
sapSystemApplicationInstanceFactory.build({
sap_system_id: sapSystemID,
features: sapSystemTypes[0],
features: 'ABAP',
}),
sapSystemApplicationInstanceFactory.build({
sap_system_id: sapSystemID,
features: sapSystemTypes[1],
features: 'J2EE',
}),
sapSystemApplicationInstanceFactory.build({
sap_system_id: sapSystemID,
features: sapSystemTypes[2],
features: 'SOME_SAP_SYSTEM_FEATURE|OTHER_SAP_APP',
}),
],
});
Expand Down

0 comments on commit a6e15b8

Please sign in to comment.