@simitgroup/simpleapp-generator 1.1.8 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,7 +26,7 @@ SimpleApp generator is a typescript code generator for convert jsonschemas becom
26
26
  1. [jsonschemas](./docs/jsonschema.md)
27
27
  2. [backend walk through](./docs/backend.md)
28
28
  3. [frontend walk through](./docs/frontend.md)
29
-
29
+ 4. [End to End test](./docs/test.md)
30
30
 
31
31
 
32
32
  # Quick start
package/docs/test.md ADDED
@@ -0,0 +1,46 @@
1
+ # Test
2
+ simple app will auto create template of CRUD test case and you can modify it to complete the test case.
3
+
4
+ The simplest standalone resource step (no foreignkey) workflow of prepare test as below:
5
+ 1. Add sample data in `stubs` at `backend/test/yourResource/stub`
6
+ 2. modify sample's `_id` according `backend/test/yourResource/yourResource.e2e-spec.ts`
7
+ 3. modify `yourResource.e2e-spec.ts` according your need such as autocomplete search text or add more test
8
+
9
+
10
+
11
+ ## Prepare Simple Test
12
+ 1. Start backend and frontend server, access your `category` page
13
+ 2. Try add new record, fill in sample data and save it.
14
+ 3. Obtain the sample json data from debug data component.
15
+ 4. Put content into stub:
16
+ a. edit `backend/test/category/stub/id1.create.ts`
17
+ b. replace json content with copied record but remain `id:"00000000-0000-0000-0000-000000000001"` unchange
18
+ 5. repeat sample step `backend/test/category/stub/id1.update.ts`, but you may change the data slightly like change `categoryName` from "Category 1" to "Category 1-updated"
19
+ 6. Go back to frontend, add new record and fill in sample data which not pass the input validation (safe failed)
20
+ 7. Copy the data into stub
21
+ a. edit `backend/test/category/stub/id2.create.ts`
22
+ b. replace json content with copied record but remain `id:"00000000-0000-0000-0000-000000000002"` unchange
23
+ 8. After added 3 sample data into stub, you may modify `backend/test/category/category.e2e-spec.ts`:
24
+ a. change `existAutoCompleteKeyword` to match partial of your sample data. Example your value `categoryName` is `Category 1`, you can define as `existAutoCompleteKeyword='Cat'`(It only search `categoryCode` and `CategoryName`)
25
+ b. you can add more sample/test by refer example in this file
26
+ 9. You may remove all others folder in `backend/test/documents/*` and remain only `category` so we can have success test
27
+ 10. execute test by run command `npm run test:e2e` in your backend
28
+
29
+
30
+ ## Prepare Test For Data with Dependency
31
+ Every test shall implement independently, in the case of `product` which depends on category records, we can:
32
+ 1. copy/modify partial of record from `backend/test/category/category.e2e-spec.ts` into `backend/test/product/product.e2e-spec.ts`
33
+ 2. execute insert `category` using `beforeAll`, you may refer:
34
+ a. [nestjs test documentation](https://docs.nestjs.com/fundamentals/testing)
35
+ b. [jest test order](https://jestjs.io/docs/setup-teardown#order-of-execution)
36
+
37
+
38
+
39
+
40
+ ## Test guide line
41
+ 1. Test shall implement in empty database cause we don't want primary key crash
42
+ 2. put sample data in stub cause we don't want our code accidentally modify the sample data
43
+ 3. default test is simplest approach, every additional api require additional test
44
+ 4. every test shall:
45
+ a. test http status
46
+ b. when data effect database, shall continue verify result using subsequent step `then`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simitgroup/simpleapp-generator",
3
- "version": "1.1.8",
3
+ "version": "1.1.9",
4
4
  "description": "frontend nuxtjs and backend nests code generator using jsonschema",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/generate.ts CHANGED
@@ -220,9 +220,9 @@ const generateSchema = ( docname: string,
220
220
  writeFileSync(targetfile,filecontent);
221
221
  //create stub files
222
222
  mkdirSync(`${targetfolder}/stub`,{recursive:true})
223
- writeFileSync(`${targetfolder}/stub/id1.create.ts`,'export default () => ({_id:"",})');
224
- writeFileSync(`${targetfolder}/stub/id1.update.ts`,'export default () => ({_id:"",})');
225
- writeFileSync(`${targetfolder}/stub/id2.create.ts`,'export default () => ({_id:"",})');
223
+ writeFileSync(`${targetfolder}/stub/id1.create.ts`,'export default () => ({_id:"00000000-0000-0000-0000-000000000001",})');
224
+ writeFileSync(`${targetfolder}/stub/id1.update.ts`,'export default () => ({_id:"00000000-0000-0000-0000-000000000001",})');
225
+ writeFileSync(`${targetfolder}/stub/id2.create.ts`,'export default () => ({_id:"00000000-0000-0000-0000-000000000002",})');
226
226
 
227
227
  }
228
228
  }