summaryrefslogtreecommitdiff
path: root/src/frontend/cypress/e2e/ProductDetail.cy.ts
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/ProductDetail.cy.ts
Initial snapshot - OpenTelemetry demo 2.1.3 -f
Diffstat (limited to 'src/frontend/cypress/e2e/ProductDetail.cy.ts')
-rw-r--r--src/frontend/cypress/e2e/ProductDetail.cy.ts53
1 files changed, 53 insertions, 0 deletions
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 {};