Skip to content

Commit

Permalink
Merge pull request #87 from AII-the-time/refactor/testing
Browse files Browse the repository at this point in the history
Refactor: testing
  • Loading branch information
raipen authored Nov 18, 2023
2 parents 0de523e + bc7b453 commit b983b18
Show file tree
Hide file tree
Showing 86 changed files with 3,240 additions and 3,290 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ jobs:
run: |
npm install
npm run prisma
npm run seed
- name: Run Tests
uses: ArtiomTr/jest-coverage-report-action@v2
id: coverage
Expand Down
6 changes: 6 additions & 0 deletions .local.docker.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ DB_HOST=db
DB_PORT=3306
DATABASE_URL=mysql://root:root@db/db
SENTRY_DSN=__INSERT_YOUR_SENTRY_DSN_HERE__
# if you want to use send SMS feature, you need to set these environment variables
# NCP_SENS_SECRET=__INSERT_YOUR_NCP_SENS_SECRET_HERE__
# NCP_SENS_ACCESS=__INSERT_YOUR_NCP_SENS_ACCESS_HERE__
# NCP_SENS_MY_NUMBER=__INSERT_YOUR_NCP_SENS_MY_NUMBER_HERE__
# NCP_SENS_ID=__INSERT_YOUR_NCP_SENS_ID_HERE__
# NODE_ENV=production
2 changes: 1 addition & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ if [ "$NODE_ENV" = "production" ]; then
npm run prisma:deploy
else
npm run prisma
npm run seed

fi
npm run dev
4 changes: 3 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
preset: 'ts-jest',
preset: 'ts-jest/presets/default-esm',
testEnvironment: 'node',
collectCoverageFrom: [
'src/**/*.[jt]s?(x)',
'!**/*.d.ts',
'!src/index.ts',
'!src/loaders/index.ts',
'!src/config/index.ts',
'!src/utils/sendSMS.ts',
],
moduleNameMapper: {
'^@api$': '<rootDir>/src/api',
Expand All @@ -22,5 +23,6 @@ export default {
'^@routes/(.*)$': '<rootDir>/src/api/routes/$1',
'^@hooks/(.*)$': '<rootDir>/src/api/hooks/$1',
'^@server$': '<rootDir>/src/server.ts',
'^@seeding/(.*)$': '<rootDir>/seeding/$1',
},
};
10 changes: 3 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@
"type": "module",
"scripts": {
"dev": "tsx watch src src/index.ts",
"test": "prisma migrate reset -f && jest --detectOpenHandles --forceExit",
"test-coverage": "prisma migrate reset -f && jest --coverage --detectOpenHandles --forceExit",
"test": "prisma migrate reset -f && node --experimental-vm-modules node_modules/jest/bin/jest.js",
"test-coverage": "prisma migrate reset -f && node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage",
"prisma": "./prisma/concat_schema.sh && prisma migrate dev --name init --preview-feature",
"prisma:deploy": "./prisma/concat_schema.sh && prisma migrate deploy --preview-feature",
"prisma:generate": "./prisma/concat_schema.sh && prisma generate",
"seed": "prisma db seed"
},
"prisma": {
"seed": "tsx prisma/seed.ts"
"prisma:generate": "./prisma/concat_schema.sh && prisma generate"
},
"keywords": [],
"author": "",
Expand Down
37 changes: 0 additions & 37 deletions prisma/migrations/20231011061113_init/migration.sql

This file was deleted.

61 changes: 0 additions & 61 deletions prisma/migrations/20231012124817_init/migration.sql

This file was deleted.

2 changes: 0 additions & 2 deletions prisma/migrations/20231013122529_init/migration.sql

This file was deleted.

21 changes: 0 additions & 21 deletions prisma/migrations/20231018133609_init/migration.sql

This file was deleted.

10 changes: 0 additions & 10 deletions prisma/migrations/20231021100541_init/migration.sql

This file was deleted.

