Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { setLanguage } from '@ui5/webcomponents-base/dist/config/Language.js';
import { setTheme } from '@ui5/webcomponents-base/dist/config/Theme.js';
import applyDirection from '@ui5/webcomponents-base/dist/locale/applyDirection.js';
import { ContentDensity, Modals, ThemeProvider } from '@ui5/webcomponents-react';
import { useEffect } from 'react';
import { StrictMode, useEffect } from 'react';
import 'tocbot/dist/tocbot.css';
import '../packages/main/dist/Assets.js';
import languages from './components/languageCodes.json';
Expand Down Expand Up @@ -56,10 +56,12 @@ const preview: Preview = {
}, [theme]);

return (
<ThemeProvider>
{viewMode !== 'docs' && <Modals />}
<Story />
</ThemeProvider>
<StrictMode>
<ThemeProvider>
{viewMode !== 'docs' && <Modals />}
<Story />
</ThemeProvider>
</StrictMode>
);
}
],
Expand Down
6 changes: 4 additions & 2 deletions cypress/support/commands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ declare global {
namespace Cypress {
interface Chainable {
/**
* Cypress mount with ThemeProvider
* Cypress mount with ThemeProvider.
*
* __Note:__ Per default `options.strict` is enabled
*/
mount: (
jsx: ReactNode,
Expand Down Expand Up @@ -43,7 +45,7 @@ declare global {
* Cypress mount with ThemeProvider
*/
Cypress.Commands.add('mount', (component, { themeProviderProps = {}, ...options } = {}) => {
return mount(<ThemeProvider {...themeProviderProps}>{component}</ThemeProvider>, options);
return mount(<ThemeProvider {...themeProviderProps}>{component}</ThemeProvider>, { strict: true, ...options });
});

// copied from https://github.com/cypress-io/cypress/discussions/21150#discussioncomment-2620947 and edited slightly
Expand Down
27 changes: 17 additions & 10 deletions packages/compat/src/components/Toolbar/Toolbar.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('Toolbar', () => {
it('overflow menu', () => {
const onOverflowChange = cy.spy().as('overflowChangeSpy');
cy.viewport(300, 500);
cy.mount(<OverflowTestComponent onOverflowChange={onOverflowChange} />);
cy.mount(<OverflowTestComponent onOverflowChange={onOverflowChange} />, { strict: false });
cy.get('@overflowChangeSpy').should('have.been.calledOnce');
cy.findByTestId('toolbarElements').should('have.text', 2);
cy.findByTestId('overflowElements').should('have.text', 3);
Expand All @@ -159,7 +159,7 @@ describe('Toolbar', () => {

// flaky - remount component instead
// cy.get(`[ui5-toggle-button]`).click();
cy.mount(<OverflowTestComponent onOverflowChange={onOverflowChange} />);
cy.mount(<OverflowTestComponent onOverflowChange={onOverflowChange} />, { strict: false });
cy.get('[ui5-popover]').should('not.have.attr', 'open');

cy.get('@overflowChangeSpy').should('have.callCount', 2);
Expand Down Expand Up @@ -324,7 +324,8 @@ describe('Toolbar', () => {
<Toolbar data-testid="tb" design={design}>
<Text>Item1</Text>
<Text>Item2</Text>
</Toolbar>
</Toolbar>,
{ strict: false }
);
let height = '44px'; //2.75rem
let background = 'rgba(0, 0, 0, 0)'; // transparent
Expand Down Expand Up @@ -371,7 +372,8 @@ describe('Toolbar', () => {
<Text data-testid="tbi" style={{ width: '100px' }}>
Item3
</Text>
</Toolbar>
</Toolbar>,
{ strict: false }
);
cy.wait(200);
cy.findAllByTestId('tbi').each(($el) => {
Expand All @@ -395,7 +397,8 @@ describe('Toolbar', () => {
<Text data-testid="tbi" style={{ width: '100px' }}>
Item3
</Text>
</Toolbar>
</Toolbar>,
{ strict: false }
);
cy.wait(200);
cy.findAllByTestId('tbiV').each(($el) => {
Expand Down Expand Up @@ -529,7 +532,7 @@ describe('Toolbar', () => {
);
};
const overflowChange = cy.spy().as('overflowChange');
cy.mount(<TestComp onOverflowChange={overflowChange} style={{ width: '200px' }} />);
cy.mount(<TestComp onOverflowChange={overflowChange} style={{ width: '200px' }} />, { strict: false });

cy.get('[ui5-toggle-button]').should('not.exist');
cy.findByText('add').click();
Expand Down Expand Up @@ -573,7 +576,8 @@ describe('Toolbar', () => {
<div id="1">Text1</div>
<div>Text2 no id</div>
<Button id="3">Text4</Button>
</Toolbar>
</Toolbar>,
{ strict: false }
);

cy.get('#1').should('have.length', 1);
Expand All @@ -590,7 +594,8 @@ describe('Toolbar', () => {
<div>Text1</div>
<div>Text2</div>
<Button>Text4</Button>
</Toolbar>
</Toolbar>,
{ strict: false }
);
cy.get('section[role="alertdialog"]').should('exist');

Expand All @@ -599,7 +604,8 @@ describe('Toolbar', () => {
<div>Text1</div>
<div>Text2</div>
<Button>Text4</Button>
</Toolbar>
</Toolbar>,
{ strict: false }
);
cy.get('section').should('not.have.attr', 'role');
cy.get('[data-component-name="ToolbarOverflowPopoverContent"]').should('have.attr', 'role', 'menu');
Expand All @@ -609,7 +615,8 @@ describe('Toolbar', () => {
<div>Text1</div>
<div>Text2</div>
<Button>Text4</Button>
</Toolbar>
</Toolbar>,
{ strict: false }
);
cy.get('section').should('not.have.attr', 'role');
cy.get('[data-component-name="ToolbarOverflowPopoverContent"]').should('have.attr', 'role', 'menu');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,13 +813,15 @@ describe('AnalyticalTable', () => {
const { onRowSelect } = props;
const [relevantPayload, setRelevantPayload] = useState<Record<string, any>>({});
const tableInstance = useRef<Record<string, any>>(null);
// strict mode
const hasRun = useRef(false);

useEffect(() => {
if (tableInstance.current) {
tableInstance.current.setGroupBy(['name']);
if (tableInstance.current && !hasRun.current) {
setTimeout(() => {
tableInstance.current.toggleAllRowsExpanded();
tableInstance.current.toggleAllRowsExpanded(true);
}, 100);
hasRun.current = true;
}
}, []);

Expand Down Expand Up @@ -850,6 +852,7 @@ describe('AnalyticalTable', () => {
onRowSelect(e);
}}
data={groupableData}
reactTableOptions={{ initialState: { groupBy: ['name'] } }}
selectionMode="Multiple"
/>
<div data-testid="selectedFlatRowsLength">
Expand Down
13 changes: 9 additions & 4 deletions packages/main/src/components/ObjectPage/ObjectPage.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -348,16 +348,18 @@ describe('ObjectPage', () => {
</ObjectPage>
);

cy.wait(200);

cy.findByText('Goals').should('not.be.visible');
cy.findByText('Employment').should('not.be.visible');
cy.findByText('Test').should('be.visible');

cy.get('[ui5-tabcontainer]').findUi5TabByText('Employment').realClick();
//fallback
cy.wait(50);
cy.get('[ui5-tabcontainer]').findUi5TabByText('Employment').realClick();
cy.findByText('Employment').should('be.visible');
cy.get('[ui5-tabcontainer]').findUi5TabByText('Goals').click();

cy.wait(200);

cy.get('[ui5-tabcontainer]').findUi5TabByText('Goals').realClick();
cy.findByText('Test').should('be.visible');

cy.get('[ui5-tabcontainer]').findUi5TabByText('Employment').focus();
Expand All @@ -377,6 +379,7 @@ describe('ObjectPage', () => {
{OPContent}
</ObjectPage>
);
cy.wait(100);

cy.findByText('Employment').should('not.be.visible');
cy.findByText('Test').should('be.visible');
Expand Down Expand Up @@ -1034,6 +1037,8 @@ describe('ObjectPage', () => {
};

cy.mount(<TestComp />);
cy.wait(200);

cy.get('[ui5-tabcontainer]').findUi5TabByText('test2').realClick();
cy.findByText('Content1').should('not.be.visible');
cy.findByText('Content2').should('be.visible');
Expand Down
3 changes: 2 additions & 1 deletion packages/main/src/components/ThemeProvider/I18n.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ describe('I18nProvider', () => {
</>
);
};
cy.mount(<TranslationComponent />);
// strict mode disabled, otherwise counter is incremented twice on each render
cy.mount(<TranslationComponent />, { strict: false });
cy.findByTestId('counter').should('have.text', 1);
cy.findByText('Please wait')
.then(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ describe('VariantManagement', () => {
VariantItem 3
</VariantItem>
]}
</VariantManagement>
</VariantManagement>,
{ strict: false }
);

cy.contains('VariantItem 2').click();
Expand All @@ -66,7 +67,7 @@ describe('VariantManagement', () => {

cy.findByText('Save').click();
cy.get('@onSaveManageViews').should('have.been.calledOnce');

//todo: investigate why this matcher fails in React strict mode
cy.get('@onSaveManageViews').should(
'have.been.calledWith',
Cypress.sinon.match({
Expand Down
Loading