Skip to content

Commit

Permalink
Patternfly v4 to v5 migration (#124)
Browse files Browse the repository at this point in the history
* Patternfly v4 to v5 migration

* Update tests

* Fix lint error

* Remove code coverage
  • Loading branch information
leSamo authored Oct 25, 2023
1 parent 872530e commit ca15010
Show file tree
Hide file tree
Showing 32 changed files with 2,555 additions and 1,159 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ globals:
render: 'readonly'
mount: 'readonly'
rules:
"react/no-unknown-property": ['error', { ignore: ['ouiaId'] }]
react/no-unknown-property: ['error', { ignore: ['ouiaId'] }]
rulesdir/forbid-pf-relative-imports: off
24 changes: 0 additions & 24 deletions config/dev.webpack.config.js

This file was deleted.

70 changes: 41 additions & 29 deletions cypress/utils/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,26 @@ import strictUriEncode from 'strict-uri-encode';

export const itIsSortedBy = (param) => {
it(`is be sorted by ${param}`, () => {
cy.get('.pf-m-selected > .pf-c-table__button').should('have.text', param);
cy.get('.pf-m-selected > .pf-v5-c-table__button').should(
'have.text',
param
);
});
};

export const itIsNotSorted = () => {
it('does not show sorting indicator', () => {
cy.get('.pf-m-selected > .pf-c-table__button').should('have.length', 0);
cy.get('.pf-m-selected > .pf-v5-c-table__button').should('have.length', 0);
});
};

export const itHasTableFunctionsDisabled = () => {
it('has export button and paginations disabled and has no bulk expand', () => {
cy.get('[data-ouia-component-id=Export] button').should('be.disabled');
it('has export buttons and paginations disabled and has no bulk expand', () => {
cy.get('button[aria-label=Export]').click();
cy.get('[aria-label=Export]')
.parent()
.get('.pf-v5-c-menu__item')
.should('be.disabled');

cy.get('[data-ouia-component-id=pagination-top] button').should(
'be.disabled'
Expand All @@ -30,34 +37,38 @@ export const itHasTableFunctionsDisabled = () => {
};

export const itHasActiveFilter = (filterName, filterValue) => {
it(`has ${filterName}: ${filterValue} filter active by default`, () => {
cy.get('.pf-c-chip-group__label').should('have.text', filterName);
cy.get('.pf-c-chip-group__main ul').should('have.text', filterValue);
it.only(`has ${filterName}: ${filterValue} filter active by default`, () => {
cy.get('.pf-v5-c-chip-group__label').should('have.text', filterName);
cy.get('.pf-v5-c-chip-group__main ul').should('have.text', filterValue);
});
};

export const itHasNoActiveFilter = () => {
it('does not have any filter active by default', () => {
cy.get('.pf-c-chip-group__label').should('have.length', 0);
cy.get('.pf-v5-c-chip-group__label').should('have.length', 0);
});
};

export const itExportsDataToFile = (jsonData, filenamePrefix) => {
it('exports data to JSON and CSV files', () => {
cy.clock(Date.now());

cy.get('[data-ouia-component-id=Export] button').click();
cy.get('[data-ouia-component-id=Export] .pf-c-dropdown__menu-item').should(
'have.length',
2
);
cy.get('[data-ouia-component-id=Export] .pf-c-dropdown__menu-item')
cy.get('button[aria-label=Export]').click();
cy.get('[aria-label=Export]')
.parent()
.get('.pf-v5-c-menu__item')
.should('have.length', 2);
cy.get('[aria-label=Export]')
.parent()
.get('.pf-v5-c-menu__item')
.contains('Export to JSON')
.click();

cy.get('[data-ouia-component-id=Export] button').click();
cy.get('button[aria-label=Export]').click();

cy.get('[data-ouia-component-id=Export] .pf-c-dropdown__menu-item')
cy.get('[aria-label=Export]')
.parent()
.get('.pf-v5-c-menu__item')
.contains('Export to CSV')
.click();

Expand Down Expand Up @@ -86,7 +97,7 @@ export const itIsExpandable = (rowCount) => {

it('has expandable and collapsable items', () => {
cy.get('tbody [id^=expand-toggle]').each((item) => cy.wrap(item).click());
cy.get('tbody .pf-c-table__expandable-row.pf-m-expanded > td').should(
cy.get('tbody .pf-v5-c-table__expandable-row.pf-m-expanded > td').should(
'have.length',
rowCount
);
Expand All @@ -96,7 +107,7 @@ export const itIsExpandable = (rowCount) => {
'true'
);
cy.get('tbody [id^=expand-toggle]').each((item) => cy.wrap(item).click());
cy.get('tbody .pf-c-table__expandable-row.pf-m-expanded > td').should(
cy.get('tbody .pf-v5-c-table__expandable-row.pf-m-expanded > td').should(
'have.length',
0
);
Expand All @@ -114,7 +125,7 @@ export const itIsExpandable = (rowCount) => {
'false'
);
cy.get('thead [id^=expand-toggle]').click();
cy.get('tbody .pf-c-table__expandable-row.pf-m-expanded > td').should(
cy.get('tbody .pf-v5-c-table__expandable-row.pf-m-expanded > td').should(
'have.length',
rowCount
);
Expand All @@ -124,7 +135,7 @@ export const itIsExpandable = (rowCount) => {
'true'
);
cy.get('thead [id^=expand-toggle]').click();
cy.get('tbody .pf-c-table__expandable-row.pf-m-expanded > td').should(
cy.get('tbody .pf-v5-c-table__expandable-row.pf-m-expanded > td').should(
'have.length',
0
);
Expand All @@ -147,7 +158,7 @@ export const itIsNotExpandable = () => {
};

export const removeFilter = (chipText) => {
cy.get(`.pf-c-chip-group__main:contains(${chipText}) button`).click();
cy.get(`.pf-v5-c-chip-group__main:contains(${chipText}) button`).click();
};

export const testSorting = (columns, isTableExpandable = false) => {
Expand Down Expand Up @@ -181,8 +192,8 @@ export const testSorting = (columns, isTableExpandable = false) => {
export const testFilters = (filters) => {
filters.forEach((filter, index) => {
it(`filters by ${filter.urlParam}`, () => {
cy.get('button[data-ouia-component-id="ConditionalFilter"]').click();
cy.get('.pf-c-dropdown__menu').children().eq(index).click();
cy.get('button[aria-label="Conditional filter"]').click();
cy.get('.pf-v5-c-menu__list-item button').eq(index).click();

switch (filter.type) {
case 'text': {
Expand All @@ -200,7 +211,7 @@ export const testFilters = (filters) => {
case 'radio': {
cy.get(filter.selector).click();

cy.get('.pf-c-select__menu')
cy.get('.pf-v5-c-menu__list-item')
.children()
.each((child, index) => {
if (index === 0) {
Expand Down Expand Up @@ -233,14 +244,14 @@ export const testFilters = (filters) => {

// uncheck all possible values selected by default
if (filter.activeByDefault) {
cy.get('.pf-c-select__menu input[type="checkbox"]').uncheck({
cy.get('.pf-v5-c-menu__list-item input[type="checkbox"]').uncheck({
multiple: true,
});
}

let selectedValues = [];

cy.get('.pf-c-select__menu')
cy.get('.pf-v5-c-menu__list-item')
.children()
.each((child, index) => {
const allItems = uniqBy(
Expand Down Expand Up @@ -326,13 +337,14 @@ export const testFilters = (filters) => {

export const testPagination = () => {
const navigationButtons =
'#options-menu-top-pagination > .pf-c-pagination__nav button';
'#options-menu-top-pagination > .pf-v5-c-pagination__nav button';

it('should change page size', () => {
cy.get(navigationButtons).eq(0).should('be.disabled');
cy.get(navigationButtons).eq(1).should('be.disabled');
cy.get('#options-menu-top-pagination .pf-c-options-menu button').click();
cy.get('.pf-c-options-menu__menu button').eq(0).click();

cy.get('#options-menu-top-pagination .pf-v5-c-menu-toggle').click();
cy.get('.pf-v5-c-menu__content button').eq(0).click();

cy.url().should('include', `limit=10`);
cy.get(navigationButtons).eq(1).should('be.enabled');
Expand Down
23 changes: 23 additions & 0 deletions fec.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
appUrl: '/openshift/insights/vulnerability',
debug: true,
useProxy: true,
proxyVerbose: true,
sassPrefix: '.ocp-vulnerability, .ocpVulnerability',
interceptChromeConfig: false,
plugins: [],
hotReload: process.env.HOT === 'true',
moduleFederation: {
exclude: ['react-router-dom'],
shared: [
{
'react-router-dom': {
singleton: true,
import: false,
version: '^6.3.0',
requiredVersion: '^6.3.0',
},
},
],
},
};
Loading

0 comments on commit ca15010

Please sign in to comment.