Skip to content

Commit

Permalink
fix: summary e2e-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelrss committed Nov 13, 2023
1 parent 07a57fe commit 4c7e769
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 21 deletions.
10 changes: 10 additions & 0 deletions src/features/layout/formLayoutSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,16 @@ export const formLayoutSlice = () => {
moveToNextPage: mkAction<LayoutTypes.IMoveToNextPage>({
takeEvery: moveToNextPageSaga,
}),
/**
* This action (setPageOrder) is used by the e2e-tests
* in summary.ts. It is not used in the application.
*/
setPageOrder: mkAction<{ order: string[] }>({
reducer: (state, action) => {
const { order } = action.payload;
state.uiConfig.pageOrderConfig.order = order;
},
}),
moveToNextPageRejected: genericReject,
updateHiddenLayouts: mkAction<LayoutTypes.IHiddenLayoutsUpdate>({
takeEvery: findAndMoveToNextVisibleLayout,
Expand Down
1 change: 0 additions & 1 deletion src/features/layout/formLayoutTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export interface IKeepComponentScrollPos {

export interface IMoveToNextPage {
runValidations?: TriggersPageValidation;
skipMoveToNext?: boolean;
keepScrollPos?: IKeepComponentScrollPos;
}

Expand Down
12 changes: 0 additions & 12 deletions src/features/layout/update/updateFormLayoutSagas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,6 @@ describe('updateLayoutSagas', () => {
.run();
});

it('should not update current view if skipMoveToNext is true', () => {
const action: PayloadAction<IMoveToNextPage> = {
type: 'test',
payload: {
skipMoveToNext: true,
},
};
return expectSaga(moveToNextPageSaga, action)
.provide([[select(), state]])
.run();
});

it('stateless: should fetch pageOrder and update state accordingly', () => {
const action: PayloadAction<IMoveToNextPage> = {
type: 'test',
Expand Down
6 changes: 1 addition & 5 deletions src/features/layout/update/updateFormLayoutSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export function* updateCurrentViewSaga({
}

export function* moveToNextPageSaga({
payload: { runValidations, skipMoveToNext, keepScrollPos },
payload: { runValidations, keepScrollPos },
}: PayloadAction<IMoveToNextPage>): SagaIterator {
try {
const state: IRuntimeState = yield select();
Expand All @@ -184,10 +184,6 @@ export function* moveToNextPageSaga({
return;
}

if (skipMoveToNext) {
return;
}

const returnToView = state.formLayout.uiConfig.returnToView;
const layoutOrder = getLayoutOrderFromPageOrderConfig(state.formLayout.uiConfig.pageOrderConfig) || [];
const newView = returnToView || layoutOrder[layoutOrder.indexOf(currentView) + 1];
Expand Down
2 changes: 1 addition & 1 deletion src/layout/NavigationBar/NavigationBarComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export const NavigationBarComponent = ({ node }: INavigationBar) => {
{pageIds.map((pageId, index) => (
<li
key={pageId}
className={cn(classes.containerBase)}
className={classes.containerBase}
>
<NavigationButton
current={currentPageId === pageId}
Expand Down
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export interface IPageOrderConfig {
* is not in this list, it should be considered hidden. It will be null until layouts have been fetched.
*
* Do NOT use this directly, as it will not respect layouts hidden using expressions!
* @see getLayoutOrderFromTracks
* @see getLayoutOrderFromPageOrderConfig
* @see selectLayoutOrder
*/
order: string[] | null;
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/integration/frontend-test/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ function injectExtraPageAndSetTriggers(trigger?: Triggers | undefined) {
cy.get('#readyForPrint').then(() => {
cy.reduxDispatch({
// Injecting the new page into redux
type: 'formLayout/calculatePageOrderAndMoveToNextPageFulfilled',
type: 'formLayout/setPageOrder',
payload: {
order: ['form', 'summary', 'grid', 'lastPage'],
},
Expand Down

0 comments on commit 4c7e769

Please sign in to comment.