Skip to content

Commit 3b46aad

Browse files
committed
Update e2e unit test
* Updated how to upload the dictionaries.
1 parent 8b81e5e commit 3b46aad

9 files changed

+69
-52
lines changed

sequencing-server/jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default {
1313
testRunner: 'jest-circus/runner',
1414
// testRegex: "(/test/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
1515
testRegex: '((\\.|/)(test|spec))\\.(jsx?|tsx?)$',
16-
testPathIgnorePatterns: ['/node_modules/', '/build/'],
16+
testPathIgnorePatterns: ['/node_modules/', '/build/', '/plugins/'],
1717
coverageReporters: ['html'],
1818
setupFiles: ['dotenv/config', './src/polyfills.ts'],
1919
globalSetup: './jestGlobalSetup.js',

sequencing-server/test/batchLoaders/expansionBatchLoader.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ let parcelId: number;
1515

1616
beforeAll(async () => {
1717
graphqlClient = await getGraphQLClient();
18-
commandDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.COMMAND)).id;
19-
channelDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.CHANNEL)).id;
20-
parameterDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.PARAMETER)).id;
18+
commandDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.COMMAND)).command.id;
19+
channelDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.CHANNEL)).channel.id;
20+
parameterDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.PARAMETER)).parameter.id;
2121
parcelId = (
2222
await insertParcel(
2323
graphqlClient,

sequencing-server/test/batchLoaders/expansionSetBatchLoader.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ let parcelId: number;
1818

1919
beforeAll(async () => {
2020
graphqlClient = await getGraphQLClient();
21-
commandDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.COMMAND)).id;
22-
channelDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.CHANNEL)).id;
23-
paramaterDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.PARAMETER)).id;
21+
commandDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.COMMAND)).command.id;
22+
channelDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.CHANNEL)).channel.id;
23+
paramaterDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.PARAMETER)).parameter.id;
2424
parcelId = (
2525
await insertParcel(
2626
graphqlClient,

sequencing-server/test/command-expansion.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ let parcelId: number;
3434

3535
beforeAll(async () => {
3636
graphqlClient = await getGraphQLClient();
37-
commandDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.COMMAND)).id;
38-
channelDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.CHANNEL)).id;
39-
parameterDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.PARAMETER)).id;
37+
commandDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.COMMAND)).command.id;
38+
channelDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.CHANNEL)).channel.id;
39+
parameterDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.PARAMETER)).parameter.id;
4040
parcelId = (
4141
await insertParcel(
4242
graphqlClient,

sequencing-server/test/command-types.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ let parameterDictionaryId: number;
1111

1212
beforeAll(async () => {
1313
graphqlClient = await getGraphQLClient();
14-
commandDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.COMMAND)).id;
15-
channelDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.CHANNEL)).id;
16-
parameterDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.PARAMETER)).id;
14+
commandDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.COMMAND)).command.id;
15+
channelDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.CHANNEL)).channel.id;
16+
parameterDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.PARAMETER)).parameter.id;
1717
});
1818

1919
afterAll(async () => {

sequencing-server/test/db-state.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ beforeAll(async () => {
3333
});
3434

3535
beforeEach(async () => {
36-
commandDictonaryId = (await insertDictionary(graphqlClient, DictionaryType.COMMAND)).id;
37-
channelDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.CHANNEL)).id;
38-
parameterDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.PARAMETER)).id;
36+
commandDictonaryId = (await insertDictionary(graphqlClient, DictionaryType.COMMAND)).command.id;
37+
channelDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.CHANNEL)).channel.id;
38+
parameterDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.PARAMETER)).parameter.id;
3939
parcelId = (
4040
await insertParcel(graphqlClient, commandDictonaryId, channelDictionaryId, parameterDictionaryId, 'db-parcel-test')
4141
).parcelId;

