// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`MF Remote App Generator --ssr should generate the correct files 1`] = `
"import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    RouterModule.forRoot(
      [
        {
          path: '',
          loadChildren: () =>
            import('./remote-entry/entry.module').then(
              (m) => m.RemoteEntryModule
            ),
        },
      ],
      { initialNavigation: 'enabledBlocking' }
    ),
  ],
  providers: [],
  bootstrap: [AppComponent],
})
export class AppModule {}
"
`;

exports[`MF Remote App Generator --ssr should generate the correct files 2`] = `
"import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';

platformBrowserDynamic()
  .bootstrapModule(AppModule)
  .catch((err) => console.error(err));
"
`;

exports[`MF Remote App Generator --ssr should generate the correct files 3`] = `
"export { AppServerModule } from './app/app.server.module';
"
`;

exports[`MF Remote App Generator --ssr should generate the correct files 4`] = `
"import 'zone.js/dist/zone-node';

import { APP_BASE_HREF } from '@angular/common';
import { ngExpressEngine } from '@nguniversal/express-engine';
import * as express from 'express';
import * as cors from 'cors';
import { existsSync } from 'fs';
import { join } from 'path';

import { AppServerModule } from './bootstrap.server';

// The Express app is exported so that it can be used by serverless Functions.
export function app(): express.Express {
  const server = express();
  const browserBundles = join(process.cwd(), 'dist/apps/test/browser');
  const serverBundles = join(process.cwd(), 'dist/apps/test/server');

  server.use(cors());
  const indexHtml = existsSync(join(browserBundles, 'index.original.html'))
    ? 'index.original.html'
    : 'index';

  // Our Universal express-engine (found @ https://github.com/angular/universal/tree/main/modules/express-engine)
  server.engine(
    'html',
    ngExpressEngine({
      bootstrap: AppServerModule,
    })
  );

  server.set('view engine', 'html');
  server.set('views', browserBundles);

  // Example Express Rest API endpoints
  // server.get('/api/**', (req, res) => { });
  // Serve static files from /browser
  // serve static files
  server.use('/', express.static(browserBundles, { maxAge: '1y' }));
  server.use('/server', express.static(serverBundles, { maxAge: '1y' }));

  // All regular routes use the Universal engine
  server.get('*', (req, res) => {
    res.render(indexHtml, {
      req,
      providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }],
    });
  });

  return server;
}

