home app fragment
This commit is contained in:
parent
1b33835b14
commit
51f0f6e5c3
10 changed files with 1054 additions and 320 deletions
|
@ -1,144 +0,0 @@
|
||||||
import { getH1, getH3 } from "../support/app.po";
|
|
||||||
|
|
||||||
describe("3000-home/", () => {
|
|
||||||
beforeEach(() => cy.visit("/"));
|
|
||||||
|
|
||||||
describe("Warmup Next", () => {
|
|
||||||
xit("warms pages concurrently", () => {
|
|
||||||
const urls = [
|
|
||||||
"/shop",
|
|
||||||
"/checkout",
|
|
||||||
"/checkout/test-title",
|
|
||||||
"/checkout/test-check-button",
|
|
||||||
"/api/test",
|
|
||||||
];
|
|
||||||
urls.forEach((url) => {
|
|
||||||
cy.request(url); // This makes a GET request, not a full page visit
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Welcome message", () => {
|
|
||||||
it("should display welcome message", () => {
|
|
||||||
getH1().contains("This is SPA combined");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Image checks", () => {
|
|
||||||
xit("should check that the home-webpack-png and shop-webpack-png images are not 404", () => {
|
|
||||||
// Get the src attribute of the home-webpack-png image
|
|
||||||
cy.debug()
|
|
||||||
.get("img.home-webpack-png")
|
|
||||||
.invoke("attr", "src")
|
|
||||||
.then((src) => {
|
|
||||||
cy.log(src);
|
|
||||||
cy.request(src).its("status").should("eq", 200);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Get the src attribute of the shop-webpack-png image
|
|
||||||
cy.get("img.shop-webpack-png")
|
|
||||||
.invoke("attr", "src")
|
|
||||||
.then((src) => {
|
|
||||||
// Send a GET request to the src URL
|
|
||||||
cy.request(src).its("status").should("eq", 200);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Routing checks", () => {
|
|
||||||
it("check that clicking back and forwards in client side routeing still renders the content correctly", () => {
|
|
||||||
cy.visit("/shop");
|
|
||||||
cy.wait(3000);
|
|
||||||
cy.url().should("include", "/shop");
|
|
||||||
getH1().contains("Shop Page");
|
|
||||||
//eslint-disable-next-line
|
|
||||||
cy.wait(3000);
|
|
||||||
cy.get(".home-menu-link").contains("Home 3000");
|
|
||||||
cy.get(".home-menu-link").click();
|
|
||||||
cy.wait(2000);
|
|
||||||
cy.url().should("include", "/");
|
|
||||||
cy.wait(700);
|
|
||||||
getH1().contains("This is SPA combined");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("3000-home/checkout", () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
cy.visit("/checkout");
|
|
||||||
cy.visit("/");
|
|
||||||
cy.visit("/checkout");
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Welcome message", () => {
|
|
||||||
it("should display welcome message", () => {
|
|
||||||
getH1().contains("checkout page");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Tag checks", () => {
|
|
||||||
it("should check that a .description + pre tag exists", () => {
|
|
||||||
cy.get(".description").should("exist");
|
|
||||||
cy.get("main pre").should("exist");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("3000-home/checkout/test-title", () => {
|
|
||||||
beforeEach(() => cy.visit("/checkout/test-title"));
|
|
||||||
|
|
||||||
it("should display welcome message", () => {
|
|
||||||
getH3().contains("This title came");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("3000-home/checkout/test-check-button", () => {
|
|
||||||
beforeEach(() => cy.visit("/checkout/test-check-button"));
|
|
||||||
|
|
||||||
it("should display welcome message", () => {
|
|
||||||
cy.get("button").contains("Button");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("3000-home/shop", () => {
|
|
||||||
beforeEach(() => cy.visit("/shop"));
|
|
||||||
|
|
||||||
describe("Welcome message", () => {
|
|
||||||
it("should display welcome message", () => {
|
|
||||||
getH1().contains("Shop Page");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Image checks", () => {
|
|
||||||
xit("should check that shop-webpack-png images are not 404", () => {
|
|
||||||
// Get the src attribute of the shop-webpack-png image
|
|
||||||
cy.get("img.shop-webpack-png")
|
|
||||||
.invoke("attr", "src")
|
|
||||||
.then((src) => {
|
|
||||||
// Send a GET request to the src URL
|
|
||||||
cy.request(src).its("status").should("eq", 200);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it("should check that shop-webpack-png images are not 404 between route clicks", () => {
|
|
||||||
cy.visit("/");
|
|
||||||
cy.visit("/shop");
|
|
||||||
cy.url().should("include", "/shop");
|
|
||||||
getH1().contains("Shop Page");
|
|
||||||
cy.get(".home-menu-link").click();
|
|
||||||
//eslint-disable-next-line
|
|
||||||
cy.wait(2999);
|
|
||||||
cy.get("img.shop-webpack-png")
|
|
||||||
.invoke("attr", "src")
|
|
||||||
.then((src) => {
|
|
||||||
// Send a GET request to the src URL
|
|
||||||
cy.request(src).its("status").should("eq", 200);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Tag checks", () => {
|
|
||||||
it("should check that a .description + pre tag exists", () => {
|
|
||||||
cy.get(".description + pre").should("exist");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"name": "Using fixtures to represent data",
|
|
||||||
"email": "hello@cypress.io",
|
|
||||||
"body": "Fixtures are a great way to mock data for responses to routes"
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
export const getH1 = () => cy.get("h1");
|
|
||||||
export const getH2 = () => cy.get("h2");
|
|
||||||
export const getH3 = () => cy.get("h3");
|
|
|
@ -1,35 +0,0 @@
|
||||||
/// <reference types="cypress" />
|
|
||||||
|
|
||||||
// ***********************************************
|
|
||||||
// This example commands.ts shows you how to
|
|
||||||
// create various custom commands and overwrite
|
|
||||||
// existing commands.
|
|
||||||
//
|
|
||||||
// For more comprehensive examples of custom
|
|
||||||
// commands please read more here:
|
|
||||||
// https://on.cypress.io/custom-commands
|
|
||||||
// ***********************************************
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
||||||
declare namespace Cypress {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
interface Chainable<Subject> {
|
|
||||||
login(email: string, password: string): void;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -- This is a parent command --
|
|
||||||
Cypress.Commands.add("login", (email, password) => {
|
|
||||||
console.log("Custom command example: Login", email, password);
|
|
||||||
});
|
|
||||||
//
|
|
||||||
// -- This is a child command --
|
|
||||||
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// -- This is a dual command --
|
|
||||||
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// -- This will overwrite an existing command --
|
|
||||||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
|
|
@ -1,17 +0,0 @@
|
||||||
// ***********************************************************
|
|
||||||
// This example support/e2e.ts is processed and
|
|
||||||
// loaded automatically before your test files.
|
|
||||||
//
|
|
||||||
// This is a great place to put global configuration and
|
|
||||||
// behavior that modifies Cypress.
|
|
||||||
//
|
|
||||||
// You can change the location of this file or turn off
|
|
||||||
// automatically serving support files with the
|
|
||||||
// 'supportFile' configuration option.
|
|
||||||
//
|
|
||||||
// You can read more here:
|
|
||||||
// https://on.cypress.io/configuration
|
|
||||||
// ***********************************************************
|
|
||||||
|
|
||||||
// Import commands.ts using ES2015 syntax:
|
|
||||||
import "./commands";
|
|
|
@ -1,20 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "../tsconfig.json",
|
|
||||||
"compilerOptions": {
|
|
||||||
"allowJs": true,
|
|
||||||
"outDir": "../../dist/out-tsc",
|
|
||||||
"module": "commonjs",
|
|
||||||
"types": ["cypress", "node"],
|
|
||||||
"sourceMap": false
|
|
||||||
},
|
|
||||||
"include": [
|
|
||||||
"**/*.ts",
|
|
||||||
"**/*.js",
|
|
||||||
"../cypress.config.ts",
|
|
||||||
"../**/*.cy.ts",
|
|
||||||
"../**/*.cy.tsx",
|
|
||||||
"../**/*.cy.js",
|
|
||||||
"../**/*.cy.jsx",
|
|
||||||
"../**/*.d.ts"
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,63 +1,5 @@
|
||||||
const { withNx } = require("@nx/next/plugins/with-nx");
|
|
||||||
const NextFederationPlugin = require("@module-federation/nextjs-mf");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {import('@nx/next/plugins/with-nx').WithNxOptions}
|
|
||||||
**/
|
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
nx: {
|
|
||||||
// Set this to true if you would like to to use SVGR
|
|
||||||
// See: https://github.com/gregberge/svgr
|
|
||||||
svgr: false,
|
|
||||||
},
|
|
||||||
webpack(config, options) {
|
webpack(config, options) {
|
||||||
const { isServer } = options;
|
|
||||||
config.watchOptions = {
|
|
||||||
ignored: ["**/node_modules/**", "**/@mf-types/**"],
|
|
||||||
};
|
|
||||||
// used for testing build output snapshots
|
|
||||||
const remotes = {
|
|
||||||
checkout: `checkout@http://localhost:3002/_next/static/${
|
|
||||||
isServer ? "ssr" : "chunks"
|
|
||||||
}/remoteEntry.js`,
|
|
||||||
home_app: `home_app@http://localhost:3000/_next/static/${
|
|
||||||
isServer ? "ssr" : "chunks"
|
|
||||||
}/remoteEntry.js`,
|
|
||||||
shop: `shop@http://localhost:3001/_next/static/${
|
|
||||||
isServer ? "ssr" : "chunks"
|
|
||||||
}/remoteEntry.js`,
|
|
||||||
};
|
|
||||||
|
|
||||||
config.plugins.push(
|
|
||||||
new NextFederationPlugin({
|
|
||||||
name: "home_app",
|
|
||||||
filename: "static/chunks/remoteEntry.js",
|
|
||||||
remotes: {
|
|
||||||
shop: remotes.shop,
|
|
||||||
checkout: remotes.checkout,
|
|
||||||
},
|
|
||||||
exposes: {
|
|
||||||
"./SharedNav": "./components/SharedNav",
|
|
||||||
"./menu": "./components/menu",
|
|
||||||
},
|
|
||||||
shared: {
|
|
||||||
"lodash/": {},
|
|
||||||
antd: {
|
|
||||||
requiredVersion: "5.19.1",
|
|
||||||
version: "5.19.1",
|
|
||||||
},
|
|
||||||
"@ant-design/": {
|
|
||||||
singleton: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
extraOptions: {
|
|
||||||
debug: false,
|
|
||||||
exposePages: true,
|
|
||||||
enableImageLoaderFix: true,
|
|
||||||
enableUrlLoaderFix: true,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
config.plugins.push({
|
config.plugins.push({
|
||||||
name: "xxx",
|
name: "xxx",
|
||||||
apply(compiler) {
|
apply(compiler) {
|
||||||
|
@ -68,4 +10,4 @@ const nextConfig = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = withNx(nextConfig);
|
module.exports = nextConfig;
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es2017",
|
"target": "es5",
|
||||||
"jsx": "preserve",
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
"module": "esnext",
|
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"esModuleInterop": true,
|
"skipLibCheck": true,
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
"strict": false,
|
"strict": false,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "node",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
|
"jsx": "preserve",
|
||||||
"incremental": true
|
"incremental": true
|
||||||
},
|
},
|
||||||
"include": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "next-env.d.ts"],
|
"include": ["next-env.d.ts", "environment.d.ts", "**/*.ts", "**/*.tsx"],
|
||||||
"exclude": ["node_modules", "jest.config.ts"]
|
"exclude": ["node_modules"]
|
||||||
}
|
}
|
||||||
|
|
1072
pnpm-lock.yaml
1072
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
@ -3,3 +3,4 @@ packages:
|
||||||
- 'bench/*'
|
- 'bench/*'
|
||||||
- 'packages/next-swc/crates/next-core/js'
|
- 'packages/next-swc/crates/next-core/js'
|
||||||
- 'examples/next-css'
|
- 'examples/next-css'
|
||||||
|
- 'examples/federation-single-app'
|
||||||
|
|
Loading…
Reference in a new issue