Skip to content

Commit

Permalink
feat: add e2e testing structure
Browse files Browse the repository at this point in the history
  • Loading branch information
cmoinier committed Feb 26, 2025
1 parent d678318 commit 1a7bc01
Show file tree
Hide file tree
Showing 11 changed files with 1,851 additions and 2,905 deletions.
10 changes: 10 additions & 0 deletions apps/webcomponents-e2e/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": ["plugin:cypress/recommended", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
}
]
}
23 changes: 23 additions & 0 deletions apps/webcomponents-e2e/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { defineConfig } from 'cypress'
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset.js'
import { configureCommonPlugins } from '../../tools/e2e/plugins.js'
import { cypressBrowserPermissionsPlugin } from 'cypress-browser-permissions'
import { fileURLToPath } from 'url'

export default defineConfig({
e2e: {
...nxE2EPreset(fileURLToPath(import.meta.url)),
supportFile: 'src/support/e2e.ts',
devServer: {
framework: 'angular',
bundler: 'webpack',
},
video: false,
downloadsFolder: 'cypress/downloads',
screenshotsFolder: 'cypress/screenshots',
setupNodeEvents(on, config) {
cypressBrowserPermissionsPlugin(on, config)
configureCommonPlugins(on, config)
},
},
})
3 changes: 3 additions & 0 deletions apps/webcomponents-e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
37 changes: 37 additions & 0 deletions apps/webcomponents-e2e/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "demo-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/demo-e2e/src",
"projectType": "application",
"tags": [],
"implicitDependencies": ["demo"],
"targets": {
"e2e": {
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/demo-e2e/cypress.config.ts",
"devServerTarget": "webcomponents:serve:development",
"testingType": "e2e",
"browser": "chrome",
"port": "cypress-auto"
},
"configurations": {
"production": {
"devServerTarget": "webcomponents:serve:production"
}
},
"env": {
"browserPermissions": {
"write": "allow"
}
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/demo-e2e/**/*.{js,ts}"]
}
}
}
}
16 changes: 16 additions & 0 deletions apps/webcomponents-e2e/src/e2e/webcomponents.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
describe('Webcomponents', () => {
beforeEach(() => {
cy.visit('/')
})

describe('Search input', () => {
describe('With list', () => {
it('should make suggestions', () => {})
it('should open the datahub on click', () => {})
})
describe('Without list', () => {
it('should make suggestions', () => {})
it('should show an infinite results list', () => {})
})
})
})
10 changes: 10 additions & 0 deletions apps/webcomponents-e2e/src/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// ***********************************************
// 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
// ***********************************************
import '../../../../tools/e2e/commands'
25 changes: 25 additions & 0 deletions apps/webcomponents-e2e/src/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************************
// 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'
import { VIEWPORT_SIZE } from '../../../../tools/e2e/settings'

beforeEach(() => {
cy.viewport(VIEWPORT_SIZE[0], VIEWPORT_SIZE[1])

// all tests should show english translations
window.localStorage.setItem('geonetwork-ui-language', 'en')
})
10 changes: 10 additions & 0 deletions apps/webcomponents-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"sourceMap": false,
"outDir": "../../dist/out-tsc",
"allowJs": false,
"types": ["cypress", "node"]
},
"include": ["src/**/*.ts"]
}
1 change: 0 additions & 1 deletion apps/webcomponents/src/app/webcomponents.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const CUSTOM_ELEMENTS: [new (...args) => BaseComponent, string][] = [
]

@NgModule({
exports: [],
declarations: [
AppComponent,
BaseComponent,
Expand Down
Loading

0 comments on commit 1a7bc01

Please sign in to comment.