Skip to content

Commit

Permalink
Revert other changes
Browse files Browse the repository at this point in the history
  • Loading branch information
karlhorky committed Nov 15, 2023
1 parent 4c9e084 commit 71884c8
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 69 deletions.
40 changes: 40 additions & 0 deletions __tests__/__snapshots__/e2e.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Passes in the next-js-passing test project 1`] = `
"🚀 UpLeveled Preflight
[COMPLETED] All changes committed to Git
[COMPLETED] ESLint
[COMPLETED] ESLint config is latest version
[COMPLETED] GitHub repo has deployed project link under About
[COMPLETED] Next.js project has sharp installed
[COMPLETED] No dependencies without types
[COMPLETED] No dependency problems
[COMPLETED] No extraneous files committed to Git
[COMPLETED] No secrets committed to Git
[COMPLETED] No unused dependencies
[COMPLETED] Preflight is latest version
[COMPLETED] Prettier
[COMPLETED] Project folder name matches correct format
[COMPLETED] Stylelint
[COMPLETED] Stylelint config is latest version
[COMPLETED] Use single package manager
[COMPLETED] node_modules/ folder ignored in Git
[STARTED] All changes committed to Git
[STARTED] ESLint
[STARTED] ESLint config is latest version
[STARTED] GitHub repo has deployed project link under About
[STARTED] Next.js project has sharp installed
[STARTED] No dependencies without types
[STARTED] No dependency problems
[STARTED] No extraneous files committed to Git
[STARTED] No secrets committed to Git
[STARTED] No unused dependencies
[STARTED] Preflight is latest version
[STARTED] Prettier
[STARTED] Project folder name matches correct format
[STARTED] Stylelint
[STARTED] Stylelint config is latest version
[STARTED] Use single package manager
[STARTED] node_modules/ folder ignored in Git"
`;

exports[`Passes in the next-js-passing test project 2`] = `""`;

exports[`Passes in the react-passing test project 1`] = `
"🚀 UpLeveled Preflight
[COMPLETED] All changes committed to Git
Expand Down
110 changes: 41 additions & 69 deletions __tests__/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ import { beforeAll, expect, test } from '@jest/globals';
import { execaCommand } from 'execa';
import pMap from 'p-map';

const tempDir = tmpdir();
const tempDir = process.env.GITHUB_ACTIONS
? // Switch to `tmpdir()` on GitHub Actions to avoid
// ESLint crashing with Windows paths over the 260
// character MAX_PATH limit
// https://github.com/upleveled/preflight/pull/469/#issuecomment-1812422819
// https://github.com/eslint/eslint/issues/17763
tmpdir()
: '__tests__/fixtures/__temp';

