Skip to content

Commit e5f00c3

Browse files
jhockettsobolk
andauthored
test: split e2e test file (#12150)
* test: split e2e test file * test: update windows smoke test list * fix: typos * Update parameter-store-2.test.ts * Update split-e2e-tests-v2.ts --------- Co-authored-by: Kamil Sobol <sobol.k.r@gmail.com>
1 parent d954a83 commit e5f00c3

File tree

3 files changed

+101
-85
lines changed

3 files changed

+101
-85
lines changed

packages/amplify-e2e-tests/src/__tests__/parameter-store.test.ts renamed to packages/amplify-e2e-tests/src/__tests__/parameter-store-1.test.ts

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import {
2-
addAuthWithEmailVerificationAndUserPoolGroupTriggers,
32
addFunction,
4-
amplifyPull,
53
amplifyPushAuth,
64
createNewProjectDir,
75
deleteProject,
@@ -10,10 +8,6 @@ import {
108
generateRandomShortId,
119
getAppId,
1210
getProjectMeta,
13-
getTeamProviderInfo,
14-
gitCleanFdx,
15-
gitCommitAll,
16-
gitInit,
1711
initJSProjectWithProfile,
1812
} from '@aws-amplify/amplify-e2e-core';
1913
import { addEnvironmentCarryOverEnvVars, checkoutEnvironment, removeEnvironment } from '../environment/env';
@@ -108,82 +102,3 @@ describe('upload and delete parameters', () => {
108102
);
109103
});
110104
});
111-
112-
describe('parameters in Parameter Store', () => {
113-
let projRoot: string;
114-
const envName = 'enva';
115-
116-
beforeAll(async () => {
117-
projRoot = await createNewProjectDir('multi-env-parameters-test');
118-
});
119-
120-
afterAll(async () => {
121-
await deleteProject(projRoot);
122-
deleteProjectDir(projRoot);
123-
});
124-
125-
it('hydrates missing parameters into TPI on pull', async () => {
126-
await initJSProjectWithProfile(projRoot, { disableAmplifyAppCreation: false, envName });
127-
const meta = getProjectMeta(projRoot);
128-
expect(meta).toBeDefined();
129-
const appId = getAppId(projRoot);
130-
expect(appId).toBeDefined();
131-
const region = meta.providers.awscloudformation.Region;
132-
expect(region).toBeDefined();
133-
await gitInit(projRoot);
134-
await gitCommitAll(projRoot); // commit all just after init, so no categories block exists in TPI yet
135-
136-
const envVariableName = 'envVariableName';
137-
const envVariableValue = 'envVariableValue';
138-
139-
const fnName = `parameterstestfn${generateRandomShortId()}`;
140-
await addFunction(
141-
projRoot,
142-
{
143-
name: fnName,
144-
functionTemplate: 'Hello World',
145-
environmentVariables: {
146-
key: envVariableName,
147-
value: envVariableValue,
148-
},
149-
},
150-
'nodejs',
151-
);
152-
await addAuthWithEmailVerificationAndUserPoolGroupTriggers(projRoot);
153-
await amplifyPushAuth(projRoot);
154-
const expectedParamsAfterPush = [
155-
{ name: 'deploymentBucketName' },
156-
{ name: envVariableName, value: envVariableValue },
157-
{ name: 's3Key' },
158-
];
159-
await expectParametersOptionalValue(expectedParamsAfterPush, [], region, appId, envName, 'function', fnName);
160-
161-
const preCleanTpi = getTeamProviderInfo(projRoot);
162-
163-
// test pull --restore same dir
164-
await gitCleanFdx(projRoot); // clear TPI
165-
await amplifyPull(projRoot, { appId, envName, withRestore: true, emptyDir: true });
166-
const postPullWithRestoreTpi = getTeamProviderInfo(projRoot);
167-
expect(postPullWithRestoreTpi).toEqual(preCleanTpi);
168-
169-
// test pull same dir
170-
await gitCleanFdx(projRoot); // clear TPI
171-
await amplifyPull(projRoot, { appId, envName, withRestore: false, emptyDir: true });
172-
const postPullWithoutRestoreTpi = getTeamProviderInfo(projRoot);
173-
expect(postPullWithoutRestoreTpi).toEqual(preCleanTpi);
174-
175-
expect(await getTpiAfterPullInEmptyDir(appId, envName, true)).toEqual(preCleanTpi);
176-
expect(await getTpiAfterPullInEmptyDir(appId, envName, false)).toEqual(preCleanTpi);
177-
});
178-
179-
const getTpiAfterPullInEmptyDir = async (appId: string, envName: string, withRestore: boolean): Promise<Record<string, any>> => {
180-
let emptyDir: string;
181-
try {
182-
emptyDir = await createNewProjectDir('empty-dir-parameters-test');
183-
await amplifyPull(emptyDir, { appId, envName, withRestore, emptyDir: true });
184-
return getTeamProviderInfo(emptyDir);
185-
} finally {
186-
deleteProjectDir(emptyDir);
187-
}
188-
};
189-
});
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import {
2+
addAuthWithEmailVerificationAndUserPoolGroupTriggers,
3+
addFunction,
4+
amplifyPull,
5+
amplifyPushAuth,
6+
createNewProjectDir,
7+
deleteProject,
8+
deleteProjectDir,
9+
expectParametersOptionalValue,
10+
generateRandomShortId,
11+
getAppId,
12+
getProjectMeta,
13+
getTeamProviderInfo,
14+
gitCleanFdx,
15+
gitCommitAll,
16+
gitInit,
17+
initJSProjectWithProfile,
18+
} from '@aws-amplify/amplify-e2e-core';
19+
20+
describe('parameters in Parameter Store', () => {
21+
let projRoot: string;
22+
const envName = 'enva';
23+
24+
beforeEach(async () => {
25+
projRoot = await createNewProjectDir('multi-env');
26+
});
27+
28+
afterEach(async () => {
29+
await deleteProject(projRoot);
30+
deleteProjectDir(projRoot);
31+
});
32+
33+
it('hydrates missing parameters into TPI on pull', async () => {
34+
await initJSProjectWithProfile(projRoot, { disableAmplifyAppCreation: false, envName });
35+
const meta = getProjectMeta(projRoot);
36+
expect(meta).toBeDefined();
37+
const appId = getAppId(projRoot);
38+
expect(appId).toBeDefined();
39+
const region = meta.providers.awscloudformation.Region;
40+
expect(region).toBeDefined();
41+
await gitInit(projRoot);
42+
await gitCommitAll(projRoot); // commit all just after init, so no categories block exists in TPI yet
43+
44+
const envVariableName = 'envVariableName';
45+
const envVariableValue = 'envVariableValue';
46+
47+
const fnName = `parameterstestfn${generateRandomShortId()}`;
48+
await addFunction(
49+
projRoot,
50+
{
51+
name: fnName,
52+
functionTemplate: 'Hello World',
53+
environmentVariables: {
54+
key: envVariableName,
55+
value: envVariableValue,
56+
},
57+
},
58+
'nodejs',
59+
);
60+
await addAuthWithEmailVerificationAndUserPoolGroupTriggers(projRoot);
61+
await amplifyPushAuth(projRoot);
62+
const expectedParamsAfterPush = [
63+
{ name: 'deploymentBucketName' },
64+
{ name: envVariableName, value: envVariableValue },
65+
{ name: 's3Key' },
66+
];
67+
await expectParametersOptionalValue(expectedParamsAfterPush, [], region, appId, envName, 'function', fnName);
68+
69+
const preCleanTpi = getTeamProviderInfo(projRoot);
70+
71+
// test pull --restore same dir
72+
await gitCleanFdx(projRoot); // clear TPI
73+
await amplifyPull(projRoot, { appId, envName, withRestore: true, emptyDir: true });
74+
const postPullWithRestoreTpi = getTeamProviderInfo(projRoot);
75+
expect(postPullWithRestoreTpi).toEqual(preCleanTpi);
76+
77+
// test pull same dir
78+
await gitCleanFdx(projRoot); // clear TPI
79+
await amplifyPull(projRoot, { appId, envName, withRestore: false, emptyDir: true });
80+
const postPullWithoutRestoreTpi = getTeamProviderInfo(projRoot);
81+
expect(postPullWithoutRestoreTpi).toEqual(preCleanTpi);
82+
83+
expect(await getTpiAfterPullInEmptyDir(appId, envName, true)).toEqual(preCleanTpi);
84+
expect(await getTpiAfterPullInEmptyDir(appId, envName, false)).toEqual(preCleanTpi);
85+
});
86+
87+
const getTpiAfterPullInEmptyDir = async (appId: string, envName: string, withRestore: boolean): Promise<Record<string, any>> => {
88+
let emptyDir: string;
89+
try {
90+
emptyDir = await createNewProjectDir('empty-dir-parameters-test');
91+
await amplifyPull(emptyDir, { appId, envName, withRestore, emptyDir: true });
92+
return getTeamProviderInfo(emptyDir);
93+
} finally {
94+
deleteProjectDir(emptyDir);
95+
}
96+
};
97+
});

scripts/split-e2e-tests-v2.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const RUN_SOLO = [
1414
'src/__tests__/geo-remove-3.test.ts',
1515
'src/__tests__/geo-update-1.test.ts',
1616
'src/__tests__/geo-update-2.test.ts',
17+
'src/__tests__/hostingPROD.test.ts',
1718
'src/__tests__/import_auth_1a.test.ts',
1819
'src/__tests__/import_auth_1b.test.ts',
1920
'src/__tests__/import_auth_2a.test.ts',
@@ -82,6 +83,9 @@ const WINDOWS_SMOKE_TESTS = [
8283
'src/__tests__/hooks-b.test.ts',
8384
// hosting
8485
'src/__tests__/hostingPROD.test.ts',
86+
// parameter store
87+
'src/__tests__/parameter-store-1.test.ts',
88+
'src/__tests__/parameter-store-2.test.ts',
8589
// interactions
8690
'src/__tests__/interactions.test.ts',
8791
// schema auth test

0 commit comments

Comments
 (0)