console/integration-tests/tests/api/sign-up.spec.ts
Dotan Simha 34b80e9492
Drop dockest, refactor integration testkit, and run all integration tests in parallel (#883)
Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com>
2022-12-28 10:37:23 +01:00

62 lines
1.6 KiB
TypeScript

import { gql } from '@app/gql';
import { execute } from '../../testkit/graphql';
import { initSeed } from '../../testkit/seed';
test.concurrent('should auto-create an organization for freshly signed-up user', async () => {
const { ownerToken } = await initSeed().createOwner();
const result = await execute({
document: gql(/* GraphQL */ `
query organizations {
organizations {
total
nodes {
id
name
}
}
}
`),
authToken: ownerToken,
}).then(r => r.expectNoGraphQLErrors());
expect(result.organizations.total).toBe(1);
});
test.concurrent(
'should auto-create an organization for freshly signed-up user with no race-conditions',
async () => {
const { ownerToken } = await initSeed().createOwner();
const query1 = execute({
document: gql(/* GraphQL */ `
query organizations {
organizations {
total
nodes {
id
name
}
}
}
`),
authToken: ownerToken,
}).then(r => r.expectNoGraphQLErrors());
const query2 = execute({
document: gql(/* GraphQL */ `
query organizations {
organizations {
total
nodes {
id
name
}
}
}
`),
authToken: ownerToken,
}).then(r => r.expectNoGraphQLErrors());
const [result1, result2] = await Promise.all([query1, query2]);
expect(result1.organizations.total).toBe(1);
expect(result2.organizations.total).toBe(1);
},
);