## Context - Removing search* integration tests instead of fixing them because they will be replaced by global search very soon - Fixed billing + add missing seeds to make them work - Fixed integration tests not using consistently the correct "test" db - Fixed ci not running the with-db-reset configuration due to nx configuration being used twice for different level of the command - Enriched .env.test - Fixed parts where exceptions were not thrown properly and not caught by exception handler to convert to 400 when needed - Refactored feature flag service that had 2 different implementations in lab and admin panel + added tests - Fixed race condition when migrations are created at the same timestamp and doing the same type of operation, in this case object deletion could break because table could be deleted earlier than its relations - Fixed many integration tests that were not up to date since the CI has been broken for a while --------- Co-authored-by: Charles Bochet <charlesBochet@users.noreply.github.com>
85 lines
2.0 KiB
TypeScript
85 lines
2.0 KiB
TypeScript
import request from 'supertest';
|
|
|
|
const SERVER_URL = `http://localhost:${APP_PORT}`;
|
|
|
|
const client = request(SERVER_URL);
|
|
|
|
const auth = {
|
|
email: 'tim@apple.dev',
|
|
password: 'Applecar2025',
|
|
};
|
|
|
|
describe('AuthResolve (integration)', () => {
|
|
let loginToken: string;
|
|
|
|
it('should getLoginTokenFromCredentials with email and password', () => {
|
|
const queryData = {
|
|
query: `
|
|
mutation GetLoginTokenFromCredentials {
|
|
getLoginTokenFromCredentials(email: "${auth.email}", password: "${auth.password}") {
|
|
loginToken {
|
|
token
|
|
expiresAt
|
|
}
|
|
}
|
|
}
|
|
`,
|
|
};
|
|
|
|
return client
|
|
.post('/graphql')
|
|
.set('Origin', SERVER_URL)
|
|
.send(queryData)
|
|
.expect(200)
|
|
.expect((res) => {
|
|
expect(res.body.data).toBeDefined();
|
|
expect(res.body.errors).toBeUndefined();
|
|
})
|
|
.expect((res) => {
|
|
const data = res.body.data.getLoginTokenFromCredentials;
|
|
|
|
expect(data).toBeDefined();
|
|
expect(data.loginToken).toBeDefined();
|
|
|
|
loginToken = data.loginToken.token;
|
|
});
|
|
});
|
|
|
|
it('should getAuthTokensFromLoginToken with login token', () => {
|
|
const queryData = {
|
|
query: `
|
|
mutation GetAuthTokensFromLoginToken {
|
|
getAuthTokensFromLoginToken(loginToken: "${loginToken}") {
|
|
tokens {
|
|
accessToken {
|
|
token
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`,
|
|
};
|
|
|
|
return client
|
|
.post('/graphql')
|
|
.set('Origin', SERVER_URL)
|
|
.send(queryData)
|
|
.expect(200)
|
|
.expect((res) => {
|
|
expect(res.body.data).toBeDefined();
|
|
expect(res.body.errors).toBeUndefined();
|
|
})
|
|
.expect((res) => {
|
|
const data = res.body.data.getAuthTokensFromLoginToken;
|
|
|
|
expect(data).toBeDefined();
|
|
expect(data.tokens).toBeDefined();
|
|
|
|
const accessToken = data.tokens.accessToken;
|
|
|
|
expect(accessToken).toBeDefined();
|
|
expect(accessToken.token).toBeDefined();
|
|
});
|
|
});
|
|
});
|