-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/4.0.0-alpha.3'
- Loading branch information
Showing
20 changed files
with
411 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1 @@ | ||
# These are supported funding model platforms | ||
|
||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] | ||
patreon: # Replace with a single Patreon username | ||
open_collective: mnfst | ||
ko_fi: # Replace with a single Ko-fi username | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
otechie: # Replace with a single Otechie username | ||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry | ||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Manifest End-2-End tests | ||
|
||
This folder contains the End-2-End tests for the Manifest core package. | ||
|
||
Run tests: | ||
|
||
```bash | ||
npm run test:e2e | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: 'mock-backend-for-e2e-tests' | ||
entities: | ||
Owner: | ||
properties: | ||
- name | ||
- { name: email, type: email } | ||
|
||
Dog: | ||
properties: | ||
- name | ||
- { name: age, type: number } | ||
- { name: birthdate, type: date } | ||
belongsTo: | ||
- Owner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Test, TestingModule } from '@nestjs/testing' | ||
import { AppModule } from '../src/app.module' | ||
import { YamlService } from '../src/manifest/services/yaml/yaml.service' | ||
import { INestApplication } from '@nestjs/common' | ||
import supertest from 'supertest' | ||
import { load } from 'js-yaml' | ||
import fs from 'fs' | ||
|
||
let app: INestApplication | ||
|
||
beforeAll(async () => { | ||
// Set environment variables for testing. | ||
process.env.NODE_ENV = 'test' | ||
process.env.DB_DATABASE = ':memory:' | ||
process.env.DB_DROP_SCHEMA = 'true' | ||
|
||
// Start the NestJS application mocking some services. | ||
const moduleFixture: TestingModule = await Test.createTestingModule({ | ||
imports: [AppModule] | ||
}) | ||
.overrideProvider(YamlService) | ||
.useValue({ | ||
load: () => | ||
load( | ||
fs.readFileSync( | ||
`${process.cwd()}/e2e/assets/mock-backend.yml`, | ||
'utf8' | ||
) | ||
) | ||
}) | ||
.compile() | ||
|
||
app = moduleFixture.createNestApplication() | ||
|
||
// Store request object in global scope to use in tests. | ||
global.request = supertest(app.getHttpServer()) | ||
|
||
await app.init() | ||
}) | ||
|
||
afterAll(async () => { | ||
delete global.request | ||
await app.close() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { Paginator, SelectOption } from '@mnfst/types' | ||
|
||
describe('CRUD (e2e)', () => { | ||
const dummyDog = { | ||
name: 'Fido', | ||
age: 5 | ||
} | ||
|
||
it('POST /dynamic/:entity', async () => { | ||
const response = await global.request.post('/dynamic/dogs').send(dummyDog) | ||
|
||
expect(response.status).toBe(201) | ||
}) | ||
|
||
it('GET /dynamic/:entity', async () => { | ||
const response = await global.request.get('/dynamic/dogs') | ||
|
||
expect(response.status).toBe(200) | ||
expect(response.body).toMatchObject<Paginator<any>>({ | ||
data: expect.any(Array), | ||
currentPage: expect.any(Number), | ||
lastPage: expect.any(Number), | ||
from: expect.any(Number), | ||
to: expect.any(Number), | ||
total: expect.any(Number), | ||
perPage: expect.any(Number) | ||
}) | ||
expect(response.body.data.length).toBe(1) | ||
}) | ||
|
||
it('GET /dynamic/:entity/select-options', async () => { | ||
const response = await global.request.get('/dynamic/dogs/select-options') | ||
|
||
expect(response.status).toBe(200) | ||
expect(response.body).toMatchObject<SelectOption[]>([ | ||
{ | ||
label: dummyDog.name, | ||
id: 1 | ||
} | ||
]) | ||
}) | ||
|
||
it('GET /dynamic/:entity/:id', async () => { | ||
const response = await global.request.get('/dynamic/dogs/1') | ||
|
||
expect(response.status).toBe(200) | ||
expect(response.body).toMatchObject(dummyDog) | ||
}) | ||
|
||
it('PUT /dynamic/:entity/:id', async () => { | ||
const newName = 'Rex' | ||
|
||
const response = await global.request.put('/dynamic/dogs/1').send({ | ||
name: newName | ||
}) | ||
|
||
expect(response.status).toBe(200) | ||
|
||
const updatedResponse = await global.request.get('/dynamic/dogs/1') | ||
|
||
expect(updatedResponse.status).toBe(200) | ||
expect(updatedResponse.body).toMatchObject({ | ||
...dummyDog, | ||
name: newName | ||
}) | ||
}) | ||
|
||
it('DELETE /dynamic/:entity/:id', async () => { | ||
const response = await global.request.delete('/dynamic/dogs/1') | ||
|
||
expect(response.status).toBe(200) | ||
|
||
const updatedResponse = await global.request.get('/dynamic/dogs/1') | ||
|
||
expect(updatedResponse.status).toBe(404) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
describe('Health (e2e)', () => { | ||
it('GET /health', () => { | ||
return global.request | ||
.get('/health') | ||
.expect(200) | ||
.expect(JSON.stringify({ status: 'OK' })) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { EntityManifest } from '@mnfst/types' | ||
|
||
describe('Manifest (e2e)', () => { | ||
it('GET /manifest', async () => { | ||
const response = await global.request.get('/manifest') | ||
|
||
expect(response.status).toBe(200) | ||
expect(response.body).toMatchObject({ | ||
name: expect.any(String), | ||
entities: expect.any(Object) | ||
}) | ||
|
||
expect(Object.keys(response.body.entities).length).toBeGreaterThan(0) | ||
|
||
Object.values(response.body.entities).forEach((entity: EntityManifest) => { | ||
expect(entity).toMatchObject<Partial<EntityManifest>>({ | ||
properties: expect.any(Array) | ||
}) | ||
|
||
if (entity.belongsTo !== undefined) { | ||
expect(entity.belongsTo).toEqual(expect.any(Array)) | ||
} | ||
}) | ||
}) | ||
|
||
it('GET /manifest/entities/:slug', async () => { | ||
const response = await global.request.get('/manifest/entities/dogs') | ||
|
||
expect(response.status).toBe(200) | ||
expect(response.body).toMatchObject<Partial<EntityManifest>>({ | ||
properties: expect.any(Array) | ||
}) | ||
|
||
if (response.body.belongsTo !== undefined) { | ||
expect(response.body.belongsTo).toEqual(expect.any(Array)) | ||
} | ||
}) | ||
}) |
Oops, something went wrong.