Skip to content

Commit 9dd7abc

Browse files
Merge branch 'main' into share-filter
# Conflicts: # apps/next-app-router/next-app-router-4000/cypress.config.ts # apps/next-app-router/next-app-router-4000/cypress/support/commands.ts
2 parents e15d158 + 52b123f commit 9dd7abc

File tree

16 files changed

+162
-40
lines changed

16 files changed

+162
-40
lines changed

apps/next-app-router/next-app-router-4000/cypress.config.ts

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,11 @@
11
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
22
import { defineConfig } from 'cypress';
3-
import { execSync } from 'child_process';
43

54
export default defineConfig({
6-
projectId: 'next-app-router-4000',
5+
projectId: '27e40c91-5ac3-4433-8a87-651d10f51cf6',
76
e2e: {
87
...nxE2EPreset(__filename, { cypressDir: 'cypress' }),
9-
// Please ensure you use `cy.origin()` when navigating between domains and remove this option.
10-
// See https://docs.cypress.io/app/references/migration-guide#Changes-to-cyorigin
11-
injectDocumentDomain: true,
12-
setupNodeEvents(on, config) {
13-
// Kill servers when ALL tests are done (not after each test file)
14-
on('after:run', (results) => {
15-
console.log('🧹 All tests completed, cleaning up servers...');
16-
console.log(
17-
`📊 Test results: ${results.totalPassed} passed, ${results.totalFailed} failed`,
18-
);
19-
20-
try {
21-
console.log('🔪 Killing servers on ports 4000 and 4001...');
22-
execSync('npx kill-port 4000 4001', { stdio: 'inherit' });
23-
console.log('✅ Server cleanup completed successfully');
24-
} catch (error) {
25-
console.log(
26-
'⚠️ Error during server cleanup (servers may already be closed):',
27-
error.message,
28-
);
29-
}
30-
});
31-
32-
// Log when each spec starts (but don't kill servers)
33-
on('before:spec', (spec) => {
34-
console.log(`🚀 Starting spec: ${spec.name}`);
35-
});
36-
37-
// Log when each spec ends (but don't kill servers)
38-
on('after:spec', (spec, results) => {
39-
console.log(
40-
`✨ Completed spec: ${spec.name} - ${results.stats.passes} passed, ${results.stats.failures} failed`,
41-
);
42-
});
43-
},
8+
baseUrl: 'http://localhost:4000',
449
},
4510
defaultCommandTimeout: 20000,
4611
retries: {
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { getH1 } from '../support/app.po';
2+
3+
describe('next-app-router-4000', () => {
4+
beforeEach(() => cy.visit('/'));
5+
6+
describe('Home page', () => {
7+
it('should display examples heading', () => {
8+
getH1().contains('Examples');
9+
});
10+
11+
it('should have remote button from module federation', () => {
12+
cy.get('button').contains('Button from remote').should('exist');
13+
});
14+
15+
it('should have navigation links', () => {
16+
cy.get('a[href="/layouts"]').should('exist');
17+
cy.get('a[href="/error-handling"]').should('exist');
18+
cy.get('a[href="/loading"]').should('exist');
19+
});
20+
});
21+
22+
describe('Navigation', () => {
23+
it('should navigate to layouts page', () => {
24+
cy.get('a[href="/layouts"]').first().click();
25+
cy.url().should('include', '/layouts');
26+
});
27+
28+
it('should navigate to parallel routes', () => {
29+
cy.get('a[href="/parallel-routes"]').first().click();
30+
cy.url().should('include', '/parallel-routes');
31+
});
32+
});
33+
34+
describe('Module Federation', () => {
35+
it('should load remote button component', () => {
36+
cy.get('button').contains('Button from remote').should('be.visible');
37+
});
38+
});
39+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "hello@cypress.io",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const getH1 = () => cy.get('h1');
2+
export const getH2 = () => cy.get('h2');
3+
export const getH3 = () => cy.get('h3');
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"sourceMap": false,
5+
"outDir": "../../../dist/out-tsc",
6+
"allowJs": true,
7+
"types": ["cypress", "node"],
8+
"esModuleInterop": true,
9+
"forceConsistentCasingInFileNames": true,
10+
"strict": true,
11+
"skipLibCheck": true
12+
},
13+
"include": ["**/*.ts", "**/*.js", "../cypress.config.ts"]
14+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
2+
import { defineConfig } from 'cypress';
3+
4+
export default defineConfig({
5+
projectId: '27e40c91-5ac3-4433-8a87-651d10f51cf6',
6+
e2e: {
7+
...nxE2EPreset(__filename, { cypressDir: 'cypress' }),
8+
baseUrl: 'http://localhost:4001',
9+
},
10+
defaultCommandTimeout: 20000,
11+
retries: {
12+
runMode: 2,
13+
openMode: 1,
14+
},
15+
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
describe('next-app-router-4001', () => {
2+
beforeEach(() => cy.visit('/'));
3+
4+
describe('Remote component (Button)', () => {
5+
it('should export Button component for module federation', () => {
6+
// This app serves as a remote that exports the Button component
7+
// Testing that the app loads successfully
8+
cy.visit('/');
9+
});
10+
});
11+
12+
describe('Button component functionality', () => {
13+
it('should render default button', () => {
14+
// If there's a test page that renders the button
15+
cy.visit('/');
16+
// Check if the page loads without errors
17+
cy.get('body').should('exist');
18+
});
19+
});
20+
21+
describe('Module Federation Remote', () => {
22+
it('should be accessible as a remote module', () => {
23+
// Verify the app is running and accessible
24+
cy.request('/').its('status').should('eq', 200);
25+
});
26+
});
27+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "hello@cypress.io",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const getH1 = () => cy.get('h1');
2+
export const getH2 = () => cy.get('h2');
3+
export const getH3 = () => cy.get('h3');
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// ***********************************************
2+
// This example commands.ts shows you how to
3+
// create various custom commands and overwrite
4+
// existing commands.
5+
//
6+
// For more comprehensive examples of custom
7+
// commands please read more here:
8+
// https://on.cypress.io/custom-commands
9+
// ***********************************************

0 commit comments

Comments
 (0)