function cloneRepoToFixtures(repoPath: string, fixtureDirName: string) {
return execaCommand(
Expand All @@ -21,42 +28,30 @@ const testRepos: Repo[] = [
{
repoPath: 'upleveled/preflight-test-project-react-passing',
dirName: 'react-passing',
// installCommands:
// process.platform === 'win32'
// ? [
// 'pnpm config set node-linker hoisted --location project',
// 'pnpm install --frozen-lockfile',
// 'rm .npmrc',
// ]
// : ['pnpm install --frozen-lockfile'],
},
// {
// repoPath: 'upleveled/preflight-test-project-next-js-passing',
// dirName: 'next-js-passing',
// installCommands:
// // libpg-query is not yet supported on Windows
// // https://github.com/pganalyze/libpg_query/issues/44
// process.platform === 'win32'
// ? [
// // `pnpm remove` also installs if node_modules doesn't
// // exist (no need to run `pnpm install` as well)
// 'pnpm remove @ts-safeql/eslint-plugin libpg-query',
// // Commit packages.json and pnpm-lock.yaml changes to
// // avoid failing "All changes committed to Git" check
// 'git config user.email github-actions[bot]@users.noreply.github.com',
// 'git config user.name github-actions[bot]',
// 'git commit --all --message Remove\\ SafeSQL\\ for\\ Windows',
// // 'pnpm setup',
// // 'pnpm add --global ../../../preflight',
// ]
// : [
// 'pnpm install --frozen-lockfile',
// // Run project database migrations
// 'pnpm migrate up',
// // 'pnpm setup',
// // 'pnpm add --global ../../../preflight',
// ],
// },
{
repoPath: 'upleveled/preflight-test-project-next-js-passing',
dirName: 'next-js-passing',
installCommands:
// libpg-query is not yet supported on Windows
// https://github.com/pganalyze/libpg_query/issues/44
process.platform === 'win32'
? [
// `pnpm remove` also installs if node_modules doesn't
// exist (no need to run `pnpm install` as well)
'pnpm remove @ts-safeql/eslint-plugin libpg-query',
// Commit packages.json and pnpm-lock.yaml changes to
// avoid failing "All changes committed to Git" check
'git config user.email github-actions[bot]@users.noreply.github.com',
'git config user.name github-actions[bot]',
'git commit --all --message Remove\\ SafeSQL\\ for\\ Windows',
]
: [
'pnpm install --frozen-lockfile',
// Run project database migrations
'pnpm migrate up',
],
},
];

beforeAll(
Expand Down Expand Up @@ -85,10 +80,6 @@ beforeAll(
(command) =>
execaCommand(command, {
cwd: `${tempDir}/${dirName}`,
// env: {
// PNPM_HOME: '/usr/local/bin',
// SHELL: 'bash',
// },
}),
{ concurrency: 1 },
);
Expand All @@ -113,24 +104,6 @@ function sortStdoutAndStripVersionNumber(stdout: string) {
}

test('Passes in the react-passing test project', async () => {
if (process.platform === 'win32') {
// const { stdout: stdout1 } = await execaCommand('dir', {
// cwd: `D:\\a\\preflight\\preflight\\__tests__\\fixtures\\__temp\\react-passing\\node_modules\\.pnpm\\[email protected]_@[email protected]_@[email protected]_@ty_xvhbeu5qc6hlxssq5gmtnagbti\\node_modules\\eslint-plugin-jsx-expressions\\`,
// });
// console.log(stdout1);
// const { stdout: stdout2 } = await execaCommand('dir', {
// cwd: `D:\\a\\preflight\\preflight\\__tests__\\fixtures\\__temp\\react-passing\\node_modules\\`,
// });
// console.log(stdout2);
// const { stdout: stdout3 } = await execaCommand('type index.js', {
// cwd: `D:\\a\\preflight\\preflight\\__tests__\\fixtures\\__temp\\react-passing\\node_modules\\.pnpm\\[email protected]_@[email protected]_@[email protected]_@ty_xvhbeu5qc6hlxssq5gmtnagbti\\node_modules\\eslint-config-upleveled\\`,
// });
// console.log(stdout3);
// await execaCommand('pnpm install --shamefully-hoist', {
// cwd: `${fixturesTempDir}/react-passing`,
// });
}

const { stdout, stderr } = await execaCommand(
`${process.cwd()}/bin/preflight.js`,
{
Expand All @@ -142,15 +115,14 @@ test('Passes in the react-passing test project', async () => {
expect(stderr.replace(/^\(node:\d+\) /, '')).toMatchSnapshot();
}, 30000);

// test('Passes in the next-js-passing test project', async () => {

// const { stdout, stderr } = await execaCommand(
// '../../../../bin/preflight.js',
// {
// cwd: `${fixturesTempDir}/next-js-passing`,
// },
// );
test('Passes in the next-js-passing test project', async () => {
const { stdout, stderr } = await execaCommand(
'../../../../bin/preflight.js',
{
cwd: `${fixturesTempDir}/next-js-passing`,

Check failure on line 122 in __tests__/e2e.test.ts

View workflow job for this annotation

GitHub Actions / ubuntu-latest: Build, lint, test

'fixturesTempDir' is not defined
},
);

// expect(sortStdoutAndStripVersionNumber(stdout)).toMatchSnapshot();
// expect(stderr.replace(/^\(node:\d+\) /, '')).toMatchSnapshot();
// }, 45000);
expect(sortStdoutAndStripVersionNumber(stdout)).toMatchSnapshot();
expect(stderr.replace(/^\(node:\d+\) /, '')).toMatchSnapshot();
}, 45000);

0 comments on commit 71884c8

Please sign in to comment.