diff --git a/__e2e__/commands/add.test.js b/__e2e__/commands/add.test.js index 249f96b0f..3211ec31a 100644 --- a/__e2e__/commands/add.test.js +++ b/__e2e__/commands/add.test.js @@ -31,8 +31,8 @@ describe('mevn add', () => { [ `${DOWN}${DOWN}${DOWN}${ENTER}`, // Choose Nuxt.js `${SPACE}${ENTER}`, // Opt for @nuxtjs/axios module - `${DOWN}${ENTER}`, // Choose spa as the rendering mode - `${DOWN}${ENTER}`, // Choose static as the deploy target + ENTER, // Choose universal as the rendering mode + ENTER, // Choose server as the deploy target `Y${ENTER}`, // Requires server directory ], tempDirPath, @@ -41,33 +41,52 @@ describe('mevn add', () => { // Invoke the add command await runPromptWithAnswers( ['add'], - [ENTER, `${DOWN}${SPACE}${DOWN}${DOWN}${SPACE}${ENTER}`], // Choose @nuxtjs/pwa module and the vuex addon + [ + ENTER, + `${DOWN}${SPACE}${DOWN}${DOWN}${DOWN}${SPACE}${DOWN}${DOWN}${DOWN}${DOWN}${SPACE}${ENTER}`, + ], // Choose @nuxtjs/pwa, nuxt-oauth and @nuxtjs/storybook modules genPath, ); // nuxt.config.js const nuxtConfig = require(path.join(clientPath, 'nuxt.config.js')).default; expect(nuxtConfig.buildModules).toContain('@nuxtjs/pwa'); + expect(nuxtConfig.modules).toContain('nuxt-oauth'); + expect(nuxtConfig.buildModules).not.toContain('@nuxtjs/storybook'); expect(nuxtConfig.modules).toContain('@nuxtjs/axios'); // .mevnrc const projectConfig = JSON.parse( fs.readFileSync(path.join(genPath, '.mevnrc')), ); - expect(projectConfig.modules).toContain('pwa'); - expect(projectConfig.modules).toContain('vuex'); - expect(projectConfig.modules).toContain('axios'); + ['pwa', 'oauth', 'storybook', 'vuex', 'axios'].forEach((module) => + expect(projectConfig.modules).toContain(module), + ); + expect(projectConfig.isConfigured).toBe(true); // package.json const pkgJson = JSON.parse( fs.readFileSync(path.join(clientPath, 'package.json')), ); + expect(pkgJson.dependencies['nuxt-oauth']).toBeTruthy(); expect(pkgJson.devDependencies['@nuxtjs/pwa']).toBeTruthy(); + expect(pkgJson.devDependencies['@nuxtjs/storybook']).toBeTruthy(); // @nuxtjs/axios should be installed via mevn serve since it was opted at first expect(pkgJson.devDependencies['@nuxtjs/axios']).not.toBeTruthy(); - // vuex-store + const gitIgnoreContent = fs + .readFileSync(path.join(clientPath, '.gitignore'), 'utf8') + .split('\n'); + expect(gitIgnoreContent.includes('.nuxt-storybook')).toBeTruthy(); + expect(gitIgnoreContent.includes('storybook-static')).toBeTruthy(); + + const nuxtIgnoreContent = fs + .readFileSync(path.join(clientPath, '.nuxtignore'), 'utf8') + .split('\n'); + expect(nuxtIgnoreContent.includes('**/*.stories.js')).toBeTruthy(); + + // vuex-store is activated via nuxt-oauth expect( fs.readFileSync(path.join(clientPath, 'store', 'index.js')), ).toBeTruthy(); diff --git a/__e2e__/commands/init.test.js b/__e2e__/commands/init.test.js index 7b1af5b35..cd19f4f41 100644 --- a/__e2e__/commands/init.test.js +++ b/__e2e__/commands/init.test.js @@ -64,6 +64,7 @@ describe('mevn init', () => { // .mevnrc const projectConfigContent = { name: 'my-app', + renderingMode: 'spa', template: 'Nuxt.js', modules: ['pwa', 'content'], deployTarget: 'static', diff --git a/jest/helpers.js b/jest/helpers.js index 14763bb79..a7b66d874 100644 --- a/jest/helpers.js +++ b/jest/helpers.js @@ -23,7 +23,7 @@ export const runPromptWithAnswers = (args, answers, testPath) => { setTimeout(() => { process.stdin.write(answers[0]); writeToStdin(answers.slice(1)); - }, 2000); + }, 3000); } else { process.stdin.end(); } diff --git a/jest/setupE2eTests.js b/jest/setupE2eTests.js index 09ffd355d..43e2888a6 100644 --- a/jest/setupE2eTests.js +++ b/jest/setupE2eTests.js @@ -1 +1 @@ -jest.setTimeout(60000); +jest.setTimeout(240000); diff --git a/src/commands/basic/add.js b/src/commands/basic/add.js index beb7c60ce..7d17515ac 100644 --- a/src/commands/basic/add.js +++ b/src/commands/basic/add.js @@ -477,7 +477,7 @@ const addDeps = async (deps, { dev }) => { // Update modules entry with the installed Nuxt.js modules const installedNuxtModules = [].concat(modules, buildModules, addons); if ( - installedNuxtModules.includes('nuxt-oauth') && + installedNuxtModules.includes('oauth') && !installedNuxtModules.includes('vuex') ) { // Vuex Store is activated with nuxt-oauth