summaryrefslogtreecommitdiff
path: root/src/frontend/cypress/e2e
diff options
context:
space:
mode:
authorSaumit <justsaumit@protonmail.com>2025-09-27 02:14:26 +0530
committerSaumit <justsaumit@protonmail.com>2025-09-27 02:14:26 +0530
commit82e03978b89938219958032efb1448cc76baa181 (patch)
tree626f3e54d52ecd49be0ed3bee30abacc0453d081 /src/frontend/cypress/e2e
Initial snapshot - OpenTelemetry demo 2.1.3 -f
Diffstat (limited to 'src/frontend/cypress/e2e')
-rw-r--r--src/frontend/cypress/e2e/Checkout.cy.ts54
-rw-r--r--src/frontend/cypress/e2e/Home.cy.ts28
-rw-r--r--src/frontend/cypress/e2e/ProductDetail.cy.ts53
3 files changed, 135 insertions, 0 deletions
diff --git a/src/frontend/cypress/e2e/Checkout.cy.ts b/src/frontend/cypress/e2e/Checkout.cy.ts
new file mode 100644
index 0000000..1feca43
--- /dev/null
+++ b/src/frontend/cypress/e2e/Checkout.cy.ts
@@ -0,0 +1,54 @@
+// Copyright The OpenTelemetry Authors
+// SPDX-License-Identifier: Apache-2.0
+
+import { CypressFields, getElementByField } from '../../utils/Cypress';
+
+describe.skip('Checkout Flow', () => {
+ before(() => {
+ cy.intercept('POST', '/api/cart*').as('addToCart');
+ cy.intercept('GET', '/api/cart*').as('getCart');
+ cy.intercept('POST', '/api/checkout*').as('placeOrder');
+ });
+
+ beforeEach(() => {
+ cy.visit('/');
+ });
+
+ it('should create an order with two items', () => {
+ getElementByField(CypressFields.ProductCard).first().click();
+ getElementByField(CypressFields.ProductAddToCart).click();
+
+ cy.wait('@addToCart');
+ cy.wait('@getCart', { timeout: 10000 });
+ cy.wait(2000);
+
+ cy.location('href').should('match', /\/cart$/);
+ getElementByField(CypressFields.CartItemCount).should('contain', '1');
+
+ cy.visit('/');
+
+ getElementByField(CypressFields.ProductCard).last().click();
+ getElementByField(CypressFields.ProductAddToCart).click();
+
+ cy.wait('@addToCart');
+ cy.wait('@getCart', { timeout: 10000 });
+ cy.wait(2000);
+
+ cy.location('href').should('match', /\/cart$/);
+ getElementByField(CypressFields.CartItemCount).should('contain', '2');
+
+ getElementByField(CypressFields.CartIcon).click({ force: true });
+ getElementByField(CypressFields.CartGoToShopping).click();
+
+ cy.location('href').should('match', /\/cart$/);
+
+ getElementByField(CypressFields.CheckoutPlaceOrder).click();
+
+ cy.wait('@placeOrder');
+
+ cy.location('href').should('match', /\/checkout/);
+ getElementByField(CypressFields.CheckoutItem).should('have.length', 2);
+ });
+});
+
+export {};
diff --git a/src/frontend/cypress/e2e/Home.cy.ts b/src/frontend/cypress/e2e/Home.cy.ts
new file mode 100644
index 0000000..300912f
--- /dev/null
+++ b/src/frontend/cypress/e2e/Home.cy.ts
@@ -0,0 +1,28 @@
+// Copyright The OpenTelemetry Authors
+// SPDX-License-Identifier: Apache-2.0
+
+import getSymbolFromCurrency from 'currency-symbol-map';
+import SessionGateway from '../../gateways/Session.gateway';
+import { CypressFields, getElementByField } from '../../utils/Cypress';
+
+describe('Home Page', () => {
+ beforeEach(() => {
+ cy.visit('/');
+ });
+
+ it('should validate the home page', () => {
+ getElementByField(CypressFields.HomePage).should('exist');
+ getElementByField(CypressFields.ProductCard, getElementByField(CypressFields.ProductList)).should('have.length', 10);
+
+ getElementByField(CypressFields.SessionId).should('contain', SessionGateway.getSession().userId);
+ });
+
+ it('should change currency', () => {
+ getElementByField(CypressFields.CurrencySwitcher).select('EUR');
+ getElementByField(CypressFields.ProductCard, getElementByField(CypressFields.ProductList)).should('have.length', 10);
+
+ getElementByField(CypressFields.CurrencySwitcher).should('have.value', 'EUR');
+
+ getElementByField(CypressFields.ProductCard).should('contain', getSymbolFromCurrency('EUR'));
+ });
+});
diff --git a/src/frontend/cypress/e2e/ProductDetail.cy.ts b/src/frontend/cypress/e2e/ProductDetail.cy.ts
new file mode 100644
index 0000000..f165d3d
--- /dev/null
+++ b/src/frontend/cypress/e2e/ProductDetail.cy.ts
@@ -0,0 +1,53 @@
+// Copyright The OpenTelemetry Authors
+// SPDX-License-Identifier: Apache-2.0
+
+import { CypressFields, getElementByField } from '../../utils/Cypress';
+
+describe.skip('Product Detail Page', () => {
+ beforeEach(() => {
+ cy.visit('/');
+ });
+
+ it('should validate the product detail page', () => {
+ cy.intercept('GET', '/api/products/*').as('getProduct');
+ cy.intercept('GET', '/api/data*').as('getAd');
+ cy.intercept('GET', '/api/recommendations*').as('getRecommendations');
+
+ getElementByField(CypressFields.ProductCard).first().click();
+
+ cy.wait('@getProduct');
+ cy.wait('@getAd');
+ cy.wait('@getRecommendations');
+
+ getElementByField(CypressFields.ProductDetail).should('exist');
+ getElementByField(CypressFields.ProductPicture).should('exist');
+ getElementByField(CypressFields.ProductName).should('exist');
+ getElementByField(CypressFields.ProductDescription).should('exist');
+ getElementByField(CypressFields.ProductAddToCart).should('exist');
+
+ getElementByField(CypressFields.ProductCard, getElementByField(CypressFields.RecommendationList)).should(
+ 'have.length',
+ 4
+ );
+ getElementByField(CypressFields.Ad).should('exist');
+ });
+
+ it('should add item to cart', () => {
+ cy.intercept('POST', '/api/cart*').as('addToCart');
+ cy.intercept('GET', '/api/cart*').as('getCart');
+ getElementByField(CypressFields.ProductCard).first().click();
+ getElementByField(CypressFields.ProductAddToCart).click();
+
+ cy.wait('@addToCart');
+ cy.wait('@getCart', { timeout: 10000 });
+ cy.wait(2000);
+ cy.location('href').should('match', /\/cart$/);
+
+ getElementByField(CypressFields.CartItemCount).should('contain', '1');
+ getElementByField(CypressFields.CartIcon).click({ force: true });
+
+ getElementByField(CypressFields.CartDropdownItem).should('have.length', 1);
+ });
+});
+
+export {};