2 changes: 0 additions & 2 deletions prisma/migrations/20231023140257_init/migration.sql

This file was deleted.

2 changes: 0 additions & 2 deletions prisma/migrations/20231023141607_init/migration.sql

This file was deleted.

5 changes: 0 additions & 5 deletions prisma/migrations/20231023141928_init/migration.sql

This file was deleted.

2 changes: 0 additions & 2 deletions prisma/migrations/20231023142813_init/migration.sql

This file was deleted.

11 changes: 0 additions & 11 deletions prisma/migrations/20231023143459_init/migration.sql

This file was deleted.

2 changes: 0 additions & 2 deletions prisma/migrations/20231023143545_init/migration.sql

This file was deleted.

2 changes: 0 additions & 2 deletions prisma/migrations/20231023144220_init/migration.sql

This file was deleted.

87 changes: 87 additions & 0 deletions prisma/migrations/20231025074215_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
-- AlterTable
ALTER TABLE `Category` ADD COLUMN `deletedAt` DATETIME(3) NULL;

-- AlterTable
ALTER TABLE `Menu` ADD COLUMN `deletedAt` DATETIME(3) NULL;

-- AlterTable
ALTER TABLE `Option` ADD COLUMN `deletedAt` DATETIME(3) NULL;

-- AlterTable
ALTER TABLE `Order` ADD COLUMN `deletedAt` DATETIME(3) NULL;

-- AlterTable
ALTER TABLE `PreOrder` ADD COLUMN `deletedAt` DATETIME(3) NULL;

-- CreateTable
CREATE TABLE `Recipe` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`menuId` INTEGER NOT NULL,
`stockId` INTEGER NULL,
`mixedStockId` INTEGER NULL,
`coldRegularAmount` INTEGER NULL,
`coldSizeUpAmount` INTEGER NULL,
`hotRegularAmount` INTEGER NULL,
`hotSizeUpAmount` INTEGER NULL,

PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `Stock` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`updatedAt` DATETIME(3) NOT NULL,
`storeId` INTEGER NOT NULL,
`name` VARCHAR(191) NOT NULL,
`amount` INTEGER NULL,
`unit` VARCHAR(191) NULL,
`price` DECIMAL(65, 30) NULL,
`currentAmount` INTEGER NULL,
`noticeThreshold` INTEGER NOT NULL DEFAULT 0,
`deletedAt` DATETIME(3) NULL,

PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `MixedStock` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`storeId` INTEGER NOT NULL,
`name` VARCHAR(191) NOT NULL,
`totalAmount` INTEGER NULL,
`unit` VARCHAR(191) NULL,
`deletedAt` DATETIME(3) NULL,

PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `Mixing` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`mixedStockId` INTEGER NOT NULL,
`stockId` INTEGER NOT NULL,
`amount` INTEGER NOT NULL,

PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `Recipe` ADD CONSTRAINT `Recipe_menuId_fkey` FOREIGN KEY (`menuId`) REFERENCES `Menu`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Recipe` ADD CONSTRAINT `Recipe_stockId_fkey` FOREIGN KEY (`stockId`) REFERENCES `Stock`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Recipe` ADD CONSTRAINT `Recipe_mixedStockId_fkey` FOREIGN KEY (`mixedStockId`) REFERENCES `MixedStock`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Stock` ADD CONSTRAINT `Stock_storeId_fkey` FOREIGN KEY (`storeId`) REFERENCES `Store`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `MixedStock` ADD CONSTRAINT `MixedStock_storeId_fkey` FOREIGN KEY (`storeId`) REFERENCES `Store`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Mixing` ADD CONSTRAINT `Mixing_mixedStockId_fkey` FOREIGN KEY (`mixedStockId`) REFERENCES `MixedStock`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Mixing` ADD CONSTRAINT `Mixing_stockId_fkey` FOREIGN KEY (`stockId`) REFERENCES `Stock`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
Loading

0 comments on commit b983b18

Please sign in to comment.