Skip to content

Commit

Permalink
MWB-952: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverBerserk committed Jan 21, 2025
1 parent 16719bc commit 3f81924
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ Feature: Mapping Packages States
Then I get redirected to Mapping Packages list page
Then I search for Mapping Package
When I open actions menu


Scenario: State Details
Then I click on View Last State
Then I receive Mapping Packages State

Scenario Outline: <tab_name> Reports
Then I click on "<tab_name>" Reports Tab
Then I receive Mapping Packages State "<tab_name>"
Then I click on "<tab_name>" Data
Then I receive Mapping Packages Suite "<tab_name>"
Then I click on "<tab_name>" Data
Then I receive Mapping Packages Test "<tab_name>"
Examples:
| tab_name |
| Xpath |
| Sparql |
| Shacl |

# Scenario Outline: <tab_name> Reports
# Then I click on "<tab_name>" Reports Tab
# Then I receive Mapping Packages State "<tab_name>"
# Then I click on "<tab_name>" Data
# Then I receive Mapping Packages Suite "<tab_name>"
# Then I click on "<tab_name>" Data
# Then I receive Mapping Packages Test "<tab_name>"
# Examples:
# | tab_name |
# | Xpath |
# | Sparql |
# | Shacl |
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ Then('I search for Mapping Package', () => {

Then('I click on View Last State', () => {
cy.intercept('GET', appURLPrefix + 'mapping_packages/state/*',).as('getState')
cy.intercept('GET', appURLPrefix + 'package_validator/xpath/state/*',).as('getXpath')
cy.intercept('GET', appURLPrefix + 'package_validator/sparql/state/*',).as('getSparql')
cy.intercept('GET', appURLPrefix + 'package_validator/shacl/state/*',).as('getShacl')
cy.get('#view_last_state_button').click()
})

Then('I receive Mapping Packages State', () => {
cy.wait('@getState').its('response.statusCode').should('eq', 200)
cy.wait('@getXpath').its('response.statusCode').should('eq', 200)
cy.wait('@getSparql').its('response.statusCode').should('eq', 200)
cy.wait('@getShacl').its('response.statusCode').should('eq', 200)
})

Then('I click on {string} Reports Tab', (tabName) => {
Expand Down
2 changes: 1 addition & 1 deletion mapping_workbench/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"@types/react-slick": "0.23.10",
"@types/react-syntax-highlighter": "15.5.6",
"babel-plugin-prismjs": "^2.1.0",
"cypress": "^13.13.3",
"cypress": "^13.17.0",
"cypress-cucumber-preprocessor": "^4.3.1",
"eslint": "9.15.0",
"eslint-config-next": "15.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ const Page = () => {

const handleExport = (setIsExporting) => exportPackage(sectionApi, id, setIsExporting, item)

const disabledTabs = {
xpath: !validationReport.xpath?.length,
sparql: !validationReport.sparql?.length,
shacl: !validationReport.shacl?.length,
}

return (
<>
<Seo title={`App: ${sectionApi.SECTION_ITEM_TITLE} View`}/>
Expand Down Expand Up @@ -194,7 +200,7 @@ const Page = () => {
id={tab.value + '_reports_tab'}
label={tab.label}
value={tab.value}
disabled={!validationReportTree.test_data_suites?.length}
disabled={!validationReportTree.test_data_suites?.length || disabledTabs[tab.value]}
/>
))}
</Tabs>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const ListTable = (props) => {
} = props;

const handleOpenDetails = ({title, notices}) => {
console.log('on open details')
const description = notices.map((notice, i) =>
<Box key={'notice' + i}>
<Button type='link'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,73 +16,73 @@ export const resultColor = (result) => {
case "unverifiable":
case "valid":
return "success"
default: return "info"
default:
return "info"
}
}

export const ResultChip = ({label, color, clickable}) => {
return(
export const ResultChip = ({label, color, clickable, onClick}) => {
return (
<Chip label={label}
clickable={clickable}
color={resultColor(color ?? label)}
/>
onClick={onClick}
/>
)
}


export const SorterHeader = ({fieldName, title, desc, sort, onSort}) => {
return <Tooltip enterDelay={300}
title="Sort"
>
<TableSortLabel
active={sort.column === fieldName}
direction={sort.direction}
onClick={() => onSort(fieldName, desc)}>
{title ?? fieldName}
</TableSortLabel>
</Tooltip>
title="Sort"
>
<TableSortLabel
active={sort.column === fieldName}
direction={sort.direction}
onClick={() => onSort(fieldName, desc)}>
{title ?? fieldName}
</TableSortLabel>
</Tooltip>
}

export const sortItems = (items, sort) => {
const sortColumn = sort.column
if(!sortColumn) {
return items
} else {
return items.sort((a,b) => {
if (typeof a[sortColumn] === "string")
return sort.direction === "asc" ?
a[sortColumn]?.localeCompare(b[sortColumn]) :
b[sortColumn]?.localeCompare(a[sortColumn])
else
return sort.direction === "asc" ?
a[sortColumn] - b[sortColumn] :
b[sortColumn] - a[sortColumn]
})
}
const sortColumn = sort.column
if (!sortColumn) {
return items
} else {
return items.sort((a, b) => {
if (typeof a[sortColumn] === "string")
return sort.direction === "asc" ?
a[sortColumn]?.localeCompare(b[sortColumn]) :
b[sortColumn]?.localeCompare(a[sortColumn])
else
return sort.direction === "asc" ?
a[sortColumn] - b[sortColumn] :
b[sortColumn] - a[sortColumn]
})
}
}

export const TableSkeleton = ({lines = 5}) => {
return new Array(lines).fill("").map((e, i) =>
<Skeleton key={'line' + i}
height={50}/>)
<Skeleton key={'line' + i}
height={50}/>)
}

export const TableNoData = () => {
return <Stack justifyContent="center"
direction="row">
<Alert severity="info">No Data !</Alert>
</Stack>
direction="row">
<Alert severity="info">No Data !</Alert>
</Stack>
}

export const TableErrorFetching = () => {
return <Stack justifyContent="center"
direction="row">
<Alert severity="error">Error on fetching data !</Alert>
</Stack>
direction="row">
<Alert severity="error">Error on fetching data !</Alert>
</Stack>
}



export const TableLoadWrapper = ({children, data, dataState, lines}) => {
if (dataState.load) return <TableSkeleton lines={lines}/>
if (dataState.error) return <TableErrorFetching/>
Expand Down

0 comments on commit 3f81924

Please sign in to comment.