Skip to content

Commit 9d72621

Browse files
committed
Fix Tests
1 parent 6419016 commit 9d72621

File tree

4 files changed

+342
-0
lines changed

4 files changed

+342
-0
lines changed

tests/cypress/fixtures/flow.json

Lines changed: 316 additions & 0 deletions
Large diffs are not rendered by default.

tests/cypress/integration/5-AI-SiteGen-onboarding-flow/6-preview.cy.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from '../wp-module-support/siteGen.cy';
99
import {
1010
apiList,
11+
flowMock,
1112
siteGenMockAll,
1213
homePagesMock,
1314
homePagesRegenerate,
@@ -18,6 +19,10 @@ describe( 'SiteGen Site Preview Step', function () {
1819
cy.visit(
1920
'wp-admin/index.php?page=nfd-onboarding#/sitegen/step/preview'
2021
);
22+
cy.intercept( apiList.flow, ( req ) => {
23+
flowMock( req );
24+
} ).as( 'flowCall' );
25+
2126
cy.intercept( apiList.sitegen, ( req ) => {
2227
siteGenMockAll( req );
2328
} ).as( 'sitegenCalls' );

tests/cypress/integration/5-AI-SiteGen-onboarding-flow/7-editor.cy.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// <reference types="Cypress" />
22
import {
33
apiList,
4+
flowMock,
45
customizeDataMock,
56
themeStyleMock,
67
} from '../wp-module-support/MockApi.cy';
@@ -16,6 +17,11 @@ describe( 'SiteGen Site Editor Step', function () {
1617
cy.visit(
1718
'wp-admin/index.php?page=nfd-onboarding#/sitegen/step/preview'
1819
);
20+
21+
cy.intercept( apiList.flow, ( req ) => {
22+
flowMock( req );
23+
} ).as( 'flowCall' );
24+
1925
cy.wait( 10000 );
2026
} );
2127

tests/cypress/integration/wp-module-support/MockApi.cy.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ const theme_style_mock = require( '../../fixtures/theme-style.json' );
1212
const customize_data_mock = require( '../../fixtures/customize-data.json' );
1313
const homepage_regenerate_mock = require( '../../fixtures/homepage-regenerate.json' );
1414
const migrate_connect_mock = require( '../../fixtures/migrate-connect.json' );
15+
const flow_mock = require( '../../fixtures/flow.json' );
1516

1617
export const apiList = {
18+
flow:
19+
'/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fflow&flow=sitegen&_locale=user',
1720
sitegen:
1821
'/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fsitegen%2Fgenerate&flow=sitegen&_locale=user',
1922
homepages:
@@ -28,6 +31,18 @@ export const apiList = {
2831
'/index.php?rest_route=%2Fnewfold-migration%2Fv1%2Fmigrate%2Fconnect&_locale=user',
2932
};
3033

34+
export const flowMock = ( req ) => {
35+
const requestBody = req.body;
36+
req.reply( {
37+
statusCode: 200,
38+
body: flow_mock,
39+
headers: {
40+
'content-type': 'application/json',
41+
},
42+
delay: 3000,
43+
} );
44+
};
45+
3146
export const siteGenMockAll = ( req ) => {
3247
const requestBody = req.body;
3348
const sitegen_identifiers = {

0 commit comments

Comments
 (0)