Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autom/e2e #467

Merged
merged 7 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Account Back autom tests
name: Account Module Installation autom tests

on:
pull_request:
types: [opened, reopened, synchronize]
workflow_dispatch:
schedule:
- cron: "0 10 * * 1-5"

env:
BASE_URL: ${{secrets.BASE_URL}}
Expand All @@ -21,12 +21,12 @@ jobs:

steps:
- name: Checkout Repository
uses: 'actions/checkout@v4'
uses: "actions/checkout@v4"

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 'node'
node-version: "node"

- name: Install dependencies
working-directory: ./e2e
Expand All @@ -53,8 +53,8 @@ jobs:
working-directory: ./e2e
run: npm run test-all-version
continue-on-error: true
- name: Generate Allur Repport

- name: Generate Allure Repport
working-directory: ./e2e
run: npm run generate-allure-report

Expand All @@ -63,5 +63,3 @@ jobs:
with:
name: allure-report
path: ./e2e/allure-report/


16 changes: 8 additions & 8 deletions e2e-env/shop-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ ping_url() {

ping_url $appUrl

# cd ../e2e
# # Ajouter ou écraser les variables dans le fichier .env
# sed -i '' "/^BASE_URL=/c\\
# BASE_URL=${appUrl}/admin-dev/
# " .env
# sed -i '' "/^BASE_URL_FO=/c\\
# BASE_URL_FO=${appUrl}
# " .env
cd ../e2e
# Ajouter ou écraser les variables dans le fichier .env
sed -i '' "/^BASE_URL=/c\\
BASE_URL=${appUrl}/admin-dev/
" .env
sed -i '' "/^BASE_URL_FO=/c\\
BASE_URL_FO=${appUrl}
" .env


echo "Tests environment is available at: $appUrl/admin-dev/"
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {title} from 'process';
import {Locales} from '~/types/locales';

export const moduleManagerPagesLocales: Locales = {
moduleManager: {
en_EN: {
title: 'Module manager'
title: 'Module manager',
titleOldPsVersion: 'List of modules'
}
},
}
};
12 changes: 6 additions & 6 deletions e2e/fixtures/login.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ export const gotToModuleManagerPage = base.extend<ShippingFixtures>({
page: async ({page}, use) => {
const pm = new PageManager(page);
await page.goto(Globals.base_url);
if (await pm.frombasePage().isAnotherMethodLinkVisible()) {
await pm.frombasePage().connectWithAnotherMethod();
}else if (await pm.fromDashboardPage().isSecureModeMethodLinkVisible()) {
await pm.fromDashboardPage().connectSecureModeMethodLink();
}
await pm.frombasePage().handleConnectionMode();
await pm.frombasePage().login(Globals.admin_email, Globals.admin_password);
await page.waitForTimeout(5000);
if (await pm.fromDashboardPage().isPopupVisible()) {
await pm.fromDashboardPage().closePopup();
}
await pm.fromDashboardPage().getPageMainTitle();
await pm.frombasePage().goToSubMenu(pm.frombasePage().modulesParentLink, pm.frombasePage().moduleManagerLink);
if (await pm.fromDashboardPage().getShopVersion()) {
await pm.frombasePage().goToListOfModulesOldPsVersion();
} else {
await pm.frombasePage().goToSubMenu(pm.frombasePage().modulesParentLink, pm.frombasePage().moduleManagerLink);
}
await use(page);
}
});
21 changes: 11 additions & 10 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
"scripts": {
"lint": "eslint . --ext .ts",
"build-shop": "cd ../e2e-env && ./shop-build.sh",
"test-shop-1.7.8.7": "npm run build-shop -- 1.7.8.7-7.4-fpm-alpine && npx playwright test back || true && mkdir -p allure-results-1.7.8.7 && for file in allure-results/*.json; do jq '.labels[] |= if .name == \"parentSuite\" then .value |= . + \"-1.7.8.7\" else . end | .testCaseId |= . + \"-1.7.8.7\" | .historyId |= . + \"-1.7.8.7\"' \"$file\" > \"$file.tmp\" && mv \"$file.tmp\" \"$file\"; done && cp -r allure-results/* allure-results-1.7.8.7/ && rm -rf allure-results/*",
"test-shop-1.6.1.24": "npm run build-shop -- 1.6.1.24-7.1-fpm-alpine && npx playwright test back || true && mkdir -p allure-results-1.6.1.24 && for file in allure-results/*.json; do jq '.labels[] |= if .name == \"parentSuite\" then .value |= . + \"-1.6.1.24\" else . end | .testCaseId |= . + \"-1.6.1.24\" | .historyId |= . + \"-1.6.1.24\"' \"$file\" > \"$file.tmp\" && mv \"$file.tmp\" \"$file\"; done && cp -r allure-results/* allure-results-1.6.1.24/ && rm -rf allure-results/*",
"test-shop-1.7.8.11": "npm run build-shop -- 1.7.8.11-7.4-fpm-alpine && npx playwright test back || true && mkdir -p allure-results-1.7.8.11 && for file in allure-results/*.json; do jq '.labels[] |= if .name == \"parentSuite\" then .value |= . + \"-1.7.8.11\" else . end | .testCaseId |= . + \"-1.7.8.11\" | .historyId |= . + \"-1.7.8.11\"' \"$file\" > \"$file.tmp\" && mv \"$file.tmp\" \"$file\"; done && cp -r allure-results/* allure-results-1.7.8.11/ && rm -rf allure-results/*",
"test-shop-1.7.8.8": "npm run build-shop -- 1.7.8.8-7.4-fpm-alpine && npx playwright test back || true && mkdir -p allure-results-1.7.8.8 && for file in allure-results/*.json; do jq '.labels[] |= if .name == \"parentSuite\" then .value |= . + \"-1.7.8.8\" else . end | .testCaseId |= . + \"-1.7.8.8\" | .historyId |= . + \"-1.7.8.8\"' \"$file\" > \"$file.tmp\" && mv \"$file.tmp\" \"$file\"; done && cp -r allure-results/* allure-results-1.7.8.8/ && rm -rf allure-results/*",
"test-shop-8.1.0-8.1": "npm run build-shop -- 8.1.0-8.1-fpm-alpine && npx playwright test back || true && mkdir -p allure-results-8.1.0-8.1 && for file in allure-results/*.json; do jq '.labels[] |= if .name == \"parentSuite\" then .value |= . + \"-8.1.0-8.1\" else . end | .testCaseId |= . + \"-8.1.0-8.1\" | .historyId |= . + \"-8.1.0-8.1\"' \"$file\" > \"$file.tmp\" && mv \"$file.tmp\" \"$file\"; done && cp -r allure-results/* allure-results-8.1.0-8.1/ && rm -rf allure-results/*",
"test-shop-8.1.1": "npm run build-shop -- 8.1.1-8.1-fpm-alpine && npx playwright test back || true && mkdir -p allure-results-8.1.1 && for file in allure-results/*.json; do jq '.labels[] |= if .name == \"parentSuite\" then .value |= . + \"-8.1.1\" else . end | .testCaseId |= . + \"-8.1.1\" | .historyId |= . + \"-8.1.1\"' \"$file\" > \"$file.tmp\" && mv \"$file.tmp\" \"$file\"; done && cp -r allure-results/* allure-results-8.1.1/ && rm -rf allure-results/*",
"test-shop-8.1.5": "npm run build-shop -- 8.1.5-8.1-fpm-alpine && npx playwright test back || true && mkdir -p allure-results-8.1.5 && for file in allure-results/*.json; do jq '.labels[] |= if .name == \"parentSuite\" then .value |= . + \"-8.1.5\" else . end | .testCaseId |= . + \"-8.1.5\" | .historyId |= . + \"-8.1.5\"' \"$file\" > \"$file.tmp\" && mv \"$file.tmp\" \"$file\"; done && cp -r allure-results/* allure-results-8.1.5/ && rm -rf allure-results/*",
"test-shop-nightly": "npm run build-shop -- nightly && npx playwright test || true && mkdir -p allure-results-nightly && for file in allure-results/*.json; do jq '.labels[] |= if .name == \"parentSuite\" then .value |= . + \"-nightly\" else . end | .testCaseId |= . + \"-nightly\" | .historyId |= . + \"-nightly\"' \"$file\" > \"$file.tmp\" && mv \"$file.tmp\" \"$file\"; done && cp -r allure-results/* allure-results-nightly/ && rm -rf allure-results/*",
"test-shop-1.7.8.7": "npm run build-shop -- 1.7.8.7-7.4-fpm-alpine && npx playwright test && mkdir -p allure-results-1.7.8.7 && for file in allure-results/*.json; do jq '.labels[] |= if .name == \"parentSuite\" then .value |= . + \"-1.7.8.7\" else . end | .testCaseId |= . + \"-1.7.8.7\" | .historyId |= . + \"-1.7.8.7\"' \"$file\" > \"$file.tmp\" && mv \"$file.tmp\" \"$file\"; done && cp -r allure-results/* allure-results-1.7.8.7/ && rm -rf allure-results/*",
"test-shop-1.6.1.24": "npm run build-shop -- 1.6.1.24-7.1-fpm-alpine && npx playwright test && mkdir -p allure-results-1.6.1.24 && for file in allure-results/*.json; do jq '.labels[] |= if .name == \"parentSuite\" then .value |= . + \"-1.6.1.24\" else . end | .testCaseId |= . + \"-1.6.1.24\" | .historyId |= . + \"-1.6.1.24\"' \"$file\" > \"$file.tmp\" && mv \"$file.tmp\" \"$file\"; done && cp -r allure-results/* allure-results-1.6.1.24/ && rm -rf allure-results/*",
"test-shop-1.7.8.11": "npm run build-shop -- 1.7.8.11-7.4-fpm-alpine && npx playwright test && mkdir -p allure-results-1.7.8.11 && for file in allure-results/*.json; do jq '.labels[] |= if .name == \"parentSuite\" then .value |= . + \"-1.7.8.11\" else . end | .testCaseId |= . + \"-1.7.8.11\" | .historyId |= . + \"-1.7.8.11\"' \"$file\" > \"$file.tmp\" && mv \"$file.tmp\" \"$file\"; done && cp -r allure-results/* allure-results-1.7.8.11/ && rm -rf allure-results/*",
"test-shop-1.7.8.8": "npm run build-shop -- 1.7.8.8-7.4-fpm-alpine && npx playwright test && mkdir -p allure-results-1.7.8.8 && for file in allure-results/*.json; do jq '.labels[] |= if .name == \"parentSuite\" then .value |= . + \"-1.7.8.8\" else . end | .testCaseId |= . + \"-1.7.8.8\" | .historyId |= . + \"-1.7.8.8\"' \"$file\" > \"$file.tmp\" && mv \"$file.tmp\" \"$file\"; done && cp -r allure-results/* allure-results-1.7.8.8/ && rm -rf allure-results/*",
"test-shop-8.1.0-8.1": "npm run build-shop -- 8.1.0-8.1-fpm-alpine && npx playwright test && mkdir -p allure-results-8.1.0-8.1 && for file in allure-results/*.json; do jq '.labels[] |= if .name == \"parentSuite\" then .value |= . + \"-8.1.0-8.1\" else . end | .testCaseId |= . + \"-8.1.0-8.1\" | .historyId |= . + \"-8.1.0-8.1\"' \"$file\" > \"$file.tmp\" && mv \"$file.tmp\" \"$file\"; done && cp -r allure-results/* allure-results-8.1.0-8.1/ && rm -rf allure-results/*",
"test-shop-8.1.1": "npm run build-shop -- 8.1.1-8.1-fpm-alpine && npx playwright test && mkdir -p allure-results-8.1.1 && for file in allure-results/*.json; do jq '.labels[] |= if .name == \"parentSuite\" then .value |= . + \"-8.1.1\" else . end | .testCaseId |= . + \"-8.1.1\" | .historyId |= . + \"-8.1.1\"' \"$file\" > \"$file.tmp\" && mv \"$file.tmp\" \"$file\"; done && cp -r allure-results/* allure-results-8.1.1/ && rm -rf allure-results/*",
"test-shop-8.1.5": "npm run build-shop -- 8.1.5-8.1-fpm-alpine && npx playwright test && mkdir -p allure-results-8.1.5 && for file in allure-results/*.json; do jq '.labels[] |= if .name == \"parentSuite\" then .value |= . + \"-8.1.5\" else . end | .testCaseId |= . + \"-8.1.5\" | .historyId |= . + \"-8.1.5\"' \"$file\" > \"$file.tmp\" && mv \"$file.tmp\" \"$file\"; done && cp -r allure-results/* allure-results-8.1.5/ && rm -rf allure-results/*",
"test-shop-8.2.0": "npm run build-shop -- 8.2.0-8.1-fpm-alpine && npx playwright test && mkdir -p allure-results-8.2.0 && for file in allure-results/*.json; do jq '.labels[] |= if .name == \"parentSuite\" then .value |= . + \"-8.2.0\" else . end | .testCaseId |= . + \"-8.2.0\" | .historyId |= . + \"-8.2.0\"' \"$file\" > \"$file.tmp\" && mv \"$file.tmp\" \"$file\"; done && cp -r allure-results/* allure-results-8.2.0/ && rm -rf allure-results/*",
"test-shop-nightly": "npm run build-shop -- nightly && npx playwright test && mkdir -p allure-results-nightly && for file in allure-results/*.json; do jq '.labels[] |= if .name == \"parentSuite\" then .value |= . + \"-nightly\" else . end | .testCaseId |= . + \"-nightly\" | .historyId |= . + \"-nightly\"' \"$file\" > \"$file.tmp\" && mv \"$file.tmp\" \"$file\"; done && cp -r allure-results/* allure-results-nightly/ && rm -rf allure-results/*",
"merge-allure-results": "rm -rf allure-results && mkdir allure-results && for dir in allure-results-*; do cp -r \"$dir\"/* allure-results/; done && rm -rf allure-results-*",
"test-all-version": "npx npm-run-all --serial test-shop-1.7.8.7 test-shop-1.6.1.24 test-shop-1.7.8.11 test-shop-1.7.8.8 test-shop-8.1.0-8.1 test-shop-8.1.1 test-shop-8.1.5 test-shop-nightly && npm run merge-allure-results",
"test-all-version": "npx npm-run-all --serial test-shop-1.7.8.7 test-shop-1.6.1.24 test-shop-1.7.8.11 test-shop-1.7.8.8 test-shop-8.1.0-8.1 test-shop-8.1.1 test-shop-8.1.5 test-shop-8.2.0 test-shop-nightly && npm run merge-allure-results",
"generate-allure-report": "allure generate allure-results --clean -o allure-report",
"clean-test-results": "rm -rf allure-report allure-results allure-results-* test-results"
},
Expand Down Expand Up @@ -41,4 +42,4 @@
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.6"
}
}
}
70 changes: 24 additions & 46 deletions e2e/pages/basePage.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
// Import pages
import {CommonPage} from '@prestashopcorp/tests-framework';
import type {FrameLocator, Locator, Page} from '@playwright/test';
import {expect, Locator, Page} from '@playwright/test';
import {Globals} from '../utils/globals';
import {modulePsAccount} from 'data/local/modules/modulePsAccount';

