Skip to content

Commit

Permalink
Integration test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
wictorwilen committed May 27, 2021
1 parent 2031f6b commit d82371f
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 24 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/generator-integration-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Integration test for generator-teams

on: [push]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 15.x, 16.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
working-directory: packages/generator-teams
- run: npm run test-integration
working-directory: packages/generator-teams
env:
CI: true
1 change: 1 addition & 0 deletions packages/generator-teams/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
* Moved custom `skip-install` implementation to native Yeoman version
* Updated to Microsoft Teams JS SDK 1.10
* Node 10.x no longer supported
* Improved integration testing for generator

### Deleted

Expand Down
3 changes: 2 additions & 1 deletion packages/generator-teams/src/app/templates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"scripts": {
"start": "node dist/server.js",
"build": "gulp build",
"manifest": "gulp manifest",
"lint": "eslint ./src --ext .js,.jsx,.ts,.tsx",
"debug": "gulp serve --debug"<% if (unitTestsEnabled) { %>,
"test": "jest",
Expand Down Expand Up @@ -64,7 +65,7 @@
"vinyl": "2.2.0",
"webpack": "5.0.0",
"yargs": "^16.0.3",
"yoteams-build-core": "^1.1.0",
"yoteams-build-core": "^1.2.0-preview",
"webpack-node-externals": "^2.5.2"
},
"browserslist": [
Expand Down
61 changes: 38 additions & 23 deletions packages/generator-teams/tests/helpers/TestHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ export const SCRIPT_FILES = [
"src/client/tsconfig.json"
];

export const DIST_FILES = [
'dist/server.js',
'dist/web/index.html',
'dist/web/privacy.html',
'dist/web/tou.html',
'dist/web/assets/icon.png',
'dist/web/scripts/client.js',
'dist/web/styles/main.css',
];

export const basePrompts = {
"solutionName": "teams-solution",
"whichFolder": "current",
Expand Down Expand Up @@ -116,7 +126,7 @@ export enum TestTypes {
UNIT = "UNIT",
INTEGRATION = "INTEGRATION"
}
export function coreTests(manifestVersion: string, prompts: any) {
export async function coreTests(manifestVersion: string, prompts: any, projectPath: string) {
it("Should have root files", async () => {
assert.file(ROOT_FILES);
});
Expand Down Expand Up @@ -236,6 +246,28 @@ export function coreTests(manifestVersion: string, prompts: any) {
});
})
}

// Integration tests
if (process.env.TEST_TYPE == TestTypes.INTEGRATION) {
it("Should run npm install successfully", async () => {
const npmInstallResult = await runNpmCommand("npm install --prefer-offline", projectPath);
assert.strictEqual(false, npmInstallResult);
});

it("Should run npm build successfully", async () => {
const npmRunBuildResult = await runNpmCommand("npm run build", projectPath);
assert.strictEqual(false, npmRunBuildResult);
});

it("Should validate manifest successfully", async () => {
const npmResult = await runNpmCommand("npm run manifest", projectPath);
assert.strictEqual(false, npmResult);
});

it("Should have ./dist files", async () => {
assert.file(DIST_FILES);
});
}
}


Expand All @@ -244,13 +276,13 @@ export async function runTests(prefix: string, tests: any[], additionalTests: Fu
describe(test.description, async () => {
for (const manifestVersion of test.manifestVersions as string[]) {
// run without unit tests
runTest(manifestVersion, test, false);
await runTest(manifestVersion, test, false);
// run with tests
runTest(manifestVersion, test, true);
await runTest(manifestVersion, test, true);
// upgrade if possible
if (UPGRADE_PATHS[manifestVersion]) {
for (const upgradeTo of UPGRADE_PATHS[manifestVersion])
runUpgradeTest(manifestVersion, upgradeTo, test, false);
await runUpgradeTest(manifestVersion, upgradeTo, test, false);
}
}
});
Expand Down Expand Up @@ -278,22 +310,13 @@ export async function runTests(prefix: string, tests: any[], additionalTests: Fu
.withGenerators(DEPENDENCIES);
});

coreTests(manifestVersion, prompts);
coreTests(manifestVersion, prompts, projectPath);


if (additionalTests) {
await additionalTests(prompts);
}



if (process.env.TEST_TYPE == TestTypes.INTEGRATION) {
const npmInstallResult = await runNpmCommand("npm install --prefer-offline", projectPath);
assert.strictEqual(false, npmInstallResult);

const npmRunBuildResult = await runNpmCommand("npm run build", projectPath);
assert.strictEqual(false, npmRunBuildResult);
}
});
}

Expand Down Expand Up @@ -334,16 +357,8 @@ export async function runTests(prefix: string, tests: any[], additionalTests: Fu
.withGenerators(DEPENDENCIES);
});

coreTests(to, prompts, projectPath);

coreTests(to, prompts);

if (process.env.TEST_TYPE == TestTypes.INTEGRATION) {
const npmInstallResult = await runNpmCommand("npm install --prefer-offline", projectPath);
assert.strictEqual(false, npmInstallResult);

const npmRunBuildResult = await runNpmCommand("npm run build", projectPath);
assert.strictEqual(false, npmRunBuildResult);
}
});
}
}

0 comments on commit d82371f

Please sign in to comment.