Skip to content

Commit

Permalink
Merge pull request #47 from empawlowski/feature/ui-tests
Browse files Browse the repository at this point in the history
feature/ui-tests
  • Loading branch information
empawlowski authored Jan 14, 2025
2 parents be2dfd0 + f97a0f0 commit f1edf00
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 78 deletions.
1 change: 1 addition & 0 deletions src/assets/data/ui/visual.data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const visualData = {
inventory: 'inventory.png',
product: 'product.png',
cart: 'cart.png',
checkout: 'checkout.png',
};
Binary file added src/assets/images/ui/product.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 0 additions & 32 deletions src/tests/e2e/cart.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { loginData } from '@_src/assets/data/e2e/login.data';
import * as report from '@_src/assets/data/report/allure.data.json';
import { visualData } from '@_src/assets/data/ui/visual.data';
import { Configuration } from '@_src/config/configuration';
import { test } from '@_src/fixtures/base.fixture';
import * as allure from 'allure-js-commons';

Expand Down Expand Up @@ -65,33 +63,3 @@ test.describe('Cart', { tag: [report.tags.regression] }, () => {
});
});
});

test.describe('Cart with errors', { tag: [report.tags.regression, report.tags.visual] }, () => {
test.use({ storageState: { cookies: [], origins: [] } });
test.beforeEach('Add running test title', async () => {
await allure.epic(report.epic.application);
await allure.feature(report.feature.cart);

console.log(`Running ${test.info().title}`);
});
test.afterEach('Close the page', async ({ base }, testInfo) => {
console.log(`Finished ${testInfo.title} with status ${testInfo.status}`);

await base.resetApp();
await base.logoutFromApp();
await base.closePage();
});

test('Visual effect for page', async ({ login, header, base }) => {
await allure.owner(report.owner.mrp);
// Arrange
test.fail(); //? added to not create a failure report
console.warn('This test will finish with status failed');
const screenshot = visualData.cart;
// Act
await login.logIn(Configuration.userVisual, Configuration.password);
await header.clickShoppingCart();
// Assert
await base.expectHaveScreenshot(screenshot);
});
});
33 changes: 0 additions & 33 deletions src/tests/e2e/checkout.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { checkoutData } from '@_src/assets/data/e2e/checkout.data';
import { loginData } from '@_src/assets/data/e2e/login.data';
import * as report from '@_src/assets/data/report/allure.data.json';
import { visualData } from '@_src/assets/data/ui/visual.data';
import { Configuration } from '@_src/config/configuration';
import { createCheckoutUser } from '@_src/factories/user.factory';
import { test } from '@_src/fixtures/base.fixture';
import { faker } from '@faker-js/faker';
Expand Down Expand Up @@ -231,34 +229,3 @@ test.describe('Checkout', { tag: [report.tags.regression] }, () => {
});
});
});

test.describe('Checkout with errors', { tag: [report.tags.regression, report.tags.visual] }, () => {
test.use({ storageState: { cookies: [], origins: [] } });
test.beforeEach('Add running test title', async () => {
await allure.epic(report.epic.application);
await allure.feature(report.feature.checkout);

console.log(`Running ${test.info().title}`);
});
test.afterEach('Close the page', async ({ base }, testInfo) => {
console.log(`Finished ${testInfo.title} with status ${testInfo.status}`);

await base.resetApp();
await base.logoutFromApp();
await base.closePage();
});

test('Visual effect for page', async ({ login, header, cart, checkout }) => {
await allure.owner(report.owner.mrp);
// Arrange
test.fail(); //? added to not create a failure report
console.warn('This test will finish with status failed');
const screenshot = visualData.checkout;
// Act
await login.logIn(Configuration.userVisual, Configuration.password);
await header.clickShoppingCart();
await cart.clickCheckout();
// Assert
await checkout.expectHaveScreenshot(screenshot);
});
});
13 changes: 0 additions & 13 deletions src/tests/e2e/inventory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as product from '@_src/assets/data/e2e/inventory-item.data.json';
import { inventoryData } from '@_src/assets/data/e2e/inventory.data';
import { loginData } from '@_src/assets/data/e2e/login.data';
import * as report from '@_src/assets/data/report/allure.data.json';
import { visualData } from '@_src/assets/data/ui/visual.data';
import { Configuration } from '@_src/config/configuration';
import { type Locator, expect, test } from '@_src/fixtures/base.fixture';
import * as allure from 'allure-js-commons';
Expand Down Expand Up @@ -195,16 +194,4 @@ test.describe('Inventory with errors', { tag: [report.tags.regression, report.ta
// Assert
await inventory.expectIncorrectImageOnProduct(link);
});

test('Visual effect for page', async ({ login, base }) => {
await allure.owner(report.owner.mrp);
// Arrange
test.fail(); //? added to not create a failure report
console.warn('This test will finish with status failed');
const screenshot = visualData.inventory;
// Act
await login.logIn(Configuration.userVisual, Configuration.password);
// Assert
await base.expectHaveScreenshot(screenshot);
});
});
78 changes: 78 additions & 0 deletions src/tests/ui/ui.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import * as product from '@_src/assets/data/e2e/inventory-item.data.json';
import * as report from '@_src/assets/data/report/allure.data.json';
import { visualData } from '@_src/assets/data/ui/visual.data';
import { Configuration } from '@_src/config/configuration';
import { test } from '@_src/fixtures/base.fixture';
import * as allure from 'allure-js-commons';

