feat: basic e2e

This commit is contained in:
DarkSky
2022-08-08 02:30:15 +08:00
parent 45763aa4e3
commit 9dd693e873
17 changed files with 1178 additions and 599 deletions
+2
View File
@@ -0,0 +1,2 @@
NX_LOCAL=true
NX_E2E=true
+3 -2
View File
@@ -21,8 +21,9 @@ jobs:
parallel-commands: |
pnpm exec nx-cloud record -- pnpm exec nx format:check
parallel-commands-on-agents: |
pnpm exec nx affected --target=lint --parallel=3 --exclude=components-common,keck,theme
pnpm exec nx affected --target=build --parallel=3
pnpm exec nx affected --target=lint --parallel=2 --exclude=components-common,keck,theme
pnpm exec nx affected --target=build --parallel=2
pnpm e2e:ci
agents:
name: Nx Cloud - Agents
+17
View File
@@ -0,0 +1,17 @@
{
"extends": ["plugin:cypress/recommended", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["src/plugins/index.js"],
"rules": {
"@typescript-eslint/no-var-requires": "off",
"no-undef": "off"
}
}
]
}
+17
View File
@@ -0,0 +1,17 @@
import { defineConfig } from 'cypress';
module.exports = defineConfig({
e2e: {
supportFile: './src/support/index.ts',
specPattern: './src/integration',
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
fileServerFolder: '.',
fixturesFolder: './src/fixtures',
video: false,
// videosFolder: '../../dist/cypress/apps/ligo-virgo-e2e/videos',
screenshotsFolder: '../../dist/cypress/apps/ligo-virgo-e2e/screenshots',
chromeWebSecurity: false,
});
+28
View File
@@ -0,0 +1,28 @@
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/ligo-virgo-e2e/src",
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nrwl/cypress:cypress",
"options": {
"cypressConfig": "apps/ligo-virgo-e2e/cypress.config.ts",
"devServerTarget": "ligo-virgo:serve"
},
"configurations": {
"production": {
"devServerTarget": "ligo-virgo:serve:production"
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/ligo-virgo-e2e/**/*.{js,ts}"]
}
}
},
"tags": [],
"implicitDependencies": ["ligo-virgo"]
}
@@ -0,0 +1,4 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io"
}
@@ -0,0 +1,14 @@
import { getTitle, getBoard } from '../support/app.po';
describe('ligo-virgo', () => {
beforeEach(() => cy.visit('/'));
it('basic load check', () => {
getTitle().contains('Get Started with AFFiNE');
cy.get('.block_container').contains('The Essentials');
getBoard().click();
cy.get('.tl-inner-div').contains('Graduating');
});
});
@@ -0,0 +1,3 @@
export const getTitle = () => cy.get('span[title]');
export const getDoc = () => cy.contains('Doc');
export const getBoard = () => cy.contains('Board');
@@ -0,0 +1,33 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> {
login(email: string, password: string): void;
}
}
//
// -- This is a parent command --
Cypress.Commands.add('login', (email, password) => {
console.log('Custom command example: Login', email, password);
});
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
+17
View File
@@ -0,0 +1,17 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands';
+10
View File
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"sourceMap": false,
"outDir": "../../dist/out-tsc",
"allowJs": true,
"types": ["cypress", "node"]
},
"include": ["src/**/*.ts", "src/**/*.js"]
}
+2 -1
View File
@@ -48,7 +48,8 @@
"configurations": {
"production": {
"buildTarget": "ligo-virgo:build:production",
"hmr": false
"hmr": false,
"open": false
}
}
},
+2
View File
@@ -16,6 +16,7 @@ module.exports = function (webpackConfig) {
const config = getNxWebpackConfig(webpackConfig);
const isProd = config.mode === 'production';
const isE2E = process.env.NX_E2E;
const style9 = {
test: /\.(tsx|ts|js|mjs|jsx)$/,
@@ -158,6 +159,7 @@ module.exports = function (webpackConfig) {
global: {},
}),
isProd &&
!isE2E &&
new HtmlWebpackPlugin({
title: 'AFFiNE - All In One Workos',
favicon: path.resolve(
+10 -5
View File
@@ -4,12 +4,14 @@
"license": "MIT",
"author": "AFFiNE <developer@affine.pro>",
"scripts": {
"start": "env-cmd -f .env.local-dev nx serve ligo-virgo",
"e2e": "env-cmd -f .github/env/.env.e2e nx e2e ligo-virgo-e2e --watch",
"e2e:ci": "env-cmd -f .github/env/.env.e2e nx e2e ligo-virgo-e2e --prod",
"start": "env-cmd -f .github/env/.env.local-dev nx serve ligo-virgo",
"start:affine": "nx serve ligo-virgo",
"start:keck": "nx serve keck",
"start:venus": "nx serve venus",
"build": "nx build ligo-virgo",
"build:local": "env-cmd -f .env.local-dev nx build ligo-virgo",
"build:local": "env-cmd -f .github/env/.env.local-dev nx build ligo-virgo",
"build:keck": "nx build keck",
"build:venus": "nx build venus",
"build:analytic": "cross-env BUNDLE_ANALYZER=true nx build --skip-nx-cache",
@@ -80,10 +82,11 @@
"tslib": "^2.4.0"
},
"devDependencies": {
"@firebase/auth": "^0.20.4",
"@firebase/auth": "^0.20.5",
"@headlessui/react": "^1.6.5",
"@heroicons/react": "^1.0.6",
"@nrwl/cli": "^14.4.0",
"@nrwl/cypress": "^14.4.0",
"@nrwl/eslint-plugin-nx": "^14.4.0",
"@nrwl/jest": "^14.4.0",
"@nrwl/js": "^14.4.0",
@@ -117,18 +120,20 @@
"compression-webpack-plugin": "^10.0.0",
"cross-env": "^7.0.3",
"css-minimizer-webpack-plugin": "^4.0.0",
"cypress": "^10.4.0",
"cz-customizable": "^5.3.0",
"env-cmd": "^10.1.0",
"eslint": "^8.19.0",
"eslint-config-next": "12.2.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-cypress": "^2.10.3",
"eslint-plugin-filename-rules": "^1.2.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.6.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"firebase": "^9.8.4",
"firebase": "^9.9.2",
"fs-extra": "^10.1.0",
"html-webpack-plugin": "^5.5.0",
"husky": "^8.0.1",
@@ -142,7 +147,7 @@
"ts-jest": "^28.0.5",
"ts-node": "^10.8.2",
"typescript": "^4.7.4",
"webpack": "^5.73.0",
"webpack": "^5.74.0",
"webpack-bundle-analyzer": "^4.5.0"
},
"lint-staged": {
+1015 -591
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -28,6 +28,7 @@
"framework-virgo": "libs/framework/virgo",
"keck": "apps/keck",
"ligo-virgo": "apps/ligo-virgo",
"ligo-virgo-e2e": "apps/ligo-virgo-e2e",
"utils": "libs/utils",
"venus": "apps/venus"
}