Skip to content

Commit

Permalink
fix: init override test fix (#8768)
Browse files Browse the repository at this point in the history
  • Loading branch information
akshbhu authored and kaustavghosh06 committed Nov 11, 2021
1 parent ef6615c commit 6c4ce7a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
15 changes: 15 additions & 0 deletions packages/amplify-e2e-core/src/categories/hosting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,21 @@ export function amplifyPushWithUpdate(cwd: string): Promise<void> {
});
}

export function amplifyPublishWithUpdate(cwd: string): Promise<void> {
return new Promise((resolve, reject) => {
spawn(getCLIPath(), ['publish'], { cwd, stripColors: true })
.wait('Are you sure you want to continue?')
.sendCarriageReturn()
.run((err: Error) => {
if (!err) {
resolve();
} else {
reject(err);
}
});
});
}

export function amplifyPublishWithoutUpdate(cwd: string): Promise<void> {
return new Promise((resolve, reject) => {
spawn(getCLIPath(), ['publish'], { cwd, stripColors: true }).run((err: Error) => {
Expand Down
7 changes: 4 additions & 3 deletions packages/amplify-e2e-tests/src/__tests__/hostingPROD.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CloudFront } from 'aws-sdk';
import { amplifyPublishWithoutUpdate, createReactTestProject, resetBuildCommand } from 'amplify-e2e-core';
import { amplifyPublishWithoutUpdate, amplifyPublishWithUpdate, createReactTestProject, resetBuildCommand } from 'amplify-e2e-core';

import { initJSProjectWithProfile, deleteProject, deleteS3Bucket } from 'amplify-e2e-core';
import { addPRODHosting, removePRODCloudFront, removeHosting, amplifyPushWithoutCodegen } from 'amplify-e2e-core';
Expand Down Expand Up @@ -45,7 +45,8 @@ describe('amplify add hosting', () => {
it('publish successfully', async () => {
let error;
try {
await amplifyPublishWithoutUpdate(projRoot);
// root stack updated
await amplifyPublishWithUpdate(projRoot);
} catch (err) {
error = err;
}
Expand All @@ -56,7 +57,7 @@ describe('amplify add hosting', () => {
const currentBuildCommand = resetBuildCommand(projRoot, '');
let error;
try {
await amplifyPublishWithoutUpdate(projRoot);
await amplifyPublishWithUpdate(projRoot);
} catch (err) {
error = err;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/amplify-e2e-tests/src/__tests__/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe('amplify init', () => {
});

afterEach(async () => {
// await deleteProject(projRoot);
// deleteProjectDir(projRoot);
await deleteProject(projRoot);
deleteProjectDir(projRoot);
});

it('should pull sandbox and download schema', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ export const storeRootStackTemplate = async (context: $TSContext, template?: Tem
// generate template again as the folder structure was not created when root stack was initiaized
if (template === undefined) {
template = await transformRootStack(context);
await prePushCfnTemplateModifier(template);
}

// apply Modifiers
await prePushCfnTemplateModifier(template);
// RootStack deployed to backend/awscloudformation/build
const projectRoot = pathManager.findProjectRoot();
const rootStackBackendBuildDir = pathManager.getRootStackBuildDirPath(projectRoot);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ export async function transformResourceWithOverrides(context: $TSContext, resour
printer.info('Overrides functionality is not impleented for this category');
}
} else {
if (FeatureFlags.getBoolean('overrides.project')) {
await storeRootStackTemplate(context);
}
const template = await transformRootStack(context);
await prePushCfnTemplateModifier(template);
// RootStack deployed to backend/awscloudformation/build
const projectRoot = pathManager.findProjectRoot();
const rootStackBackendBuildDir = pathManager.getRootStackBuildDirPath(projectRoot);
fs.ensureDirSync(rootStackBackendBuildDir);
const rootStackBackendFilePath = path.join(rootStackBackendBuildDir, rootStackFileName);
JSONUtilities.writeJson(rootStackBackendFilePath, template);
}
} catch (err) {
return;
Expand Down

0 comments on commit 6c4ce7a

Please sign in to comment.