Skip to content

Commit 39f38ac

Browse files
authored
feat(deploy-preview): introduce deploy previews (#447)
* feat(deploy-preview): introduce deploy previews * chore(deploy-preview): switch test script to deploy preview folder * chore(gitignore): update to gitignore * chore(node): remove yarn build from prepare (debug) * fix(script): fix to uppercase bug in Linux * fix(script): fix to uppercase bug in Linux * chore(script): remove console log * feat(percy): add percy functionality and cypress e2e testing * chore(gitignore): add tmp directory for cypress cache
1 parent 11111c9 commit 39f38ac

17 files changed

Lines changed: 4556 additions & 824 deletions

File tree

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ zip
88
**/.DS_Store
99
.vercel
1010
.parcel-cache
11-
dist
11+
.idea
12+
dist
13+
/deploy-preview
14+
/tmp
15+
.env

.huskyrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"hooks": {
3+
"commit-msg": "commitlint -e $HUSKY_GIT_PARAMS",
4+
"pre-commit": "lint-staged"
5+
}
6+
}

cypress/.percy.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"version": 2,
3+
"snapshot": {
4+
"widths": [
5+
375,
6+
1280
7+
]
8+
}
9+
}

cypress/cypress.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"baseUrl": "http://localhost:8080",
3+
"browser": "chrome",
4+
"headless": true,
5+
"fixturesFolder": false,
6+
"video": false,
7+
"screenshotsFolder": "cypress/screenshots",
8+
"videosFolder": "cypress/videos",
9+
"integrationFolder": "cypress/integration",
10+
"supportFile": "cypress/support/index.js",
11+
"pluginsFile": "cypress/plugins/index.js",
12+
"testFiles": "**/*.e2e.js",
13+
"pageLoadTimeout": 80000,
14+
"defaultCommandTimeout": 80000,
15+
"retries": {
16+
"runMode": 2,
17+
"openMode": 0
18+
},
19+
"numTestsKeptInMemory": 0
20+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Copyright IBM Corp. 2021
3+
*
4+
* This source code is licensed under the Apache-2.0 license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
'use strict';
9+
10+
describe('Plex test page', () => {
11+
it('should load the basic test page', () => {
12+
cy.visit('/index.html', { timeout: 10000 });
13+
14+
cy.wait(5000);
15+
16+
// Take a snapshot for visual diffing
17+
cy.percySnapshot('test | basic');
18+
});
19+
});

cypress/plugins/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Copyright IBM Corp. 2021
3+
*
4+
* This source code is licensed under the Apache-2.0 license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
// eslint-disable-next-line no-unused-vars
9+
module.exports = (on, config) => {
10+
// `on` is used to hook into various events Cypress emits
11+
// `config` is the resolved Cypress config
12+
};

cypress/support/commands.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright IBM Corp. 2021
3+
*
4+
* This source code is licensed under the Apache-2.0 license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
// ***********************************************
9+
// This example commands.js shows you how to
10+
// create various custom commands and overwrite
11+
// existing commands.
12+
//
13+
// For more comprehensive examples of custom
14+
// commands please read more here:
15+
// https://on.cypress.io/custom-commands
16+
// ***********************************************
17+
//
18+
//
19+
// -- This is a parent command --
20+
// Cypress.Commands.add('login', (email, password) => { ... })
21+
//
22+
//
23+
// -- This is a child command --
24+
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
25+
//
26+
//
27+
// -- This is a dual command --
28+
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
29+
//
30+
//
31+
// -- This will overwrite an existing command --
32+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

cypress/support/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Copyright IBM Corp. 2021
3+
*
4+
* This source code is licensed under the Apache-2.0 license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import '@percy/cypress';
9+
import './commands';

gulp-tasks/build.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @license
3+
*
4+
* Copyright IBM Corp. 2021
5+
*
6+
* This source code is licensed under the Apache-2.0 license found in the
7+
* LICENSE file in the root directory of this source tree.
8+
*/
9+
10+
'use strict';
11+
12+
require('./build/deploy-preview');

gulp-tasks/build/deploy-preview.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* @license
3+
*
4+
* Copyright IBM Corp. 2021
5+
*
6+
* This source code is licensed under the Apache-2.0 license found in the
7+
* LICENSE file in the root directory of this source tree.
8+
*/
9+
10+
'use strict';
11+
12+
const gulp = require('gulp');
13+
const config = require('../config');
14+
15+
/**
16+
* Copies test file to the deploy-preview folder
17+
*
18+
* @returns {*} gulp stream
19+
*/
20+
function _copyTest() {
21+
return gulp
22+
.src([config.testSrc])
23+
.pipe(gulp.dest(config.deployPreviewPath));
24+
}
25+
26+
/**
27+
* Copies dist files to the deploy-preview folder. Must run `gulp build` first!
28+
*
29+
* @returns {*} gulp stream
30+
*/
31+
function _copyCss() {
32+
return gulp
33+
.src([`${config.cssSrc}/**/*`])
34+
.pipe(gulp.dest(config.deployPreviewCSSPath));
35+
}
36+
37+
/**
38+
* Copies font files to the dist folder
39+
*
40+
* @returns {*} gulp stream
41+
*/
42+
function _copyFonts() {
43+
return gulp
44+
.src(['IBM-Plex-*/fonts/**/*.*'])
45+
.pipe(gulp.dest(config.deployPreviewFontsPath));
46+
}
47+
48+
gulp.task('build:deploy-preview:test', _copyTest);
49+
gulp.task('build:deploy-preview:css', _copyCss);
50+
gulp.task('build:deploy-preview:fonts', _copyFonts);
51+
gulp.task('build:deploy-preview', gulp.parallel('build:deploy-preview:test','build:deploy-preview:css','build:deploy-preview:fonts'));

0 commit comments

Comments
 (0)