From 31fbb4d8398cea62b2fdb91f7c7f5ecc7c19a9e7 Mon Sep 17 00:00:00 2001 From: Alejandro Lembke Barrientos Date: Sat, 7 Oct 2023 03:43:44 +0000 Subject: [PATCH] PR-149165: adding cypress folder. --- cypress/e2e/App.test.ts | 20 +++++++++++++ cypress/fixtures/example.json | 5 ++++ cypress/support/commands.ts | 37 ++++++++++++++++++++++++ cypress/support/component-index.html | 13 +++++++++ cypress/support/component.ts | 42 ++++++++++++++++++++++++++++ cypress/support/e2e.ts | 20 +++++++++++++ 6 files changed, 137 insertions(+) create mode 100644 cypress/e2e/App.test.ts create mode 100644 cypress/fixtures/example.json create mode 100644 cypress/support/commands.ts create mode 100644 cypress/support/component-index.html create mode 100644 cypress/support/component.ts create mode 100644 cypress/support/e2e.ts diff --git a/cypress/e2e/App.test.ts b/cypress/e2e/App.test.ts new file mode 100644 index 0000000..d558736 --- /dev/null +++ b/cypress/e2e/App.test.ts @@ -0,0 +1,20 @@ +describe('Initial Component Tests', () => { + it('Will show the Initial Component page.', () => { + cy.visit('/'); + cy.get('a').contains('Other Component'); + }); + it('Will Redirect to Other Component page.', () => { + cy.visit('/'); + cy.get('a').contains('Other Component').click(); + cy.get('a').contains('Initial Component'); + }); + it('Will show the Other Component page.', () => { + cy.visit('/other-component'); + cy.get('a').contains('Initial Component'); + }); + it('Will Redirect to Initial Component page.', () => { + cy.visit('/other-component'); + cy.get('a').contains('Initial Component').click(); + cy.get('a').contains('Other Component'); + }); +}); \ No newline at end of file diff --git a/cypress/fixtures/example.json b/cypress/fixtures/example.json new file mode 100644 index 0000000..02e4254 --- /dev/null +++ b/cypress/fixtures/example.json @@ -0,0 +1,5 @@ +{ + "name": "Using fixtures to represent data", + "email": "hello@cypress.io", + "body": "Fixtures are a great way to mock data for responses to routes" +} diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts new file mode 100644 index 0000000..698b01a --- /dev/null +++ b/cypress/support/commands.ts @@ -0,0 +1,37 @@ +/// +// *********************************************** +// This example commands.ts 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 +// *********************************************** +// +// +// -- This is a parent command -- +// Cypress.Commands.add('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) => { ... }) +// +// declare global { +// namespace Cypress { +// interface Chainable { +// login(email: string, password: string): Chainable +// drag(subject: string, options?: Partial): Chainable +// dismiss(subject: string, options?: Partial): Chainable +// visit(originalFn: CommandOriginalFn, url: string, options: Partial): Chainable +// } +// } +// } \ No newline at end of file diff --git a/cypress/support/component-index.html b/cypress/support/component-index.html new file mode 100644 index 0000000..f87366e --- /dev/null +++ b/cypress/support/component-index.html @@ -0,0 +1,13 @@ + + + + + + + + Components App + + +
+ + \ No newline at end of file diff --git a/cypress/support/component.ts b/cypress/support/component.ts new file mode 100644 index 0000000..00ae19b --- /dev/null +++ b/cypress/support/component.ts @@ -0,0 +1,42 @@ +// *********************************************************** +// This example support/component.ts 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 +// *********************************************************** + +//Importing global styles +import '../../src/frontend/styles/global.scss'; + +// Import commands.js using ES2015 syntax: +import './commands'; + +// Alternatively you can use CommonJS syntax: +// require('./commands') + +import { mount } from 'cypress/react18'; + +// Augment the Cypress namespace to include type definitions for +// your custom command. +// Alternatively, can be defined in cypress/support/component.d.ts +// with a at the top of your spec. +declare global { + namespace Cypress { + interface Chainable { + mount: typeof mount + } + } +} + +Cypress.Commands.add('mount', mount); + +// Example use: +// cy.mount() diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts new file mode 100644 index 0000000..598ab5f --- /dev/null +++ b/cypress/support/e2e.ts @@ -0,0 +1,20 @@ +// *********************************************************** +// This example support/e2e.ts 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'; + +// Alternatively you can use CommonJS syntax: +// require('./commands')