test(e2e): upload tests (#16078)

This commit is contained in:
Adam Bradley
2018-10-25 01:03:01 -05:00
committed by GitHub
parent 3c7fee5cca
commit 6b8c87e2da
6 changed files with 84 additions and 4 deletions

View File

@ -106,9 +106,79 @@ class CIScreenshotConnector extends IonicConnector {
timespan.finish(`publishing build finished`); timespan.finish(`publishing build finished`);
await this.uploadTests(results);
return results; return results;
} }
async uploadTests(results) {
const timespan = this.logger.createTimeSpan(`uploading tests started`);
const appRoot = path.join(__dirname, '..', '..');
let uploadPaths = [];
const cssDir = path.join(appRoot, 'css');
fs.readdirSync(cssDir).forEach(cssFile => {
uploadPaths.push(path.join(cssDir, cssFile));
});
uploadPaths.push(path.join(appRoot, 'scripts', 'testing', 'styles.css'));
const distDir = path.join(appRoot, 'dist');
uploadPaths.push(path.join(distDir, 'ionic.js'));
const distIonicDir = path.join(distDir, 'ionic');
fs.readdirSync(distIonicDir).forEach(distIonicFile => {
uploadPaths.push(path.join(distIonicDir, distIonicFile));
});
// const distIonicSvgDir = path.join(distIonicDir, 'svg');
// fs.readdirSync(distIonicSvgDir).forEach(distIonicSvgFile => {
// uploadPaths.push(path.join(distIonicSvgDir, distIonicSvgFile));
// });
results.currentBuild.screenshots.forEach(screenshot => {
const testDir = path.dirname(screenshot.testPath);
const testIndexHtml = path.join(appRoot, testDir, 'index.html');
if (!uploadPaths.includes(testIndexHtml)) {
uploadPaths.push(testIndexHtml);
}
});
uploadPaths = uploadPaths.filter(p => p.endsWith('.js') || p.endsWith('.css') || p.endsWith('.html') || p.endsWith('.svg'));
const fileCount = uploadPaths.length;
const uploadBatches = [];
while (uploadPaths.length > 0) {
uploadBatches.push(uploadPaths.splice(0, 20));
}
for (const batch of uploadBatches) {
await Promise.all(batch.map(async uploadPath => {
const stream = fs.createReadStream(uploadPath);
const relPath = path.relative(appRoot, uploadPath);
const key = `test/${results.currentBuild.id}/${relPath}`;
let contentType = 'text/plain';
if (uploadPath.endsWith('.js')) {
contentType = 'application/javascript'
} else if (uploadPath.endsWith('.css')) {
contentType = 'text/css'
} else if (uploadPath.endsWith('.html')) {
contentType = 'text/html'
} else if (uploadPath.endsWith('.svg')) {
contentType = 'image/svg+xml'
}
this.logger.debug(`uploading: ${key} ${contentType}`);
await s3.upload({ Bucket: S3_BUCKET, Key: key, Body: stream, ContentType: contentType }).promise();
}));
}
timespan.finish(`uploading tests finished: ${fileCount} files`);
}
async getScreenshotCache() { async getScreenshotCache() {
const timespan = this.logger.createTimeSpan(`get screenshot cache started`, true); const timespan = this.logger.createTimeSpan(`get screenshot cache started`, true);

View File

@ -6,8 +6,10 @@ it('modal: basic', async () => {
}); });
await page.click('.e2ePresentModal'); await page.click('.e2ePresentModal');
const popover = await page.find('ion-modal');
expect(popover).not.toBeNull(); const modal = await page.find('ion-modal');
await modal.waitForVisible();
await page.waitFor(250);
const compare = await page.compareScreenshot(); const compare = await page.compareScreenshot();
expect(compare).toMatchScreenshot(); expect(compare).toMatchScreenshot();

View File

@ -6,8 +6,10 @@ it('modal: standalone', async () => {
}); });
await page.click('#basic'); await page.click('#basic');
const popover = await page.find('ion-modal');
expect(popover).not.toBeNull(); const modal = await page.find('ion-modal');
await modal.waitForVisible();
await page.waitFor(250);
const compare = await page.compareScreenshot(); const compare = await page.compareScreenshot();
expect(compare).toMatchScreenshot(); expect(compare).toMatchScreenshot();

View File

@ -5,6 +5,8 @@ it('searchbar: basic', async () => {
url: '/src/components/searchbar/test/basic?ionic:_testing=true' url: '/src/components/searchbar/test/basic?ionic:_testing=true'
}); });
await page.waitFor(250);
const compare = await page.compareScreenshot(); const compare = await page.compareScreenshot();
expect(compare).toMatchScreenshot(); expect(compare).toMatchScreenshot();
}); });

View File

@ -5,6 +5,8 @@ it('searchbar: standalone', async () => {
url: '/src/components/searchbar/test/standalone?ionic:_testing=true' url: '/src/components/searchbar/test/standalone?ionic:_testing=true'
}); });
await page.waitFor(250);
const compare = await page.compareScreenshot(); const compare = await page.compareScreenshot();
expect(compare).toMatchScreenshot(); expect(compare).toMatchScreenshot();
}); });

View File

@ -5,6 +5,8 @@ it('searchbar: toolbar', async () => {
url: '/src/components/searchbar/test/toolbar?ionic:_testing=true' url: '/src/components/searchbar/test/toolbar?ionic:_testing=true'
}); });
await page.waitFor(250);
const compare = await page.compareScreenshot(); const compare = await page.compareScreenshot();
expect(compare).toMatchScreenshot(); expect(compare).toMatchScreenshot();
}); });