export default class BasePage extends CommonPage {
public readonly emailInput: Locator;
public readonly passwordInput: Locator;
public readonly submitLoginButton: Locator;
private readonly anotherMethodLink: Locator;
private readonly secureModeMethodLink: Locator;

/* <<<<<<<<<<<<<<< SHIPPING >>>>>>>>>>>>>>>>>>>>>> */
public readonly shippingParentLink: Locator;
public readonly shippingCarriersLink: Locator;
public readonly shippingPreferencesLink: Locator;

/* <<<<<<<<<<<<<<< MODULEMANAGER >>>>>>>>>>>>>>>>>>>>>> */
public readonly modulesParentLink: Locator;
public readonly moduleManagerLink: Locator;
Expand All @@ -24,18 +14,6 @@ export default class BasePage extends CommonPage {
constructor(page: Page) {
super(page);

/* <<<<<<<<<<<<<<< Selectors >>>>>>>>>>>>>>>>>>>>>> */
this.emailInput = this.page.locator('#email');
this.passwordInput = this.page.locator('#passwd');
this.submitLoginButton = this.page.getByRole('button', {name: 'Log in'});
this.anotherMethodLink = this.page.getByRole('link', {name: 'Connect with another method'});
this.secureModeMethodLink = this.page.getByRole('link', {name: 'log in to secure mode (https://)'});

/* <<<<<<<<<<<<<<< SHIPPING >>>>>>>>>>>>>>>>>>>>>> */
this.shippingParentLink = this.page.locator('#subtab-AdminParentShipping');
this.shippingCarriersLink = this.page.locator('#subtab-AdminCarriers');
this.shippingPreferencesLink = this.page.locator('#subtab-AdminShipping');

/* <<<<<<<<<<<<<<< MODULEMANAGER >>>>>>>>>>>>>>>>>>>>>> */
this.modulesParentLink = this.page.locator('#subtab-AdminParentModulesSf');
this.moduleManagerLink = this.page.locator('#subtab-AdminModulesSf');
Expand All @@ -44,35 +22,29 @@ export default class BasePage extends CommonPage {
}

/**
* Is Link for Secure Mode method is visible
* @returns
* True if another login method visible
* Click on connect with another method if visible
*/
isSecureModeMethodLinkVisible(): Promise<boolean> {
return this.isVisible(this.secureModeMethodLink, 1000);
async connectWithAnotherMethod(): Promise<void> {
if (await this.page.getByRole('link', {name: 'Connect with another method'}).isVisible()) {
await this.page.getByRole('link', {name: 'Connect with another method'}).click();
}
}

/**
* Click on connect with Secure Mode
* Click on connect with Secure Mode if visible
*/
async connectSecureModeMethodLink(): Promise<void> {
await this.clickAndWaitForLoadState(this.secureModeMethodLink, 'networkidle');
}

/**
* Is Link for another method is visible
* @returns
* True if another login method visible
*/
isAnotherMethodLinkVisible(): Promise<boolean> {
return this.isVisible(this.anotherMethodLink, 1000);
if (await this.page.getByRole('link', {name: 'log in to secure mode (https://)'}).isVisible()) {
await this.page.getByRole('link', {name: 'log in to secure mode (https://)'}).click();
}
}

/**
* Click on connect with another method
* Handle connection mode if necessary
*/
async connectWithAnotherMethod(): Promise<void> {
await this.clickAndWaitForLoadState(this.anotherMethodLink, 'networkidle');
async handleConnectionMode(): Promise<void> {
await this.connectWithAnotherMethod();
await this.connectSecureModeMethodLink();
}

/**
Expand All @@ -82,10 +54,11 @@ export default class BasePage extends CommonPage {
* The page title
*/
async login(email: string = Globals.admin_email, password: string = Globals.admin_password) {
await this.setValue(this.emailInput, email);
await this.setValue(this.passwordInput, password);
await this.clickAndWaitForLoadState(this.submitLoginButton, 'domcontentloaded');
await this.page.locator('#email').fill(email);
await this.page.locator('#passwd').fill(password);
await this.page.getByRole('button', {name: 'Log in'}).click();
}

/**
* Is a menu with submenus open
* @param parentLocator {Locator}
Expand Down Expand Up @@ -122,4 +95,9 @@ export default class BasePage extends CommonPage {
await this.clickAndWaitForLoadState(linkLocator, 'domcontentloaded');
}
}

async goToListOfModulesOldPsVersion() {
await this.page.locator('.icon-AdminParentModules').hover();
await this.page.locator('#subtab-AdminModules').filter({hasText: 'Modules and Services'}).click();
}
}
12 changes: 12 additions & 0 deletions e2e/pages/dashboard/dashboardPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ export default class DashboardPage extends BasePage {
expect(title).toContainText(dashboardPagesLocales.dashboard.en_EN.title);
}

/**
* Get Shop version
* @param page {Page} The browser tab
* Return Shop Version
*/

async getShopVersion(): Promise<boolean> {
const versionLocator = this.page.locator('#shop_version');
const versionText = await versionLocator.first().textContent();
return versionText?.includes('1.6') ?? false;
}

/**
* Check if Popup is Visible
* @param page {Page} The browser tab
Expand Down
Loading
Loading