test.describe('Pages with errors', { tag: [report.tags.regression, report.tags.visual] }, () => {
test.use({ storageState: { cookies: [], origins: [] } });
test.beforeEach('Add running test title', async () => {
await allure.epic(report.epic.application);

console.log(`Running ${test.info().title}`);
});
test.afterEach('Close the page', async ({ base }, testInfo) => {
console.log(`Finished ${testInfo.title} with status ${testInfo.status}`);

await base.resetApp();
await base.logoutFromApp();
await base.closePage();
});

test('Visual effect for cart', async ({ login, header, base }) => {
await allure.feature(report.feature.cart);
await allure.owner(report.owner.mrp);
// Arrange
test.fail(); //? added to not create a failure report
console.warn('This test will finish with status failed');
const screenshot: string = visualData.cart;
// Act
await login.logIn(Configuration.userVisual, Configuration.password);
await header.clickShoppingCart();
// Assert
await base.expectHaveScreenshot(screenshot);
});

test('Visual effect for checkout', async ({ login, header, cart, checkout }) => {
await allure.feature(report.feature.checkout);
await allure.owner(report.owner.mrp);
// Arrange
test.fail(); //? added to not create a failure report
console.warn('This test will finish with status failed');
const screenshot: string = visualData.checkout;
// Act
await login.logIn(Configuration.userVisual, Configuration.password);
await header.clickShoppingCart();
await cart.clickCheckout();
// Assert
await checkout.expectHaveScreenshot(screenshot);
});

test('Visual effect for inventory', async ({ login, base }) => {
await allure.feature(report.feature.inventory);
await allure.owner(report.owner.mrp);
// Arrange
test.fail(); //? added to not create a failure report
console.warn('This test will finish with status failed');
const screenshot: string = visualData.inventory;
// Act
await login.logIn(Configuration.userVisual, Configuration.password);
// Assert
await base.expectHaveScreenshot(screenshot);
});

test('Visual effect for single product view', async ({ login, inventory, base }) => {
await allure.feature(report.feature.inventory);
await allure.owner(report.owner.mrp);
// Arrange
test.fail(); //? added to not create a failure report
console.warn('This test will finish with status failed');
const screenshot: string = visualData.product;
// Act
await login.logIn(Configuration.userProblem, Configuration.password);
await inventory.clickOnProductTitleName(product[5].title);
// Assert
await base.expectHaveScreenshot(screenshot);
});
});
11 changes: 11 additions & 0 deletions src/tests/ui/visual-screenshots.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as product from '@_src/assets/data/e2e/inventory-item.data.json';
import { loginData } from '@_src/assets/data/e2e/login.data';
import * as report from '@_src/assets/data/report/allure.data.json';
import { visualData } from '@_src/assets/data/ui/visual.data';
Expand Down Expand Up @@ -28,6 +29,16 @@ test.describe('Visual screenshot for pages', { tag: [report.tags.visual] }, () =
await base.takeScreenshot(screenshot);
});

test('Single product view', async ({ inventory, base }) => {
await allure.owner(report.owner.mrp);
// Arrange
const screenshot = visualData.product;
// Act
await inventory.clickOnProductTitleName(product[5].title);
// Assert
await base.takeScreenshot(screenshot);
});

test('Cart', async ({ base, header }) => {
await allure.owner(report.owner.mrp);
// Arrange
Expand Down

0 comments on commit f1edf00

Please sign in to comment.