function run(): void {
  const port = process.env['PORT'] || 4000;

  // Start up the Node server
  const server = app();
  server.listen(port, () => {
    console.log(\`Node Express server listening on http://localhost:\${port}\`);

    /**
     * DO NOT REMOVE IF USING @nx/angular:module-federation-dev-ssr executor
     * to serve your Host application with this Remote application.
     * This message allows Nx to determine when the Remote is ready to be
     * consumed by the Host.
     */
    process.send && process.send('nx.server.ready');
  });
}

run();

export * from './bootstrap.server';
"
`;

exports[`MF Remote App Generator --ssr should generate the correct files 5`] = `
"import('./src/main.server');
"
`;

exports[`MF Remote App Generator --ssr should generate the correct files 6`] = `
"module.exports = {
  name: 'test',
  exposes: {
    './Module': 'apps/test/src/app/remote-entry/entry.module.ts',
  },
};
"
`;

exports[`MF Remote App Generator --ssr should generate the correct files 7`] = `
"const { withModuleFederationForSSR } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederationForSSR(config);
"
`;

exports[`MF Remote App Generator --ssr should generate the correct files 8`] = `
"import { Component } from '@angular/core';

@Component({
  selector: 'proj-test-entry',
  template: \`<proj-nx-welcome></proj-nx-welcome>\`,
})
export class RemoteEntryComponent {}
"
`;

exports[`MF Remote App Generator --ssr should generate the correct files 9`] = `
"import { Route } from '@angular/router';

export const appRoutes: Route[] = [
  {
    path: '',
    loadChildren: () =>
      import('./remote-entry/entry.module').then((m) => m.RemoteEntryModule),
  },
];
"
`;

exports[`MF Remote App Generator --ssr should generate the correct files 10`] = `
"import { Route } from '@angular/router';
import { RemoteEntryComponent } from './entry.component';

export const remoteRoutes: Route[] = [
  { path: '', component: RemoteEntryComponent },
];
"
`;

exports[`MF Remote App Generator --ssr should generate the correct files 11`] = `
{
  "configurations": {
    "development": {
      "buildOptimizer": false,
      "extractLicenses": false,
      "optimization": false,
      "sourceMap": true,
      "vendorChunk": true,
    },
    "production": {
      "outputHashing": "media",
    },
  },
  "defaultConfiguration": "production",
  "dependsOn": [
    "build",
  ],
  "executor": "@nx/angular:webpack-server",
  "options": {
    "customWebpackConfig": {
      "path": "apps/test/webpack.server.config.js",
    },
    "main": "apps/test/server.ts",
    "outputPath": "dist/apps/test/server",
    "tsConfig": "apps/test/tsconfig.server.json",
  },
}
`;

exports[`MF Remote App Generator --ssr should generate the correct files 12`] = `
"import { Route } from '@angular/router';
import { RemoteEntryComponent } from './entry.component';

export const remoteRoutes: Route[] = [
  { path: '', component: RemoteEntryComponent },
];
"
`;

exports[`MF Remote App Generator --ssr should generate the correct files 13`] = `
{
  "dependsOn": [
    "build",
    "server",
  ],
  "executor": "nx:run-commands",
  "options": {
    "command": "PORT=4201 node dist/apps/test/server/main.js",
  },
}
`;

exports[`MF Remote App Generator should generate a remote mf app with a host 1`] = `
"const { withModuleFederation } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederation(config);
"
`;

exports[`MF Remote App Generator should generate a remote mf app with a host 2`] = `
"const { withModuleFederation } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederation(config);
"
`;

exports[`MF Remote App Generator should generate a remote mf app with no host 1`] = `
"const { withModuleFederation } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederation(config);
"
`;

exports[`MF Remote App Generator should generate the a remote setup for standalone components 1`] = `
"import { importProvidersFrom } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { RemoteEntryComponent } from './app/remote-entry/entry.component';
import { appRoutes } from './app/app.routes';

bootstrapApplication(RemoteEntryComponent, {
  providers: [
    importProvidersFrom(
      RouterModule.forRoot(appRoutes, { initialNavigation: 'enabledBlocking' })
    ),
  ],
});
"
`;

exports[`MF Remote App Generator should generate the a remote setup for standalone components 2`] = `
"module.exports = {
  name: 'test',
  exposes: {
    './Routes': 'apps/test/src/app/remote-entry/entry.routes.ts',
  },
};
"
`;

exports[`MF Remote App Generator should generate the a remote setup for standalone components 3`] = `
"import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { NxWelcomeComponent } from './nx-welcome.component';

@Component({
  standalone: true,
  imports: [CommonModule, NxWelcomeComponent],
  selector: 'proj-test-entry',
  template: \`<proj-nx-welcome></proj-nx-welcome>\`,
})
export class RemoteEntryComponent {}
"
`;

exports[`MF Remote App Generator should generate the a remote setup for standalone components 4`] = `
"import { Route } from '@angular/router';

export const appRoutes: Route[] = [
  {
    path: '',
    loadChildren: () =>
      import('./remote-entry/entry.routes').then((m) => m.remoteRoutes),
  },
];
"
`;

exports[`MF Remote App Generator should generate the a remote setup for standalone components 5`] = `
"import { Route } from '@angular/router';
import { RemoteEntryComponent } from './entry.component';

export const remoteRoutes: Route[] = [
  { path: '', component: RemoteEntryComponent },
];
"
`;