sequencing-server/test/dictionary.spec.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -19,43 +19,43 @@ beforeAll(async () => {
1919
describe('upload dictionaries', () => {
2020
it('should upload a command dictionary and all of the fields should be populated correctly', async () => {
2121
// During the test we use a uuid for the mission so there's no conflicting command dictionaries.
22-
const { id, dictionary_path, mission, parsed_json } = await insertDictionary(graphqlClient, DictionaryType.COMMAND);
22+
const { command } = await insertDictionary(graphqlClient, DictionaryType.COMMAND);
2323

24-
expect(dictionary_path).toBe(`/usr/src/app/sequencing_file_store/${mission}/command_lib.${mission}.ts`);
24+
expect(command.dictionary_path).toBe(`/usr/src/app/sequencing_file_store/${command.mission}/command_lib.${command.mission}.ts`);
2525

26-
expect(parsed_json).toStrictEqual(
27-
ampcs.parse(commandDictionaryString.replace(/(Banana Nation|1.0.0.0)/g, mission)),
26+
expect(command.parsed_json).toStrictEqual(
27+
ampcs.parse(commandDictionaryString.replace(/(Banana Nation|1.0.0.0)/g, command.mission)),
2828
);
2929

30-
await removeDictionary(graphqlClient, id, DictionaryType.COMMAND);
30+
await removeDictionary(graphqlClient, command.id, DictionaryType.COMMAND);
3131
}, 30000);
3232

3333
it('should upload a channel dictionary and all of the fields should be populated correctly', async () => {
3434
// During the test we use a uuid for the mission so there's no conflicting command dictionaries.
35-
const { id, dictionary_path, mission, parsed_json } = await insertDictionary(graphqlClient, DictionaryType.CHANNEL);
35+
const { channel } = await insertDictionary(graphqlClient, DictionaryType.CHANNEL);
3636

37-
expect(dictionary_path).toBe(`/usr/src/app/sequencing_file_store/${mission}/channel_lib.${mission}.ts`);
37+
expect(channel.dictionary_path).toBe(`/usr/src/app/sequencing_file_store/${channel.mission}/channel_lib.${channel.mission}.ts`);
3838

39-
expect(parsed_json).toEqual(
40-
ampcs.parseChannelDictionary(channelDictionaryString.replace(/(Banana Nation|1.0.0.0)/g, mission)),
39+
expect(channel.parsed_json).toEqual(
40+
ampcs.parseChannelDictionary(channelDictionaryString.replace(/(Banana Nation|1.0.0.0)/g, channel.mission)),
4141
);
4242

43-
await removeDictionary(graphqlClient, id, DictionaryType.CHANNEL);
43+
await removeDictionary(graphqlClient, channel.id, DictionaryType.CHANNEL);
4444
}, 30000);
4545

4646
it('should upload a parameter dictionary and all of the fields should be populated correctly', async () => {
4747
// During the test we use a uuid for the mission so there's no conflicting command dictionaries.
48-
const { id, dictionary_path, mission, parsed_json } = await insertDictionary(
48+
const { parameter } = await insertDictionary(
4949
graphqlClient,
5050
DictionaryType.PARAMETER,
5151
);
5252

53-
expect(dictionary_path).toBe(`/usr/src/app/sequencing_file_store/${mission}/parameter_lib.${mission}.ts`);
53+
expect(parameter.dictionary_path).toBe(`/usr/src/app/sequencing_file_store/${parameter.mission}/parameter_lib.${parameter.mission}.ts`);
5454

55-
expect(parsed_json).toEqual(
56-
ampcs.parseParameterDictionary(parameterDictionaryString.replace(/(Banana Nation|1.0.0.1)/g, mission)),
55+
expect(parameter.parsed_json).toEqual(
56+
ampcs.parseParameterDictionary(parameterDictionaryString.replace(/(Banana Nation|1.0.0.1)/g, parameter.mission)),
5757
);
5858

59-
await removeDictionary(graphqlClient, id, DictionaryType.PARAMETER);
59+
await removeDictionary(graphqlClient, parameter.id, DictionaryType.PARAMETER);
6060
}, 30000);
6161
});

sequencing-server/test/sequence-generation.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ let parcelId: number;
3838

3939
beforeAll(async () => {
4040
graphqlClient = await getGraphQLClient();
41-
commandDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.COMMAND)).id;
42-
channelDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.CHANNEL)).id;
43-
parameterDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.PARAMETER)).id;
41+
commandDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.COMMAND)).command.id;
42+
channelDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.CHANNEL)).channel.id;
43+
parameterDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.PARAMETER)).parameter.id;
4444
parcelId = (
4545
await insertParcel(
4646
graphqlClient,

sequencing-server/test/testUtils/Dictionary.ts

+35-18
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,21 @@ export async function insertDictionary(
2222
graphqlClient: GraphQLClient,
2323
type: DictionaryType,
2424
): Promise<{
25-
id: number;
26-
dictionary_path: string;
27-
mission: string;
28-
version: string;
29-
parsed_json: CommandDictionary | ChannelDictionary | ParameterDictionary;
25+
command: {id: number;
26+
dictionary_path: string;
27+
mission: string;
28+
version: string;
29+
parsed_json: CommandDictionary}
30+
parameter: {id: number;
31+
dictionary_path: string;
32+
mission: string;
33+
version: string;
34+
parsed_json: ParameterDictionary}
35+
channel: {id: number;
36+
dictionary_path: string;
37+
mission: string;
38+
version: string;
39+
parsed_json: ChannelDictionary}
3040
}> {
3141
let dictonaryString = commandDictionaryString;
3242
switch (type) {
@@ -39,28 +49,35 @@ export async function insertDictionary(
3949
}
4050
const res = await graphqlClient.request<{
4151
uploadDictionary: {
42-
id: number;
43-
dictionary_path: string;
44-
mission: string;
45-
version: string;
46-
parsed_json: CommandDictionary | ChannelDictionary | ParameterDictionary;
52+
command: {id: number;
53+
dictionary_path: string;
54+
mission: string;
55+
version: string;
56+
parsed_json: CommandDictionary}
57+
parameter: {id: number;
58+
dictionary_path: string;
59+
mission: string;
60+
version: string;
61+
parsed_json: ParameterDictionary}
62+
channel: {id: number;
63+
dictionary_path: string;
64+
mission: string;
65+
version: string;
66+
parsed_json: ChannelDictionary}
4767
};
4868
}>(
4969
gql`
50-
mutation PutDictionary($dictionary: String!, $type: String!) {
51-
uploadDictionary(dictionary: $dictionary, type: $type) {
52-
id
53-
dictionary_path
54-
mission
55-
version
56-
parsed_json
70+
mutation PutDictionary($dictionary: String!) {
71+
uploadDictionary(dictionary: $dictionary) {
72+
command
73+
parameter
74+
channel
5775
}
5876
}
5977
`,
6078
{
6179
// Generate a UUID for the command dictionary name and version to avoid conflicts when testing.
6280
dictionary: dictonaryString.replace(/(Banana Nation|1.0.0.0|1.0.0.1)/g, randomUUID()),
63-
type,
6481
},
6582
);
6683

0 commit comments

Comments
 (0)