diff --git a/.github/workflows/e2e_api_tests.yml b/.github/workflows/e2e_api_tests.yml index 624179b4d0..248bfa97e5 100644 --- a/.github/workflows/e2e_api_tests.yml +++ b/.github/workflows/e2e_api_tests.yml @@ -1,8 +1,8 @@ name: E2E_API Tests on: + # workflow will run daily at 8:00 AM BDT (2:00 AM UTC) schedule: - # workflow will run daily at 8:00 AM BDT (2:00 AM UTC) - cron: '0 2 * * *' # workflow will trigger on pull request pull_request: @@ -13,15 +13,15 @@ on: # workflow can be manually triggered workflow_dispatch: - inputs: - testsuite: - description: Choose which test suite to run - default: All - type: choice - options: - - E2E - - API - - All + inputs: + testsuite: + description: Choose which test suite to run + default: All + type: choice + options: + - E2E + - API + - All # Cancels all previous workflow runs for pull requests that have not completed. concurrency: @@ -58,6 +58,7 @@ env: SYSTEM_INFO: ./tests/pw/playwright/systemInfo.json API_TEST_RESULT: ./tests/pw/playwright-report/api/summary-report/results.json E2E_TEST_RESULT: ./tests/pw/playwright-report/e2e/summary-report/results.json + API_COVERAGE: ./tests/pw/playwright-report/api/coverage-report/coverage.json jobs: tests: @@ -66,11 +67,11 @@ jobs: steps: - name: Checkout testing repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Use desired version of NodeJS if: success() - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: '16' cache: 'npm' @@ -78,7 +79,7 @@ jobs: - name: Composer install and build (Dokan-lite) if: success() run: | - composer install --no-dev -o + composer install --no-dev -o - name: Npm install and build (Dokan-lite) if: success() @@ -87,12 +88,19 @@ jobs: npm run build # Install test dependencies - - name: Install dependencies + - name: Install test dependencies if: success() run: | cd tests/pw npm ci + # Create wp debuglog file + - name: Create wp debuglog file + if: success() + run: | + cd tests/pw + mkdir -p wp-data && touch wp-data/debug.log + # Start wordpress environment - name: Start WordPress Env id: wp-env @@ -142,7 +150,7 @@ jobs: - name: Cache playwright binaries id: playwright-cache if: success() - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.cache/ms-playwright @@ -186,7 +194,7 @@ jobs: # Prepare test summary - name: Prepare test summary id: prepare-test-summary - uses: actions/github-script@v6 + uses: actions/github-script@v7 if: always() with: result-encoding: string @@ -194,34 +202,42 @@ jobs: const script = require("./tests/pw/utils/gitTestSummary.ts") return await script({github, context, core}) - # # Find PR comment - # - name: Find PR comment by github-actions[bot] - # uses: peter-evans/find-comment@v2 - # id: find-comment - # if: github.event_name == 'pull_request' - # with: - # issue-number: ${{ github.event.pull_request.number }} - # comment-author: 'github-actions[bot]' - # body-includes: Tests Summary - - # # Post test summary as PR comment - # - name: Create or update PR comment - # uses: peter-evans/create-or-update-comment@v2 - # if: github.event_name == 'pull_request' - # with: - # comment-id: ${{ steps.find-comment.outputs.comment-id }} - # issue-number: ${{ github.event.pull_request.number }} - # body: ${{ steps.prepare-test-summary.outputs.result }} - # reactions: hooray - # edit-mode: replace + # Find PR comment + - name: Find PR comment by github-actions[bot] + uses: peter-evans/find-comment@v3 + id: find-comment + if: github.event_name == 'pull_request' + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: Tests Summary + + # Post test summary as PR comment + - name: Create or update PR comment + uses: peter-evans/create-or-update-comment@v4 + if: github.event_name == 'pull_request' + with: + comment-id: ${{ steps.find-comment.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: ${{ steps.prepare-test-summary.outputs.result }} + reactions: hooray + edit-mode: replace + + # Backup Database + - name: Backup Database + if: success() + run: | + cd tests/pw + npm run wp-env run tests-cli wp db export wp-data/db.sql # Upload artifacts - name: Archive test artifacts (screenshots, HTML snapshots, Reports) - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: always() with: name: test-artifact path: | + tests/pw/wp-data tests/pw/playwright tests/pw/playwright-report if-no-files-found: ignore diff --git a/tests/pw/.env.example b/tests/pw/.env.example index bfcc1405e1..4e4b787ef0 100644 --- a/tests/pw/.env.example +++ b/tests/pw/.env.example @@ -14,6 +14,7 @@ BASE_URL=https://example.com [Base URL of the test site] CI=true [CI/CD environment indicator] SLOWMO=10 [Slow down test execution by provided seconds] [optional] NO_SETUP=true [Whether not to run setup tests before actual tests] [optional] +SITE_PATH=/users/rk/sites/dokan [Path of the local test site][only for local testing] # Database Configuration DB_HOST_NAME=localhost [Database server hostname or IP address] diff --git a/tests/pw/.eslintignore b/tests/pw/.eslintignore index c6bdf3d86b..25a5452113 100644 --- a/tests/pw/.eslintignore +++ b/tests/pw/.eslintignore @@ -12,12 +12,10 @@ types/ # System Files .DS_Store Thumbs.db -{"mode":"full","isActive":false} # Docs files *_spec3.json # Custom files -TODO.ts TODO.md \ No newline at end of file diff --git a/tests/pw/.gitignore b/tests/pw/.gitignore index 9ce7da8f57..70790e9c27 100644 --- a/tests/pw/.gitignore +++ b/tests/pw/.gitignore @@ -120,6 +120,7 @@ dist .tern-port # Stores VSCode versions used for testing VSCode extensions +.vscode/settings.json .vscode-test # yarn v2 @@ -175,11 +176,6 @@ test-results/ playwright-report/ playwright/.cache/ visual.spec.ts-snapshots/ -storageState.json -adminStorageState.json -customerStorageState.json -vendorStorageState.json -systemInfo.json # vscode .vscode/ diff --git a/tests/pw/.htaccess b/tests/pw/.htaccess index 8e5df81db7..aa188b913a 100644 --- a/tests/pw/.htaccess +++ b/tests/pw/.htaccess @@ -11,4 +11,13 @@ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] +php_value max_execution_time 300 +php_value max_input_time 300 +php_value max_input_vars 10000 +php_value memory_limit 1G +php_value post_max_size 1G +php_value upload_max_filesize 1G + + php_flag opcache.enable Off + # END WordPress \ No newline at end of file diff --git a/tests/pw/.prettierignore b/tests/pw/.prettierignore index 94dd707335..4a30c86fc7 100644 --- a/tests/pw/.prettierignore +++ b/tests/pw/.prettierignore @@ -18,7 +18,8 @@ Thumbs.db *_spec3.json # Custom files -TODO.ts +.wp-env.json +.wp-env.override TODO.md diff --git a/tests/pw/.wp-env.json b/tests/pw/.wp-env.json index 70dbce6752..8fc507fc16 100644 --- a/tests/pw/.wp-env.json +++ b/tests/pw/.wp-env.json @@ -2,16 +2,10 @@ "env": { "tests": { "port": 9999, - "core": "https://wordpress.org/latest.zip", + "core": null, "phpVersion": "7.4", - "plugins": [ - "https://downloads.wordpress.org/plugin/woocommerce.latest-stable.zip", - "../../", - "https://github.com/shashwatahalder01/TestUtils/raw/main/ba.zip" - ], - "themes": [ - "https://downloads.wordpress.org/theme/storefront.latest-stable.zip" - ], + "plugins": ["WP-API/Basic-Auth", "https://downloads.wordpress.org/plugin/woocommerce.latest-stable.zip", "../../"], + "themes": ["https://downloads.wordpress.org/theme/storefront.latest-stable.zip"], "config": { "WP_DEBUG": "true", "SCRIPT_DEBUG": "true", @@ -19,7 +13,9 @@ "WP_DEBUG_DISPLAY": "true" }, "mappings": { - ".htaccess": ".htaccess" + ".htaccess": ".htaccess", + "wp-data": "./wp-data", + "wp-content/debug.log": "./wp-data/debug.log" } } } diff --git a/tests/pw/.wp-env.override b/tests/pw/.wp-env.override index c988950818..c1ae967364 100644 --- a/tests/pw/.wp-env.override +++ b/tests/pw/.wp-env.override @@ -1,16 +1,16 @@ { - "env": { - "tests": { - "plugins": [ - "https://downloads.wordpress.org/plugin/woocommerce.latest-stable.zip", - "../../", - "../../../../", - "https://github.com/shashwatahalder01/TestUtils/raw/main/ba.zip", - "https://github.com/shashwatahalder01/TestUtils/raw/main/wa.zip", - "https://github.com/shashwatahalder01/TestUtils/raw/main/wb.zip", - "https://github.com/shashwatahalder01/TestUtils/raw/main/wps.zip", - "https://github.com/shashwatahalder01/TestUtils/raw/main/ws.zip" - ] + "env": { + "tests": { + "plugins": [ + "WP-API/Basic-Auth", + "https://downloads.wordpress.org/plugin/woocommerce.latest-stable.zip", + "../../", + "../../../../", + "../../../woocommerce-bookings", + "../../../woocommerce-product-addons", + "../../../woocommerce-simple-auctions", + "../../../woocommerce-subscriptions" + ] + } } - } -} \ No newline at end of file +} diff --git a/tests/pw/README.MD b/tests/pw/README.MD index 3f40bd27ce..f0ca99a43a 100644 --- a/tests/pw/README.MD +++ b/tests/pw/README.MD @@ -125,6 +125,7 @@ BASE_URL=https://example.com [Base URL of the test site] CI=true [CI/CD environment indicator] SLOWMO=10 [Slow down test execution by provided seconds] [optional] NO_SETUP=true [Whether not to run setup tests before actual tests] [optional] +SITE_PATH=/users/rk/sites/dokan [Path of the local test site][only for local testing] # Database Configuration DB_HOST_NAME=localhost [Database server hostname or IP address] diff --git a/tests/pw/api.config.ts b/tests/pw/api.config.ts index 89701c8e47..79fa0d4682 100644 --- a/tests/pw/api.config.ts +++ b/tests/pw/api.config.ts @@ -1,26 +1,44 @@ import { defineConfig, expect } from '@playwright/test'; import { customExpect } from '@utils/pwMatchers'; import 'dotenv/config'; +const { CI, BASE_URL, NO_SETUP, ADMIN, ADMIN_PASSWORD } = process.env; export default defineConfig({ - testDir: './tests/api' /* test directory */, - outputDir: 'playwright/api/test-artifacts/' /* Folder for test artifacts such as screenshots, videos, traces, etc. */, - globalSetup: './global-setup' /* Path to the global setup file. This file will be required and run before all the tests. */, - // globalTeardown: './global-teardown' /* Path to the global teardown file. This file will be required and run after all the tests. */, - globalTimeout: process.env.CI ? 20 * (60 * 1000) : 20 * (60 * 1000) /* Maximum time in milliseconds the whole test suite can run */, - maxFailures: process.env.CI ? 30 : 30 /* The maximum number of test failures for the whole test suite run. After reaching this number, testing will stop and exit with an error. */, - timeout: process.env.CI ? 10 * 1000 : 15 * 1000 /* Maximum time one test can run for. */, + /* test directory */ + testDir: './tests/api', + /* Folder for test artifacts such as screenshots, videos, traces, etc. */ + outputDir: 'playwright/api/test-artifacts/', + /* Path to the global setup file. This file will be required and run before all the tests. */ + globalSetup: './global-setup', + /* Path to the global teardown file. This file will be required and run after all the tests. */ + // globalTeardown: './global-teardown', + /* Maximum time in milliseconds the whole test suite can run */ + globalTimeout: CI ? 20 * (60 * 1000) : 20 * (60 * 1000), + /* The maximum number of test failures for the whole test suite run. After reaching this number, testing will stop and exit with an error. */ + maxFailures: CI ? 30 : 30, + /* Maximum time one test can run for. */ + timeout: CI ? 15 * 1000 : 20 * 1000, + /* Configuration for the expect assertion library */ expect: { - timeout: 5 * 1000 /* Maximum time expect() should wait for the condition to be met. For example in `await expect(locator).toHaveText();`*/, - } /* Configuration for the expect assertion library */, - preserveOutput: 'always' /* Whether to preserve test output in the testConfig.outputDir. Defaults to 'always'. */, - // fullyParallel : true, /* Run tests in files in parallel */ - // forbidOnly : !!process.env.CI, /* Fail the build on CI if you accidentally left testonly in the source code. */ - repeatEach: 1 /* The number of times to repeat each test, useful for debugging flaky tests. */, - retries: process.env.CI ? 1 : 0 /* The maximum number of retry attempts given to failed tests. */, - workers: process.env.CI ? 4 : 4 /* Opt out of parallel tests on CI. */, - reportSlowTests: { max: 2, threshold: 10 } /* Whether to report slow test files. Pass null to disable this feature. */, - reporter: process.env.CI + /* Maximum time expect() should wait for the condition to be met. For example in `await expect(locator).toHaveText();`*/ + timeout: 5 * 1000, + }, + /* Whether to preserve test output in the testConfig.outputDir. Defaults to 'always'. */ + preserveOutput: 'always', + /* Run tests in files in parallel */ + // fullyParallel : true, + /* Fail the build on CI if you accidentally left testonly in the source code. */ + // forbidOnly : !!CI, + /* The number of times to repeat each test, useful for debugging flaky tests. */ + repeatEach: CI ? 1 : 0, + /* The maximum number of retry attempts given to failed tests. */ + retries: CI ? 1 : 0, + /* Opt out of parallel tests on CI. */ + workers: CI ? 4 : 4, + /* Whether to report slow test files. Pass null to disable this feature. */ + reportSlowTests: { max: 2, threshold: 10 }, + /* Configure reporters */ + reporter: CI ? [ ['github'], ['html', { open: 'never', outputFolder: 'playwright-report/api/html/html-report-api' }], @@ -36,12 +54,14 @@ export default defineConfig({ ], use: { - baseURL: process.env.BASE_URL ? process.env.BASE_URL : 'http://localhost:9999' /* Base URL */, - ignoreHTTPSErrors: true /* Whether to ignore HTTPS errors during navigation. */, + /* Base URL */ + baseURL: BASE_URL ? BASE_URL : 'http://localhost:9999', + /* Whether to ignore HTTPS errors during navigation. */ + ignoreHTTPSErrors: true, /* api request headers */ extraHTTPHeaders: { Accept: '*/*', - Authorization: 'Basic ' + Buffer.from(process.env.ADMIN + ':' + process.env.ADMIN_PASSWORD).toString('base64'), + Authorization: 'Basic ' + Buffer.from(ADMIN + ':' + ADMIN_PASSWORD).toString('base64'), }, }, @@ -65,10 +85,19 @@ export default defineConfig({ { name: 'api_tests', testMatch: /.*\.spec\.ts/, - dependencies: process.env.NO_SETUP ? [] : ['api_setup'] /* whether not to run setup tests before running actual tests */, + /* whether not to run setup tests before running actual tests */ + dependencies: NO_SETUP ? [] : ['api_setup'], + /* whether not to run teardown tests after running actual tests */ + teardown: NO_SETUP ? undefined : 'coverage_report', // teardown: 'global_teardown', }, + // coverage_report + { + name: 'coverage_report', + testMatch: '_coverage.teardown.ts', + }, + // global_teardown // { // name: 'global_teardown', diff --git a/tests/pw/e2e.config.ts b/tests/pw/e2e.config.ts index d3230d94db..4b9ca2ec64 100644 --- a/tests/pw/e2e.config.ts +++ b/tests/pw/e2e.config.ts @@ -1,31 +1,49 @@ import { defineConfig, devices, expect } from '@playwright/test'; import { customExpect } from '@utils/pwMatchers'; import 'dotenv/config'; +const { CI, BASE_URL, SLOWMO, NO_SETUP } = process.env; export default defineConfig({ - testDir: './tests/e2e' /* test directory */, - outputDir: 'playwright/e2e/test-artifacts/' /* Folder for test artifacts such as screenshots, videos, traces, etc. */, - globalSetup: './global-setup' /* Path to the global setup file. This file will be required and run before all the tests. */, - // globalTeardown: './global-teardown' /* Path to the global teardown file. This file will be required and run after all the tests. */, - globalTimeout: process.env.CI ? 40 * (60 * 1000) : 40 * (60 * 1000) /* Maximum time in milliseconds the whole test suite can run */, - maxFailures: process.env.CI ? 40 : 30 /* The maximum number of test failures for the whole test suite run. After reaching this number, testing will stop and exit with an error. */, - timeout: process.env.CI ? 50 * 1000 : 35 * 1000 /* Maximum time one test can run for. */, + /* test directory */ + testDir: './tests/e2e', + /* Folder for test artifacts such as screenshots, videos, traces, etc. */ + outputDir: 'playwright/e2e/test-artifacts/', + /* Path to the global setup file. This file will be required and run before all the tests. */ + globalSetup: './global-setup', + /* Path to the global teardown file. This file will be required and run after all the tests. */ + // globalTeardown: './global-teardown' , + /* Maximum time in milliseconds the whole test suite can run */ + globalTimeout: CI ? 40 * (60 * 1000) : 40 * (60 * 1000), + /* The maximum number of test failures for the whole test suite run. After reaching this number, testing will stop and exit with an error. */ + maxFailures: CI ? 40 : 40, + /* Maximum time one test can run for. */ + timeout: CI ? 45 * 1000 : 45 * 1000, + /* Configuration for the expect assertion library */ expect: { - timeout: 15 * 1000 /* Maximum time expect() should wait for the condition to be met. For example in `await expect(locator).toHaveText();`*/, + /* Maximum time expect() should wait for the condition to be met. For example in `await expect(locator).toHaveText();`*/ + timeout: 15 * 1000, toHaveScreenshot: { maxDiffPixelRatio: 0.2, maxDiffPixels: 500, threshold: 0.5, }, - } /* Configuration for the expect assertion library */, - preserveOutput: 'always' /* Whether to preserve test output in the testConfig.outputDir. Defaults to 'always'. */, - // fullyParallel : true, /* Run tests in files in parallel */ - // forbidOnly : !!process.env.CI, /* Fail the build on CI if you accidentally left test-only in the source code. */ - repeatEach: 1 /* The number of times to repeat each test, useful for debugging flaky tests. */, - retries: process.env.CI ? 1 : 0 /* The maximum number of retry attempts given to failed tests. */, - workers: process.env.CI ? 4 : 1 /* Opt out of parallel tests on CI. */, - reportSlowTests: { max: 2, threshold: 25 } /* Whether to report slow test files. Pass null to disable this feature. */, - reporter: process.env.CI + }, + /* Whether to preserve test output in the testConfig.outputDir. Defaults to 'always'. */ + preserveOutput: 'always', + /* Run tests in files in parallel */ + // fullyParallel : true, + /* Fail the build on CI if you accidentally left test-only in the source code. */ + // forbidOnly : !!CI, + /* The number of times to repeat each test, useful for debugging flaky tests. */ + repeatEach: CI ? 1 : 0, + /* The maximum number of retry attempts given to failed tests. */ + retries: CI ? 1 : 0, + /* Opt out of parallel tests on CI. */ + workers: CI ? 4 : 4, + /* Whether to report slow test files. Pass null to disable this feature. */ + reportSlowTests: { max: 2, threshold: 25 }, + /* Configure reporters */ + reporter: CI ? [ ['github'], ['html', { open: 'never', outputFolder: 'playwright-report/e2e/html/html-report-e2e' }], @@ -42,22 +60,46 @@ export default defineConfig({ use: { ...devices['Desktop Chrome'], - acceptDownloads: true /* Whether to automatically download all the attachments. */, - actionTimeout: 20 * 1000 /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */, - navigationTimeout: 20 * 1000 /* Maximum time each navigation such as 'goto()' can take. */, - baseURL: process.env.BASE_URL ? process.env.BASE_URL : 'http://localhost:9999' /* Base URL */, - // browserName: 'chromium' /* Name of the browser that runs tests. */, - bypassCSP: true /* Toggles bypassing page's Content-Security-Policy. */, - // channel: 'chrome' /* Browser distribution channel. */, - // colorScheme: 'dark' /* Emulates 'prefers-colors-scheme' media feature, supported values are 'light', 'dark', 'no-preference' */, - headless: process.env.CI ? !!process.env.CI : false /* Whether to run tests on headless or non-headless mode */, - ignoreHTTPSErrors: true /* Whether to ignore HTTPS errors during navigation. */, - trace: 'on-first-retry' /* Record trace only when retrying a test for the first time. */, - screenshot: 'only-on-failure' /* Capture screenshot after each test failure. */, - // video: 'retain-on-failure' /* Record video only when retrying a test for the first time. */, - video: 'on-first-retry' /* Record video only when retrying a test for the first time. */, - // viewport : { width: 1280, height: 720 }, /* Size of viewport */ - launchOptions: { slowMo: process.env.SLOWMO ? Number(process.env.SLOWMO) * 1000 : 0 /* whether to slow down test execution by provided seconds */ }, + /* Whether to automatically download all the attachments. */ + acceptDownloads: true, + /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ + actionTimeout: 30 * 1000, + /* Maximum time each navigation such as 'goto()' can take. */ + navigationTimeout: 30 * 1000, + /* Base URL */ + baseURL: BASE_URL ? BASE_URL : 'http://localhost:9999', + /* Name of the browser that runs tests. */ + // browserName: 'chromium', + /* Toggles bypassing page's Content-Security-Policy. */ + bypassCSP: true, + /* Browser distribution channel. */ + // channel: 'chrome', + /* Emulates 'prefers-colors-scheme' media feature, supported values are 'light', 'dark', 'no-preference' */ + // colorScheme: 'dark' , + /* Whether to run tests on headless or non-headless mode */ + headless: CI ? !!CI : false, + /* Whether to ignore HTTPS errors during navigation. */ + ignoreHTTPSErrors: true, + /* Record trace only when retrying a test for the first time. */ + // trace: 'on-first-retry', + trace: { + mode: 'on-first-retry', + snapshots: true, + screenshots: true, + sources: true, + attachments: true, + }, + /* Capture screenshot after each test failure. */ + screenshot: { + mode: 'only-on-failure', + fullPage: true, + }, + /* Record video only when retrying a test for the first time. */ + video: 'on-first-retry', + /* Size of viewport */ + // viewport: { width: 1420, height: 900 }, // default 1280x720 + /* whether to slow down test execution by provided seconds */ + launchOptions: { slowMo: SLOWMO ? Number(SLOWMO) * 1000 : 0 }, }, projects: [ @@ -74,14 +116,16 @@ export default defineConfig({ name: 'e2e_setup', // testMatch: /.*\.setup\.ts/, testMatch: '_env.setup.ts', - dependencies: process.env.NO_SETUP ? [] : ['auth_setup'] /* whether not to run setup tests before running actual tests */, + /* whether not to run setup tests before running actual tests */ + dependencies: NO_SETUP ? [] : ['auth_setup'], }, // e2e_tests { name: 'e2e_tests', testMatch: /.*\.spec\.ts/, - dependencies: process.env.NO_SETUP ? [] : ['e2e_setup'] /* whether not to run setup tests before running actual tests */, + /* whether not to run setup tests before running actual tests */ + dependencies: NO_SETUP ? [] : ['e2e_setup'], }, // local site setup project diff --git a/tests/pw/global-setup.ts b/tests/pw/global-setup.ts index 65da7bbf43..935ba211cb 100644 --- a/tests/pw/global-setup.ts +++ b/tests/pw/global-setup.ts @@ -1,9 +1,19 @@ import { FullConfig, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; +import { helpers } from '@utils/helpers'; +import { data } from '@utils/testData'; + +const { CI } = process.env; async function globalSetup(config: FullConfig) { console.log('Global Setup running....'); + // rewrite permalink structure + !CI && helpers.exeCommand(data.command.permalinkLocal); + + // activate theme: storefront + !CI && helpers.exeCommand(data.command.activateTheme); + // get site url structure let serverUrl = config.projects[0]?.use.baseURL as string; const apiUtils = new ApiUtils(await request.newContext({ ignoreHTTPSErrors: true })); diff --git a/tests/pw/package-lock.json b/tests/pw/package-lock.json index 56b102a98b..c49044d9db 100644 --- a/tests/pw/package-lock.json +++ b/tests/pw/package-lock.json @@ -9,22 +9,22 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@faker-js/faker": "^8.3.1", - "@playwright/test": "1.38", - "@wordpress/env": "^9.0.0", - "dotenv": "^16.3.1", - "mysqlconnector": "^2.0.5", + "@faker-js/faker": "^8.4.0", + "@playwright/test": "1.41", + "@wordpress/env": "^9.2.0", + "dotenv": "^16.4.1", + "mysqlconnector": "^2.0.6", "php-serialize": "^4.1.1", "zod": "^3.22.4" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^6.18.1", - "@typescript-eslint/parser": "^6.18.1", + "@typescript-eslint/eslint-plugin": "^6.21.0", + "@typescript-eslint/parser": "^6.21.0", "eslint": "^8.56.0", "eslint-config-prettier": "^9.1.0", - "eslint-plugin-playwright": "^0.21.0", - "npm-check-updates": "^16.14.12", - "prettier": "^3.1.1", + "eslint-plugin-playwright": "^0.22.2", + "npm-check-updates": "^16.14.14", + "prettier": "^3.2.5", "typescript": "^5.3.3" } }, @@ -122,9 +122,9 @@ } }, "node_modules/@faker-js/faker": { - "version": "8.3.1", - "resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-8.3.1.tgz", - "integrity": "sha512-FdgpFxY6V6rLZE9mmIBb9hM0xpfvQOSNOLnzolzKwsE1DH+gC7lEKV1p1IbR0lAYyvYd5a4u3qWJzowUkw1bIw==", + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-8.4.0.tgz", + "integrity": "sha512-htW87352wzUCdX1jyUQocUcmAaFqcR/w082EC8iP/gtkF0K+aKcBp0hR5Arb7dzR8tQ1TrhE9DNa5EbJELm84w==", "funding": [ { "type": "opencollective", @@ -424,11 +424,11 @@ } }, "node_modules/@playwright/test": { - "version": "1.38.1", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.38.1.tgz", - "integrity": "sha512-NqRp8XMwj3AK+zKLbZShl0r/9wKgzqI/527bkptKXomtuo+dOjU9NdMASQ8DNC9z9zLOMbG53T4eihYr3XR+BQ==", + "version": "1.41.0", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.41.0.tgz", + "integrity": "sha512-Grvzj841THwtpBOrfiHOeYTJQxDRnKofMSzCiV8XeyLWu3o89qftQ4BCKfkziJhSUQRd0utKhrddtIsiraIwmw==", "dependencies": { - "playwright": "1.38.1" + "playwright": "1.41.0" }, "bin": { "playwright": "cli.js" @@ -627,16 +627,16 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.18.1.tgz", - "integrity": "sha512-nISDRYnnIpk7VCFrGcu1rnZfM1Dh9LRHnfgdkjcbi/l7g16VYRri3TjXi9Ir4lOZSw5N/gnV/3H7jIPQ8Q4daA==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.21.0.tgz", + "integrity": "sha512-oy9+hTPCUFpngkEZUSzbf9MxI65wbKFoQYsgPdILTfbUldp5ovUuphZVe4i30emU9M/kP+T64Di0mxl7dSw3MA==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.18.1", - "@typescript-eslint/type-utils": "6.18.1", - "@typescript-eslint/utils": "6.18.1", - "@typescript-eslint/visitor-keys": "6.18.1", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/type-utils": "6.21.0", + "@typescript-eslint/utils": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -662,15 +662,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.18.1.tgz", - "integrity": "sha512-zct/MdJnVaRRNy9e84XnVtRv9Vf91/qqe+hZJtKanjojud4wAVy/7lXxJmMyX6X6J+xc6c//YEWvpeif8cAhWA==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.21.0.tgz", + "integrity": "sha512-tbsV1jPne5CkFQCgPBcDOt30ItF7aJoZL997JSF7MhGQqOeT3svWRYxiqlfA5RUdlHN6Fi+EI9bxqbdyAUZjYQ==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "6.18.1", - "@typescript-eslint/types": "6.18.1", - "@typescript-eslint/typescript-estree": "6.18.1", - "@typescript-eslint/visitor-keys": "6.18.1", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/typescript-estree": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", "debug": "^4.3.4" }, "engines": { @@ -690,13 +690,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.18.1.tgz", - "integrity": "sha512-BgdBwXPFmZzaZUuw6wKiHKIovms97a7eTImjkXCZE04TGHysG+0hDQPmygyvgtkoB/aOQwSM/nWv3LzrOIQOBw==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.21.0.tgz", + "integrity": "sha512-OwLUIWZJry80O99zvqXVEioyniJMa+d2GrqpUTqi5/v5D5rOrppJVBPa0yKCblcigC0/aYAzxxqQ1B+DS2RYsg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.18.1", - "@typescript-eslint/visitor-keys": "6.18.1" + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -707,13 +707,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.18.1.tgz", - "integrity": "sha512-wyOSKhuzHeU/5pcRDP2G2Ndci+4g653V43gXTpt4nbyoIOAASkGDA9JIAgbQCdCkcr1MvpSYWzxTz0olCn8+/Q==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.21.0.tgz", + "integrity": "sha512-rZQI7wHfao8qMX3Rd3xqeYSMCL3SoiSQLBATSiVKARdFGCYSRvmViieZjqc58jKgs8Y8i9YvVVhRbHSTA4VBag==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "6.18.1", - "@typescript-eslint/utils": "6.18.1", + "@typescript-eslint/typescript-estree": "6.21.0", + "@typescript-eslint/utils": "6.21.0", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, @@ -734,9 +734,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.18.1.tgz", - "integrity": "sha512-4TuMAe+tc5oA7wwfqMtB0Y5OrREPF1GeJBAjqwgZh1lEMH5PJQgWgHGfYufVB51LtjD+peZylmeyxUXPfENLCw==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.21.0.tgz", + "integrity": "sha512-1kFmZ1rOm5epu9NZEZm1kckCDGj5UJEf7P1kliH4LKu/RkwpsfqqGmY2OOcUs18lSlQBKLDYBOGxRVtrMN5lpg==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -747,13 +747,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.18.1.tgz", - "integrity": "sha512-fv9B94UAhywPRhUeeV/v+3SBDvcPiLxRZJw/xZeeGgRLQZ6rLMG+8krrJUyIf6s1ecWTzlsbp0rlw7n9sjufHA==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.21.0.tgz", + "integrity": "sha512-6npJTkZcO+y2/kr+z0hc4HwNfrrP4kNYh57ek7yCNlrBjWQ1Y0OS7jiZTkgumrvkX5HkEKXFZkkdFNkaW2wmUQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.18.1", - "@typescript-eslint/visitor-keys": "6.18.1", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -799,17 +799,17 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.18.1.tgz", - "integrity": "sha512-zZmTuVZvD1wpoceHvoQpOiewmWu3uP9FuTWo8vqpy2ffsmfCE8mklRPi+vmnIYAIk9t/4kOThri2QCDgor+OpQ==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.21.0.tgz", + "integrity": "sha512-NfWVaC8HP9T8cbKQxHcsJBY5YE1O33+jpMwN45qzWWaPDZgLIbo12toGMWnmhvCpd3sIxkpDw3Wv1B3dYrbDQQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.18.1", - "@typescript-eslint/types": "6.18.1", - "@typescript-eslint/typescript-estree": "6.18.1", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/typescript-estree": "6.21.0", "semver": "^7.5.4" }, "engines": { @@ -824,12 +824,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.18.1.tgz", - "integrity": "sha512-/kvt0C5lRqGoCfsbmm7/CwMqoSkY3zzHLIjdhHZQW3VFrnz7ATecOHR7nb7V+xn4286MBxfnQfQhAmCI0u+bJA==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.21.0.tgz", + "integrity": "sha512-JJtkDduxLi9bivAB+cYOVMtbkqdPOhZ+ZI5LC47MIRrDV4Yn2o+ZnW10Nkmr28xRpSpdJ6Sm42Hjf2+REYXm0A==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.18.1", + "@typescript-eslint/types": "6.21.0", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -847,9 +847,9 @@ "dev": true }, "node_modules/@wordpress/env": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/@wordpress/env/-/env-9.0.0.tgz", - "integrity": "sha512-Fyec0k5N7kaXVIpTnJ2zO/n3CIiq8cPDsUaFoLVKI+yv2cVuq1dSQyc1lLXB9Gu+SNvmfbq7nNVVmNfKgpAkrw==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/@wordpress/env/-/env-9.2.0.tgz", + "integrity": "sha512-2gl65WYbkuTjnW2SHKjeqdpLTgnPc/xVvFiwG+2p/RJwDHSuw1xXSdFqFUh3+wC/4cuXy9b2ZBm/SYsBoc8DDw==", "dependencies": { "chalk": "^4.0.0", "copy-dir": "^1.3.0", @@ -1721,9 +1721,9 @@ } }, "node_modules/dotenv": { - "version": "16.3.1", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", - "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", + "version": "16.4.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.1.tgz", + "integrity": "sha512-CjA3y+Dr3FyFDOAMnxZEGtnW9KBR2M0JvvUtXNW+dYJL5ROWxP9DUHCwgFqpMk0OXCc0ljhaNTr2w/kutYIcHQ==", "engines": { "node": ">=12" }, @@ -1888,9 +1888,9 @@ } }, "node_modules/eslint-plugin-playwright": { - "version": "0.21.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-playwright/-/eslint-plugin-playwright-0.21.0.tgz", - "integrity": "sha512-Y6qwguE9L6LB1JCsnPKaHbo+Z4X8/MngD82N0NkwiZ0ch0UVc4Oc2ZqmxanFxftIddnvwtNNlzUezglLlzUzKA==", + "version": "0.22.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-playwright/-/eslint-plugin-playwright-0.22.2.tgz", + "integrity": "sha512-LtOB9myIX1O7HHqg9vtvBLjvXq1MXKuXIcD1nS+qZiMUJV6s9HBdilURAr9pIFc9kEelbVF54hOJ8pMxHvJP7g==", "dev": true, "dependencies": { "globals": "^13.23.0" @@ -3474,9 +3474,9 @@ } }, "node_modules/mysqlconnector": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/mysqlconnector/-/mysqlconnector-2.0.5.tgz", - "integrity": "sha512-SiHISVNxo+D3YLjdcdpOmCSdJGtgeBSdQEAr1l20jVLWgr17VAMRBdJe5udSQAqMTtzLRM/dF+OSO0ieYqK95w==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/mysqlconnector/-/mysqlconnector-2.0.6.tgz", + "integrity": "sha512-JyIKHqwYCXjHq5z2rIJIxgL/ty6hxssRihLrU16ScctR9uRB4APQvd2pcYhMSJ4US37zwG3CIUSXqVGUQX4Jkg==", "dependencies": { "mysql": "2.18.1" } @@ -3607,9 +3607,9 @@ } }, "node_modules/npm-check-updates": { - "version": "16.14.12", - "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-16.14.12.tgz", - "integrity": "sha512-5FvqaDX8AqWWTDQFbBllgLwoRXTvzlqVIRSKl9Kg8bYZTfNwMnrp1Zlmb5e/ocf11UjPTc+ShBFjYQ7kg6FL0w==", + "version": "16.14.14", + "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-16.14.14.tgz", + "integrity": "sha512-Y3ajS/Ep40jM489rLBdz9jehn/BMil5s9fA4PSr2ZJxxSmtLWCSmRqsI2IEZ9Nb3MTMu8a3s7kBs0l+JbjdkTA==", "dev": true, "dependencies": { "chalk": "^5.3.0", @@ -4326,11 +4326,11 @@ } }, "node_modules/playwright": { - "version": "1.38.1", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.38.1.tgz", - "integrity": "sha512-oRMSJmZrOu1FP5iu3UrCx8JEFRIMxLDM0c/3o4bpzU5Tz97BypefWf7TuTNPWeCe279TPal5RtPPZ+9lW/Qkow==", + "version": "1.41.0", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.41.0.tgz", + "integrity": "sha512-XOsfl5ZtAik/T9oek4V0jAypNlaCNzuKOwVhqhgYT3os6kH34PzbRb74F0VWcLYa5WFdnmxl7qyAHBXvPv7lqQ==", "dependencies": { - "playwright-core": "1.38.1" + "playwright-core": "1.41.0" }, "bin": { "playwright": "cli.js" @@ -4343,9 +4343,9 @@ } }, "node_modules/playwright-core": { - "version": "1.38.1", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.38.1.tgz", - "integrity": "sha512-tQqNFUKa3OfMf4b2jQ7aGLB8o9bS3bOY0yMEtldtC2+spf8QXG9zvXLTXUeRsoNuxEYMgLYR+NXfAa1rjKRcrg==", + "version": "1.41.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.41.0.tgz", + "integrity": "sha512-UGKASUhXmvqm2Lxa1fNr8sFwAtqjpgBRr9jQ7XBI8Rn5uFiEowGUGwrruUQsVPIom4bk7Lt+oLGpXobnXzrBIw==", "bin": { "playwright-core": "cli.js" }, @@ -4363,9 +4363,9 @@ } }, "node_modules/prettier": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.1.tgz", - "integrity": "sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==", + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", "dev": true, "bin": { "prettier": "bin/prettier.cjs" @@ -5841,9 +5841,9 @@ "dev": true }, "@faker-js/faker": { - "version": "8.3.1", - "resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-8.3.1.tgz", - "integrity": "sha512-FdgpFxY6V6rLZE9mmIBb9hM0xpfvQOSNOLnzolzKwsE1DH+gC7lEKV1p1IbR0lAYyvYd5a4u3qWJzowUkw1bIw==" + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-8.4.0.tgz", + "integrity": "sha512-htW87352wzUCdX1jyUQocUcmAaFqcR/w082EC8iP/gtkF0K+aKcBp0hR5Arb7dzR8tQ1TrhE9DNa5EbJELm84w==" }, "@humanwhocodes/config-array": { "version": "0.11.13", @@ -6059,11 +6059,11 @@ "optional": true }, "@playwright/test": { - "version": "1.38.1", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.38.1.tgz", - "integrity": "sha512-NqRp8XMwj3AK+zKLbZShl0r/9wKgzqI/527bkptKXomtuo+dOjU9NdMASQ8DNC9z9zLOMbG53T4eihYr3XR+BQ==", + "version": "1.41.0", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.41.0.tgz", + "integrity": "sha512-Grvzj841THwtpBOrfiHOeYTJQxDRnKofMSzCiV8XeyLWu3o89qftQ4BCKfkziJhSUQRd0utKhrddtIsiraIwmw==", "requires": { - "playwright": "1.38.1" + "playwright": "1.41.0" } }, "@pnpm/config.env-replace": { @@ -6221,16 +6221,16 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.18.1.tgz", - "integrity": "sha512-nISDRYnnIpk7VCFrGcu1rnZfM1Dh9LRHnfgdkjcbi/l7g16VYRri3TjXi9Ir4lOZSw5N/gnV/3H7jIPQ8Q4daA==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.21.0.tgz", + "integrity": "sha512-oy9+hTPCUFpngkEZUSzbf9MxI65wbKFoQYsgPdILTfbUldp5ovUuphZVe4i30emU9M/kP+T64Di0mxl7dSw3MA==", "dev": true, "requires": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.18.1", - "@typescript-eslint/type-utils": "6.18.1", - "@typescript-eslint/utils": "6.18.1", - "@typescript-eslint/visitor-keys": "6.18.1", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/type-utils": "6.21.0", + "@typescript-eslint/utils": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -6240,54 +6240,54 @@ } }, "@typescript-eslint/parser": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.18.1.tgz", - "integrity": "sha512-zct/MdJnVaRRNy9e84XnVtRv9Vf91/qqe+hZJtKanjojud4wAVy/7lXxJmMyX6X6J+xc6c//YEWvpeif8cAhWA==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.21.0.tgz", + "integrity": "sha512-tbsV1jPne5CkFQCgPBcDOt30ItF7aJoZL997JSF7MhGQqOeT3svWRYxiqlfA5RUdlHN6Fi+EI9bxqbdyAUZjYQ==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "6.18.1", - "@typescript-eslint/types": "6.18.1", - "@typescript-eslint/typescript-estree": "6.18.1", - "@typescript-eslint/visitor-keys": "6.18.1", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/typescript-estree": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", "debug": "^4.3.4" } }, "@typescript-eslint/scope-manager": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.18.1.tgz", - "integrity": "sha512-BgdBwXPFmZzaZUuw6wKiHKIovms97a7eTImjkXCZE04TGHysG+0hDQPmygyvgtkoB/aOQwSM/nWv3LzrOIQOBw==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.21.0.tgz", + "integrity": "sha512-OwLUIWZJry80O99zvqXVEioyniJMa+d2GrqpUTqi5/v5D5rOrppJVBPa0yKCblcigC0/aYAzxxqQ1B+DS2RYsg==", "dev": true, "requires": { - "@typescript-eslint/types": "6.18.1", - "@typescript-eslint/visitor-keys": "6.18.1" + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0" } }, "@typescript-eslint/type-utils": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.18.1.tgz", - "integrity": "sha512-wyOSKhuzHeU/5pcRDP2G2Ndci+4g653V43gXTpt4nbyoIOAASkGDA9JIAgbQCdCkcr1MvpSYWzxTz0olCn8+/Q==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.21.0.tgz", + "integrity": "sha512-rZQI7wHfao8qMX3Rd3xqeYSMCL3SoiSQLBATSiVKARdFGCYSRvmViieZjqc58jKgs8Y8i9YvVVhRbHSTA4VBag==", "dev": true, "requires": { - "@typescript-eslint/typescript-estree": "6.18.1", - "@typescript-eslint/utils": "6.18.1", + "@typescript-eslint/typescript-estree": "6.21.0", + "@typescript-eslint/utils": "6.21.0", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" } }, "@typescript-eslint/types": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.18.1.tgz", - "integrity": "sha512-4TuMAe+tc5oA7wwfqMtB0Y5OrREPF1GeJBAjqwgZh1lEMH5PJQgWgHGfYufVB51LtjD+peZylmeyxUXPfENLCw==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.21.0.tgz", + "integrity": "sha512-1kFmZ1rOm5epu9NZEZm1kckCDGj5UJEf7P1kliH4LKu/RkwpsfqqGmY2OOcUs18lSlQBKLDYBOGxRVtrMN5lpg==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.18.1.tgz", - "integrity": "sha512-fv9B94UAhywPRhUeeV/v+3SBDvcPiLxRZJw/xZeeGgRLQZ6rLMG+8krrJUyIf6s1ecWTzlsbp0rlw7n9sjufHA==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.21.0.tgz", + "integrity": "sha512-6npJTkZcO+y2/kr+z0hc4HwNfrrP4kNYh57ek7yCNlrBjWQ1Y0OS7jiZTkgumrvkX5HkEKXFZkkdFNkaW2wmUQ==", "dev": true, "requires": { - "@typescript-eslint/types": "6.18.1", - "@typescript-eslint/visitor-keys": "6.18.1", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -6317,27 +6317,27 @@ } }, "@typescript-eslint/utils": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.18.1.tgz", - "integrity": "sha512-zZmTuVZvD1wpoceHvoQpOiewmWu3uP9FuTWo8vqpy2ffsmfCE8mklRPi+vmnIYAIk9t/4kOThri2QCDgor+OpQ==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.21.0.tgz", + "integrity": "sha512-NfWVaC8HP9T8cbKQxHcsJBY5YE1O33+jpMwN45qzWWaPDZgLIbo12toGMWnmhvCpd3sIxkpDw3Wv1B3dYrbDQQ==", "dev": true, "requires": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.18.1", - "@typescript-eslint/types": "6.18.1", - "@typescript-eslint/typescript-estree": "6.18.1", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/typescript-estree": "6.21.0", "semver": "^7.5.4" } }, "@typescript-eslint/visitor-keys": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.18.1.tgz", - "integrity": "sha512-/kvt0C5lRqGoCfsbmm7/CwMqoSkY3zzHLIjdhHZQW3VFrnz7ATecOHR7nb7V+xn4286MBxfnQfQhAmCI0u+bJA==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.21.0.tgz", + "integrity": "sha512-JJtkDduxLi9bivAB+cYOVMtbkqdPOhZ+ZI5LC47MIRrDV4Yn2o+ZnW10Nkmr28xRpSpdJ6Sm42Hjf2+REYXm0A==", "dev": true, "requires": { - "@typescript-eslint/types": "6.18.1", + "@typescript-eslint/types": "6.21.0", "eslint-visitor-keys": "^3.4.1" } }, @@ -6348,9 +6348,9 @@ "dev": true }, "@wordpress/env": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/@wordpress/env/-/env-9.0.0.tgz", - "integrity": "sha512-Fyec0k5N7kaXVIpTnJ2zO/n3CIiq8cPDsUaFoLVKI+yv2cVuq1dSQyc1lLXB9Gu+SNvmfbq7nNVVmNfKgpAkrw==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/@wordpress/env/-/env-9.2.0.tgz", + "integrity": "sha512-2gl65WYbkuTjnW2SHKjeqdpLTgnPc/xVvFiwG+2p/RJwDHSuw1xXSdFqFUh3+wC/4cuXy9b2ZBm/SYsBoc8DDw==", "requires": { "chalk": "^4.0.0", "copy-dir": "^1.3.0", @@ -6980,9 +6980,9 @@ } }, "dotenv": { - "version": "16.3.1", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", - "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==" + "version": "16.4.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.1.tgz", + "integrity": "sha512-CjA3y+Dr3FyFDOAMnxZEGtnW9KBR2M0JvvUtXNW+dYJL5ROWxP9DUHCwgFqpMk0OXCc0ljhaNTr2w/kutYIcHQ==" }, "eastasianwidth": { "version": "0.2.0", @@ -7125,9 +7125,9 @@ "requires": {} }, "eslint-plugin-playwright": { - "version": "0.21.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-playwright/-/eslint-plugin-playwright-0.21.0.tgz", - "integrity": "sha512-Y6qwguE9L6LB1JCsnPKaHbo+Z4X8/MngD82N0NkwiZ0ch0UVc4Oc2ZqmxanFxftIddnvwtNNlzUezglLlzUzKA==", + "version": "0.22.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-playwright/-/eslint-plugin-playwright-0.22.2.tgz", + "integrity": "sha512-LtOB9myIX1O7HHqg9vtvBLjvXq1MXKuXIcD1nS+qZiMUJV6s9HBdilURAr9pIFc9kEelbVF54hOJ8pMxHvJP7g==", "dev": true, "requires": { "globals": "^13.23.0" @@ -8318,9 +8318,9 @@ } }, "mysqlconnector": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/mysqlconnector/-/mysqlconnector-2.0.5.tgz", - "integrity": "sha512-SiHISVNxo+D3YLjdcdpOmCSdJGtgeBSdQEAr1l20jVLWgr17VAMRBdJe5udSQAqMTtzLRM/dF+OSO0ieYqK95w==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/mysqlconnector/-/mysqlconnector-2.0.6.tgz", + "integrity": "sha512-JyIKHqwYCXjHq5z2rIJIxgL/ty6hxssRihLrU16ScctR9uRB4APQvd2pcYhMSJ4US37zwG3CIUSXqVGUQX4Jkg==", "requires": { "mysql": "2.18.1" } @@ -8419,9 +8419,9 @@ } }, "npm-check-updates": { - "version": "16.14.12", - "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-16.14.12.tgz", - "integrity": "sha512-5FvqaDX8AqWWTDQFbBllgLwoRXTvzlqVIRSKl9Kg8bYZTfNwMnrp1Zlmb5e/ocf11UjPTc+ShBFjYQ7kg6FL0w==", + "version": "16.14.14", + "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-16.14.14.tgz", + "integrity": "sha512-Y3ajS/Ep40jM489rLBdz9jehn/BMil5s9fA4PSr2ZJxxSmtLWCSmRqsI2IEZ9Nb3MTMu8a3s7kBs0l+JbjdkTA==", "dev": true, "requires": { "chalk": "^5.3.0", @@ -8925,18 +8925,18 @@ "dev": true }, "playwright": { - "version": "1.38.1", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.38.1.tgz", - "integrity": "sha512-oRMSJmZrOu1FP5iu3UrCx8JEFRIMxLDM0c/3o4bpzU5Tz97BypefWf7TuTNPWeCe279TPal5RtPPZ+9lW/Qkow==", + "version": "1.41.0", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.41.0.tgz", + "integrity": "sha512-XOsfl5ZtAik/T9oek4V0jAypNlaCNzuKOwVhqhgYT3os6kH34PzbRb74F0VWcLYa5WFdnmxl7qyAHBXvPv7lqQ==", "requires": { "fsevents": "2.3.2", - "playwright-core": "1.38.1" + "playwright-core": "1.41.0" } }, "playwright-core": { - "version": "1.38.1", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.38.1.tgz", - "integrity": "sha512-tQqNFUKa3OfMf4b2jQ7aGLB8o9bS3bOY0yMEtldtC2+spf8QXG9zvXLTXUeRsoNuxEYMgLYR+NXfAa1rjKRcrg==" + "version": "1.41.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.41.0.tgz", + "integrity": "sha512-UGKASUhXmvqm2Lxa1fNr8sFwAtqjpgBRr9jQ7XBI8Rn5uFiEowGUGwrruUQsVPIom4bk7Lt+oLGpXobnXzrBIw==" }, "prelude-ls": { "version": "1.2.1", @@ -8945,9 +8945,9 @@ "dev": true }, "prettier": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.1.tgz", - "integrity": "sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==", + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", "dev": true }, "proc-log": { diff --git a/tests/pw/package.json b/tests/pw/package.json index 7599202537..fdd2140013 100644 --- a/tests/pw/package.json +++ b/tests/pw/package.json @@ -11,17 +11,18 @@ "pw:deps-only": "playwright install-deps chromium", "test": "npx playwright test", "test:site_setup": "npx playwright test --project=site_setup", - "test:api": "npx playwright test --project=api_tests --config=api.config.ts ", - "test:e2e": "npx playwright test --project=e2e_tests --config=e2e.config.ts ", + "test:api": "npx playwright test --project=api_tests --config=api.config.ts", + "test:e2e": "npx playwright test --project=e2e_tests --config=e2e.config.ts", "test:e2e-i": "npx playwright test --project=e2e_tests --headed", - "test:e2e:lite": "npx playwright test --project=e2e_tests --grep '@lite|@liteOnly' --grep-invert '@pro' --config=e2e.config.ts ", - "test:api:lite": "npx playwright test --project=api_tests --grep '@lite|@liteOnly' --grep-invert @pro --config=api.config.ts ", - "test:e2e:lite:explo": "npx playwright test --project=e2e_tests --grep '(?=.*@lite)(?=.*@explo)' --config=e2e.config.ts ", - "test:api:pro": "npx playwright test --project=api_tests --grep '@lite|@pro' --grep-invert @liteOnly --config=api.config.ts ", - "test:e2e:pro": "npx playwright test --project=e2e_tests --grep '@lite|@pro' --grep-invert @liteOnly --config=e2e.config.ts ", - "test:e2e:visual": "npx playwright test --project=e2e_tests --grep @visual --config=e2e.config.ts ", - "test:e2e:explo": "npx playwright test --project=e2e_tests --grep @explo --config=e2e.config.ts ", - "test:e2e:core": "npx playwright test --project=e2e_tests --grep @core --config=e2e.config.ts ", + "test:e2e:lite": "npx playwright test --project=e2e_tests --grep '@lite|@liteOnly' --grep-invert '@pro' --config=e2e.config.ts", + "test:api:lite": "npx playwright test --project=api_tests --grep '@lite|@liteOnly' --grep-invert @pro --config=api.config.ts", + "test:e2e:lite:explo": "npx playwright test --project=e2e_tests --grep '(?=.*@lite)(?=.*@exp)' --config=e2e.config.ts", + "test:api:pro": "npx playwright test --project=api_tests --grep '@lite|@pro' --grep-invert @liteOnly --config=api.config.ts", + "test:e2e:pro": "npx playwright test --project=e2e_tests --grep '@lite' --grep-invert @liteOnly --config=e2e.config.ts", + "test:e2e:pro_": "npx playwright test --project=e2e_tests --grep '@lite|@pro' --grep-invert @liteOnly --config=e2e.config.ts", + "test:e2e:visual": "npx playwright test --project=e2e_tests --grep @visual --config=e2e.config.ts", + "test:e2e:explo": "npx playwright test --project=e2e_tests --grep @exp --config=e2e.config.ts", + "test:e2e:core": "npx playwright test --project=e2e_tests --grep @core --config=e2e.config.ts", "test:grep": "npx playwright test --grep", "test:debug": "npx playwright test --debug", "test:codegen": "playwright codegen", @@ -51,21 +52,21 @@ "author": "", "license": "ISC", "devDependencies": { - "@typescript-eslint/eslint-plugin": "^6.18.1", - "@typescript-eslint/parser": "^6.18.1", + "@typescript-eslint/eslint-plugin": "^6.21.0", + "@typescript-eslint/parser": "^6.21.0", "eslint": "^8.56.0", "eslint-config-prettier": "^9.1.0", - "eslint-plugin-playwright": "^0.21.0", - "npm-check-updates": "^16.14.12", - "prettier": "^3.1.1", + "eslint-plugin-playwright": "^0.22.2", + "npm-check-updates": "^16.14.14", + "prettier": "^3.2.5", "typescript": "^5.3.3" }, "dependencies": { - "@faker-js/faker": "^8.3.1", - "@playwright/test": "1.38", - "@wordpress/env": "^9.0.0", - "dotenv": "^16.3.1", - "mysqlconnector": "^2.0.5", + "@faker-js/faker": "^8.4.0", + "@playwright/test": "1.41", + "@wordpress/env": "^9.2.0", + "dotenv": "^16.4.1", + "mysqlconnector": "^2.0.6", "php-serialize": "^4.1.1", "zod": "^3.22.4" } diff --git a/tests/pw/pages/abuseReportsPage.ts b/tests/pw/pages/abuseReportsPage.ts index 5d47627075..655f761127 100644 --- a/tests/pw/pages/abuseReportsPage.ts +++ b/tests/pw/pages/abuseReportsPage.ts @@ -5,6 +5,10 @@ import { helpers } from '@utils/helpers'; import { data } from '@utils/testData'; import { product } from '@utils/interfaces'; +// selectors +const abuseReportAdmin = selector.admin.dokan.abuseReports; +const abuseReportCustomer = selector.customer.cSingleProduct.reportAbuse; + export class AbuseReportsPage extends AdminPage { constructor(page: Page) { super(page); @@ -17,27 +21,27 @@ export class AbuseReportsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.abuseReports); // abuse reports text is visible - await this.toBeVisible(selector.admin.dokan.abuseReports.abuseReportsText); + await this.toBeVisible(abuseReportAdmin.abuseReportsText); // bulk action elements are visible - await this.multipleElementVisible(selector.admin.dokan.abuseReports.bulkActions); + await this.multipleElementVisible(abuseReportAdmin.bulkActions); // filter elements are visible - const { filterInput, ...filters } = selector.admin.dokan.abuseReports.filters; + const { filterInput, ...filters } = abuseReportAdmin.filters; await this.multipleElementVisible(filters); // abuse report table elements are visible - await this.multipleElementVisible(selector.admin.dokan.abuseReports.table); + await this.multipleElementVisible(abuseReportAdmin.table); } // abuse report details async abuseReportDetails() { await this.goIfNotThere(data.subUrls.backend.dokan.abuseReports); - await this.click(selector.admin.dokan.abuseReports.abuseReportFirstCell); + await this.click(abuseReportAdmin.abuseReportFirstCell); // abuse report modal elements are visible - await this.multipleElementVisible(selector.admin.dokan.abuseReports.abuseReportModal); - await this.click(selector.admin.dokan.abuseReports.abuseReportModal.closeModal); + await this.multipleElementVisible(abuseReportAdmin.abuseReportModal); + await this.click(abuseReportAdmin.abuseReportModal.closeModal); } // filter abuse reports @@ -46,18 +50,18 @@ export class AbuseReportsPage extends AdminPage { switch (action) { case 'by-reason': - await this.selectByLabelAndWaitForResponse(data.subUrls.api.dokan.abuseReports, selector.admin.dokan.abuseReports.filters.filterByAbuseReason, input); + await this.selectByLabelAndWaitForResponse(data.subUrls.api.dokan.abuseReports, abuseReportAdmin.filters.filterByAbuseReason, input); break; case 'by-product': - await this.click(selector.admin.dokan.abuseReports.filters.filterByProduct); - await this.typeAndWaitForResponse(data.subUrls.api.wc.wcProducts, selector.admin.dokan.abuseReports.filters.filterInput, input); + await this.click(abuseReportAdmin.filters.filterByProduct); + await this.typeAndWaitForResponse(data.subUrls.api.wc.wcProducts, abuseReportAdmin.filters.filterInput, input); await this.pressAndWaitForResponse(data.subUrls.api.dokan.abuseReports, data.key.enter); break; case 'by-vendor': - await this.click(selector.admin.dokan.abuseReports.filters.filterByVendors); - await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, selector.admin.dokan.abuseReports.filters.filterInput, input); + await this.click(abuseReportAdmin.filters.filterByVendors); + await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, abuseReportAdmin.filters.filterInput, input); await this.pressAndWaitForResponse(data.subUrls.api.dokan.abuseReports, data.key.enter); break; @@ -65,7 +69,7 @@ export class AbuseReportsPage extends AdminPage { break; } - const count = (await this.getElementText(selector.admin.dokan.abuseReports.numberOfRowsFound))?.split(' ')[0]; + const count = (await this.getElementText(abuseReportAdmin.numberOfRowsFound))?.split(' ')[0]; expect(Number(count)).toBeGreaterThan(0); } @@ -74,37 +78,36 @@ export class AbuseReportsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.abuseReports); // ensure row exists - await this.notToBeVisible(selector.admin.dokan.abuseReports.noRowsFound); + await this.notToBeVisible(abuseReportAdmin.noRowsFound); - await this.click(selector.admin.dokan.abuseReports.bulkActions.selectAll); - await this.selectByValue(selector.admin.dokan.abuseReports.bulkActions.selectAction, action); - await this.clickAndAcceptAndWaitForResponse(data.subUrls.api.dokan.abuseReports, selector.admin.dokan.abuseReports.bulkActions.applyAction); + await this.click(abuseReportAdmin.bulkActions.selectAll); + await this.selectByValue(abuseReportAdmin.bulkActions.selectAction, action); + await this.clickAndAcceptAndWaitForResponse(data.subUrls.api.dokan.abuseReports, abuseReportAdmin.bulkActions.applyAction); } // customer report product async reportProduct(productName: string, report: product['report']): Promise { - // await this.goToProductDetails(productName); - await this.goto(data.subUrls.frontend.productDetails(helpers.slugify(productName))); // for non logged user scenario, to load db changes - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.customer.cSingleProduct.reportAbuse.reportAbuse); + await this.goto(data.subUrls.frontend.productDetails(helpers.slugify(productName))); + await this.clickAndWaitForResponse(data.subUrls.ajax, abuseReportCustomer.reportAbuse); // non logged user - const isNonLoggedUser = await this.isVisible(selector.customer.cSingleProduct.reportAbuse.nonLoggedUser.userName); + const isNonLoggedUser = await this.isVisible(abuseReportCustomer.nonLoggedUser.userName); if (isNonLoggedUser) { - await this.clearAndType(selector.customer.cSingleProduct.reportAbuse.nonLoggedUser.userName, report.username); - await this.clearAndType(selector.customer.cSingleProduct.reportAbuse.nonLoggedUser.userPassword, report.password); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.customer.cSingleProduct.reportAbuse.nonLoggedUser.login); + await this.clearAndType(abuseReportCustomer.nonLoggedUser.userName, report.username); + await this.clearAndType(abuseReportCustomer.nonLoggedUser.userPassword, report.password); + await this.clickAndWaitForResponse(data.subUrls.ajax, abuseReportCustomer.nonLoggedUser.login); } - await this.click(selector.customer.cSingleProduct.reportAbuse.reportReasonByName(report.reportReason)); - await this.clearAndType(selector.customer.cSingleProduct.reportAbuse.reportDescription, report.reportReasonDescription); + await this.click(abuseReportCustomer.reportReasonByName(report.reportReason)); + await this.clearAndType(abuseReportCustomer.reportDescription, report.reportReasonDescription); // is guest - const isGuest = await this.isVisible(selector.customer.cSingleProduct.reportAbuse.guestName); + const isGuest = await this.isVisible(abuseReportCustomer.guestName); if (isGuest) { - await this.clearAndType(selector.customer.cSingleProduct.reportAbuse.guestName, report.guestName()); - await this.clearAndType(selector.customer.cSingleProduct.reportAbuse.guestEmail, report.guestEmail()); + await this.clearAndType(abuseReportCustomer.guestName, report.guestName()); + await this.clearAndType(abuseReportCustomer.guestEmail, report.guestEmail()); } - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.customer.cSingleProduct.reportAbuse.reportSubmit); - await this.toContainText(selector.customer.cSingleProduct.reportAbuse.reportSubmitSuccessMessage, report.reportSubmitSuccessMessage); + await this.clickAndWaitForResponse(data.subUrls.ajax, abuseReportCustomer.reportSubmit); + await this.toContainText(abuseReportCustomer.reportSubmitSuccessMessage, report.reportSubmitSuccessMessage); // close popup - await this.click(selector.customer.cSingleProduct.reportAbuse.confirmReportSubmit); + await this.click(abuseReportCustomer.confirmReportSubmit); } } diff --git a/tests/pw/pages/adminDashboardPage.ts b/tests/pw/pages/adminDashboardPage.ts index 24e4620490..02ca627ed9 100644 --- a/tests/pw/pages/adminDashboardPage.ts +++ b/tests/pw/pages/adminDashboardPage.ts @@ -5,6 +5,9 @@ import { helpers } from '@utils/helpers'; import { data } from '@utils/testData'; import { user, adminDashboard } from '@utils/interfaces'; +// selectors +const dashboardAdmin = selector.admin.dokan.dashboard; + export class AdminDashboardPage extends AdminPage { constructor(page: Page) { super(page); @@ -17,46 +20,46 @@ export class AdminDashboardPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.dokan); // dashboard text is visible - await this.toBeVisible(selector.admin.dokan.dashboard.dashboardText); + await this.toBeVisible(dashboardAdmin.dashboardText); // header elements are visible - await this.multipleElementVisible(selector.admin.dokan.dashboard.header); + await this.multipleElementVisible(dashboardAdmin.header); // at a glance elements are visible - await this.multipleElementVisible(selector.admin.dokan.dashboard.atAGlance); + await this.multipleElementVisible(dashboardAdmin.atAGlance); // overview elements are visible - await this.multipleElementVisible(selector.admin.dokan.dashboard.overview); + await this.multipleElementVisible(dashboardAdmin.overview); // dokan new update elements are visible - await this.multipleElementVisible(selector.admin.dokan.dashboard.dokanNewUpdates); + await this.multipleElementVisible(dashboardAdmin.dokanNewUpdates); // Subscribe box elements are visible - const { thankYouMessage, ...subscribeBox } = selector.admin.dokan.dashboard.subscribeBox; + const { thankYouMessage, ...subscribeBox } = dashboardAdmin.subscribeBox; await this.multipleElementVisible(subscribeBox); } // at a glance value async dokanAtAGlanceValueAccuracy(atAGlanceValues: adminDashboard['summary']) { await this.goIfNotThere(data.subUrls.backend.dokan.dokan); - const netSales = (await this.getElementText(selector.admin.dokan.dashboard.atAGlance.netSalesThisMonth)) as string; - const commissionEarned = (await this.getElementText(selector.admin.dokan.dashboard.atAGlance.commissionEarned)) as string; + const netSales = (await this.getElementText(dashboardAdmin.atAGlance.netSalesThisMonth)) as string; + const commissionEarned = (await this.getElementText(dashboardAdmin.atAGlance.commissionEarned)) as string; expect(helpers.roundToTwo(helpers.price(netSales))).toBe(helpers.roundToTwo(atAGlanceValues.sales.this_month)); expect(helpers.roundToTwo(helpers.price(commissionEarned))).toBe(helpers.roundToTwo(atAGlanceValues.earning.this_month)); - await this.toContainText(selector.admin.dokan.dashboard.atAGlance.signupThisMonth, atAGlanceValues.vendors.this_month + ' Vendor'); - await this.toContainText(selector.admin.dokan.dashboard.atAGlance.vendorAwaitingApproval, atAGlanceValues.vendors.inactive + ' Vendor'); - await this.toContainText(selector.admin.dokan.dashboard.atAGlance.productCreatedThisMonth, atAGlanceValues.products.this_month + ' Products'); - await this.toContainText(selector.admin.dokan.dashboard.atAGlance.withdrawAwaitingApproval, atAGlanceValues.withdraw.pending + ' Withdrawals'); + await this.toContainText(dashboardAdmin.atAGlance.signupThisMonth, atAGlanceValues.vendors.this_month + ' Vendor'); + await this.toContainText(dashboardAdmin.atAGlance.vendorAwaitingApproval, atAGlanceValues.vendors.inactive + ' Vendor'); + await this.toContainText(dashboardAdmin.atAGlance.productCreatedThisMonth, atAGlanceValues.products.this_month + ' Products'); + await this.toContainText(dashboardAdmin.atAGlance.withdrawAwaitingApproval, atAGlanceValues.withdraw.pending + ' Withdrawals'); } // add dokan news subscriber async addDokanNewsSubscriber(user: user['userDetails']) { await this.goIfNotThere(data.subUrls.backend.dokan.dokan); - await this.clearAndType(selector.admin.dokan.dashboard.subscribeBox.subscriberName, user.name()); - await this.clearAndType(selector.admin.dokan.dashboard.subscribeBox.subscriberEmail, user.email()); - await this.clickAndWaitForResponse(data.subUrls.backend.dokan.subscribe, selector.admin.dokan.dashboard.subscribeBox.subscribeButton, 302); - await this.toContainText(selector.admin.dokan.dashboard.subscribeBox.thankYouMessage, 'Thank you for subscribing!'); + await this.clearAndType(dashboardAdmin.subscribeBox.subscriberName, user.name()); + await this.clearAndType(dashboardAdmin.subscribeBox.subscriberEmail, user.email()); + await this.clickAndWaitForResponse(data.subUrls.backend.dokan.subscribe, dashboardAdmin.subscribeBox.subscribeButton, 302); + await this.toContainText(dashboardAdmin.subscribeBox.thankYouMessage, 'Thank you for subscribing!'); } } diff --git a/tests/pw/pages/adminPage.ts b/tests/pw/pages/adminPage.ts index 3d87eaa723..6856bcfb77 100644 --- a/tests/pw/pages/adminPage.ts +++ b/tests/pw/pages/adminPage.ts @@ -7,6 +7,11 @@ import { helpers } from '@utils/helpers'; const { DOKAN_PRO } = process.env; +// selectors +const setupWizardAdmin = selector.admin.dokan.setupWizard; +const reportsAdmin = selector.admin.dokan.reports; +const woocommerceSettings = selector.admin.wooCommerce.settings; + export class AdminPage extends BasePage { constructor(page: Page) { super(page); @@ -31,10 +36,10 @@ export class AdminPage extends BasePage { // Enable Password Field async enablePasswordInputField(woocommerce: woocommerce) { await this.goToWooCommerceSettings(); - await this.click(selector.admin.wooCommerce.settings.accounts); - await this.uncheck(selector.admin.wooCommerce.settings.automaticPasswordGeneration); - await this.click(selector.admin.wooCommerce.settings.accountSaveChanges); - await this.toContainText(selector.admin.wooCommerce.settings.updatedSuccessMessage, woocommerce.saveSuccessMessage); + await this.click(woocommerceSettings.accounts); + await this.uncheck(woocommerceSettings.automaticPasswordGeneration); + await this.click(woocommerceSettings.accountSaveChanges); + await this.toContainText(woocommerceSettings.updatedSuccessMessage, woocommerce.saveSuccessMessage); } // Admin Set Currency Options @@ -42,23 +47,23 @@ export class AdminPage extends BasePage { await this.goToWooCommerceSettings(); // Set Currency Options - await this.clearAndType(selector.admin.wooCommerce.settings.thousandSeparator, currency.currencyOptions.thousandSeparator); - await this.clearAndType(selector.admin.wooCommerce.settings.decimalSeparator, currency.currencyOptions.decimalSeparator); - await this.clearAndType(selector.admin.wooCommerce.settings.numberOfDecimals, currency.currencyOptions.numberOfDecimals); - await this.click(selector.admin.wooCommerce.settings.generalSaveChanges); - await this.toContainText(selector.admin.wooCommerce.settings.updatedSuccessMessage, currency.saveSuccessMessage); + await this.clearAndType(woocommerceSettings.thousandSeparator, currency.currencyOptions.thousandSeparator); + await this.clearAndType(woocommerceSettings.decimalSeparator, currency.currencyOptions.decimalSeparator); + await this.clearAndType(woocommerceSettings.numberOfDecimals, currency.currencyOptions.numberOfDecimals); + await this.click(woocommerceSettings.generalSaveChanges); + await this.toContainText(woocommerceSettings.updatedSuccessMessage, currency.saveSuccessMessage); } // Admin Set Currency async setCurrency(currency: string) { await this.goToWooCommerceSettings(); - const currentCurrency = await this.getElementText(selector.admin.wooCommerce.settings.currency); + const currentCurrency = await this.getElementText(woocommerceSettings.currency); if (currentCurrency !== currency) { - await this.click(selector.admin.wooCommerce.settings.currency); - await this.clearAndType(selector.admin.wooCommerce.settings.currency, currency); + await this.click(woocommerceSettings.currency); + await this.clearAndType(woocommerceSettings.currency, currency); await this.press(data.key.enter); - await this.click(selector.admin.wooCommerce.settings.generalSaveChanges); - await this.toContainText(selector.admin.wooCommerce.settings.updatedSuccessMessage, data.payment.currency.saveSuccessMessage); + await this.click(woocommerceSettings.generalSaveChanges); + await this.toContainText(woocommerceSettings.updatedSuccessMessage, data.payment.currency.saveSuccessMessage); } } @@ -66,19 +71,19 @@ export class AdminPage extends BasePage { async getOrderDetails(orderNumber: string) { await this.goIfNotThere(data.subUrls.backend.dokan.allLogs); - await this.clearAndType(selector.admin.dokan.reports.allLogs.search, orderNumber); + await this.clearAndType(reportsAdmin.allLogs.search, orderNumber); const aOrderDetails = { - orderNumber: ((await this.getElementText(selector.admin.dokan.reports.allLogs.orderDetails.orderId)) as string).split('#')[1], - store: await this.getElementText(selector.admin.dokan.reports.allLogs.orderDetails.store), - orderTotal: helpers.price((await this.getElementText(selector.admin.dokan.reports.allLogs.orderDetails.orderTotal)) as string), - vendorEarning: helpers.price((await this.getElementText(selector.admin.dokan.reports.allLogs.orderDetails.vendorEarning)) as string), - commission: helpers.price((await this.getElementText(selector.admin.dokan.reports.allLogs.orderDetails.commission)) as string), - gatewayFee: helpers.price((await this.getElementText(selector.admin.dokan.reports.allLogs.orderDetails.gatewayFee)) as string), - shippingCost: helpers.price((await this.getElementText(selector.admin.dokan.reports.allLogs.orderDetails.shippingCost)) as string), - tax: helpers.price((await this.getElementText(selector.admin.dokan.reports.allLogs.orderDetails.tax)) as string), - orderStatus: await this.getElementText(selector.admin.dokan.reports.allLogs.orderDetails.orderStatus), - orderDate: await this.getElementText(selector.admin.dokan.reports.allLogs.orderDetails.orderDate), + orderNumber: ((await this.getElementText(reportsAdmin.allLogs.orderDetails.orderId)) as string).split('#')[1], + store: await this.getElementText(reportsAdmin.allLogs.orderDetails.store), + orderTotal: helpers.price((await this.getElementText(reportsAdmin.allLogs.orderDetails.orderTotal)) as string), + vendorEarning: helpers.price((await this.getElementText(reportsAdmin.allLogs.orderDetails.vendorEarning)) as string), + commission: helpers.price((await this.getElementText(reportsAdmin.allLogs.orderDetails.commission)) as string), + gatewayFee: helpers.price((await this.getElementText(reportsAdmin.allLogs.orderDetails.gatewayFee)) as string), + shippingCost: helpers.price((await this.getElementText(reportsAdmin.allLogs.orderDetails.shippingCost)) as string), + tax: helpers.price((await this.getElementText(reportsAdmin.allLogs.orderDetails.tax)) as string), + orderStatus: await this.getElementText(reportsAdmin.allLogs.orderDetails.orderStatus), + orderDate: await this.getElementText(reportsAdmin.allLogs.orderDetails.orderDate), }; return aOrderDetails; @@ -95,78 +100,48 @@ export class AdminPage extends BasePage { // Admin Set Dokan Setup Wizard async setDokanSetupWizard(dokanSetupWizard: dokanSetupWizard) { - // await this.hover(selector.admin.aDashboard.dokan) - // await this.click(selector.admin.dokan.toolsMenu) - // await this.click(selector.admin.dokan.tools.openSetupWizard) - await this.goIfNotThere(data.subUrls.backend.dokan.setupWizard); - await this.click(selector.admin.dokan.dokanSetupWizard.letsGo); + await this.click(setupWizardAdmin.letsGo); // Store - await this.clearAndType(selector.admin.dokan.dokanSetupWizard.vendorStoreURL, dokanSetupWizard.vendorStoreURL); - await this.selectByValue(selector.admin.dokan.dokanSetupWizard.shippingFeeRecipient, dokanSetupWizard.shippingFeeRecipient); - await this.selectByValue(selector.admin.dokan.dokanSetupWizard.taxFeeRecipient, dokanSetupWizard.taxFeeRecipient); - await this.selectByValue(selector.admin.dokan.dokanSetupWizard.mapApiSource, dokanSetupWizard.mapApiSource); - await this.clearAndType(selector.admin.dokan.dokanSetupWizard.googleMapApiKey, dokanSetupWizard.googleMapApiKey); - await this.enableSwitcherSetupWizard(selector.admin.dokan.dokanSetupWizard.shareEssentialsOff); - DOKAN_PRO && (await this.selectByValue(selector.admin.dokan.dokanSetupWizard.sellingProductTypes, dokanSetupWizard.sellingProductTypes)); - await this.click(selector.admin.dokan.dokanSetupWizard.continue); - // await this.click(selector.admin.dokan.dokanSetupWizard.skipThisStep) + await this.clearAndType(setupWizardAdmin.vendorStoreURL, dokanSetupWizard.vendorStoreURL); + await this.selectByValue(setupWizardAdmin.shippingFeeRecipient, dokanSetupWizard.shippingFeeRecipient); + await this.selectByValue(setupWizardAdmin.taxFeeRecipient, dokanSetupWizard.taxFeeRecipient); + await this.selectByValue(setupWizardAdmin.mapApiSource, dokanSetupWizard.mapApiSource); + await this.clearAndType(setupWizardAdmin.googleMapApiKey, dokanSetupWizard.googleMapApiKey); + await this.enableSwitcherSetupWizard(setupWizardAdmin.shareEssentialsOff); + DOKAN_PRO && (await this.selectByValue(setupWizardAdmin.sellingProductTypes, dokanSetupWizard.sellingProductTypes)); + await this.click(setupWizardAdmin.continue); + // await this.click(setupWizardAdmin.skipThisStep) // Selling - await this.enableSwitcherSetupWizard(selector.admin.dokan.dokanSetupWizard.newVendorEnableSelling); - await this.selectByValue(selector.admin.dokan.dokanSetupWizard.commissionType, dokanSetupWizard.commissionType); - await this.clearAndType(selector.admin.dokan.dokanSetupWizard.adminCommission, dokanSetupWizard.adminCommission); - await this.enableSwitcherSetupWizard(selector.admin.dokan.dokanSetupWizard.orderStatusChange); - await this.click(selector.admin.dokan.dokanSetupWizard.continue); - // await this.click(selector.admin.dokan.dokanSetupWizard.skipThisStep) + await this.enableSwitcherSetupWizard(setupWizardAdmin.newVendorEnableSelling); + await this.selectByValue(setupWizardAdmin.commissionType, dokanSetupWizard.commissionType); + await this.clearAndType(setupWizardAdmin.adminCommission, dokanSetupWizard.adminCommission); + await this.enableSwitcherSetupWizard(setupWizardAdmin.orderStatusChange); + await this.click(setupWizardAdmin.continue); + // await this.click(setupWizardAdmin.skipThisStep) // Withdraw - await this.enableSwitcherSetupWizard(selector.admin.dokan.dokanSetupWizard.payPal); - await this.enableSwitcherSetupWizard(selector.admin.dokan.dokanSetupWizard.bankTransfer); - // await this.enableSwitcherSetupWizard(selector.admin.dokan.dokanSetupWizard.wirecard) - // await this.enableSwitcherSetupWizard(selector.admin.dokan.dokanSetupWizard.stripe) - DOKAN_PRO && (await this.enableSwitcherSetupWizard(selector.admin.dokan.dokanSetupWizard.custom)); - DOKAN_PRO && (await this.enableSwitcherSetupWizard(selector.admin.dokan.dokanSetupWizard.skrill)); - await this.clearAndType(selector.admin.dokan.dokanSetupWizard.minimumWithdrawLimit, dokanSetupWizard.minimumWithdrawLimit); - await this.enableSwitcherSetupWizard(selector.admin.dokan.dokanSetupWizard.orderStatusForWithdrawCompleted); - await this.enableSwitcherSetupWizard(selector.admin.dokan.dokanSetupWizard.orderStatusForWithdrawProcessing); - await this.click(selector.admin.dokan.dokanSetupWizard.continue); + await this.enableSwitcherSetupWizard(setupWizardAdmin.payPal); + await this.enableSwitcherSetupWizard(setupWizardAdmin.bankTransfer); + // await this.enableSwitcherSetupWizard(setupWizardAdmin.wirecard) + // await this.enableSwitcherSetupWizard(setupWizardAdmin.stripe) + DOKAN_PRO && (await this.enableSwitcherSetupWizard(setupWizardAdmin.custom)); + DOKAN_PRO && (await this.enableSwitcherSetupWizard(setupWizardAdmin.skrill)); + await this.clearAndType(setupWizardAdmin.minimumWithdrawLimit, dokanSetupWizard.minimumWithdrawLimit); + await this.enableSwitcherSetupWizard(setupWizardAdmin.orderStatusForWithdrawCompleted); + await this.enableSwitcherSetupWizard(setupWizardAdmin.orderStatusForWithdrawProcessing); + await this.click(setupWizardAdmin.continue); // Recommended - await this.disableSwitcherSetupWizard(selector.admin.dokan.dokanSetupWizard.wooCommerceConversionTracking); - await this.disableSwitcherSetupWizard(selector.admin.dokan.dokanSetupWizard.weMail); - await this.disableSwitcherSetupWizard(selector.admin.dokan.dokanSetupWizard.texty); - await this.click(selector.admin.dokan.dokanSetupWizard.continueRecommended); + await this.disableSwitcherSetupWizard(setupWizardAdmin.wooCommerceConversionTracking); + await this.disableSwitcherSetupWizard(setupWizardAdmin.weMail); + await this.disableSwitcherSetupWizard(setupWizardAdmin.texty); + await this.click(setupWizardAdmin.continueRecommended); // Ready! - await this.click(selector.admin.dokan.dokanSetupWizard.visitDokanDashboard); + await this.click(setupWizardAdmin.visitDokanDashboard); await this.toBeVisible(selector.admin.dokan.dashboard.dashboardText); } - - // dokan notice & promotion - - // dokan notice - async dokanPromotion() { - await this.goto(data.subUrls.backend.dokan.dokan); - // dokan promotion elements are visible - const isPromotionVisible = await this.isVisible(selector.admin.dokan.promotion.promotion); - if (isPromotionVisible) { - await this.multipleElementVisible(selector.admin.dokan.promotion); - } else { - console.log('No promotion is ongoing'); - } - } - - // dokan notice - async dokanNotice() { - await this.goto(data.subUrls.backend.dokan.dokan); - - // dokan notice elements are visible - const isPromotionVisible = await this.isVisible(selector.admin.dokan.promotion.promotion); - isPromotionVisible ? await this.notToHaveCount(selector.admin.dokan.notice.noticeDiv1, 0) : await this.notToHaveCount(selector.admin.dokan.notice.noticeDiv, 0); - await this.notToHaveCount(selector.admin.dokan.notice.slider, 0); - await this.notToHaveCount(selector.admin.dokan.notice.sliderPrev, 0); - await this.notToHaveCount(selector.admin.dokan.notice.sliderNext, 0); - } } diff --git a/tests/pw/pages/announcementsPage.ts b/tests/pw/pages/announcementsPage.ts index 2e75fe7d44..838851c6cc 100644 --- a/tests/pw/pages/announcementsPage.ts +++ b/tests/pw/pages/announcementsPage.ts @@ -5,6 +5,10 @@ import { data } from '@utils/testData'; import { announcement } from '@utils/interfaces'; import { helpers } from '@utils/helpers'; +// selectors +const announcementsAdmin = selector.admin.dokan.announcements; +const announcementsVendor = selector.vendor.vAnnouncement; + export class AnnouncementsPage extends AdminPage { constructor(page: Page) { super(page); @@ -17,84 +21,85 @@ export class AnnouncementsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.announcements); // announcement text is visible - await this.toBeVisible(selector.admin.dokan.announcements.announcementText); + await this.toBeVisible(announcementsAdmin.announcementText); // and announcement is visible - await this.toBeVisible(selector.admin.dokan.announcements.addNewAnnouncement); + await this.toBeVisible(announcementsAdmin.addNewAnnouncement); // nav tabs are visible - await this.multipleElementVisible(selector.admin.dokan.announcements.navTabs); + await this.multipleElementVisible(announcementsAdmin.navTabs); // bulk action elements are visible - await this.multipleElementVisible(selector.admin.dokan.announcements.bulkActions); + await this.multipleElementVisible(announcementsAdmin.bulkActions); // announcement table elements are visible - await this.multipleElementVisible(selector.admin.dokan.announcements.table); + await this.multipleElementVisible(announcementsAdmin.table); // add announcement fields are visible - await this.click(selector.admin.dokan.announcements.addNewAnnouncement); - const { contentHtmlBody, schedule, ...addAnnouncement } = selector.admin.dokan.announcements.addAnnouncement; + await this.click(announcementsAdmin.addNewAnnouncement); + const { contentHtmlBody, schedule, ...addAnnouncement } = announcementsAdmin.addAnnouncement; await this.multipleElementVisible(addAnnouncement); await this.goBack(); } // update announcement fields async updateAnnouncementFields(announcement: announcement) { - await this.clearAndType(selector.admin.dokan.announcements.addAnnouncement.title, announcement.title); - await this.typeFrameSelector(selector.admin.dokan.announcements.addAnnouncement.contentIframe, selector.admin.dokan.announcements.addAnnouncement.contentHtmlBody, announcement.content); - await this.selectByValue(selector.admin.dokan.announcements.addAnnouncement.sendAnnouncementTo, announcement.receiver); + await this.clearAndType(announcementsAdmin.addAnnouncement.title, announcement.title); + await this.typeFrameSelector(announcementsAdmin.addAnnouncement.contentIframe, announcementsAdmin.addAnnouncement.contentHtmlBody, announcement.content); + await this.selectByValue(announcementsAdmin.addAnnouncement.sendAnnouncementTo, announcement.receiver); if (announcement.publishType === 'immediately') { - await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.announcements, selector.admin.dokan.announcements.addAnnouncement.publish); - await this.toBeVisible(selector.admin.dokan.announcements.announcementStatusPublished(announcement.title)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.announcements, announcementsAdmin.addAnnouncement.publish); + await this.toBeVisible(announcementsAdmin.announcementStatusPublished(announcement.title)); } else { - await this.click(selector.admin.dokan.announcements.addAnnouncement.schedule.addSchedule); - await this.selectByNumber(selector.admin.dokan.announcements.addAnnouncement.schedule.month, announcement.scheduleDate.getMonth()); - await this.clearAndType(selector.admin.dokan.announcements.addAnnouncement.schedule.day, String(announcement.scheduleDate.getDate())); - await this.clearAndType(selector.admin.dokan.announcements.addAnnouncement.schedule.year, String(announcement.scheduleDate.getFullYear())); - await this.clearAndType(selector.admin.dokan.announcements.addAnnouncement.schedule.hour, String(announcement.scheduleDate.getHours())); - await this.clearAndType(selector.admin.dokan.announcements.addAnnouncement.schedule.minute, String(announcement.scheduleDate.getMinutes())); - await this.click(selector.admin.dokan.announcements.addAnnouncement.schedule.ok); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.announcements, selector.admin.dokan.announcements.addAnnouncement.publish); - await this.toBeVisible(selector.admin.dokan.announcements.announcementStatusScheduled(announcement.title)); + await this.click(announcementsAdmin.addAnnouncement.schedule.addSchedule); + await this.selectByNumber(announcementsAdmin.addAnnouncement.schedule.month, announcement.scheduleDate.getMonth()); + await this.clearAndType(announcementsAdmin.addAnnouncement.schedule.day, String(announcement.scheduleDate.getDate())); + await this.clearAndType(announcementsAdmin.addAnnouncement.schedule.year, String(announcement.scheduleDate.getFullYear())); + await this.clearAndType(announcementsAdmin.addAnnouncement.schedule.hour, String(announcement.scheduleDate.getHours())); + await this.clearAndType(announcementsAdmin.addAnnouncement.schedule.minute, String(announcement.scheduleDate.getMinutes())); + await this.click(announcementsAdmin.addAnnouncement.schedule.ok); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.announcements, announcementsAdmin.addAnnouncement.publish); + await this.toBeVisible(announcementsAdmin.announcementStatusScheduled(announcement.title)); } } // add announcement async addAnnouncement(announcement: announcement) { await this.goIfNotThere(data.subUrls.backend.dokan.announcements); - await this.click(selector.admin.dokan.announcements.addNewAnnouncement); + await this.click(announcementsAdmin.addNewAnnouncement); await this.updateAnnouncementFields(announcement); } // edit announcement async editAnnouncement(announcement: announcement) { await this.goto(data.subUrls.backend.dokan.announcements); - await this.hover(selector.admin.dokan.announcements.announcementCell(announcement.title)); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.announcements, selector.admin.dokan.announcements.announcementEdit(announcement.title)); + await this.hover(announcementsAdmin.announcementCell(announcement.title)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.announcements, announcementsAdmin.announcementEdit(announcement.title)); await this.updateAnnouncementFields(announcement); } // update announcement async updateAnnouncement(announcementTitle: string, action: string) { - await this.goto(data.subUrls.backend.dokan.announcements); - // await this.goIfNotThere(data.subUrls.backend.dokan.announcements); + // await this.goto(data.subUrls.backend.dokan.announcements); + await this.goIfNotThere(data.subUrls.backend.dokan.announcements); switch (action) { case 'trash': - await this.hover(selector.admin.dokan.announcements.announcementCellPublished(announcementTitle)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.announcements, selector.admin.dokan.announcements.announcementDelete(announcementTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.announcements, announcementsAdmin.navTabs.published); + await this.hover(announcementsAdmin.announcementCellPublished(announcementTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.announcements, announcementsAdmin.announcementDelete(announcementTitle)); break; case 'restore': - await this.clickAndWaitForResponse(data.subUrls.api.dokan.announcements, selector.admin.dokan.announcements.navTabs.trash); - await this.hover(selector.admin.dokan.announcements.announcementCellPublished(announcementTitle)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.announcements, selector.admin.dokan.announcements.announcementRestore(announcementTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.announcements, announcementsAdmin.navTabs.trash); + await this.hover(announcementsAdmin.announcementCellPublished(announcementTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.announcements, announcementsAdmin.announcementRestore(announcementTitle)); break; case 'permanently-delete': - await this.clickAndWaitForResponse(data.subUrls.api.dokan.announcements, selector.admin.dokan.announcements.navTabs.trash); - await this.hover(selector.admin.dokan.announcements.announcementCellPublished(announcementTitle)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.announcements, selector.admin.dokan.announcements.announcementPermanentlyDelete(announcementTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.announcements, announcementsAdmin.navTabs.trash); + await this.hover(announcementsAdmin.announcementCellPublished(announcementTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.announcements, announcementsAdmin.announcementPermanentlyDelete(announcementTitle)); break; default: @@ -108,11 +113,11 @@ export class AnnouncementsPage extends AdminPage { // await this.goIfNotThere(data.subUrls.backend.dokan.announcements); // ensure row exists - await this.notToBeVisible(selector.admin.dokan.announcements.noRowsFound); + await this.notToBeVisible(announcementsAdmin.noRowsFound); - await this.click(selector.admin.dokan.announcements.bulkActions.selectAll); - await this.selectByValue(selector.admin.dokan.announcements.bulkActions.selectAction, action); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.announcements, selector.admin.dokan.announcements.bulkActions.applyAction); + await this.click(announcementsAdmin.bulkActions.selectAll); + await this.selectByValue(announcementsAdmin.bulkActions.selectAction, action); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.announcements, announcementsAdmin.bulkActions.applyAction); } // vendor @@ -120,27 +125,27 @@ export class AnnouncementsPage extends AdminPage { // vendor announcements render properly async vendorAnnouncementsRenderProperly() { await this.goIfNotThere(data.subUrls.frontend.vDashboard.announcements); - await this.notToHaveCount(selector.vendor.vAnnouncement.announcementDiv, 0); - await this.notToHaveCount(selector.vendor.vAnnouncement.announcementDate, 0); - await this.notToHaveCount(selector.vendor.vAnnouncement.announcementHeading, 0); - await this.notToHaveCount(selector.vendor.vAnnouncement.announcementContent, 0); - await this.notToHaveCount(selector.vendor.vAnnouncement.removeAnnouncement, 0); + await this.notToHaveCount(announcementsVendor.announcementDiv, 0); + await this.notToHaveCount(announcementsVendor.announcementDate, 0); + await this.notToHaveCount(announcementsVendor.announcementHeading, 0); + await this.notToHaveCount(announcementsVendor.announcementContent, 0); + await this.notToHaveCount(announcementsVendor.removeAnnouncement, 0); } // vendor view announcement async vendorViewAnnouncement(announcement: { title: string; content: string }) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.announcements); - await this.clickAndWaitForLoadState(selector.vendor.vAnnouncement.announcementLink(announcement.title)); - await this.toContainText(selector.vendor.vAnnouncement.announcement.title, announcement.title); - await this.toContainText(selector.vendor.vAnnouncement.announcement.content, helpers.stringBetweenTags(announcement.content)); - await this.toBeVisible(selector.vendor.vAnnouncement.announcement.date); - await this.toBeVisible(selector.vendor.vAnnouncement.announcement.backToAllNotice); + await this.clickAndWaitForLoadState(announcementsVendor.announcementLink(announcement.title)); + await this.toContainText(announcementsVendor.announcement.title, announcement.title); + await this.toContainText(announcementsVendor.announcement.content, helpers.stringBetweenTags(announcement.content)); + await this.toBeVisible(announcementsVendor.announcement.date); + await this.toBeVisible(announcementsVendor.announcement.backToAllNotice); } // vendor delete announcement async vendorDeleteAnnouncement(title: string) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.announcements); - await this.click(selector.vendor.vAnnouncement.deleteAnnouncement(title)); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vAnnouncement.confirmDeleteAnnouncement); + await this.click(announcementsVendor.deleteAnnouncement(title)); + await this.clickAndWaitForResponse(data.subUrls.ajax, announcementsVendor.confirmDeleteAnnouncement); } } diff --git a/tests/pw/pages/basePage.ts b/tests/pw/pages/basePage.ts index 4e39261e21..e269523018 100644 --- a/tests/pw/pages/basePage.ts +++ b/tests/pw/pages/basePage.ts @@ -6,6 +6,7 @@ import { expect, Page, BrowserContext, Cookie, Request, Response, Locator, Frame, FrameLocator, JSHandle, ElementHandle } from '@playwright/test'; import { data } from '@utils/testData'; +import { selector } from '@pages/selectors'; // This Page Contains All Necessary Playwright Automation Methods @@ -239,6 +240,20 @@ export class BasePage { return response; } + // click & wait for multiple responses + async clickAndWaitForMultipleResponses(subUrls: string[][], selector: string, code = 200): Promise { + // todo: fix this; also update for same and different subUrls + const promises = []; + subUrls.forEach(subUrl => { + console.log('subUls: ', subUrl[0], ' code: ', subUrl[1]); + const promise = this.page.waitForResponse(resp => resp.url().includes(subUrl[0] as string) && resp.status() === (subUrl[1] ?? code)); + promises.push(promise); + }); + promises.push(this.page.locator(selector).click()); + const response = await Promise.all([...promises, this.page.locator(selector).click()]); + return response; + } + // click & accept async clickAndAccept(selector: string): Promise { await Promise.all([this.acceptAlert(), this.page.locator(selector).click()]); @@ -269,11 +284,7 @@ export class BasePage { // type & wait for response async typeAndWaitForResponse(subUrl: string, selector: string, text: string, code = 200): Promise { - const [response] = await Promise.all([ - this.page.waitForResponse(resp => resp.url().includes(subUrl) && resp.status() === code), - // await this.page.locator(selector).pressSequentially(text), - this.clearAndFill(selector, text), - ]); + const [response] = await Promise.all([this.page.waitForResponse(resp => resp.url().includes(subUrl) && resp.status() === code), this.clearAndFill(selector, text)]); return response; } @@ -600,17 +611,19 @@ export class BasePage { } // Or - async clearInputField1(selector: string): Promise { + + async clearInputFieldByMultipleClick(selector: string): Promise { const element = this.getElement(selector); await element.click({ clickCount: 3 }); await this.press('Backspace'); } // Or - // async clearInputField2(selector): Promise { - // let element = await this.getElement(selector) - // await this.page.evaluate(element => element.value = '', element) - // } + + async clearInputFieldByEvaluate(selector: string): Promise { + const element = this.getElement(selector); + await this.page.evaluate(element => (element.value = ''), element); // todo: fix + } // clear input field and type async clearAndType(selector: string, text: string): Promise { @@ -755,7 +768,7 @@ export class BasePage { async uploadFile(selector: string, files: string | string[]): Promise { // await this.page.setInputFiles(selector, files, { noWaitAfter: true }); await this.page.setInputFiles(selector, files); - await this.wait(1.5); + await this.wait(1.5); //todo: resolve this } // upload file @@ -845,7 +858,7 @@ export class BasePage { async typeFrameSelector(frame: string, frameSelector: string, text: string): Promise { const locator = this.page.frameLocator(frame).locator(frameSelector); await locator.fill(text); - await locator.pressSequentially(text); + // await locator.pressSequentially(text); } /** @@ -873,7 +886,8 @@ export class BasePage { // check locator async checkLocator(selector: string): Promise { const locator = this.page.locator(selector); - await locator.check({ force: true }); // forced is used to avoid "locator.check: Clicking the checkbox did not change its state" error + await locator.check(); + // await locator.check({ force: true }); // forced is used to avoid "locator.check: Clicking the checkbox did not change its state" error } // click locator @@ -1042,7 +1056,6 @@ export class BasePage { // get last matching locator lastLocator(selector: string): Locator { - // todo: update all selector parameter to both selector or locator const locator = this.page.locator(selector); return locator.last(); } @@ -1306,13 +1319,14 @@ export class BasePage { // assert any element to be visible async toBeVisibleAnyOfThem(selectors: string[]) { - // todo: extend nd improve this method + // todo: extend and improve this method const res = []; for (const selector of selectors) { res.push(await this.isVisible(selector)); } const result = res.includes(true); expect(result).toBeTruthy(); + // todo: return which elements are true for further operation } // assert element to be visible @@ -1326,7 +1340,7 @@ export class BasePage { } // assert element to contain text - async toContainText(selector: string, text: string) { + async toContainText(selector: string, text: string | RegExp) { await expect(this.page.locator(selector)).toContainText(text); } @@ -1509,6 +1523,19 @@ export class BasePage { } } + async uploadMedia(file: string) { + // await this.wait(0.5); + const uploadedMediaIsVisible = await this.isVisible(selector.wpMedia.uploadedMediaFirst); + if (uploadedMediaIsVisible) { + await this.click(selector.wpMedia.uploadedMediaFirst); + } else { + await this.uploadFile(selector.wpMedia.selectFilesInput, file); + const isSelectDisabled = await this.isDisabled(selector.wpMedia.select); + isSelectDisabled && (await this.click(selector.wpMedia.selectUploadedMedia)); + await this.click(selector.wpMedia.select); + } + } + // upload file async wpUploadFile(filePath: string | string[]) { // wp image upload diff --git a/tests/pw/pages/couponsPage.ts b/tests/pw/pages/couponsPage.ts index d3455e7970..b3a8dc47d1 100644 --- a/tests/pw/pages/couponsPage.ts +++ b/tests/pw/pages/couponsPage.ts @@ -6,6 +6,9 @@ import { helpers } from '@utils/helpers'; import { data } from '@utils/testData'; import { coupon } from '@utils/interfaces'; +const couponsAdmin = selector.admin.marketing; +const couponsVendor = selector.vendor.vCoupon; + export class CouponsPage extends AdminPage { constructor(page: Page) { super(page); @@ -15,22 +18,20 @@ export class CouponsPage extends AdminPage { // add marketplace coupon async addMarketplaceCoupon(coupon: coupon) { - // await this.goIfNotThere(data.subUrls.backend.wc.coupons); await this.goIfNotThere(data.subUrls.backend.wc.addCoupon); - // await this.clickAndWaitForResponse(data.subUrls.backend.wc.addCoupon, selector.admin.marketing.addCoupon); // blocked by woocommer setup div - await this.clearAndType(selector.admin.marketing.addNewCoupon.couponCode, coupon.title); - await this.clearAndType(selector.admin.marketing.addNewCoupon.couponDescription, coupon.description); - await this.selectByValue(selector.admin.marketing.addNewCoupon.discountType, coupon.discountType); - await this.clearAndType(selector.admin.marketing.addNewCoupon.couponAmount, coupon.amount()); + await this.clearAndType(couponsAdmin.addNewCoupon.couponCode, coupon.title); + await this.clearAndType(couponsAdmin.addNewCoupon.couponDescription, coupon.description); + await this.selectByValue(couponsAdmin.addNewCoupon.discountType, coupon.discountType); + await this.clearAndType(couponsAdmin.addNewCoupon.couponAmount, coupon.amount()); - await this.click(selector.admin.marketing.addNewCoupon.vendorLimits); - await this.check(selector.admin.marketing.addNewCoupon.enableForAllVendors); - await this.check(selector.admin.marketing.addNewCoupon.showOnStores); - await this.check(selector.admin.marketing.addNewCoupon.notifyVendors); + await this.click(couponsAdmin.addNewCoupon.vendorLimits); + await this.check(couponsAdmin.addNewCoupon.enableForAllVendors); + await this.check(couponsAdmin.addNewCoupon.showOnStores); + await this.check(couponsAdmin.addNewCoupon.notifyVendors); await this.scrollToTop(); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, selector.admin.marketing.addNewCoupon.publish); - await this.toContainText(selector.admin.marketing.addNewCoupon.publishSuccessMessage, 'Coupon updated.'); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, couponsAdmin.addNewCoupon.publish); + await this.toContainText(couponsAdmin.addNewCoupon.publishSuccessMessage, 'Coupon updated.'); } // vendor coupons render properly @@ -38,59 +39,59 @@ export class CouponsPage extends AdminPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.coupons); // coupon text is visible - await this.toBeVisible(selector.vendor.vCoupon.couponText); + await this.toBeVisible(couponsVendor.couponText); // add new coupon is visible - await this.toBeVisible(selector.vendor.vCoupon.addNewCoupon); + await this.toBeVisible(couponsVendor.addNewCoupon); // coupon menus are visible - await this.multipleElementVisible(selector.vendor.vCoupon.menus); + await this.multipleElementVisible(couponsVendor.menus); // table elements are visible - await this.multipleElementVisible(selector.vendor.vCoupon.table); + await this.multipleElementVisible(couponsVendor.table); } // vendor view marketplace coupon async viewMarketPlaceCoupon(marketplaceCoupon: string) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.coupons); - await this.click(selector.vendor.vCoupon.menus.marketplaceCoupons); - await this.toBeVisible(selector.vendor.vCoupon.marketPlaceCoupon.marketPlaceCoupon); - marketplaceCoupon && (await this.toBeVisible(selector.vendor.vCoupon.marketPlaceCoupon.couponCell(marketplaceCoupon))); + await this.click(couponsVendor.menus.marketplaceCoupons); + await this.toBeVisible(couponsVendor.marketPlaceCoupon.marketPlaceCoupon); + marketplaceCoupon && (await this.toBeVisible(couponsVendor.marketPlaceCoupon.couponCell(marketplaceCoupon))); } // update coupon fields async updateCouponFields(coupon: coupon) { - await this.clearAndType(selector.vendor.vCoupon.couponTitle, coupon.title); - await this.clearAndType(selector.vendor.vCoupon.description, coupon.description); - await this.selectByValue(selector.vendor.vCoupon.discountType, coupon.discountType); - await this.clearAndType(selector.vendor.vCoupon.amount, coupon.amount()); - await this.click(selector.vendor.vCoupon.selectAll); - await this.check(selector.vendor.vCoupon.applyForNewProducts); - await this.check(selector.vendor.vCoupon.showOnStore); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.coupons, selector.vendor.vCoupon.createCoupon, 302); + await this.clearAndType(couponsVendor.couponTitle, coupon.title); + await this.clearAndType(couponsVendor.description, coupon.description); + await this.selectByValue(couponsVendor.discountType, coupon.discountType); + await this.clearAndType(couponsVendor.amount, coupon.amount()); + await this.click(couponsVendor.selectAll); + await this.check(couponsVendor.applyForNewProducts); + await this.check(couponsVendor.showOnStore); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.coupons, couponsVendor.createCoupon, 302); } // vendor add coupon async addCoupon(coupon: coupon) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.coupons); - await this.click(selector.vendor.vCoupon.addNewCoupon); + await this.click(couponsVendor.addNewCoupon); await this.updateCouponFields(coupon); } // vendor edit coupon async editCoupon(coupon: coupon) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.coupons); - await this.clickAndWaitForLoadState(selector.vendor.vCoupon.couponLink(coupon.title)); + await this.clickAndWaitForLoadState(couponsVendor.couponLink(coupon.title)); await this.updateCouponFields(coupon); - await this.toContainText(selector.vendor.vCoupon.dokanMessage, selector.vendor.vCoupon.couponUpdateSuccessMessage); + await this.toContainText(couponsVendor.dokanMessage, couponsVendor.couponUpdateSuccessMessage); } // vendor edit coupon async deleteCoupon(couponCode: string) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.coupons); - await this.hover(selector.vendor.vCoupon.couponCell(couponCode)); - await this.clickAndAccept(selector.vendor.vCoupon.couponDelete(couponCode)); - await this.toContainText(selector.vendor.vCoupon.dokanMessage, 'Coupon has been deleted successfully!'); + await this.hover(couponsVendor.couponCell(couponCode)); + await this.clickAndAccept(couponsVendor.couponDelete(couponCode)); + await this.toContainText(couponsVendor.dokanMessage, 'Coupon has been deleted successfully!'); } // customer diff --git a/tests/pw/pages/licensePage.ts b/tests/pw/pages/licensePage.ts index 0b1c21eada..ef3964d8b9 100644 --- a/tests/pw/pages/licensePage.ts +++ b/tests/pw/pages/licensePage.ts @@ -3,6 +3,9 @@ import { AdminPage } from '@pages/adminPage'; import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; +// selectors +const licenseAdmin = selector.admin.dokan.license; + export class LicensePage extends AdminPage { constructor(page: Page) { super(page); @@ -15,25 +18,25 @@ export class LicensePage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.license); // license settings text is visible - await this.toBeVisible(selector.admin.dokan.license.licenseText); + await this.toBeVisible(licenseAdmin.licenseText); // license section elements are visible - await this.multipleElementVisible(selector.admin.dokan.license.activateSection); + await this.multipleElementVisible(licenseAdmin.activateSection); } // activate license async activateLicense(key: string, type = 'correct') { await this.goIfNotThere(data.subUrls.backend.dokan.license); - const alreadyActivated = await this.isVisible(selector.admin.dokan.license.deactivateLicense); + const alreadyActivated = await this.isVisible(licenseAdmin.deactivateLicense); if (!alreadyActivated) { - await this.clearAndType(selector.admin.dokan.license.activateSection.licenseKeyInput, key); - await this.clickAndWaitForResponse(data.subUrls.backend.dokan.license, selector.admin.dokan.license.activateSection.activateLicense); + await this.clearAndType(licenseAdmin.activateSection.licenseKeyInput, key); + await this.clickAndWaitForResponse(data.subUrls.backend.dokan.license, licenseAdmin.activateSection.activateLicense); if (type === 'correct') { - await this.toContainText(selector.admin.dokan.license.successNotice, 'License activated successfully.'); - await this.toBeVisible(selector.admin.dokan.license.activateLicenseInfo); - await this.toBeVisible(selector.admin.dokan.license.refreshLicense); + await this.toContainText(licenseAdmin.successNotice, 'License activated successfully.'); + await this.toBeVisible(licenseAdmin.activateLicenseInfo); + await this.toBeVisible(licenseAdmin.refreshLicense); } else { - await this.toContainText(selector.admin.dokan.license.errorNotice, 'Invalid License Key'); + await this.toContainText(licenseAdmin.errorNotice, 'Invalid License Key'); } } else { console.log('License already activated!!'); @@ -43,8 +46,8 @@ export class LicensePage extends AdminPage { // deactivate license async deactivateLicense() { await this.goIfNotThere(data.subUrls.backend.dokan.license); - await this.clickAndWaitForResponse(data.subUrls.backend.dokan.license, selector.admin.dokan.license.deactivateLicense); - await this.toContainText(selector.admin.dokan.license.successNotice, 'License deactivated successfully.'); - await this.notToBeVisible(selector.admin.dokan.license.refreshLicense); + await this.clickAndWaitForResponse(data.subUrls.backend.dokan.license, licenseAdmin.deactivateLicense); + await this.toContainText(licenseAdmin.successNotice, 'License deactivated successfully.'); + await this.notToBeVisible(licenseAdmin.refreshLicense); } } diff --git a/tests/pw/pages/loginPage.ts b/tests/pw/pages/loginPage.ts index 2c54f3a6c1..e45185c6c2 100644 --- a/tests/pw/pages/loginPage.ts +++ b/tests/pw/pages/loginPage.ts @@ -77,6 +77,7 @@ export class LoginPage extends BasePage { // admin logout async logoutBackend(): Promise { + await this.goIfNotThere(data.subUrls.backend.adminLogin); await this.hover(selector.backend.userMenu); await this.clickAndWaitForResponseAndLoadState(data.subUrls.backend.adminLogout, selector.backend.logout, 302); const loggedInUser = await this.getCurrentUser(); diff --git a/tests/pw/pages/modulesPage.ts b/tests/pw/pages/modulesPage.ts index 161159d2c7..3343092b1c 100644 --- a/tests/pw/pages/modulesPage.ts +++ b/tests/pw/pages/modulesPage.ts @@ -3,6 +3,9 @@ import { AdminPage } from '@pages/adminPage'; import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; +// selectors +const modulesAdmin = selector.admin.dokan.modules; + export class ModulesPage extends AdminPage { constructor(page: Page) { super(page); @@ -15,82 +18,82 @@ export class ModulesPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.modules); // modules text is visible - await this.toBeVisible(selector.admin.dokan.modules.pro.moduleText); + await this.toBeVisible(modulesAdmin.pro.moduleText); // module plan elements are visible - await this.multipleElementVisible(selector.admin.dokan.modules.pro.modulePlan); + await this.multipleElementVisible(modulesAdmin.pro.modulePlan); // navTab elements are visible - await this.multipleElementVisible(selector.admin.dokan.modules.pro.navTabs); + await this.multipleElementVisible(modulesAdmin.pro.navTabs); // module filter is visible - await this.toBeVisible(selector.admin.dokan.modules.pro.moduleFilter); + await this.toBeVisible(modulesAdmin.pro.moduleFilter); // modules search is visible - await this.toBeVisible(selector.admin.dokan.modules.pro.searchBox); + await this.toBeVisible(modulesAdmin.pro.searchBox); // modules view mode switcher is visible - await this.toBeVisible(selector.admin.dokan.modules.pro.moduleViewMode); + await this.toBeVisible(modulesAdmin.pro.moduleViewMode); // module cards and card details are visible - await this.toHaveCount(selector.admin.dokan.modules.pro.moduleCard, 38); - await this.toHaveCount(selector.admin.dokan.modules.pro.moduleIcon, 38); - await this.toHaveCount(selector.admin.dokan.modules.pro.moduleCheckbox, 38); - await this.toHaveCount(selector.admin.dokan.modules.pro.moduleName, 38); - await this.toHaveCount(selector.admin.dokan.modules.pro.moduleDescription, 38); - await this.toHaveCount(selector.admin.dokan.modules.pro.moduleActivationSwitch, 38); - await this.toHaveCount(selector.admin.dokan.modules.pro.moduleDocs, 38); - await this.toHaveCount(selector.admin.dokan.modules.pro.moduleVideos, 17); + await this.toHaveCount(modulesAdmin.pro.moduleCard, 38); + await this.toHaveCount(modulesAdmin.pro.moduleIcon, 38); + await this.toHaveCount(modulesAdmin.pro.moduleCheckbox, 38); + await this.toHaveCount(modulesAdmin.pro.moduleName, 38); + await this.toHaveCount(modulesAdmin.pro.moduleDescription, 38); + await this.toHaveCount(modulesAdmin.pro.moduleActivationSwitch, 38); + await this.toHaveCount(modulesAdmin.pro.moduleDocs, 38); + await this.toHaveCount(modulesAdmin.pro.moduleVideos, 17); // module category tags are visible - await this.toHaveCount(selector.admin.dokan.modules.pro.moduleCategoryTypes.productManagement, 13); - await this.toHaveCount(selector.admin.dokan.modules.pro.moduleCategoryTypes.integration, 6); - await this.toHaveCount(selector.admin.dokan.modules.pro.moduleCategoryTypes.uiUx, 2); - await this.toHaveCount(selector.admin.dokan.modules.pro.moduleCategoryTypes.shipping, 3); - await this.toHaveCount(selector.admin.dokan.modules.pro.moduleCategoryTypes.storeManagement, 10); - await this.toHaveCount(selector.admin.dokan.modules.pro.moduleCategoryTypes.payment, 6); - await this.toHaveCount(selector.admin.dokan.modules.pro.moduleCategoryTypes.orderManagement, 2); - await this.toHaveCount(selector.admin.dokan.modules.pro.moduleCategoryTypes.vendorManagement, 1); + await this.toHaveCount(modulesAdmin.pro.moduleCategoryTypes.productManagement, 13); + await this.toHaveCount(modulesAdmin.pro.moduleCategoryTypes.integration, 6); + await this.toHaveCount(modulesAdmin.pro.moduleCategoryTypes.uiUx, 2); + await this.toHaveCount(modulesAdmin.pro.moduleCategoryTypes.shipping, 3); + await this.toHaveCount(modulesAdmin.pro.moduleCategoryTypes.storeManagement, 10); + await this.toHaveCount(modulesAdmin.pro.moduleCategoryTypes.payment, 6); + await this.toHaveCount(modulesAdmin.pro.moduleCategoryTypes.orderManagement, 2); + await this.toHaveCount(modulesAdmin.pro.moduleCategoryTypes.vendorManagement, 1); } // search module async searchModule(moduleName: string) { await this.goIfNotThere(data.subUrls.backend.dokan.modules); - await this.clickIfVisible(selector.admin.dokan.modules.pro.clearFilter); - await this.clearAndType(selector.admin.dokan.modules.pro.searchBox, moduleName); - await this.toBeVisible(selector.admin.dokan.modules.pro.moduleCardByName(moduleName)); + await this.clickIfVisible(modulesAdmin.pro.clearFilter); + await this.clearAndType(modulesAdmin.pro.searchBox, moduleName); + await this.toBeVisible(modulesAdmin.pro.moduleCardByName(moduleName)); } // filter modules async filterModules(category: string) { await this.goto(data.subUrls.backend.dokan.modules); - await this.hover(selector.admin.dokan.modules.pro.moduleFilter); - await this.click(selector.admin.dokan.modules.pro.moduleFilterCheckBox(category)); - const numOfModules = await this.countLocator(selector.admin.dokan.modules.pro.moduleCard); - const numOfCategoryTag = await this.countLocator(selector.admin.dokan.modules.pro.moduleCategoryTag(category)); + await this.hover(modulesAdmin.pro.moduleFilter); + await this.click(modulesAdmin.pro.moduleFilterCheckBox(category)); + const numOfModules = await this.countLocator(modulesAdmin.pro.moduleCard); + const numOfCategoryTag = await this.countLocator(modulesAdmin.pro.moduleCategoryTag(category)); expect(numOfModules).toBe(numOfCategoryTag); } // activate deactivate module async activateDeactivateModule(moduleName: string) { await this.searchModule(moduleName); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.modules, selector.admin.dokan.modules.pro.moduleActivationSwitch); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.modules, modulesAdmin.pro.moduleActivationSwitch); } // modules bulk action async moduleBulkAction(action: string) { await this.goIfNotThere(data.subUrls.backend.dokan.modules); - await this.click(selector.admin.dokan.modules.pro.firstModuleCheckbox); - await this.click(selector.admin.dokan.modules.pro.selectAllBulkAction); + await this.click(modulesAdmin.pro.firstModuleCheckbox); + await this.click(modulesAdmin.pro.selectAllBulkAction); switch (action) { case 'activate': - await this.clickAndWaitForResponse(data.subUrls.api.dokan.modules, selector.admin.dokan.modules.pro.activeAll); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.modules, modulesAdmin.pro.activeAll); break; case 'deactivate': - await this.clickAndWaitForResponse(data.subUrls.api.dokan.modules, selector.admin.dokan.modules.pro.deActivateAll); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.modules, modulesAdmin.pro.deActivateAll); break; default: @@ -101,22 +104,22 @@ export class ModulesPage extends AdminPage { // module view layout async moduleViewLayout(style: string) { await this.goIfNotThere(data.subUrls.backend.dokan.modules); - const currentStyle = await this.getClassValue(selector.admin.dokan.modules.pro.currentLayout); + const currentStyle = await this.getClassValue(modulesAdmin.pro.currentLayout); if (!currentStyle?.includes(style)) { - await this.click(selector.admin.dokan.modules.pro.moduleViewMode); - await this.toHaveClass(selector.admin.dokan.modules.pro.currentLayout, style); + await this.click(modulesAdmin.pro.moduleViewMode); + await this.toHaveClass(modulesAdmin.pro.currentLayout, style); } } // inactive module exists async inActiveModuleExists() { await this.goIfNotThere(data.subUrls.backend.dokan.modules); - await this.click(selector.admin.dokan.modules.pro.navTabs.inActive); - const noModulesMessage = await this.isVisible(selector.admin.dokan.modules.pro.noModulesFound); + await this.click(modulesAdmin.pro.navTabs.inActive); + const noModulesMessage = await this.isVisible(modulesAdmin.pro.noModulesFound); if (noModulesMessage) { - await this.toContainText(selector.admin.dokan.modules.pro.noModulesFound, data.modules.noModuleMessage); + await this.toContainText(modulesAdmin.pro.noModulesFound, data.modules.noModuleMessage); } else { - const inActiveModuleNames = await this.getMultipleElementTexts(selector.admin.dokan.modules.pro.moduleName); + const inActiveModuleNames = await this.getMultipleElementTexts(modulesAdmin.pro.moduleName); throw new Error('Inactive modules: ' + inActiveModuleNames); } } diff --git a/tests/pw/pages/proPromoPage.ts b/tests/pw/pages/noticeAndPromotionPage.ts similarity index 56% rename from tests/pw/pages/proPromoPage.ts rename to tests/pw/pages/noticeAndPromotionPage.ts index 5763f97741..4910fb9ea4 100644 --- a/tests/pw/pages/proPromoPage.ts +++ b/tests/pw/pages/noticeAndPromotionPage.ts @@ -3,13 +3,39 @@ import { AdminPage } from '@pages/adminPage'; import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; -export class ProPromoPage extends AdminPage { +export class NoticeAndPromotionPage extends AdminPage { constructor(page: Page) { super(page); } - // dokan pro promo - async dokanProPromo() { + // dokan notice & promotion + + // dokan notice + async dokanNoticeRenderProperly() { + await this.goto(data.subUrls.backend.dokan.dokan); + + // dokan notice elements are visible + const isPromotionVisible = await this.isVisible(selector.admin.dokan.promotion.promotion); + isPromotionVisible ? await this.notToHaveCount(selector.admin.dokan.notice.noticeDiv1, 0) : await this.notToHaveCount(selector.admin.dokan.notice.noticeDiv, 0); + await this.notToHaveCount(selector.admin.dokan.notice.slider, 0); + await this.notToHaveCount(selector.admin.dokan.notice.sliderPrev, 0); + await this.notToHaveCount(selector.admin.dokan.notice.sliderNext, 0); + } + + // dokan promotion + async dokanPromotionRenderProperly() { + await this.goto(data.subUrls.backend.dokan.dokan); + // dokan promotion elements are visible + const isPromotionVisible = await this.isVisible(selector.admin.dokan.promotion.promotion); + if (isPromotionVisible) { + await this.multipleElementVisible(selector.admin.dokan.promotion); + } else { + console.log('No promotion is ongoing'); + } + } + + // dokan pro promotion + async dokanProPromotionRenderProperly() { // dokan promo banner await this.goIfNotThere(data.subUrls.backend.dokan.dokan); diff --git a/tests/pw/pages/ordersPage.ts b/tests/pw/pages/ordersPage.ts index 44636d5486..6b1dd99fce 100644 --- a/tests/pw/pages/ordersPage.ts +++ b/tests/pw/pages/ordersPage.ts @@ -7,6 +7,9 @@ import { orderNote, orderTrackingDetails, orderShipmentDetails, date } from '@ut const { DOKAN_PRO } = process.env; +// selectors +const ordersVendor = selector.vendor.orders; + export class OrdersPage extends VendorPage { constructor(page: Page) { super(page); @@ -19,25 +22,25 @@ export class OrdersPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.orders); // order nav menus are visible - await this.multipleElementVisible(selector.vendor.orders.menus); + await this.multipleElementVisible(ordersVendor.menus); // export elements are visible - await this.multipleElementVisible(selector.vendor.orders.export); + await this.multipleElementVisible(ordersVendor.export); // order filters elements are visible - const { filterByCustomer, filterByDate, ...filters } = selector.vendor.orders.filters; - await this.toBeVisible(selector.vendor.orders.filters.filterByCustomer.dropDown); - await this.toBeVisible(selector.vendor.orders.filters.filterByDate.dateRangeInput); + const { filterByCustomer, filterByDate, ...filters } = ordersVendor.filters; + await this.toBeVisible(ordersVendor.filters.filterByCustomer.dropDown); + await this.toBeVisible(ordersVendor.filters.filterByDate.dateRangeInput); await this.multipleElementVisible(filters); // order search elements are visible - await this.multipleElementVisible(selector.vendor.orders.search); + await this.multipleElementVisible(ordersVendor.search); // bulk action elements are visible - await this.multipleElementVisible(selector.vendor.orders.bulkActions); + await this.multipleElementVisible(ordersVendor.bulkActions); // table elements are visible - const { shipmentColumn, ...table } = selector.vendor.orders.table; + const { shipmentColumn, ...table } = ordersVendor.table; await this.multipleElementVisible(table); DOKAN_PRO && (await this.toBeVisible(shipmentColumn)); } @@ -48,13 +51,13 @@ export class OrdersPage extends VendorPage { switch (type) { case 'all': - // await this.clickAndAcceptAndWaitForResponse(data.subUrls.frontend.vDashboard.orders, selector.vendor.orders.export.exportAll ); - await this.clickAndWaitForDownload(selector.vendor.orders.export.exportAll); + // await this.clickAndAcceptAndWaitForResponse(data.subUrls.frontend.vDashboard.orders, ordersVendor.export.exportAll ); + await this.clickAndWaitForDownload(ordersVendor.export.exportAll); break; case 'filtered': - // await this.clickAndAcceptAndWaitForResponse(data.subUrls.frontend.vDashboard.orders, selector.vendor.orders.export.exportFiltered ); - await this.clickAndWaitForDownload(selector.vendor.orders.export.exportFiltered); + // await this.clickAndAcceptAndWaitForResponse(data.subUrls.frontend.vDashboard.orders, ordersVendor.export.exportFiltered ); + await this.clickAndWaitForDownload(ordersVendor.export.exportFiltered); break; default: @@ -66,10 +69,10 @@ export class OrdersPage extends VendorPage { async searchOrder(orderNumber: string): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.orders); - await this.clearAndType(selector.vendor.orders.search.searchInput, orderNumber); - await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.orders, selector.vendor.orders.search.searchBtn); - await this.toBeVisible(selector.vendor.orders.orderLink(orderNumber)); - await this.toHaveCount(selector.vendor.orders.numberOfRowsFound, 1); + await this.clearAndType(ordersVendor.search.searchInput, orderNumber); + await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.orders, ordersVendor.search.searchBtn); + await this.toBeVisible(ordersVendor.orderLink(orderNumber)); + await this.toHaveCount(ordersVendor.numberOfRowsFound, 1); } // filter orders @@ -78,16 +81,16 @@ export class OrdersPage extends VendorPage { switch (filterBy) { case 'by-customer': - await this.click(selector.vendor.orders.filters.filterByCustomer.dropDown); - await this.typeAndWaitForResponse(data.subUrls.ajax, selector.vendor.orders.filters.filterByCustomer.input, inputValue as string); - await this.click(selector.vendor.orders.filters.filterByCustomer.searchedResult); + await this.click(ordersVendor.filters.filterByCustomer.dropDown); + await this.typeAndWaitForResponse(data.subUrls.ajax, ordersVendor.filters.filterByCustomer.input, inputValue as string); + await this.click(ordersVendor.filters.filterByCustomer.searchedResult); break; case 'by-date': if (typeof inputValue !== 'string') { - await this.setAttributeValue(selector.vendor.orders.filters.filterByDate.dateRangeInput, 'value', helpers.dateFormatFYJ(inputValue.startDate) + ' - ' + helpers.dateFormatFYJ(inputValue.endDate)); - await this.setAttributeValue(selector.vendor.orders.filters.filterByDate.startDateInput, 'value', inputValue.startDate); - await this.setAttributeValue(selector.vendor.orders.filters.filterByDate.endDateInput, 'value', inputValue.endDate); + await this.setAttributeValue(ordersVendor.filters.filterByDate.dateRangeInput, 'value', helpers.dateFormatFYJ(inputValue.startDate) + ' - ' + helpers.dateFormatFYJ(inputValue.endDate)); + await this.setAttributeValue(ordersVendor.filters.filterByDate.startDateInput, 'value', inputValue.startDate); + await this.setAttributeValue(ordersVendor.filters.filterByDate.endDateInput, 'value', inputValue.endDate); } break; @@ -95,15 +98,15 @@ export class OrdersPage extends VendorPage { break; } - await this.clickAndWaitForLoadState(selector.vendor.orders.filters.filter); - await this.notToHaveCount(selector.vendor.orders.numberOfRowsFound, 0); + await this.clickAndWaitForLoadState(ordersVendor.filters.filter); + await this.notToHaveCount(ordersVendor.numberOfRowsFound, 0); } // go to order details async goToOrderDetails(orderNumber: string): Promise { await this.searchOrder(orderNumber); - await this.clickAndWaitForLoadState(selector.vendor.orders.view(orderNumber)); - await this.toContainText(selector.vendor.orders.orderDetails.orderNumber, orderNumber); + await this.clickAndWaitForLoadState(ordersVendor.view(orderNumber)); + await this.toContainText(ordersVendor.orderDetails.orderNumber, orderNumber); } // view order details @@ -111,37 +114,37 @@ export class OrdersPage extends VendorPage { await this.goToOrderDetails(orderNumber); // order details elements are visible - await this.toBeVisible(selector.vendor.orders.orderDetails.orderNumber); - await this.toBeVisible(selector.vendor.orders.orderDetails.orderDate); - DOKAN_PRO ? await this.toBeVisible(selector.vendor.orders.orderDetails.orderTotal) : await this.toBeVisible(selector.vendor.orders.orderDetails.total); + await this.toBeVisible(ordersVendor.orderDetails.orderNumber); + await this.toBeVisible(ordersVendor.orderDetails.orderDate); + DOKAN_PRO ? await this.toBeVisible(ordersVendor.orderDetails.orderTotal) : await this.toBeVisible(ordersVendor.orderDetails.total); // todo: add more fields to assert // general details elements are visible - await this.multipleElementVisible(selector.vendor.orders.generalDetails); + await this.multipleElementVisible(ordersVendor.generalDetails); - await this.click(selector.vendor.orders.status.edit); + await this.click(ordersVendor.status.edit); // status elements are visible - const { selectedOrderStatus, edit, ...status } = selector.vendor.orders.status; + const { selectedOrderStatus, edit, ...status } = ordersVendor.status; await this.multipleElementVisible(status); // order note elements are visible - await this.multipleElementVisible(selector.vendor.orders.orderNote); + await this.multipleElementVisible(ordersVendor.orderNote); if (DOKAN_PRO) { - await this.click(selector.vendor.orders.shipment.createNewShipment); + await this.click(ordersVendor.shipment.createNewShipment); // shipment elements are visible - const { createNewShipment, shipmentOrderItem, shipmentOrderItemQty, ...shipment } = selector.vendor.orders.shipment; + const { createNewShipment, shipmentOrderItem, shipmentOrderItemQty, ...shipment } = ordersVendor.shipment; await this.multipleElementVisible(shipment); } else { - await this.click(selector.vendor.orders.trackingDetails.addTrackingNumber); + await this.click(ordersVendor.trackingDetails.addTrackingNumber); // tracking detail elements are visible - const { addTrackingNumber, ...trackingDetails } = selector.vendor.orders.trackingDetails; + const { addTrackingNumber, ...trackingDetails } = ordersVendor.trackingDetails; await this.multipleElementVisible(trackingDetails); } // downloadable product elements are visible - const { revokeAccess, confirmAction, cancelAction, ...downloadableProductPermission } = selector.vendor.orders.downloadableProductPermission; + const { revokeAccess, confirmAction, cancelAction, ...downloadableProductPermission } = ordersVendor.downloadableProductPermission; await this.multipleElementVisible(downloadableProductPermission); } @@ -150,13 +153,13 @@ export class OrdersPage extends VendorPage { await this.searchOrder(orderNumber); switch (status) { case 'processing': - await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, selector.vendor.orders.processing(orderNumber), 302); - await this.notToBeVisible(selector.vendor.orders.processing(orderNumber)); + await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, ordersVendor.processing(orderNumber), 302); + await this.notToBeVisible(ordersVendor.processing(orderNumber)); break; case 'complete': - await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, selector.vendor.orders.complete(orderNumber), 302); - await this.notToBeVisible(selector.vendor.orders.complete(orderNumber)); + await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, ordersVendor.complete(orderNumber), 302); + await this.notToBeVisible(ordersVendor.complete(orderNumber)); break; default: @@ -167,10 +170,10 @@ export class OrdersPage extends VendorPage { // update order status async updateOrderStatus(orderNumber: string, status: string): Promise { await this.goToOrderDetails(orderNumber); - await this.click(selector.vendor.orders.status.edit); - await this.selectByValue(selector.vendor.orders.status.orderStatus, status); - await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, selector.vendor.orders.status.updateOrderStatus); - const currentStatus = await this.getElementText(selector.vendor.orders.status.currentOrderStatus); + await this.click(ordersVendor.status.edit); + await this.selectByValue(ordersVendor.status.orderStatus, status); + await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, ordersVendor.status.updateOrderStatus); + const currentStatus = await this.getElementText(ordersVendor.status.currentOrderStatus); expect(currentStatus?.toLowerCase()).toBe(status.split('-').pop()); // expect(currentOrderStatus?.toLowerCase()).toMatch((orderStatus.replace(/(^wc)|(\W)/g, '')).toLowerCase()); } @@ -178,34 +181,34 @@ export class OrdersPage extends VendorPage { // add order note async addOrderNote(orderNumber: string, orderNote: orderNote): Promise { await this.goToOrderDetails(orderNumber); - await this.clearAndType(selector.vendor.orders.orderNote.orderNoteInput, orderNote.note); - await this.selectByLabel(selector.vendor.orders.orderNote.orderNoteType, orderNote.noteType); - await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, selector.vendor.orders.orderNote.addNote); + await this.clearAndType(ordersVendor.orderNote.orderNoteInput, orderNote.note); + await this.selectByLabel(ordersVendor.orderNote.orderNoteType, orderNote.noteType); + await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, ordersVendor.orderNote.addNote); } // add tracking details async addTrackingDetails(orderNumber: string, orderTrackingDetails: orderTrackingDetails): Promise { await this.goToOrderDetails(orderNumber); - await this.click(selector.vendor.orders.trackingDetails.addTrackingNumber); - await this.clearAndType(selector.vendor.orders.trackingDetails.shippingProvider, orderTrackingDetails.shippingProvider); - await this.clearAndType(selector.vendor.orders.trackingDetails.trackingNumber, orderTrackingDetails.trackingNumber); - await this.setAttributeValue(selector.vendor.orders.trackingDetails.dateShipped, 'value', helpers.dateFormatFYJ(orderTrackingDetails.dateShipped)); - await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, selector.vendor.orders.trackingDetails.addTrackingDetails); + await this.click(ordersVendor.trackingDetails.addTrackingNumber); + await this.clearAndType(ordersVendor.trackingDetails.shippingProvider, orderTrackingDetails.shippingProvider); + await this.clearAndType(ordersVendor.trackingDetails.trackingNumber, orderTrackingDetails.trackingNumber); + await this.setAttributeValue(ordersVendor.trackingDetails.dateShipped, 'value', helpers.dateFormatFYJ(orderTrackingDetails.dateShipped)); + await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, ordersVendor.trackingDetails.addTrackingDetails); } // add shipment async addShipment(orderNumber: string, shipmentDetails: orderShipmentDetails): Promise { await this.goToOrderDetails(orderNumber); - await this.click(selector.vendor.orders.shipment.createNewShipment); - await this.click(selector.vendor.orders.shipment.shipmentOrderItem(shipmentDetails.shipmentOrderItem)); - await this.clearAndType(selector.vendor.orders.shipment.shipmentOrderItemQty(shipmentDetails.shipmentOrderItem), shipmentDetails.shipmentOrderItemQty); - await this.selectByValue(selector.vendor.orders.shipment.shippingStatus, shipmentDetails.shippingStatus); - await this.selectByValue(selector.vendor.orders.shipment.shippingProvider, shipmentDetails.shippingProvider); - await this.setAttributeValue(selector.vendor.orders.shipment.dateShipped, 'value', helpers.dateFormatFYJ(shipmentDetails.dateShipped)); - await this.clearAndType(selector.vendor.orders.shipment.trackingNumber, shipmentDetails.shippingProvider); - await this.clearAndType(selector.vendor.orders.shipment.comments, shipmentDetails.trackingNumber); - await this.click(selector.vendor.orders.shipment.notifyCustomer); - await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, selector.vendor.orders.shipment.createShipment); + await this.click(ordersVendor.shipment.createNewShipment); + await this.click(ordersVendor.shipment.shipmentOrderItem(shipmentDetails.shipmentOrderItem)); + await this.clearAndType(ordersVendor.shipment.shipmentOrderItemQty(shipmentDetails.shipmentOrderItem), shipmentDetails.shipmentOrderItemQty); + await this.selectByValue(ordersVendor.shipment.shippingStatus, shipmentDetails.shippingStatus); + await this.selectByValue(ordersVendor.shipment.shippingProvider, shipmentDetails.shippingProvider); + await this.setAttributeValue(ordersVendor.shipment.dateShipped, 'value', helpers.dateFormatFYJ(shipmentDetails.dateShipped)); + await this.clearAndType(ordersVendor.shipment.trackingNumber, shipmentDetails.shippingProvider); + await this.clearAndType(ordersVendor.shipment.comments, shipmentDetails.trackingNumber); + await this.click(ordersVendor.shipment.notifyCustomer); + await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, ordersVendor.shipment.createShipment); // todo: add more assertion, success message, or short shipment description div // todo: also assert on my order details or add new test } @@ -215,40 +218,40 @@ export class OrdersPage extends VendorPage { // add Downloadable Product async addDownloadableProduct(orderNumber: string, downloadableProductName: string): Promise { await this.goToOrderDetails(orderNumber); - await this.clearAndType(selector.vendor.orders.downloadableProductPermission.downloadableProductInput, downloadableProductName); + await this.clearAndType(ordersVendor.downloadableProductPermission.downloadableProductInput, downloadableProductName); await this.press(data.key.enter); - await this.clickAndAcceptAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.vendor.orders.downloadableProductPermission.grantAccess); // todo: need to fix + await this.clickAndAcceptAndWaitForResponseAndLoadState(data.subUrls.ajax, ordersVendor.downloadableProductPermission.grantAccess); // todo: need to fix } // add Downloadable Product async removeDownloadableProduct(orderNumber: string, downloadableProductName: string): Promise { await this.addDownloadableProduct(orderNumber, downloadableProductName); // todo: do it via api - await this.click(selector.vendor.orders.downloadableProductPermission.revokeAccess); - await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, selector.vendor.orders.downloadableProductPermission.confirmAction); + await this.click(ordersVendor.downloadableProductPermission.revokeAccess); + await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, ordersVendor.downloadableProductPermission.confirmAction); } // order bulk action async orderBulkAction(action: string, orderNumber?: string): Promise { orderNumber ? await this.searchOrder(orderNumber) : await this.goIfNotThere(data.subUrls.frontend.vDashboard.orders); - await this.click(selector.vendor.orders.bulkActions.selectAll); + await this.click(ordersVendor.bulkActions.selectAll); switch (action) { case 'onhold': - await this.selectByValue(selector.vendor.orders.bulkActions.selectAction, 'wc-on-hold'); + await this.selectByValue(ordersVendor.bulkActions.selectAction, 'wc-on-hold'); break; case 'processing': - await this.selectByValue(selector.vendor.orders.bulkActions.selectAction, 'wc-processing'); + await this.selectByValue(ordersVendor.bulkActions.selectAction, 'wc-processing'); break; case 'completed': - await this.selectByValue(selector.vendor.orders.bulkActions.selectAction, 'wc-completed'); + await this.selectByValue(ordersVendor.bulkActions.selectAction, 'wc-completed'); break; default: break; } - await this.clickAndAcceptAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.orders, selector.vendor.orders.bulkActions.applyAction); + await this.clickAndAcceptAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.orders, ordersVendor.bulkActions.applyAction); } } diff --git a/tests/pw/pages/paymentsPage.ts b/tests/pw/pages/paymentsPage.ts index 26eda396c4..cf7f5255dd 100644 --- a/tests/pw/pages/paymentsPage.ts +++ b/tests/pw/pages/paymentsPage.ts @@ -4,6 +4,10 @@ import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; import { payment, vendor } from '@utils/interfaces'; +// selectors +const woocommerceSettings = selector.admin.wooCommerce.settings; +const paymentSettingsVendor = selector.vendor.vPaymentSettings; + export class PaymentsPage extends AdminPage { constructor(page: Page) { super(page); @@ -15,16 +19,16 @@ export class PaymentsPage extends AdminPage { async setupBasicPaymentMethods(payment: payment) { await this.goToWooCommerceSettings(); - await this.click(selector.admin.wooCommerce.settings.payments); + await this.click(woocommerceSettings.payments); // Bank Transfer - await this.enablePaymentMethod(selector.admin.wooCommerce.settings.enableDirectBankTransfer); + await this.enablePaymentMethod(woocommerceSettings.enableDirectBankTransfer); // Payments - await this.enablePaymentMethod(selector.admin.wooCommerce.settings.enableCheckPayments); + await this.enablePaymentMethod(woocommerceSettings.enableCheckPayments); // Cash on Delivery - await this.enablePaymentMethod(selector.admin.wooCommerce.settings.enableCashOnDelivery); + await this.enablePaymentMethod(woocommerceSettings.enableCashOnDelivery); - await this.click(selector.admin.wooCommerce.settings.paymentMethodsSaveChanges); - await this.toContainText(selector.admin.wooCommerce.settings.updatedSuccessMessage, payment.saveSuccessMessage); + await this.click(woocommerceSettings.paymentMethodsSaveChanges); + await this.toContainText(woocommerceSettings.updatedSuccessMessage, payment.saveSuccessMessage); } // Admin Setup Stripe @@ -33,30 +37,30 @@ export class PaymentsPage extends AdminPage { await this.setCurrency(payment.currency.dollar); - await this.click(selector.admin.wooCommerce.settings.payments); - await this.click(selector.admin.wooCommerce.settings.setupDokanStripeConnect); + await this.click(woocommerceSettings.payments); + await this.click(woocommerceSettings.setupDokanStripeConnect); // Setup Strip Connect - await this.check(selector.admin.wooCommerce.settings.stripe.enableDisableStripe); - await this.clearAndType(selector.admin.wooCommerce.settings.stripe.title, payment.stripeConnect.title); - await this.clearAndType(selector.admin.wooCommerce.settings.stripe.description, payment.stripeConnect.description); - await this.check(selector.admin.wooCommerce.settings.stripe.nonConnectedSellers); - await this.check(selector.admin.wooCommerce.settings.stripe.displayNoticeToConnectSeller); - await this.clearAndType(selector.admin.wooCommerce.settings.stripe.displayNoticeInterval, payment.stripeConnect.displayNoticeInterval); - await this.check(selector.admin.wooCommerce.settings.stripe.threeDSecureAndSca); - await this.check(selector.admin.wooCommerce.settings.stripe.sellerPaysTheProcessingFeeIn3DsMode); - await this.check(selector.admin.wooCommerce.settings.stripe.testMode); - await this.check(selector.admin.wooCommerce.settings.stripe.stripeCheckout); - await this.click(selector.admin.wooCommerce.settings.stripe.stripeCheckoutLocale); - await this.type(selector.admin.wooCommerce.settings.stripe.stripeCheckoutLocale, payment.stripeConnect.stripeCheckoutLocale); + await this.check(woocommerceSettings.stripe.enableDisableStripe); + await this.clearAndType(woocommerceSettings.stripe.title, payment.stripeConnect.title); + await this.clearAndType(woocommerceSettings.stripe.description, payment.stripeConnect.description); + await this.check(woocommerceSettings.stripe.nonConnectedSellers); + await this.check(woocommerceSettings.stripe.displayNoticeToConnectSeller); + await this.clearAndType(woocommerceSettings.stripe.displayNoticeInterval, payment.stripeConnect.displayNoticeInterval); + await this.check(woocommerceSettings.stripe.threeDSecureAndSca); + await this.check(woocommerceSettings.stripe.sellerPaysTheProcessingFeeIn3DsMode); + await this.check(woocommerceSettings.stripe.testMode); + await this.check(woocommerceSettings.stripe.stripeCheckout); + await this.click(woocommerceSettings.stripe.stripeCheckoutLocale); + await this.type(woocommerceSettings.stripe.stripeCheckoutLocale, payment.stripeConnect.stripeCheckoutLocale); await this.press(data.key.enter); - await this.check(selector.admin.wooCommerce.settings.stripe.savedCards); + await this.check(woocommerceSettings.stripe.savedCards); // Test Credentials - await this.clearAndType(selector.admin.wooCommerce.settings.stripe.testPublishableKey, payment.stripeConnect.testPublishableKey); - await this.clearAndType(selector.admin.wooCommerce.settings.stripe.testSecretKey, payment.stripeConnect.testSecretKey); - await this.clearAndType(selector.admin.wooCommerce.settings.stripe.testClientId, payment.stripeConnect.testClientId); - await this.click(selector.admin.wooCommerce.settings.stripe.stripeSaveChanges); + await this.clearAndType(woocommerceSettings.stripe.testPublishableKey, payment.stripeConnect.testPublishableKey); + await this.clearAndType(woocommerceSettings.stripe.testSecretKey, payment.stripeConnect.testSecretKey); + await this.clearAndType(woocommerceSettings.stripe.testClientId, payment.stripeConnect.testClientId); + await this.click(woocommerceSettings.stripe.stripeSaveChanges); - await this.toContainText(selector.admin.wooCommerce.settings.updatedSuccessMessage, payment.saveSuccessMessage); + await this.toContainText(woocommerceSettings.updatedSuccessMessage, payment.saveSuccessMessage); } // Admin Setup Dokan Paypal Marketplace @@ -65,29 +69,29 @@ export class PaymentsPage extends AdminPage { await this.setCurrency(payment.currency.dollar); - await this.click(selector.admin.wooCommerce.settings.payments); - await this.click(selector.admin.wooCommerce.settings.setupDokanPayPalMarketplace); + await this.click(woocommerceSettings.payments); + await this.click(woocommerceSettings.setupDokanPayPalMarketplace); // Setup Paypal Marketplace - await this.check(selector.admin.wooCommerce.settings.paypalMarketPlace.enableDisablePayPalMarketplace); - await this.clearAndType(selector.admin.wooCommerce.settings.paypalMarketPlace.title, payment.paypalMarketPlace.title); - await this.clearAndType(selector.admin.wooCommerce.settings.paypalMarketPlace.description, payment.paypalMarketPlace.description); - await this.clearAndType(selector.admin.wooCommerce.settings.paypalMarketPlace.payPalMerchantId, payment.paypalMarketPlace.payPalMerchantId); + await this.check(woocommerceSettings.paypalMarketPlace.enableDisablePayPalMarketplace); + await this.clearAndType(woocommerceSettings.paypalMarketPlace.title, payment.paypalMarketPlace.title); + await this.clearAndType(woocommerceSettings.paypalMarketPlace.description, payment.paypalMarketPlace.description); + await this.clearAndType(woocommerceSettings.paypalMarketPlace.payPalMerchantId, payment.paypalMarketPlace.payPalMerchantId); // API Credentials - await this.check(selector.admin.wooCommerce.settings.paypalMarketPlace.payPalSandbox); - await this.clearAndType(selector.admin.wooCommerce.settings.paypalMarketPlace.sandboxClientId, payment.paypalMarketPlace.sandboxClientId); - await this.clearAndType(selector.admin.wooCommerce.settings.paypalMarketPlace.sandBoxClientSecret, payment.paypalMarketPlace.sandBoxClientSecret); - await this.clearAndType(selector.admin.wooCommerce.settings.paypalMarketPlace.payPalPartnerAttributionId, payment.paypalMarketPlace.payPalPartnerAttributionId); - await this.click(selector.admin.wooCommerce.settings.paypalMarketPlace.disbursementMode); - await this.setDropdownOptionSpan(selector.admin.wooCommerce.settings.paypalMarketPlace.disbursementModeValues, payment.paypalMarketPlace.disbursementMode); - await this.click(selector.admin.wooCommerce.settings.paypalMarketPlace.paymentButtonType); - await this.setDropdownOptionSpan(selector.admin.wooCommerce.settings.paypalMarketPlace.paymentButtonTypeValues, payment.paypalMarketPlace.paymentButtonType); - await this.clearAndType(selector.admin.wooCommerce.settings.paypalMarketPlace.marketplaceLogo, (await this.getBaseUrl()) + payment.paypalMarketPlace.marketplaceLogoPath); - await this.check(selector.admin.wooCommerce.settings.paypalMarketPlace.displayNoticeToConnectSeller); - await this.check(selector.admin.wooCommerce.settings.paypalMarketPlace.sendAnnouncementToConnectSeller); - await this.clearAndType(selector.admin.wooCommerce.settings.paypalMarketPlace.sendAnnouncementInterval, payment.paypalMarketPlace.announcementInterval); - await this.click(selector.admin.wooCommerce.settings.paypalMarketPlace.paypalMarketPlaceSaveChanges); - - await this.toContainText(selector.admin.wooCommerce.settings.updatedSuccessMessage, payment.saveSuccessMessage); + await this.check(woocommerceSettings.paypalMarketPlace.payPalSandbox); + await this.clearAndType(woocommerceSettings.paypalMarketPlace.sandboxClientId, payment.paypalMarketPlace.sandboxClientId); + await this.clearAndType(woocommerceSettings.paypalMarketPlace.sandBoxClientSecret, payment.paypalMarketPlace.sandBoxClientSecret); + await this.clearAndType(woocommerceSettings.paypalMarketPlace.payPalPartnerAttributionId, payment.paypalMarketPlace.payPalPartnerAttributionId); + await this.click(woocommerceSettings.paypalMarketPlace.disbursementMode); + await this.setDropdownOptionSpan(woocommerceSettings.paypalMarketPlace.disbursementModeValues, payment.paypalMarketPlace.disbursementMode); + await this.click(woocommerceSettings.paypalMarketPlace.paymentButtonType); + await this.setDropdownOptionSpan(woocommerceSettings.paypalMarketPlace.paymentButtonTypeValues, payment.paypalMarketPlace.paymentButtonType); + await this.clearAndType(woocommerceSettings.paypalMarketPlace.marketplaceLogo, (await this.getBaseUrl()) + payment.paypalMarketPlace.marketplaceLogoPath); + await this.check(woocommerceSettings.paypalMarketPlace.displayNoticeToConnectSeller); + await this.check(woocommerceSettings.paypalMarketPlace.sendAnnouncementToConnectSeller); + await this.clearAndType(woocommerceSettings.paypalMarketPlace.sendAnnouncementInterval, payment.paypalMarketPlace.announcementInterval); + await this.click(woocommerceSettings.paypalMarketPlace.paypalMarketPlaceSaveChanges); + + await this.toContainText(woocommerceSettings.updatedSuccessMessage, payment.saveSuccessMessage); } // Admin Setup Mangopay @@ -96,42 +100,42 @@ export class PaymentsPage extends AdminPage { await this.setCurrency(payment.currency.euro); - await this.click(selector.admin.wooCommerce.settings.payments); - await this.click(selector.admin.wooCommerce.settings.setupDokanMangoPay); + await this.click(woocommerceSettings.payments); + await this.click(woocommerceSettings.setupDokanMangoPay); // Setup Mangopay - await this.check(selector.admin.wooCommerce.settings.dokanMangoPay.enableDisableMangoPayPayment); - await this.clearAndType(selector.admin.wooCommerce.settings.dokanMangoPay.title, payment.mangoPay.title); - await this.clearAndType(selector.admin.wooCommerce.settings.dokanMangoPay.description, payment.mangoPay.description); + await this.check(woocommerceSettings.dokanMangoPay.enableDisableMangoPayPayment); + await this.clearAndType(woocommerceSettings.dokanMangoPay.title, payment.mangoPay.title); + await this.clearAndType(woocommerceSettings.dokanMangoPay.description, payment.mangoPay.description); // API Credentials - await this.check(selector.admin.wooCommerce.settings.dokanMangoPay.mangoPaySandbox); - await this.clearAndType(selector.admin.wooCommerce.settings.dokanMangoPay.sandboxClientId, payment.mangoPay.sandboxClientId); - await this.clearAndType(selector.admin.wooCommerce.settings.dokanMangoPay.sandBoxApiKey, payment.mangoPay.sandBoxApiKey); + await this.check(woocommerceSettings.dokanMangoPay.mangoPaySandbox); + await this.clearAndType(woocommerceSettings.dokanMangoPay.sandboxClientId, payment.mangoPay.sandboxClientId); + await this.clearAndType(woocommerceSettings.dokanMangoPay.sandBoxApiKey, payment.mangoPay.sandBoxApiKey); // Payment Options - await this.click(selector.admin.wooCommerce.settings.dokanMangoPay.chooseAvailableCreditCards); - await this.type(selector.admin.wooCommerce.settings.dokanMangoPay.chooseAvailableCreditCards, 'CB/Visa/Mastercard'); + await this.click(woocommerceSettings.dokanMangoPay.chooseAvailableCreditCards); + await this.type(woocommerceSettings.dokanMangoPay.chooseAvailableCreditCards, 'CB/Visa/Mastercard'); await this.press(data.key.enter); - await this.setDropdownOptionSpan(selector.admin.wooCommerce.settings.dokanMangoPay.chooseAvailableCreditCardsValues, payment.mangoPay.availableCreditCards); - await this.click(selector.admin.wooCommerce.settings.dokanMangoPay.chooseAvailableDirectPaymentServices); - await this.type(selector.admin.wooCommerce.settings.dokanMangoPay.chooseAvailableDirectPaymentServices, 'Sofort*'); + await this.setDropdownOptionSpan(woocommerceSettings.dokanMangoPay.chooseAvailableCreditCardsValues, payment.mangoPay.availableCreditCards); + await this.click(woocommerceSettings.dokanMangoPay.chooseAvailableDirectPaymentServices); + await this.type(woocommerceSettings.dokanMangoPay.chooseAvailableDirectPaymentServices, 'Sofort*'); await this.press(data.key.enter); - await this.setDropdownOptionSpan(selector.admin.wooCommerce.settings.dokanMangoPay.chooseAvailableDirectPaymentServicesValues, payment.mangoPay.availableDirectPaymentServices); - await this.check(selector.admin.wooCommerce.settings.dokanMangoPay.savedCards); + await this.setDropdownOptionSpan(woocommerceSettings.dokanMangoPay.chooseAvailableDirectPaymentServicesValues, payment.mangoPay.availableDirectPaymentServices); + await this.check(woocommerceSettings.dokanMangoPay.savedCards); // Fund Transfers and Payouts - await this.click(selector.admin.wooCommerce.settings.dokanMangoPay.transferFunds); - await this.setDropdownOptionSpan(selector.admin.wooCommerce.settings.dokanMangoPay.transferFundsValues, payment.mangoPay.transferFunds); - await this.check(selector.admin.wooCommerce.settings.dokanMangoPay.payoutMode); + await this.click(woocommerceSettings.dokanMangoPay.transferFunds); + await this.setDropdownOptionSpan(woocommerceSettings.dokanMangoPay.transferFundsValues, payment.mangoPay.transferFunds); + await this.check(woocommerceSettings.dokanMangoPay.payoutMode); // Types and Requirements of Vendors - await this.click(selector.admin.wooCommerce.settings.dokanMangoPay.typeOfVendors); - await this.setDropdownOptionSpan(selector.admin.wooCommerce.settings.dokanMangoPay.typeOfVendorsValues, payment.mangoPay.typeOfVendors); - await this.click(selector.admin.wooCommerce.settings.dokanMangoPay.businessRequirement); - await this.setDropdownOptionSpan(selector.admin.wooCommerce.settings.dokanMangoPay.businessRequirementValues, payment.mangoPay.businessRequirement); + await this.click(woocommerceSettings.dokanMangoPay.typeOfVendors); + await this.setDropdownOptionSpan(woocommerceSettings.dokanMangoPay.typeOfVendorsValues, payment.mangoPay.typeOfVendors); + await this.click(woocommerceSettings.dokanMangoPay.businessRequirement); + await this.setDropdownOptionSpan(woocommerceSettings.dokanMangoPay.businessRequirementValues, payment.mangoPay.businessRequirement); // Advanced Settings - await this.check(selector.admin.wooCommerce.settings.dokanMangoPay.displayNoticeToNonConnectedSellers); - await this.check(selector.admin.wooCommerce.settings.dokanMangoPay.sendAnnouncementToNonConnectedSellers); - await this.clearAndType(selector.admin.wooCommerce.settings.dokanMangoPay.announcementInterval, payment.mangoPay.announcementInterval); - await this.click(selector.admin.wooCommerce.settings.dokanMangoPay.dokanMangopaySaveChanges); + await this.check(woocommerceSettings.dokanMangoPay.displayNoticeToNonConnectedSellers); + await this.check(woocommerceSettings.dokanMangoPay.sendAnnouncementToNonConnectedSellers); + await this.clearAndType(woocommerceSettings.dokanMangoPay.announcementInterval, payment.mangoPay.announcementInterval); + await this.click(woocommerceSettings.dokanMangoPay.dokanMangopaySaveChanges); - await this.toContainText(selector.admin.wooCommerce.settings.updatedSuccessMessage, payment.saveSuccessMessage); + await this.toContainText(woocommerceSettings.updatedSuccessMessage, payment.saveSuccessMessage); } // Admin Setup Razorpay @@ -140,25 +144,25 @@ export class PaymentsPage extends AdminPage { await this.setCurrency(payment.currency.rupee); - await this.click(selector.admin.wooCommerce.settings.payments); - await this.click(selector.admin.wooCommerce.settings.setupDokanRazorpay); + await this.click(woocommerceSettings.payments); + await this.click(woocommerceSettings.setupDokanRazorpay); // Setup Razorpay - await this.check(selector.admin.wooCommerce.settings.dokanRazorpay.enableDisableDokanRazorpay); - await this.clearAndType(selector.admin.wooCommerce.settings.dokanRazorpay.title, payment.razorPay.title); - await this.clearAndType(selector.admin.wooCommerce.settings.dokanRazorpay.description, payment.razorPay.description); + await this.check(woocommerceSettings.dokanRazorpay.enableDisableDokanRazorpay); + await this.clearAndType(woocommerceSettings.dokanRazorpay.title, payment.razorPay.title); + await this.clearAndType(woocommerceSettings.dokanRazorpay.description, payment.razorPay.description); // API Credentials - await this.check(selector.admin.wooCommerce.settings.dokanRazorpay.razorpaySandbox); - await this.clearAndType(selector.admin.wooCommerce.settings.dokanRazorpay.testKeyId, payment.razorPay.testKeyId); - await this.clearAndType(selector.admin.wooCommerce.settings.dokanRazorpay.testKeySecret, payment.razorPay.testKeySecret); - await this.click(selector.admin.wooCommerce.settings.dokanRazorpay.disbursementMode); - await this.setDropdownOptionSpan(selector.admin.wooCommerce.settings.dokanRazorpay.disbursementModeValues, payment.razorPay.disbursementMode); - await this.check(selector.admin.wooCommerce.settings.dokanRazorpay.sellerPaysTheProcessingFee); - await this.check(selector.admin.wooCommerce.settings.dokanRazorpay.displayNoticeToConnectSeller); - await this.check(selector.admin.wooCommerce.settings.dokanRazorpay.sendAnnouncementToConnectSeller); - await this.clearAndType(selector.admin.wooCommerce.settings.dokanRazorpay.sendAnnouncementInterval, payment.razorPay.announcementInterval); - await this.click(selector.admin.wooCommerce.settings.dokanRazorpay.dokanRazorpaySaveChanges); - - await this.toContainText(selector.admin.wooCommerce.settings.updatedSuccessMessage, payment.saveSuccessMessage); + await this.check(woocommerceSettings.dokanRazorpay.razorpaySandbox); + await this.clearAndType(woocommerceSettings.dokanRazorpay.testKeyId, payment.razorPay.testKeyId); + await this.clearAndType(woocommerceSettings.dokanRazorpay.testKeySecret, payment.razorPay.testKeySecret); + await this.click(woocommerceSettings.dokanRazorpay.disbursementMode); + await this.setDropdownOptionSpan(woocommerceSettings.dokanRazorpay.disbursementModeValues, payment.razorPay.disbursementMode); + await this.check(woocommerceSettings.dokanRazorpay.sellerPaysTheProcessingFee); + await this.check(woocommerceSettings.dokanRazorpay.displayNoticeToConnectSeller); + await this.check(woocommerceSettings.dokanRazorpay.sendAnnouncementToConnectSeller); + await this.clearAndType(woocommerceSettings.dokanRazorpay.sendAnnouncementInterval, payment.razorPay.announcementInterval); + await this.click(woocommerceSettings.dokanRazorpay.dokanRazorpaySaveChanges); + + await this.toContainText(woocommerceSettings.updatedSuccessMessage, payment.saveSuccessMessage); } // Admin Setup Stripe Express @@ -167,44 +171,44 @@ export class PaymentsPage extends AdminPage { await this.setCurrency(payment.currency.dollar); - await this.click(selector.admin.wooCommerce.settings.payments); - await this.click(selector.admin.wooCommerce.settings.setupDokanStripeExpress); + await this.click(woocommerceSettings.payments); + await this.click(woocommerceSettings.setupDokanStripeExpress); // Stripe Express - await this.check(selector.admin.wooCommerce.settings.stripeExpress.enableOrDisableStripeExpress); - await this.clearAndType(selector.admin.wooCommerce.settings.stripeExpress.title, payment.stripeExpress.title); - await this.clearAndType(selector.admin.wooCommerce.settings.stripeExpress.description, payment.stripeExpress.description); + await this.check(woocommerceSettings.stripeExpress.enableOrDisableStripeExpress); + await this.clearAndType(woocommerceSettings.stripeExpress.title, payment.stripeExpress.title); + await this.clearAndType(woocommerceSettings.stripeExpress.description, payment.stripeExpress.description); // API Credentials - await this.check(selector.admin.wooCommerce.settings.stripeExpress.testMode); - await this.clearAndType(selector.admin.wooCommerce.settings.stripeExpress.testPublishableKey, payment.stripeExpress.testPublishableKey); - await this.clearAndType(selector.admin.wooCommerce.settings.stripeExpress.testSecretKey, payment.stripeExpress.testSecretKey); - await this.clearAndType(selector.admin.wooCommerce.settings.stripeExpress.testWebhookSecret, payment.stripeExpress.testWebhookSecret); + await this.check(woocommerceSettings.stripeExpress.testMode); + await this.clearAndType(woocommerceSettings.stripeExpress.testPublishableKey, payment.stripeExpress.testPublishableKey); + await this.clearAndType(woocommerceSettings.stripeExpress.testSecretKey, payment.stripeExpress.testSecretKey); + await this.clearAndType(woocommerceSettings.stripeExpress.testWebhookSecret, payment.stripeExpress.testWebhookSecret); // Payment and Disbursement - await this.click(selector.admin.wooCommerce.settings.stripeExpress.choosePaymentMethods); - await this.setDropdownOptionSpan(selector.admin.wooCommerce.settings.stripeExpress.choosePaymentMethodsValues, payment.stripeExpress.paymentMethods.card); - await this.click(selector.admin.wooCommerce.settings.stripeExpress.choosePaymentMethods); - await this.setDropdownOptionSpan(selector.admin.wooCommerce.settings.stripeExpress.choosePaymentMethodsValues, payment.stripeExpress.paymentMethods.ideal); - await this.check(selector.admin.wooCommerce.settings.stripeExpress.takeProcessingFeesFromSellers); - await this.check(selector.admin.wooCommerce.settings.stripeExpress.savedCards); - await this.check(selector.admin.wooCommerce.settings.stripeExpress.capturePaymentsManually); - await this.click(selector.admin.wooCommerce.settings.stripeExpress.disburseFunds); - await this.setDropdownOptionSpan(selector.admin.wooCommerce.settings.stripeExpress.disbursementModeValues, payment.stripeExpress.disbursementMode); - await this.clearAndType(selector.admin.wooCommerce.settings.stripeExpress.customerBankStatement, payment.stripeExpress.customerBankStatement); + await this.click(woocommerceSettings.stripeExpress.choosePaymentMethods); + await this.setDropdownOptionSpan(woocommerceSettings.stripeExpress.choosePaymentMethodsValues, payment.stripeExpress.paymentMethods.card); + await this.click(woocommerceSettings.stripeExpress.choosePaymentMethods); + await this.setDropdownOptionSpan(woocommerceSettings.stripeExpress.choosePaymentMethodsValues, payment.stripeExpress.paymentMethods.ideal); + await this.check(woocommerceSettings.stripeExpress.takeProcessingFeesFromSellers); + await this.check(woocommerceSettings.stripeExpress.savedCards); + await this.check(woocommerceSettings.stripeExpress.capturePaymentsManually); + await this.click(woocommerceSettings.stripeExpress.disburseFunds); + await this.setDropdownOptionSpan(woocommerceSettings.stripeExpress.disbursementModeValues, payment.stripeExpress.disbursementMode); + await this.clearAndType(woocommerceSettings.stripeExpress.customerBankStatement, payment.stripeExpress.customerBankStatement); // Payment Request Options (Apple Pay/Google Pay) - await this.check(selector.admin.wooCommerce.settings.stripeExpress.paymentRequestButtons); - await this.selectByValue(selector.admin.wooCommerce.settings.stripeExpress.buttonType, payment.stripeExpress.paymentRequestButtonType); - await this.selectByValue(selector.admin.wooCommerce.settings.stripeExpress.buttonTheme, payment.stripeExpress.paymentRequestButtonTheme); - await this.click(selector.admin.wooCommerce.settings.stripeExpress.buttonLocations); - await this.setDropdownOptionSpan(selector.admin.wooCommerce.settings.stripeExpress.buttonLocationsValues, payment.stripeExpress.paymentRequestButtonLocation.product); - await this.click(selector.admin.wooCommerce.settings.stripeExpress.buttonLocations); - await this.setDropdownOptionSpan(selector.admin.wooCommerce.settings.stripeExpress.buttonLocationsValues, payment.stripeExpress.paymentRequestButtonLocation.cart); + await this.check(woocommerceSettings.stripeExpress.paymentRequestButtons); + await this.selectByValue(woocommerceSettings.stripeExpress.buttonType, payment.stripeExpress.paymentRequestButtonType); + await this.selectByValue(woocommerceSettings.stripeExpress.buttonTheme, payment.stripeExpress.paymentRequestButtonTheme); + await this.click(woocommerceSettings.stripeExpress.buttonLocations); + await this.setDropdownOptionSpan(woocommerceSettings.stripeExpress.buttonLocationsValues, payment.stripeExpress.paymentRequestButtonLocation.product); + await this.click(woocommerceSettings.stripeExpress.buttonLocations); + await this.setDropdownOptionSpan(woocommerceSettings.stripeExpress.buttonLocationsValues, payment.stripeExpress.paymentRequestButtonLocation.cart); // Advanced Settings - await this.check(selector.admin.wooCommerce.settings.stripeExpress.displayNoticeToNonConnectedSellers); - await this.check(selector.admin.wooCommerce.settings.stripeExpress.sendAnnouncementToNonConnectedSellers); - await this.clearAndType(selector.admin.wooCommerce.settings.stripeExpress.announcementInterval, payment.stripeExpress.announcementInterval); - await this.click(selector.admin.wooCommerce.settings.stripeExpress.stripeExpressSaveChanges); + await this.check(woocommerceSettings.stripeExpress.displayNoticeToNonConnectedSellers); + await this.check(woocommerceSettings.stripeExpress.sendAnnouncementToNonConnectedSellers); + await this.clearAndType(woocommerceSettings.stripeExpress.announcementInterval, payment.stripeExpress.announcementInterval); + await this.click(woocommerceSettings.stripeExpress.stripeExpressSaveChanges); - await this.toContainText(selector.admin.wooCommerce.settings.updatedSuccessMessage, payment.saveSuccessMessage); + await this.toContainText(woocommerceSettings.updatedSuccessMessage, payment.saveSuccessMessage); } // vendor @@ -214,14 +218,14 @@ export class PaymentsPage extends AdminPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsPayment); // paymentMethod text is visible - await this.toBeVisible(selector.vendor.vPaymentSettings.paymentMethodText); + await this.toBeVisible(paymentSettingsVendor.paymentMethodText); // paymentMethods summary div is visible - await this.toBeVisible(selector.vendor.vPaymentSettings.paymentMethods.paymentMethodsDiv); + await this.toBeVisible(paymentSettingsVendor.paymentMethods.paymentMethodsDiv); // paymentMethods dropdown is visible - await this.toBeVisible(selector.vendor.vPaymentSettings.paymentMethods.addPaymentMethodDropDown); + await this.toBeVisible(paymentSettingsVendor.paymentMethods.addPaymentMethodDropDown); - await this.notToHaveCount(selector.vendor.vPaymentSettings.paymentMethods.noOfPaymentMethods, 0); + await this.notToHaveCount(paymentSettingsVendor.paymentMethods.noOfPaymentMethods, 0); } // vendor set basic payment settings @@ -251,28 +255,28 @@ export class PaymentsPage extends AdminPage { break; } - await this.clearAndType(selector.vendor.vPaymentSettings.paymentEmail, paymentMethod.email()); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vPaymentSettings.updateSettings); - await this.toContainText(selector.vendor.vPaymentSettings.updateSettingsSuccessMessage, paymentMethod.saveSuccessMessage); + await this.clearAndType(paymentSettingsVendor.paymentEmail, paymentMethod.email()); + await this.clickAndWaitForResponse(data.subUrls.ajax, paymentSettingsVendor.updateSettings); + await this.toContainText(paymentSettingsVendor.updateSettingsSuccessMessage, paymentMethod.saveSuccessMessage); } // bank transfer payment settings async setBankTransfer(paymentMethod: vendor['payment']): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.bankTransfer); - await this.clickIfVisible(selector.vendor.vPaymentSettings.disconnectAccount); - await this.clearAndType(selector.vendor.vPaymentSettings.bankAccountName, paymentMethod.bankAccountName); - await this.selectByValue(selector.vendor.vPaymentSettings.bankAccountType, paymentMethod.bankAccountType); - await this.clearAndType(selector.vendor.vPaymentSettings.bankAccountNumber, paymentMethod.bankAccountNumber); - await this.clearAndType(selector.vendor.vPaymentSettings.bankRoutingNumber, paymentMethod.bankRoutingNumber); - await this.clearAndType(selector.vendor.vPaymentSettings.bankName, paymentMethod.bankName); - await this.clearAndType(selector.vendor.vPaymentSettings.bankAddress, paymentMethod.bankAddress); - await this.clearAndType(selector.vendor.vPaymentSettings.bankIban, paymentMethod.bankIban); - await this.clearAndType(selector.vendor.vPaymentSettings.bankSwiftCode, paymentMethod.bankSwiftCode); + await this.clickIfVisible(paymentSettingsVendor.disconnectAccount); + await this.clearAndType(paymentSettingsVendor.bankAccountName, paymentMethod.bankAccountName); + await this.selectByValue(paymentSettingsVendor.bankAccountType, paymentMethod.bankAccountType); + await this.clearAndType(paymentSettingsVendor.bankAccountNumber, paymentMethod.bankAccountNumber); + await this.clearAndType(paymentSettingsVendor.bankRoutingNumber, paymentMethod.bankRoutingNumber); + await this.clearAndType(paymentSettingsVendor.bankName, paymentMethod.bankName); + await this.clearAndType(paymentSettingsVendor.bankAddress, paymentMethod.bankAddress); + await this.clearAndType(paymentSettingsVendor.bankIban, paymentMethod.bankIban); + await this.clearAndType(paymentSettingsVendor.bankSwiftCode, paymentMethod.bankSwiftCode); await this.check(selector.vendor.vSetup.declaration); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vPaymentSettings.addAccount); - await this.toContainText(selector.vendor.vPaymentSettings.updateSettingsSuccessMessage, paymentMethod.saveSuccessMessage); + await this.clickAndWaitForResponse(data.subUrls.ajax, paymentSettingsVendor.addAccount); + await this.toContainText(paymentSettingsVendor.updateSettingsSuccessMessage, paymentMethod.saveSuccessMessage); } // disconnect basic payment method [paypal, skrill, custom ] @@ -298,64 +302,7 @@ export class PaymentsPage extends AdminPage { break; } - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vPaymentSettings.disconnectPayment); - await this.toContainText(selector.vendor.vPaymentSettings.updateSettingsSuccessMessage, paymentMethod.saveSuccessMessage); + await this.clickAndWaitForResponse(data.subUrls.ajax, paymentSettingsVendor.disconnectPayment); + await this.toContainText(paymentSettingsVendor.updateSettingsSuccessMessage, paymentMethod.saveSuccessMessage); } - - // // paypal payment settings - // async setPaypal(paymentMethod: vendor['payment']): Promise { - // await this.goIfNotThere(data.subUrls.frontend.vDashboard.paypal); - // await this.clearAndType(selector.vendor.vPaymentSettings.paypal, paymentMethod.email()); - // await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vPaymentSettings.updateSettings); - // await this.toContainText(selector.vendor.vPaymentSettings.updateSettingsSuccessMessage, paymentMethod.saveSuccessMessage); - // } - - // // skrill Payment Settings - // async setSkrill(paymentMethod: vendor['payment']): Promise { - - // await this.clearAndType(selector.vendor.vPaymentSettings.skrill, paymentMethod.email()); - // await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vPaymentSettings.updateSettings); - // await this.toContainText(selector.vendor.vPaymentSettings.updateSettingsSuccessMessage, paymentMethod.saveSuccessMessage); - // } - - // // custom payment settings - // async setCustom(paymentMethod: vendor['payment']): Promise { - - // await this.clearAndType(selector.vendor.vPaymentSettings.customPayment, paymentMethod.email()); - // await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vPaymentSettings.updateSettings); - // await this.toContainText(selector.vendor.vPaymentSettings.updateSettingsSuccessMessage, paymentMethod.saveSuccessMessage); - // } - - // // stripe payment settings - // async setStripe(email): Promise { - // // Stripe - // await this.click(selector.vendor.vPaymentSettings.ConnectWithStripe); - // } - - // // paypal marketPlace payment settings - // async setPaypalMarketPlace(email): Promise { - // // paypal Marketplace - // await this.clearAndType(selector.vendor.vPaymentSettings.paypalMarketplace, paypalMarketplace); - // await this.click(selector.vendor.vPaymentSettings.paypalMarketplaceSignUp); - // } - - // // razorpay payment settings - // async setRazorpay(razorpay): Promise { - // // razorpay - // await this.click(selector.vendor.vPaymentSettings.rzSignup); - // // existing account info - // await this.click(selector.vendor.vPaymentSettings.rzIHaveAlreadyAnAccount); - // await this.clearAndType(selector.vendor.vPaymentSettings.rzAccountId, rzAccountId); - // await this.click(selector.vendor.vPaymentSettings.rzConnectExistingAccount); - // //new account info - // await this.clearAndType(selector.vendor.vPaymentSettings.rzAccountName, rzAccountName); - // await this.clearAndType(selector.vendor.vPaymentSettings.rzAccountEmail, rzAccountEmail); - // await this.clearAndType(selector.vendor.vPaymentSettings.rzYourCompanyName, rzYourCompanyName); - // await this.clearAndType(selector.vendor.vPaymentSettings.rzYourCompanyType, rzYourCompanyType); - // await this.clearAndType(selector.vendor.vPaymentSettings.rzBankAccountName, rzBankAccountName); - // await this.clearAndType(selector.vendor.vPaymentSettings.rzBankAccountNumber, rzBankAccountNumber); - // await this.clearAndType(selector.vendor.vPaymentSettings.rzBankIfscCode, rzBankIfscCode); - // await this.clearAndType(selector.vendor.vPaymentSettings.rzBankAccountType, rzBankAccountType); - // await this.click(selector.vendor.vPaymentSettings.rzConnectAccount); - // } } diff --git a/tests/pw/pages/pluginPage.ts b/tests/pw/pages/pluginPage.ts index 1d6d2cf5aa..e2c6ba3d20 100644 --- a/tests/pw/pages/pluginPage.ts +++ b/tests/pw/pages/pluginPage.ts @@ -4,6 +4,9 @@ import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; import { helpers } from '@utils/helpers'; +// selectors +const pluginsAdmin = selector.admin.plugins; + export class PluginPage extends BasePage { constructor(page: Page) { super(page); @@ -18,32 +21,32 @@ export class PluginPage extends BasePage { // activate plugin async activatePlugin(plugin: string) { await this.goToPlugins(); - await this.clickAndAcceptAndWaitForResponseAndLoadState(data.subUrls.backend.activatePlugin, selector.admin.plugins.activatePlugin(plugin), 302); - await this.toBeVisible(selector.admin.plugins.deactivatePlugin(plugin)); + await this.clickAndAcceptAndWaitForResponseAndLoadState(data.subUrls.backend.activatePlugin, pluginsAdmin.activatePlugin(plugin), 302); + await this.toBeVisible(pluginsAdmin.deactivatePlugin(plugin)); } // deactivate plugin [only work for plugins which doesn't have deactivation popup] async deactivatePlugin(plugin: string) { await this.goToPlugins(); - await this.clickAndAcceptAndWaitForResponseAndLoadState(data.subUrls.backend.deactivatePlugin, selector.admin.plugins.deactivatePlugin(plugin), 302); - await this.toBeVisible(selector.admin.plugins.activatePlugin(plugin)); + await this.clickAndAcceptAndWaitForResponseAndLoadState(data.subUrls.backend.deactivatePlugin, pluginsAdmin.deactivatePlugin(plugin), 302); + await this.toBeVisible(pluginsAdmin.activatePlugin(plugin)); } // deactivate dokan plugin async deactivateDokanPlugin(plugin: string, submitReason: boolean) { await this.goToPlugins(); - await this.click(selector.admin.plugins.deactivatePlugin(plugin)); - const isDeactivateModalVisible = await this.isVisible(selector.admin.plugins.deactivateReason.deactivateReasonModal(plugin)); + await this.click(pluginsAdmin.deactivatePlugin(plugin)); + const isDeactivateModalVisible = await this.isVisible(pluginsAdmin.deactivateReason.deactivateReasonModal(plugin)); console.log(isDeactivateModalVisible); if (isDeactivateModalVisible) { if (submitReason) { - await this.click(selector.admin.plugins.deactivateReason.reason(helpers.getRandomNumber(1, 7))); - await this.clickAndAcceptAndWaitForResponseAndLoadState(data.subUrls.backend.deactivatePlugin, selector.admin.plugins.deactivateReason.submitAndDeactivate, 302); + await this.click(pluginsAdmin.deactivateReason.reason(helpers.getRandomNumber(1, 7))); + await this.clickAndAcceptAndWaitForResponseAndLoadState(data.subUrls.backend.deactivatePlugin, pluginsAdmin.deactivateReason.submitAndDeactivate, 302); } else { - await this.clickAndAcceptAndWaitForResponseAndLoadState(data.subUrls.backend.deactivatePlugin, selector.admin.plugins.deactivateReason.skipAndDeactivate, 302); + await this.clickAndAcceptAndWaitForResponseAndLoadState(data.subUrls.backend.deactivatePlugin, pluginsAdmin.deactivateReason.skipAndDeactivate, 302); } - await this.toBeVisible(selector.admin.plugins.activatePlugin(plugin)); + await this.toBeVisible(pluginsAdmin.activatePlugin(plugin)); } } } diff --git a/tests/pw/pages/privacyPolicyPage.ts b/tests/pw/pages/privacyPolicyPage.ts index 6fd3d60df5..33edbe2a27 100644 --- a/tests/pw/pages/privacyPolicyPage.ts +++ b/tests/pw/pages/privacyPolicyPage.ts @@ -5,6 +5,9 @@ import { helpers } from '@utils/helpers'; import { data } from '@utils/testData'; import { storeContactData } from '@utils/interfaces'; +// selectors +const singleStoreCustomer = selector.customer.cSingleStore; + export class PrivacyPolicy extends BasePage { constructor(page: Page) { super(page); @@ -13,30 +16,30 @@ export class PrivacyPolicy extends BasePage { // contact vendor async contactVendor(storeName: string, storeContactData: storeContactData) { await this.goIfNotThere(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName))); - await this.clearAndType(selector.customer.cSingleStore.storeContactForm.name, storeContactData.name); - await this.clearAndType(selector.customer.cSingleStore.storeContactForm.email, storeContactData.email); - await this.clearAndType(selector.customer.cSingleStore.storeContactForm.message, storeContactData.message); - await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, selector.customer.cSingleStore.storeContactForm.sendMessage); - await this.toContainText(selector.customer.cSingleStore.storeContactForm.successMessage, 'Email sent successfully!'); + await this.clearAndType(singleStoreCustomer.storeContactForm.name, storeContactData.name); + await this.clearAndType(singleStoreCustomer.storeContactForm.email, storeContactData.email); + await this.clearAndType(singleStoreCustomer.storeContactForm.message, storeContactData.message); + await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, singleStoreCustomer.storeContactForm.sendMessage); + await this.toContainText(singleStoreCustomer.storeContactForm.successMessage, 'Email sent successfully!'); } // go to privacy policy async goToPrivacyPolicy(storeName: string) { await this.goIfNotThere(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName))); // ensure page suppose to open on new tab - await this.toHaveAttribute(selector.customer.cSingleStore.storeContactForm.privacyPolicyLink, 'target', '_blank'); + await this.toHaveAttribute(singleStoreCustomer.storeContactForm.privacyPolicyLink, 'target', '_blank'); // force page to open on same tab - await this.setAttributeValue(selector.customer.cSingleStore.storeContactForm.privacyPolicyLink, 'target', '_self'); - await this.clickAndWaitForUrl(helpers.stringToRegex('privacy-policy'), selector.customer.cSingleStore.storeContactForm.privacyPolicyLink); + await this.setAttributeValue(singleStoreCustomer.storeContactForm.privacyPolicyLink, 'target', '_self'); + await this.clickAndWaitForUrl(helpers.stringToRegex('privacy-policy'), singleStoreCustomer.storeContactForm.privacyPolicyLink); } async disablePrivacyPolicy(storeName: string) { await this.goIfNotThere(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName))); - await this.notToBeVisible(selector.customer.cSingleStore.storeContactForm.privacyPolicy); + await this.notToBeVisible(singleStoreCustomer.storeContactForm.privacyPolicy); } async disableStoreContactForm(storeName: string) { await this.goto(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName))); - await this.notToBeVisible(selector.customer.cSingleStore.storeContactForm.storeContactForm); + await this.notToBeVisible(singleStoreCustomer.storeContactForm.storeContactForm); } } diff --git a/tests/pw/pages/productAddonsPage.ts b/tests/pw/pages/productAddonsPage.ts index a71d8bc8a3..d993c3f15e 100644 --- a/tests/pw/pages/productAddonsPage.ts +++ b/tests/pw/pages/productAddonsPage.ts @@ -4,6 +4,9 @@ import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; import { vendor } from '@utils/interfaces'; +// selectors +const addonsVendor = selector.vendor.vAddonSettings; + export class ProductAddonsPage extends VendorPage { constructor(page: Page) { super(page); @@ -14,78 +17,79 @@ export class ProductAddonsPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsAddon); // product addon text is visible - await this.toBeVisible(selector.vendor.vAddonSettings.productAddonsText); + await this.toBeVisible(addonsVendor.productAddonsText); // visit store link is visible - await this.toBeVisible(selector.vendor.vAddonSettings.visitStore); + await this.toBeVisible(addonsVendor.visitStore); // create new addon text is visible - await this.toBeVisible(selector.vendor.vAddonSettings.createNewAddon); + await this.toBeVisible(addonsVendor.createNewAddon); - // create new text is visible - await this.toBeVisible(selector.vendor.vAddonSettings.createNew); + // create new text is visible + await this.toBeVisible(addonsVendor.createNew); // product addon table elements are visible - await this.multipleElementVisible(selector.vendor.vAddonSettings.table); + await this.multipleElementVisible(addonsVendor.table); - await this.click(selector.vendor.vAddonSettings.createNewAddon); - await this.click(selector.vendor.vAddonSettings.addon.addField); - await this.check(selector.vendor.vAddonSettings.addon.enableDescription); + await this.clickAndWaitForLoadState(addonsVendor.createNewAddon); + await this.click(addonsVendor.addon.addField); + await this.check(addonsVendor.addon.enableDescription); // product addon fields elements are visible - const { addonFieldsRow, addonUpdateSuccessMessage, ...addonFields } = selector.vendor.vAddonSettings.addon; + const { result, addonFieldsRow, addonUpdateSuccessMessage, ...addonFields } = addonsVendor.addon; await this.multipleElementVisible(addonFields); - await this.clickAndWaitForLoadState(selector.vendor.vAddonSettings.backToAddonLists); + await this.clickAndWaitForLoadState(addonsVendor.backToAddonLists); } // update addon fields async updateAddonFields(addon: vendor['addon'], add = true) { - await this.clearAndType(selector.vendor.vAddonSettings.addon.name, addon.name); - await this.clearAndType(selector.vendor.vAddonSettings.addon.priority, addon.priority); + await this.clearAndType(addonsVendor.addon.name, addon.name); + await this.clearAndType(addonsVendor.addon.priority, addon.priority); // skipped category - // await this.click(selector.vendor.vAddonSettings.addon.productCategories); - // await this.clearAndType(selector.vendor.vAddonSettings.addon.productCategories, addon.category); - // await this.press(data.key.enter); - - add ? await this.click(selector.vendor.vAddonSettings.addon.addField) : await this.click(selector.vendor.vAddonSettings.addon.addonFieldsRow('Add-on Title')); - - await this.selectByValue(selector.vendor.vAddonSettings.addon.type, addon.type); - await this.selectByValue(selector.vendor.vAddonSettings.addon.displayAs, addon.displayAs); - await this.clearAndType(selector.vendor.vAddonSettings.addon.titleRequired, addon.titleRequired); - await this.selectByValue(selector.vendor.vAddonSettings.addon.formatTitle, addon.formatTitle); - await this.check(selector.vendor.vAddonSettings.addon.enableDescription); - await this.clearAndType(selector.vendor.vAddonSettings.addon.addDescription, addon.addDescription); - // await this.click(selector.vendor.vAddonSettings.addon.requiredField); - await this.clearAndType(selector.vendor.vAddonSettings.addon.enterAnOption, addon.enterAnOption); - await this.selectByValue(selector.vendor.vAddonSettings.addon.optionPriceType, addon.optionPriceType); - await this.clearAndType(selector.vendor.vAddonSettings.addon.optionPriceInput, addon.optionPriceInput); - - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.settingsAddon, selector.vendor.vAddonSettings.addon.publishOrUpdate); - await this.toContainText(selector.vendor.vAddonSettings.addon.addonUpdateSuccessMessage, addon.saveSuccessMessage); + await this.click(addonsVendor.addon.productCategories); + await this.clearAndType(addonsVendor.addon.productCategories, addon.category); + await this.toContainText(addonsVendor.addon.result, addon.category); + await this.press(data.key.enter); + + add ? await this.click(addonsVendor.addon.addField) : await this.click(addonsVendor.addon.addonFieldsRow('Add-on Title')); + + await this.selectByValue(addonsVendor.addon.type, addon.type); + await this.selectByValue(addonsVendor.addon.displayAs, addon.displayAs); + await this.clearAndType(addonsVendor.addon.titleRequired, addon.title); + await this.selectByValue(addonsVendor.addon.formatTitle, addon.formatTitle); + await this.check(addonsVendor.addon.enableDescription); + await this.clearAndType(addonsVendor.addon.addDescription, addon.addDescription); + // await this.click(addonsVendor.addon.requiredField); + await this.clearAndType(addonsVendor.addon.enterAnOption, addon.enterAnOption); + await this.selectByValue(addonsVendor.addon.optionPriceType, addon.optionPriceType); + await this.clearAndType(addonsVendor.addon.optionPriceInput, addon.optionPriceInput); + + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.settingsAddon, addonsVendor.addon.publishOrUpdate); + await this.toContainText(addonsVendor.addon.addonUpdateSuccessMessage, addon.saveSuccessMessage); } // add addon async addAddon(addon: vendor['addon']) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsAddon); - await this.click(selector.vendor.vAddonSettings.createNewAddon); + await this.clickAndWaitForLoadState(addonsVendor.createNewAddon); await this.updateAddonFields(addon); } // edit addon async editAddon(addon: vendor['addon']): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsAddon); - await this.hover(selector.vendor.vAddonSettings.addonRow(addon.name)); - await this.clickAndWaitForLoadState(selector.vendor.vAddonSettings.editAddon(addon.name)); + await this.hover(addonsVendor.addonRow(addon.name)); + await this.clickAndWaitForLoadState(addonsVendor.editAddon(addon.name)); await this.updateAddonFields(addon, false); } // delete addon async deleteAddon(addon: vendor['addon']): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsAddon); - await this.hover(selector.vendor.vAddonSettings.addonRow(addon.name)); - await this.clickAndWaitForLoadState(selector.vendor.vAddonSettings.deleteAddon(addon.name)); - await this.toContainText(selector.vendor.vAddonSettings.addon.addonUpdateSuccessMessage, addon.deleteSuccessMessage); + await this.hover(addonsVendor.addonRow(addon.name)); + await this.clickAndWaitForLoadState(addonsVendor.deleteAddon(addon.name)); + await this.toContainText(addonsVendor.addon.addonUpdateSuccessMessage, addon.deleteSuccessMessage); } } diff --git a/tests/pw/pages/productAdvertisingPage.ts b/tests/pw/pages/productAdvertisingPage.ts index 40765115bb..a42d732f08 100644 --- a/tests/pw/pages/productAdvertisingPage.ts +++ b/tests/pw/pages/productAdvertisingPage.ts @@ -4,6 +4,9 @@ import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; import { productAdvertisement } from '@utils/interfaces'; +// selectors +const productAdvertisingAdmin = selector.admin.dokan.productAdvertising; + export class ProductAdvertisingPage extends AdminPage { constructor(page: Page) { super(page); @@ -24,68 +27,68 @@ export class ProductAdvertisingPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.productAdvertising); // product advertising text is visible - await this.toBeVisible(selector.admin.dokan.productAdvertising.productAdvertisingText); + await this.toBeVisible(productAdvertisingAdmin.productAdvertisingText); // add new Advertisement is visible - await this.toBeVisible(selector.admin.dokan.productAdvertising.addNewProductAdvertising); + await this.toBeVisible(productAdvertisingAdmin.addNewProductAdvertising); // nav tabs are visible - await this.multipleElementVisible(selector.admin.dokan.productAdvertising.navTabs); + await this.multipleElementVisible(productAdvertisingAdmin.navTabs); // bulk action elements are visible - await this.multipleElementVisible(selector.admin.dokan.productAdvertising.bulkActions); + await this.multipleElementVisible(productAdvertisingAdmin.bulkActions); // filter elements are visible - const { filterByStoreInput, filterByCreatedVia, ...filters } = selector.admin.dokan.productAdvertising.filters; + const { filterByStoreInput, filterByCreatedVia, ...filters } = productAdvertisingAdmin.filters; await this.multipleElementVisible(filters); // product advertising search is visible - await this.toBeVisible(selector.admin.dokan.productAdvertising.search); + await this.toBeVisible(productAdvertisingAdmin.search); // product advertising table elements are visible - await this.multipleElementVisible(selector.admin.dokan.productAdvertising.table); + await this.multipleElementVisible(productAdvertisingAdmin.table); // product advertising modal elements are visible - await this.click(selector.admin.dokan.productAdvertising.addNewProductAdvertising); - await this.toBeVisible(selector.admin.dokan.productAdvertising.addNewAdvertisement.selectStoreDropdown); - await this.toBeVisible(selector.admin.dokan.productAdvertising.addNewAdvertisement.selectProductDropdown); - await this.click(selector.admin.dokan.productAdvertising.addNewAdvertisement.closeModal); + await this.click(productAdvertisingAdmin.addNewProductAdvertising); + await this.toBeVisible(productAdvertisingAdmin.addNewAdvertisement.selectStoreDropdown); + await this.toBeVisible(productAdvertisingAdmin.addNewAdvertisement.selectProductDropdown); + await this.click(productAdvertisingAdmin.addNewAdvertisement.closeModal); } // add new product advertisement async addNewProductAdvertisement(advertising: productAdvertisement) { await this.goIfNotThere(data.subUrls.backend.dokan.productAdvertising); - await this.click(selector.admin.dokan.productAdvertising.addNewProductAdvertising); + await this.click(productAdvertisingAdmin.addNewProductAdvertising); - await this.click(selector.admin.dokan.productAdvertising.addNewAdvertisement.selectStoreDropdown); - await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, selector.admin.dokan.productAdvertising.addNewAdvertisement.selectStoreInput, advertising.advertisedProductStore); - await this.toContainText(selector.admin.dokan.productAdvertising.addNewAdvertisement.selectedStore, advertising.advertisedProductStore); + await this.click(productAdvertisingAdmin.addNewAdvertisement.selectStoreDropdown); + await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, productAdvertisingAdmin.addNewAdvertisement.selectStoreInput, advertising.advertisedProductStore); + await this.toContainText(productAdvertisingAdmin.addNewAdvertisement.selectedStore, advertising.advertisedProductStore); await this.press(data.key.enter); - await this.click(selector.admin.dokan.productAdvertising.addNewAdvertisement.selectProductDropdown); - await this.typeAndWaitForResponse(data.subUrls.api.dokan.products, selector.admin.dokan.productAdvertising.addNewAdvertisement.selectProductInput, advertising.advertisedProduct); - await this.toContainText(selector.admin.dokan.productAdvertising.addNewAdvertisement.selectedProduct, advertising.advertisedProduct); + await this.click(productAdvertisingAdmin.addNewAdvertisement.selectProductDropdown); + await this.typeAndWaitForResponse(data.subUrls.api.dokan.products, productAdvertisingAdmin.addNewAdvertisement.selectProductInput, advertising.advertisedProduct); + await this.toContainText(productAdvertisingAdmin.addNewAdvertisement.selectedProduct, advertising.advertisedProduct); await this.press(data.key.enter); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.productAdvertising, selector.admin.dokan.productAdvertising.addNewAdvertisement.addNew); - await this.click(selector.admin.dokan.productAdvertising.actionSuccessful); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.productAdvertising, productAdvertisingAdmin.addNewAdvertisement.addNew); + await this.click(productAdvertisingAdmin.actionSuccessful); // close modal - await this.click(selector.admin.dokan.productAdvertising.addNewAdvertisement.closeModal); + await this.click(productAdvertisingAdmin.addNewAdvertisement.closeModal); } // search advertised product async searchAdvertisedProduct(productOrOrder: string | number) { await this.goIfNotThere(data.subUrls.backend.dokan.productAdvertising); - await this.clearInputField(selector.admin.dokan.productAdvertising.search); + await this.clearInputField(productAdvertisingAdmin.search); - await this.typeAndWaitForResponseAndLoadState(data.subUrls.api.dokan.productAdvertising, selector.admin.dokan.productAdvertising.search, String(productOrOrder)); + await this.typeAndWaitForResponseAndLoadState(data.subUrls.api.dokan.productAdvertising, productAdvertisingAdmin.search, String(productOrOrder)); if (typeof productOrOrder != 'number') { - await this.toBeVisible(selector.admin.dokan.productAdvertising.advertisedProductCell(productOrOrder)); + await this.toBeVisible(productAdvertisingAdmin.advertisedProductCell(productOrOrder)); } else { - await this.toBeVisible(selector.admin.dokan.productAdvertising.advertisedProductOrderIdCell(productOrOrder)); + await this.toBeVisible(productAdvertisingAdmin.advertisedProductOrderIdCell(productOrOrder)); } } @@ -95,50 +98,50 @@ export class ProductAdvertisingPage extends AdminPage { switch (action) { case 'by-store': - await this.click(selector.admin.dokan.productAdvertising.filters.allStoresDropdown); - await this.typeAndWaitForResponse(data.subUrls.api.dokan.productAdvertising, selector.admin.dokan.productAdvertising.filters.filterByStoreInput, input); + await this.click(productAdvertisingAdmin.filters.allStoresDropdown); + await this.typeAndWaitForResponse(data.subUrls.api.dokan.productAdvertising, productAdvertisingAdmin.filters.filterByStoreInput, input); await this.pressAndWaitForResponse(data.subUrls.api.dokan.productAdvertising, data.key.enter); break; case 'by-creation': - await this.click(selector.admin.dokan.productAdvertising.filters.createdViaDropdown); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.productAdvertising, selector.admin.dokan.productAdvertising.filters.filterByCreatedVia(input)); + await this.click(productAdvertisingAdmin.filters.createdViaDropdown); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.productAdvertising, productAdvertisingAdmin.filters.filterByCreatedVia(input)); break; default: break; } - const count = (await this.getElementText(selector.admin.dokan.productAdvertising.numberOfRowsFound))?.split(' ')[0]; + const count = (await this.getElementText(productAdvertisingAdmin.numberOfRowsFound))?.split(' ')[0]; expect(Number(count)).toBeGreaterThan(0); // clear filter - await this.clickAndWaitForResponse(data.subUrls.api.dokan.productAdvertising, selector.admin.dokan.productAdvertising.filters.clearFilter); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.productAdvertising, productAdvertisingAdmin.filters.clearFilter); } // update advertised product async updateAdvertisedProduct(productName: string, action: string) { await this.searchAdvertisedProduct(productName); - await this.hover(selector.admin.dokan.productAdvertising.advertisedProductCell(productName)); + await this.hover(productAdvertisingAdmin.advertisedProductCell(productName)); switch (action) { case 'expire': - await this.click(selector.admin.dokan.productAdvertising.advertisedProductExpire(productName)); + await this.click(productAdvertisingAdmin.advertisedProductExpire(productName)); break; case 'delete': - await this.click(selector.admin.dokan.productAdvertising.advertisedProductDelete(productName)); + await this.click(productAdvertisingAdmin.advertisedProductDelete(productName)); break; default: break; } - await this.clickAndWaitForResponse(data.subUrls.api.dokan.productAdvertising, selector.admin.dokan.productAdvertising.confirmAction); - await this.click(selector.admin.dokan.productAdvertising.actionSuccessful); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.productAdvertising, productAdvertisingAdmin.confirmAction); + await this.click(productAdvertisingAdmin.actionSuccessful); // refresh table by clicking filter - await this.clickAndWaitForResponse(data.subUrls.api.dokan.productAdvertising, selector.admin.dokan.productAdvertising.filters.clearFilter); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.productAdvertising, productAdvertisingAdmin.filters.clearFilter); } // product advertising bulk action @@ -146,12 +149,12 @@ export class ProductAdvertisingPage extends AdminPage { productName ? await this.searchAdvertisedProduct(productName) : await this.goIfNotThere(data.subUrls.backend.dokan.productAdvertising); // ensure row exists - await this.notToBeVisible(selector.admin.dokan.productAdvertising.noRowsFound); + await this.notToBeVisible(productAdvertisingAdmin.noRowsFound); - await this.click(selector.admin.dokan.productAdvertising.bulkActions.selectAll); - await this.selectByValue(selector.admin.dokan.productAdvertising.bulkActions.selectAction, action); - await this.click(selector.admin.dokan.productAdvertising.bulkActions.applyAction); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.productAdvertising, selector.admin.dokan.productAdvertising.confirmAction); - await this.click(selector.admin.dokan.productAdvertising.actionSuccessful); + await this.click(productAdvertisingAdmin.bulkActions.selectAll); + await this.selectByValue(productAdvertisingAdmin.bulkActions.selectAction, action); + await this.click(productAdvertisingAdmin.bulkActions.applyAction); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.productAdvertising, productAdvertisingAdmin.confirmAction); + await this.click(productAdvertisingAdmin.actionSuccessful); } } diff --git a/tests/pw/pages/productEnquiryPage.ts b/tests/pw/pages/productEnquiryPage.ts index 80e033537f..3cd80e9fba 100644 --- a/tests/pw/pages/productEnquiryPage.ts +++ b/tests/pw/pages/productEnquiryPage.ts @@ -4,6 +4,9 @@ import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; import { product } from '@utils/interfaces'; +// selectors +const productEnquiryCustomer = selector.customer.cSingleProduct.productEnquiry; + export class ProductEnquiryPage extends CustomerPage { constructor(page: Page) { super(page); @@ -15,13 +18,13 @@ export class ProductEnquiryPage extends CustomerPage { async enquireProduct(productName: string, enquiry: product['enquiry']): Promise { await this.goToProductDetails(productName); await this.click(selector.customer.cSingleProduct.menus.productEnquiry); - const isGuest = await this.isVisible(selector.customer.cSingleProduct.productEnquiry.guest.guestName); + const isGuest = await this.isVisible(productEnquiryCustomer.guest.guestName); if (isGuest) { - await this.clearAndType(selector.customer.cSingleProduct.productEnquiry.guest.guestName, enquiry.guestName()); - await this.clearAndType(selector.customer.cSingleProduct.productEnquiry.guest.guestEmail, enquiry.guestEmail()); + await this.clearAndType(productEnquiryCustomer.guest.guestName, enquiry.guestName()); + await this.clearAndType(productEnquiryCustomer.guest.guestEmail, enquiry.guestEmail()); } - await this.clearAndType(selector.customer.cSingleProduct.productEnquiry.enquiryMessage, enquiry.enquiryDetails); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.customer.cSingleProduct.productEnquiry.submitEnquiry); - await this.toContainText(selector.customer.cSingleProduct.productEnquiry.submitEnquirySuccessMessage, enquiry.enquirySubmitSuccessMessage); + await this.clearAndType(productEnquiryCustomer.enquiryMessage, enquiry.enquiryDetails); + await this.clickAndWaitForResponse(data.subUrls.ajax, productEnquiryCustomer.submitEnquiry); + await this.toContainText(productEnquiryCustomer.submitEnquirySuccessMessage, enquiry.enquirySubmitSuccessMessage); } } diff --git a/tests/pw/pages/productQAPage.ts b/tests/pw/pages/productQAPage.ts new file mode 100644 index 0000000000..cd8497b417 --- /dev/null +++ b/tests/pw/pages/productQAPage.ts @@ -0,0 +1,295 @@ +import { Page, expect } from '@playwright/test'; +import { AdminPage } from '@pages/adminPage'; +// import { VendorPage } from '@pages/vendorPage'; +import { selector } from '@pages/selectors'; +import { data } from '@utils/testData'; +import { helpers } from '@utils/helpers'; +import { questionsAnswers } from '@utils/interfaces'; +import { BasePage } from '@pages/basePage'; + +// selectors +const productQAAdmin = selector.admin.dokan.productQA; +const productQAVendor = selector.vendor.vProductQA; +const productQACustomer = selector.customer.cSingleProduct.questionsAnswers; + +export class ProductQAPage extends BasePage { + constructor(page: Page) { + super(page); + } + + async goToProductDetails(productName: string): Promise { + await this.goIfNotThere(data.subUrls.frontend.productDetails(helpers.slugify(productName))); + } + + // admin + + // product question answers render properly + async adminProductQARenderProperly() { + await this.goIfNotThere(data.subUrls.backend.dokan.productQA); + + // product question answers text is visible + await this.toBeVisible(productQAAdmin.productQuestionAnswersText); + + // nav tabs are visible + await this.multipleElementVisible(productQAAdmin.navTabs); + + // bulk action elements are visible + const { confirmAction, bulkActionSuccessMessage, ...bulkActions } = productQAAdmin.bulkActions; + await this.multipleElementVisible(bulkActions); + + // filter elements are visible + const { filterInput, result, resetFilterByVensors, ...filters } = productQAAdmin.filters; + await this.multipleElementVisible(filters); + + // product question & answers table elements are visible + await this.multipleElementVisible(productQAAdmin.table); + } + + // admin view question details + async viewQuestionDetails(questionId: string): Promise { + await this.goIfNotThere(data.subUrls.backend.dokan.questionDetails(questionId)); + + // product question answers text is visible + await this.toBeVisible(productQAAdmin.questionDetails.productQuestionAnswersText); + + // go back is visible + await this.toBeVisible(productQAAdmin.questionDetails.goBack); + + // question details elements are visible + const { questionInput, saveQuestion, questionText, ...questionDetails } = productQAAdmin.questionDetails.questionDetails; // todo: need to add questiontext + await this.multipleElementVisible(questionDetails); + + // status elements are visible + const { hiddenStatus, showInProductPage, ...status } = productQAAdmin.questionDetails.status; + await this.multipleElementVisible(status); + + // answer elements are visible + const { questionAnswerHtmlBody, editAnswer, ...answer } = productQAAdmin.questionDetails.answer; + await this.multipleElementVisible(answer); + } + + // decrease unread question count + async decreaseUnreadQuestionCount() { + await this.goto(data.subUrls.backend.dokan.productQA); + const unreadCount = Number(await this.getElementText(productQAAdmin.unreadQuestionCount)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.productQuestions, productQAAdmin.productQuestionFirstCell); + const getNewUnreadCount = Number(await this.getElementText(productQAAdmin.unreadQuestionCount)); + expect(getNewUnreadCount).toEqual(unreadCount - 1); + } + + // filter questions + async filterQuestions(input: string, filterBy: string) { + await this.goto(data.subUrls.backend.dokan.productQA); + + switch (filterBy) { + case 'by-vendor': + await this.click(productQAAdmin.filters.filterByVendors); + await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, productQAAdmin.filters.filterInput, input); + await this.toContainText(productQAAdmin.filters.result, input); + await this.pressAndWaitForResponse(data.subUrls.api.dokan.productQuestions, data.key.enter); + break; + + case 'by-product': + await this.click(productQAAdmin.filters.filterByProducts); + await this.typeAndWaitForResponse(data.subUrls.api.wc.wcProducts, productQAAdmin.filters.filterInput, input); + await this.toContainText(productQAAdmin.filters.result, input); + await this.pressAndWaitForResponse(data.subUrls.api.dokan.productQuestions, data.key.enter); + break; + + default: + break; + } + + const count = (await this.getElementText(productQAAdmin.numberOfRowsFound))?.split(' ')[0]; + expect(Number(count)).toBeGreaterThan(0); + } + + // edit question + async editQuestion(questionId: string, questionsAnswers: questionsAnswers): Promise { + await this.goIfNotThere(data.subUrls.backend.dokan.questionDetails(questionId)); + await this.click(productQAAdmin.questionDetails.questionDetails.editQuestion); + await this.clearAndType(productQAAdmin.questionDetails.questionDetails.questionInput, questionsAnswers.editQuestion); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.productQuestions, productQAAdmin.questionDetails.questionDetails.saveQuestion); + await this.toBeVisible(productQAAdmin.questionDetails.questionSaveSuccessMessage); + await this.toContainText(productQAAdmin.questionDetails.questionDetails.questionText, questionsAnswers.editQuestion); + } + + // answer question + async answerQuestion(questionId: string, questionsAnswers: questionsAnswers): Promise { + await this.goIfNotThere(data.subUrls.backend.dokan.questionDetails(questionId)); + await this.typeFrameSelector(productQAAdmin.questionDetails.answer.questionAnswerIframe, productQAAdmin.questionDetails.answer.questionAnswerHtmlBody, questionsAnswers.answer); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.productAnswers, productQAAdmin.questionDetails.answer.saveAnswer, 201); + await this.toBeVisible(productQAAdmin.questionDetails.answerSaveSuccessMessage); + await this.toContainText(productQAAdmin.questionDetails.answer.answerText, questionsAnswers.answer); + await this.toBeVisible(productQAAdmin.questionDetails.answer.editAnswer); + } + + // edit answer + async editAnswer(questionId: string, questionsAnswers: questionsAnswers): Promise { + await this.goIfNotThere(data.subUrls.backend.dokan.questionDetails(questionId)); + await this.click(productQAAdmin.questionDetails.answer.editAnswer); + await this.typeFrameSelector(productQAAdmin.questionDetails.answer.questionAnswerIframe, productQAAdmin.questionDetails.answer.questionAnswerHtmlBody, questionsAnswers.editAnswer); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.productAnswers, productQAAdmin.questionDetails.answer.saveAnswer); + await this.toBeVisible(productQAAdmin.questionDetails.answerUpdateSuccessMessage); + await this.toContainText(productQAAdmin.questionDetails.answer.answerText, questionsAnswers.answer); + } + + // edit question visibility + async editQuestionVisibility(questionId: string, action: string): Promise { + await this.goIfNotThere(data.subUrls.backend.dokan.questionDetails(questionId)); + action == 'hide' ? await this.click(productQAAdmin.questionDetails.status.hideFromProductPage) : await this.click(productQAAdmin.questionDetails.status.showInProductPage); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.productQuestions, productQAAdmin.questionDetails.confirmAction); + await this.toBeVisible(productQAAdmin.questionDetails.visibilityStatusSaveSuccessMessage); + action == 'hide' ? await this.toBeVisible(productQAAdmin.questionDetails.status.hiddenStatus) : await this.toBeVisible(productQAAdmin.questionDetails.status.visibleStatus); + action == 'hide' ? await this.toBeVisible(productQAAdmin.questionDetails.status.showInProductPage) : await this.toBeVisible(productQAAdmin.questionDetails.status.hideFromProductPage); + } + + // delete answer + async deleteAnswer(questionId: string): Promise { + await this.goIfNotThere(data.subUrls.backend.dokan.questionDetails(questionId)); + await this.click(productQAAdmin.questionDetails.answer.deleteAnswer); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.productAnswers, productQAAdmin.questionDetails.confirmAction, 204); + await this.toBeVisible(productQAAdmin.questionDetails.answerDeleteSuccessMessage); + await this.toBeVisible(productQAAdmin.questionDetails.answer.saveAnswer); + } + + // delete question + async deleteQuestion(questionId: string): Promise { + await this.goIfNotThere(data.subUrls.backend.dokan.questionDetails(questionId)); + await this.click(productQAAdmin.questionDetails.status.deleteQuestion); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.productQuestions, productQAAdmin.questionDetails.confirmAction, 204); + // await this.toBeVisible(productQAAdmin.questionDetails.questionDeleteSuccessMessage); //todo: needed or not + } + + // product questions bulk action + async productQuestionsBulkAction(action: string) { + await this.goto(data.subUrls.backend.dokan.productQA); + + // ensure row exists + await this.notToBeVisible(productQAAdmin.noRowsFound); + + await this.click(productQAAdmin.bulkActions.selectAll); + await this.selectByValue(productQAAdmin.bulkActions.selectAction, action); + if (action == 'delete') { + await this.click(productQAAdmin.bulkActions.applyAction); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.productQuestionsBulkActions, productQAAdmin.bulkActions.confirmAction); + } + { + await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.productQuestionsBulkActions, productQAAdmin.bulkActions.applyAction); + } + await this.toBeVisible(productQAAdmin.bulkActions.bulkActionSuccessMessage); + } + + // vendor + + // product question answers render properly + async vendorProductQARenderProperly() { + await this.goIfNotThere(data.subUrls.frontend.vDashboard.productQA); + + // product question answers text is visible + await this.toBeVisible(productQAVendor.productQuestionAnswersText); + + // filter elements are visible + const { filterInput, result, ...filters } = productQAVendor.filters; + await this.multipleElementVisible(filters); + + // product question & answers table elements are visible + await this.multipleElementVisible(productQAVendor.table); + } + + // vendor view question details + async vendorViewQuestionDetails(questionId: string): Promise { + await this.goIfNotThere(data.subUrls.frontend.vDashboard.questionDetails(questionId)); + + // product question answers text is visible + await this.toBeVisible(productQAVendor.productQuestionAnswersText); + + // question details elements are visible + await this.multipleElementVisible(productQAVendor.questionDetails.questionDetails); + + // status elements are visible + await this.multipleElementVisible(productQAVendor.questionDetails.status); + + // answer elements are visible + const { questionAnswerHtmlBody, ...answer } = productQAVendor.questionDetails.answer; + await this.multipleElementVisible(answer); + } + + // filter questions + async vendorFilterQuestions(productName: string): Promise { + await this.goIfNotThere(data.subUrls.frontend.vDashboard.productQA); + await this.click(productQAVendor.filters.filterByProducts); + await this.typeAndWaitForResponse(data.subUrls.ajax, productQAVendor.filters.filterInput, productName); + await this.toContainText(productQAVendor.filters.result, productName); + await this.press(data.key.arrowDown); + await this.press(data.key.enter); + await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.productQA, productQAVendor.filters.filter); + } + + // answer question + async vendorAnswerQuestion(questionId: string, questionsAnswers: questionsAnswers): Promise { + await this.goIfNotThere(data.subUrls.frontend.vDashboard.questionDetails(questionId)); + await this.typeFrameSelector(productQAVendor.questionDetails.answer.questionAnswerIframe, productQAVendor.questionDetails.answer.questionAnswerHtmlBody, questionsAnswers.answer); + await this.clickAndWaitForResponse(data.subUrls.ajax, productQAVendor.questionDetails.answer.saveAnswer); + await this.toBeVisible(productQAVendor.questionDetails.answerSaveSuccessMessage); + await this.toContainText(productQAVendor.questionDetails.answerDetails, questionsAnswers.answer); + await this.toBeVisible(productQAVendor.questionDetails.editAnswer); + } + + // edit answer + async vendorEditAnswer(questionId: string, questionsAnswers: questionsAnswers): Promise { + await this.goIfNotThere(data.subUrls.frontend.vDashboard.questionDetails(questionId)); + await this.click(productQAVendor.questionDetails.editAnswer); + await this.typeFrameSelector(productQAVendor.questionDetails.answer.questionAnswerIframe, productQAVendor.questionDetails.answer.questionAnswerHtmlBody, questionsAnswers.editAnswer); + await this.clickAndWaitForResponse(data.subUrls.ajax, productQAVendor.questionDetails.answer.saveAnswer); + await this.toBeVisible(productQAVendor.questionDetails.answerSaveSuccessMessage); + await this.toContainText(productQAVendor.questionDetails.answerDetails, questionsAnswers.answer); + } + + // delete answer + async vendorDeleteAnswer(questionId: string): Promise { + await this.goIfNotThere(data.subUrls.frontend.vDashboard.questionDetails(questionId)); + await this.click(productQAVendor.questionDetails.deleteAnswer); + await this.clickAndWaitForResponse(data.subUrls.ajax, productQAVendor.questionDetails.confirmAction); + await this.toBeVisible(productQAVendor.questionDetails.answerDeleteSuccessMessage); + } + + // delete question + async vendorDeleteQuestion(questionId: string): Promise { + await this.goIfNotThere(data.subUrls.frontend.vDashboard.questionDetails(questionId)); + await this.click(productQAVendor.questionDetails.status.deleteQuestion); + await this.clickAndWaitForResponse(data.subUrls.ajax, productQAVendor.questionDetails.confirmAction); + await this.toBeVisible(productQAVendor.questionDetails.questionDeleteSuccessMessage); + } + + // customer + + // search question + async searchQuestion(productName: string, questionsAnswers: questionsAnswers): Promise { + await this.goToProductDetails(productName); + await this.click(selector.customer.cSingleProduct.menus.questionsAnswers); + await this.clearAndType(productQACustomer.searchInput, questionsAnswers.question); + await this.toBeVisible(productQACustomer.clearResult); + await this.toContainText(productQACustomer.matchingResult, /^Matching \d+ Q&A with/); + } + + // post question + async postQuestion(productName: string, questionsAnswers: questionsAnswers): Promise { + await this.goToProductDetails(productName); + await this.click(selector.customer.cSingleProduct.menus.questionsAnswers); + await this.clearAndType(productQACustomer.searchInput, '...'); + const isGuest = await this.isVisible(productQACustomer.loginPostQuestion); + if (isGuest) { + await this.click(productQACustomer.loginPostQuestion); + await this.clearAndType(selector.frontend.username, questionsAnswers.user.username); + await this.clearAndType(selector.frontend.userPassword, questionsAnswers.user.password); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.myAccountToProductQA, selector.frontend.logIn, 302); + + await this.click(selector.customer.cSingleProduct.menus.questionsAnswers); + await this.clearAndType(productQACustomer.searchInput, '...'); + } + await this.click(productQACustomer.postQuestion); + await this.clearAndType(productQACustomer.questionInput, questionsAnswers.question); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.productQuestions, productQACustomer.post); + } +} diff --git a/tests/pw/pages/productReviewsPage.ts b/tests/pw/pages/productReviewsPage.ts index 996adef1fe..e907bb93a3 100644 --- a/tests/pw/pages/productReviewsPage.ts +++ b/tests/pw/pages/productReviewsPage.ts @@ -3,6 +3,9 @@ import { VendorPage } from '@pages/vendorPage'; import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; +// selectors +const productReviewsVendor = selector.vendor.vReviews; + export class ProductReviewsPage extends VendorPage { constructor(page: Page) { super(page); @@ -13,30 +16,30 @@ export class ProductReviewsPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.reviews); // settings text is visible - await this.toBeVisible(selector.vendor.vReviews.reviewsText); + await this.toBeVisible(productReviewsVendor.reviewsText); // product review menu elements are visible - await this.multipleElementVisible(selector.vendor.vReviews.menus); + await this.multipleElementVisible(productReviewsVendor.menus); // product review bulk action elements are visible - await this.multipleElementVisible(selector.vendor.vReviews.bulkActions); + await this.multipleElementVisible(productReviewsVendor.bulkActions); // product review table elements are visible - await this.multipleElementVisible(selector.vendor.vReviews.table); + await this.multipleElementVisible(productReviewsVendor.table); - const noReviewsFound = await this.isVisible(selector.vendor.vReviews.noReviewsFound); + const noReviewsFound = await this.isVisible(productReviewsVendor.noReviewsFound); if (noReviewsFound) { return; } - await this.notToHaveCount(selector.vendor.vReviews.numberOfRowsFound, 0); + await this.notToHaveCount(productReviewsVendor.numberOfRowsFound, 0); } // view product review async viewProductReview(reviewMessage: string) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.reviews); - await this.clickAndWaitForLoadState(selector.vendor.vReviews.reviewLink(reviewMessage)); - await this.toBeVisible(selector.vendor.vReviews.reviewDetails.reviewMessageByMessage(reviewMessage)); + await this.clickAndWaitForLoadState(productReviewsVendor.reviewLink(reviewMessage)); + await this.toBeVisible(productReviewsVendor.reviewDetails.reviewMessageByMessage(reviewMessage)); } // update product review status @@ -45,36 +48,36 @@ export class ProductReviewsPage extends VendorPage { switch (action) { case 'unApprove': - await this.hover(selector.vendor.vReviews.reviewMessageCell(reviewMessage)); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vReviews.unApproveReview(reviewMessage)); + await this.hover(productReviewsVendor.reviewMessageCell(reviewMessage)); + await this.clickAndWaitForResponse(data.subUrls.ajax, productReviewsVendor.unApproveReview(reviewMessage)); break; case 'spam': - await this.hover(selector.vendor.vReviews.reviewMessageCell(reviewMessage)); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vReviews.spamReview(reviewMessage)); + await this.hover(productReviewsVendor.reviewMessageCell(reviewMessage)); + await this.clickAndWaitForResponse(data.subUrls.ajax, productReviewsVendor.spamReview(reviewMessage)); break; case 'trash': - await this.hover(selector.vendor.vReviews.reviewMessageCell(reviewMessage)); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vReviews.trashReview(reviewMessage)); + await this.hover(productReviewsVendor.reviewMessageCell(reviewMessage)); + await this.clickAndWaitForResponse(data.subUrls.ajax, productReviewsVendor.trashReview(reviewMessage)); break; case 'approve': - await this.clickAndWaitForLoadState(selector.vendor.vReviews.menus.pending); - await this.hover(selector.vendor.vReviews.reviewMessageCell(reviewMessage)); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vReviews.approveReview(reviewMessage)); + await this.clickAndWaitForLoadState(productReviewsVendor.menus.pending); + await this.hover(productReviewsVendor.reviewMessageCell(reviewMessage)); + await this.clickAndWaitForResponse(data.subUrls.ajax, productReviewsVendor.approveReview(reviewMessage)); break; case 'restore': - await this.clickAndWaitForLoadState(selector.vendor.vReviews.menus.trash); - await this.hover(selector.vendor.vReviews.reviewMessageCell(reviewMessage)); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vReviews.restoreReview(reviewMessage)); + await this.clickAndWaitForLoadState(productReviewsVendor.menus.trash); + await this.hover(productReviewsVendor.reviewMessageCell(reviewMessage)); + await this.clickAndWaitForResponse(data.subUrls.ajax, productReviewsVendor.restoreReview(reviewMessage)); break; case 'permanently-delete': - await this.clickAndWaitForLoadState(selector.vendor.vReviews.menus.trash); - await this.hover(selector.vendor.vReviews.reviewMessageCell(reviewMessage)); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vReviews.permanentlyDeleteReview(reviewMessage)); + await this.clickAndWaitForLoadState(productReviewsVendor.menus.trash); + await this.hover(productReviewsVendor.reviewMessageCell(reviewMessage)); + await this.clickAndWaitForResponse(data.subUrls.ajax, productReviewsVendor.permanentlyDeleteReview(reviewMessage)); break; default: @@ -87,10 +90,10 @@ export class ProductReviewsPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.reviews); // ensure row exists - await this.notToBeVisible(selector.vendor.vReviews.noReviewsFound); + await this.notToBeVisible(productReviewsVendor.noReviewsFound); - await this.click(selector.vendor.vReviews.bulkActions.selectAll); - await this.selectByValue(selector.vendor.vReviews.bulkActions.selectAction, action); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.reviews, selector.vendor.vReviews.bulkActions.applyAction); + await this.click(productReviewsVendor.bulkActions.selectAll); + await this.selectByValue(productReviewsVendor.bulkActions.selectAction, action); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.reviews, productReviewsVendor.bulkActions.applyAction); } } diff --git a/tests/pw/pages/productsPage.ts b/tests/pw/pages/productsPage.ts index e45236beed..528851a7c2 100644 --- a/tests/pw/pages/productsPage.ts +++ b/tests/pw/pages/productsPage.ts @@ -8,6 +8,10 @@ import { product, vendor } from '@utils/interfaces'; const { DOKAN_PRO } = process.env; +// selectors +const productsAdmin = selector.admin.products; +const productsVendor = selector.vendor.product; + export class ProductsPage extends AdminPage { constructor(page: Page) { super(page); @@ -16,27 +20,27 @@ export class ProductsPage extends AdminPage { // admin add product category async addCategory(categoryName: string) { await this.goIfNotThere(data.subUrls.backend.wc.addNewCategories); - await this.fill(selector.admin.products.category.name, categoryName); - await this.fill(selector.admin.products.category.slug, categoryName); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.admin.products.category.addNewCategory); - await this.toBeVisible(selector.admin.products.category.categoryCell(categoryName)); + await this.fill(productsAdmin.category.name, categoryName); + await this.fill(productsAdmin.category.slug, categoryName); + await this.clickAndWaitForResponse(data.subUrls.ajax, productsAdmin.category.addNewCategory); + await this.toBeVisible(productsAdmin.category.categoryCell(categoryName)); } // admin add product attribute async addAttribute(attribute: product['attribute']) { await this.goIfNotThere(data.subUrls.backend.wc.addNewAttributes); - await this.fill(selector.admin.products.attribute.name, attribute.attributeName); - await this.fill(selector.admin.products.attribute.slug, attribute.attributeName); - await this.clickAndWaitForResponse(data.subUrls.backend.wc.addNewAttributes, selector.admin.products.attribute.addAttribute); - await this.toBeVisible(selector.admin.products.attribute.attributeCell(attribute.attributeName)); - await this.clickAndWaitForResponse(data.subUrls.backend.wc.taxonomy, selector.admin.products.attribute.configureTerms(attribute.attributeName)); + await this.fill(productsAdmin.attribute.name, attribute.attributeName); + await this.fill(productsAdmin.attribute.slug, attribute.attributeName); + await this.clickAndWaitForResponse(data.subUrls.backend.wc.addNewAttributes, productsAdmin.attribute.addAttribute); + await this.toBeVisible(productsAdmin.attribute.attributeCell(attribute.attributeName)); + await this.clickAndWaitForResponse(data.subUrls.backend.wc.taxonomy, productsAdmin.attribute.configureTerms(attribute.attributeName)); // add new term for (const attributeTerm of attribute.attributeTerms) { - await this.fill(selector.admin.products.attribute.attributeTerm, attributeTerm); - await this.fill(selector.admin.products.attribute.attributeTermSlug, attributeTerm); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.admin.products.attribute.addAttributeTerm); - await this.toBeVisible(selector.admin.products.attribute.attributeTermCell(attributeTerm)); + await this.fill(productsAdmin.attribute.attributeTerm, attributeTerm); + await this.fill(productsAdmin.attribute.attributeTermSlug, attributeTerm); + await this.clickAndWaitForResponse(data.subUrls.ajax, productsAdmin.attribute.addAttributeTerm); + await this.toBeVisible(productsAdmin.attribute.attributeTermCell(attributeTerm)); } } @@ -45,38 +49,38 @@ export class ProductsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.wc.addNewProducts); // product basic info - await this.type(selector.admin.products.product.productName, product.productName()); - await this.selectByValue(selector.admin.products.product.productType, product.productType); - await this.click(selector.admin.products.product.general); - await this.type(selector.admin.products.product.regularPrice, product.regularPrice()); - await this.click(selector.admin.products.product.category(product.category)); + await this.type(productsAdmin.product.productName, product.productName()); + await this.selectByValue(productsAdmin.product.productType, product.productType); + await this.click(productsAdmin.product.general); + await this.type(productsAdmin.product.regularPrice, product.regularPrice()); + await this.click(productsAdmin.product.category(product.category)); // stock status if (product.stockStatus) { - await this.click(selector.admin.products.product.inventory); - await this.selectByValue(selector.admin.products.product.stockStatus, data.product.stockStatus.outOfStock); + await this.click(productsAdmin.product.inventory); + await this.selectByValue(productsAdmin.product.stockStatus, data.product.stockStatus.outOfStock); } // vendor Store Name - await this.select2ByText(selector.admin.products.product.storeName, selector.admin.products.product.storeNameInput, product.storeName); + await this.select2ByText(productsAdmin.product.storeName, productsAdmin.product.storeNameInput, product.storeName); await this.scrollToTop(); switch (product.status) { case 'publish': - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.products.product.publish); - await this.toContainText(selector.admin.products.product.updatedSuccessMessage, data.product.publishSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, productsAdmin.product.publish); + await this.toContainText(productsAdmin.product.updatedSuccessMessage, data.product.publishSuccessMessage); break; case 'draft': - await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, selector.admin.products.product.saveDraft, 302); - await this.toContainText(selector.admin.products.product.updatedSuccessMessage, data.product.draftUpdateSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, productsAdmin.product.saveDraft, 302); + await this.toContainText(productsAdmin.product.updatedSuccessMessage, data.product.draftUpdateSuccessMessage); break; case 'pending': - await this.click(selector.admin.products.product.editStatus); - await this.selectByValue(selector.admin.products.product.status, data.product.status.pending); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, selector.admin.products.product.saveDraft, 302); - await this.toContainText(selector.admin.products.product.updatedSuccessMessage, data.product.pendingProductUpdateSuccessMessage); + await this.click(productsAdmin.product.editStatus); + await this.selectByValue(productsAdmin.product.status, data.product.status.pending); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, productsAdmin.product.saveDraft, 302); + await this.toContainText(productsAdmin.product.updatedSuccessMessage, data.product.pendingProductUpdateSuccessMessage); break; default: @@ -89,41 +93,41 @@ export class ProductsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.wc.addNewProducts); // name - await this.type(selector.admin.products.product.productName, product.productName()); - await this.selectByValue(selector.admin.products.product.productType, product.productType); + await this.type(productsAdmin.product.productName, product.productName()); + await this.selectByValue(productsAdmin.product.productType, product.productType); // add attributes - await this.click(selector.admin.products.product.attributes); + await this.click(productsAdmin.product.attributes); - if (await this.isVisibleLocator(selector.admin.products.product.customProductAttribute)) { - await this.selectByValue(selector.admin.products.product.customProductAttribute, `pa_${product.attribute}`); - await this.click(selector.admin.products.product.addAttribute); + if (await this.isVisibleLocator(productsAdmin.product.customProductAttribute)) { + await this.selectByValue(productsAdmin.product.customProductAttribute, `pa_${product.attribute}`); + await this.click(productsAdmin.product.addAttribute); } else { - await this.clickAndWaitForResponse(data.subUrls.backend.wc.searchAttribute, selector.admin.products.product.addExistingAttribute); - await this.typeAndWaitForResponse(data.subUrls.backend.wc.term, selector.admin.products.product.addExistingAttributeInput, product.attribute); + await this.clickAndWaitForResponse(data.subUrls.backend.wc.searchAttribute, productsAdmin.product.addExistingAttribute); + await this.typeAndWaitForResponse(data.subUrls.backend.wc.term, productsAdmin.product.addExistingAttributeInput, product.attribute); await this.pressAndWaitForResponse(data.subUrls.ajax, data.key.enter); } - await this.clickAndWaitForResponse(data.subUrls.backend.wc.taxonomyTerms, selector.admin.products.product.selectAll); - await this.check(selector.admin.products.product.usedForVariations); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.admin.products.product.saveAttributes); + await this.clickAndWaitForResponse(data.subUrls.backend.wc.taxonomyTerms, productsAdmin.product.selectAll); + await this.check(productsAdmin.product.usedForVariations); + await this.clickAndWaitForResponse(data.subUrls.ajax, productsAdmin.product.saveAttributes); // add variations - await this.click(selector.admin.products.product.variations); - await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, selector.admin.products.product.generateVariations); + await this.click(productsAdmin.product.variations); + await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, productsAdmin.product.generateVariations); this.fillAlert('100'); - await this.selectByValue(selector.admin.products.product.addVariations, product.variations.variableRegularPrice); + await this.selectByValue(productsAdmin.product.addVariations, product.variations.variableRegularPrice); // category - await this.click(selector.admin.products.product.category(product.category)); + await this.click(productsAdmin.product.category(product.category)); // Vendor Store Name - await this.select2ByText(selector.admin.products.product.storeName, selector.admin.products.product.storeNameInput, product.storeName); + await this.select2ByText(productsAdmin.product.storeName, productsAdmin.product.storeNameInput, product.storeName); await this.scrollToTop(); // Publish - await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, selector.admin.products.product.publish, 302); - await this.toContainText(selector.admin.products.product.updatedSuccessMessage, data.product.publishSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, productsAdmin.product.publish, 302); + await this.toContainText(productsAdmin.product.updatedSuccessMessage, data.product.publishSuccessMessage); } // Admin Add Simple Subscription Product @@ -131,27 +135,27 @@ export class ProductsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.wc.addNewProducts); // Name - await this.type(selector.admin.products.product.productName, product.productName()); - await this.selectByValue(selector.admin.products.product.productType, product.productType); - await this.click(selector.admin.products.product.general); - await this.type(selector.admin.products.product.subscriptionPrice, product.subscriptionPrice()); - await this.selectByValue(selector.admin.products.product.subscriptionPeriodInterval, product.subscriptionPeriodInterval); - await this.selectByValue(selector.admin.products.product.subscriptionPeriod, product.subscriptionPeriod); - await this.selectByValue(selector.admin.products.product.expireAfter, product.expireAfter); - await this.type(selector.admin.products.product.subscriptionTrialLength, product.subscriptionTrialLength); - await this.selectByValue(selector.admin.products.product.subscriptionTrialPeriod, product.subscriptionTrialPeriod); + await this.type(productsAdmin.product.productName, product.productName()); + await this.selectByValue(productsAdmin.product.productType, product.productType); + await this.click(productsAdmin.product.general); + await this.type(productsAdmin.product.subscriptionPrice, product.subscriptionPrice()); + await this.selectByValue(productsAdmin.product.subscriptionPeriodInterval, product.subscriptionPeriodInterval); + await this.selectByValue(productsAdmin.product.subscriptionPeriod, product.subscriptionPeriod); + await this.selectByValue(productsAdmin.product.expireAfter, product.expireAfter); + await this.type(productsAdmin.product.subscriptionTrialLength, product.subscriptionTrialLength); + await this.selectByValue(productsAdmin.product.subscriptionTrialPeriod, product.subscriptionTrialPeriod); // Category - await this.click(selector.admin.products.product.category(product.category)); + await this.click(productsAdmin.product.category(product.category)); // Vendor Store Name - await this.select2ByText(selector.admin.products.product.storeName, selector.admin.products.product.storeNameInput, product.storeName); + await this.select2ByText(productsAdmin.product.storeName, productsAdmin.product.storeNameInput, product.storeName); await this.scrollToTop(); // Publish - await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, selector.admin.products.product.publish, 302); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, productsAdmin.product.publish, 302); - await this.toContainText(selector.admin.products.product.updatedSuccessMessage, data.product.publishSuccessMessage); + await this.toContainText(productsAdmin.product.updatedSuccessMessage, data.product.publishSuccessMessage); } // admin add variable product @@ -159,42 +163,42 @@ export class ProductsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.wc.addNewProducts); // name - await this.type(selector.admin.products.product.productName, product.productName()); - await this.selectByValue(selector.admin.products.product.productType, product.productType); + await this.type(productsAdmin.product.productName, product.productName()); + await this.selectByValue(productsAdmin.product.productType, product.productType); // add attributes - await this.click(selector.admin.products.product.attributes); + await this.click(productsAdmin.product.attributes); - if (await this.isVisibleLocator(selector.admin.products.product.customProductAttribute)) { - await this.selectByValue(selector.admin.products.product.customProductAttribute, `pa_${product.attribute}`); - await this.click(selector.admin.products.product.addAttribute); + if (await this.isVisibleLocator(productsAdmin.product.customProductAttribute)) { + await this.selectByValue(productsAdmin.product.customProductAttribute, `pa_${product.attribute}`); + await this.click(productsAdmin.product.addAttribute); } else { - await this.clickAndWaitForResponse(data.subUrls.backend.wc.searchAttribute, selector.admin.products.product.addExistingAttribute); - await this.typeAndWaitForResponse(data.subUrls.backend.wc.term, selector.admin.products.product.addExistingAttributeInput, product.attribute); + await this.clickAndWaitForResponse(data.subUrls.backend.wc.searchAttribute, productsAdmin.product.addExistingAttribute); + await this.typeAndWaitForResponse(data.subUrls.backend.wc.term, productsAdmin.product.addExistingAttributeInput, product.attribute); await this.pressAndWaitForResponse(data.subUrls.ajax, data.key.enter); } - await this.clickAndWaitForResponse(data.subUrls.backend.wc.taxonomyTerms, selector.admin.products.product.selectAll); - await this.check(selector.admin.products.product.usedForVariations); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.admin.products.product.saveAttributes); + await this.clickAndWaitForResponse(data.subUrls.backend.wc.taxonomyTerms, productsAdmin.product.selectAll); + await this.check(productsAdmin.product.usedForVariations); + await this.clickAndWaitForResponse(data.subUrls.ajax, productsAdmin.product.saveAttributes); // await this.wait(2); // add variations - await this.click(selector.admin.products.product.variations); - await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, selector.admin.products.product.generateVariations); + await this.click(productsAdmin.product.variations); + await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, productsAdmin.product.generateVariations); this.fillAlert('100'); - await this.selectByValue(selector.admin.products.product.addVariations, product.variations.variableRegularPrice); + await this.selectByValue(productsAdmin.product.addVariations, product.variations.variableRegularPrice); // category - await this.click(selector.admin.products.product.category(product.category)); + await this.click(productsAdmin.product.category(product.category)); // Vendor Store Name - await this.select2ByText(selector.admin.products.product.storeName, selector.admin.products.product.storeNameInput, product.storeName); + await this.select2ByText(productsAdmin.product.storeName, productsAdmin.product.storeNameInput, product.storeName); await this.scrollToTop(); // Publish - await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, selector.admin.products.product.publish, 302); - await this.toContainText(selector.admin.products.product.updatedSuccessMessage, data.product.publishSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, productsAdmin.product.publish, 302); + await this.toContainText(productsAdmin.product.updatedSuccessMessage, data.product.publishSuccessMessage); } // Admin Add External Product @@ -202,23 +206,23 @@ export class ProductsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.wc.addNewProducts); // Name - await this.type(selector.admin.products.product.productName, product.productName()); - await this.selectByValue(selector.admin.products.product.productType, product.productType); - await this.click(selector.admin.products.product.general); - await this.type(selector.admin.products.product.productUrl, this.getBaseUrl() + product.productUrl); - await this.type(selector.admin.products.product.buttonText, product.buttonText); - await this.type(selector.admin.products.product.regularPrice, product.regularPrice()); + await this.type(productsAdmin.product.productName, product.productName()); + await this.selectByValue(productsAdmin.product.productType, product.productType); + await this.click(productsAdmin.product.general); + await this.type(productsAdmin.product.productUrl, this.getBaseUrl() + product.productUrl); + await this.type(productsAdmin.product.buttonText, product.buttonText); + await this.type(productsAdmin.product.regularPrice, product.regularPrice()); // Category - await this.click(selector.admin.products.product.category(product.category)); + await this.click(productsAdmin.product.category(product.category)); // Vendor Store Name - await this.select2ByText(selector.admin.products.product.storeName, selector.admin.products.product.storeNameInput, product.storeName); + await this.select2ByText(productsAdmin.product.storeName, productsAdmin.product.storeNameInput, product.storeName); await this.scrollToTop(); // Publish - await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, selector.admin.products.product.publish, 302); - await this.toContainText(selector.admin.products.product.updatedSuccessMessage, data.product.publishSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, productsAdmin.product.publish, 302); + await this.toContainText(productsAdmin.product.updatedSuccessMessage, data.product.publishSuccessMessage); } // Admin Add Dokan Subscription Product @@ -226,28 +230,28 @@ export class ProductsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.wc.addNewProducts); // Name - await this.type(selector.admin.products.product.productName, product.productName()); - await this.selectByValue(selector.admin.products.product.productType, product.productType); - await this.click(selector.admin.products.product.general); - await this.type(selector.admin.products.product.regularPrice, product.regularPrice()); + await this.type(productsAdmin.product.productName, product.productName()); + await this.selectByValue(productsAdmin.product.productType, product.productType); + await this.click(productsAdmin.product.general); + await this.type(productsAdmin.product.regularPrice, product.regularPrice()); // Category - await this.click(selector.admin.products.product.category(product.category)); + await this.click(productsAdmin.product.category(product.category)); // Subscription Details - await this.type(selector.admin.products.product.numberOfProducts, product.numberOfProducts); - await this.type(selector.admin.products.product.packValidity, product.packValidity); - await this.type(selector.admin.products.product.advertisementSlot, product.advertisementSlot); - await this.type(selector.admin.products.product.expireAfterDays, product.expireAfterDays); - await this.click(selector.admin.products.product.recurringPayment); + await this.type(productsAdmin.product.numberOfProducts, product.numberOfProducts); + await this.type(productsAdmin.product.packValidity, product.packValidity); + await this.type(productsAdmin.product.advertisementSlot, product.advertisementSlot); + await this.type(productsAdmin.product.expireAfterDays, product.expireAfterDays); + await this.click(productsAdmin.product.recurringPayment); // // Vendor Store Name - // await this.select2ByText(selector.admin.products.product.storeName, selector.admin.products.product.storeNameInput, product.storeName); + // await this.select2ByText(productsAdmin.product.storeName, productsAdmin.product.storeNameInput, product.storeName); // await this.scrollToTop(); // Publish - await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, selector.admin.products.product.publish, 302); - await this.toContainText(selector.admin.products.product.updatedSuccessMessage, data.product.publishSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, productsAdmin.product.publish, 302); + await this.toContainText(productsAdmin.product.updatedSuccessMessage, data.product.publishSuccessMessage); } // vendor @@ -257,29 +261,29 @@ export class ProductsPage extends AdminPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.products); // product nav menus are visible - const { draft, pendingReview, ...menus } = selector.vendor.product.menus; + const { draft, pendingReview, ...menus } = productsVendor.menus; await this.multipleElementVisible(menus); // add new product is visible - await this.toBeVisible(selector.vendor.product.create.addNewProduct); + await this.toBeVisible(productsVendor.create.addNewProduct); // import export is visible - DOKAN_PRO && (await this.multipleElementVisible(selector.vendor.product.importExport)); + DOKAN_PRO && (await this.multipleElementVisible(productsVendor.importExport)); // product filters elements are visible - const { filterByType, filterByOther, ...filters } = selector.vendor.product.filters; + const { filterByType, filterByOther, ...filters } = productsVendor.filters; await this.multipleElementVisible(filters); DOKAN_PRO && (await this.toBeVisible(filterByType)); DOKAN_PRO && (await this.toBeVisible(filterByOther)); // product search elements are visible - await this.multipleElementVisible(selector.vendor.product.search); + await this.multipleElementVisible(productsVendor.search); // bulk action elements are visible - await this.multipleElementVisible(selector.vendor.product.bulkActions); + await this.multipleElementVisible(productsVendor.bulkActions); // table elements are visible - const { productAdvertisementColumn, ...table } = selector.vendor.product.table; + const { productAdvertisementColumn, ...table } = productsVendor.table; await this.multipleElementVisible(table); } @@ -288,8 +292,8 @@ export class ProductsPage extends AdminPage { // vendor add product async addProduct(productName: string): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.products); - await this.clickAndWaitForLoadState(selector.vendor.product.create.addNewProduct); - await this.clearAndType(selector.vendor.product.edit.title, productName); + await this.clickAndWaitForLoadState(productsVendor.create.addNewProduct); + await this.clearAndType(productsVendor.edit.title, productName); } // vendor add simple product @@ -298,25 +302,25 @@ export class ProductsPage extends AdminPage { const productPrice = product.regularPrice(); await this.goIfNotThere(data.subUrls.frontend.vDashboard.products); if (productPopup) { - await this.click(selector.vendor.product.create.addNewProduct); - await this.waitForVisibleLocator(selector.vendor.product.create.productName); - await this.clearAndType(selector.vendor.product.create.productName, productName); - await this.clearAndType(selector.vendor.product.create.productPrice, productPrice); + await this.click(productsVendor.create.addNewProduct); + await this.waitForVisibleLocator(productsVendor.create.productName); + await this.clearAndType(productsVendor.create.productName, productName); + await this.clearAndType(productsVendor.create.productPrice, productPrice); // await this.addProductCategory(product.category); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.vendor.product.create.createProduct); - const createdProduct = await this.getElementValue(selector.vendor.product.edit.title); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, productsVendor.create.createProduct); + const createdProduct = await this.getElementValue(productsVendor.edit.title); expect(createdProduct.toLowerCase()).toBe(productName.toLowerCase()); } else { - await this.clickAndWaitForLoadState(selector.vendor.product.create.addNewProduct); - await this.clearAndType(selector.vendor.product.edit.title, productName); - await this.clearAndType(selector.vendor.product.edit.price, productPrice); + await this.clickAndWaitForLoadState(productsVendor.create.addNewProduct); + await this.clearAndType(productsVendor.edit.title, productName); + await this.clearAndType(productsVendor.edit.price, productPrice); // await this.addProductCategory(product.category); - await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.products, selector.vendor.product.saveProduct, 302); - await this.toContainText(selector.vendor.product.dokanMessage, 'The product has been saved successfully. '); - await this.toHaveValue(selector.vendor.product.edit.title, productName); - await this.toHaveValue(selector.vendor.product.create.productPrice, productPrice); + await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.products, productsVendor.saveProduct, 302); + await this.toContainText(productsVendor.dokanMessage, 'The product has been saved successfully. '); + await this.toHaveValue(productsVendor.edit.title, productName); + await this.toHaveValue(productsVendor.create.productPrice, productPrice); } } @@ -325,25 +329,25 @@ export class ProductsPage extends AdminPage { const productName = product.productName(); const productPrice = product.regularPrice(); productPopup ? await this.vendorAddSimpleProduct(product, productPopup) : await this.addProduct(productName); - await this.clearAndType(selector.vendor.product.create.productPrice, productPrice); - await this.check(selector.vendor.product.edit.downloadable); + await this.clearAndType(productsVendor.create.productPrice, productPrice); + await this.check(productsVendor.edit.downloadable); // await this.addProductCategory(product.category); - await this.click(selector.vendor.product.downloadableOptions.addFile); - await this.clearAndType(selector.vendor.product.downloadableOptions.fileName, product.downloadableOptions.fileName); - await this.click(selector.vendor.product.downloadableOptions.chooseFile); + await this.click(productsVendor.downloadableOptions.addFile); + await this.clearAndType(productsVendor.downloadableOptions.fileName, product.downloadableOptions.fileName); + await this.click(productsVendor.downloadableOptions.chooseFile); await this.uploadMedia(product.downloadableOptions.fileUrl); - await this.clearAndType(selector.vendor.product.downloadableOptions.downloadLimit, product.downloadableOptions.downloadLimit); - await this.clearAndType(selector.vendor.product.downloadableOptions.downloadExpiry, product.downloadableOptions.downloadExpiry); + await this.clearAndType(productsVendor.downloadableOptions.downloadLimit, product.downloadableOptions.downloadLimit); + await this.clearAndType(productsVendor.downloadableOptions.downloadExpiry, product.downloadableOptions.downloadExpiry); - await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.products, selector.vendor.product.saveProduct, 302); - await this.toContainText(selector.vendor.product.updatedSuccessMessage, product.saveSuccessMessage); - await this.toHaveValue(selector.vendor.product.edit.title, productName); - await this.toHaveValue(selector.vendor.product.create.productPrice, productPrice); - await this.toBeChecked(selector.vendor.product.edit.downloadable); - await this.toHaveValue(selector.vendor.product.downloadableOptions.fileName, product.downloadableOptions.fileName); - await this.toHaveValue(selector.vendor.product.downloadableOptions.downloadLimit, product.downloadableOptions.downloadLimit); - await this.toHaveValue(selector.vendor.product.downloadableOptions.downloadExpiry, product.downloadableOptions.downloadExpiry); + await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.products, productsVendor.saveProduct, 302); + await this.toContainText(productsVendor.updatedSuccessMessage, product.saveSuccessMessage); + await this.toHaveValue(productsVendor.edit.title, productName); + await this.toHaveValue(productsVendor.create.productPrice, productPrice); + await this.toBeChecked(productsVendor.edit.downloadable); + await this.toHaveValue(productsVendor.downloadableOptions.fileName, product.downloadableOptions.fileName); + await this.toHaveValue(productsVendor.downloadableOptions.downloadLimit, product.downloadableOptions.downloadLimit); + await this.toHaveValue(productsVendor.downloadableOptions.downloadExpiry, product.downloadableOptions.downloadExpiry); } // vendor add vitual product @@ -351,16 +355,16 @@ export class ProductsPage extends AdminPage { const productName = product.productName(); const productPrice = product.regularPrice(); productPopup ? await this.vendorAddSimpleProduct(product, productPopup) : await this.addProduct(productName); - await this.clearAndType(selector.vendor.product.create.productPrice, productPrice); - await this.check(selector.vendor.product.edit.virtual); + await this.clearAndType(productsVendor.create.productPrice, productPrice); + await this.check(productsVendor.edit.virtual); // await this.addProductCategory(product.category); - await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.products, selector.vendor.product.saveProduct, 302); - await this.toContainText(selector.vendor.product.updatedSuccessMessage, product.saveSuccessMessage); - await this.toHaveValue(selector.vendor.product.edit.title, productName); - await this.toHaveValue(selector.vendor.product.create.productPrice, productPrice); - await this.toBeChecked(selector.vendor.product.edit.virtual); - await this.notToBeVisible(selector.vendor.product.shipping.shippingContainer); + await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.products, productsVendor.saveProduct, 302); + await this.toContainText(productsVendor.updatedSuccessMessage, product.saveSuccessMessage); + await this.toHaveValue(productsVendor.edit.title, productName); + await this.toHaveValue(productsVendor.create.productPrice, productPrice); + await this.toBeChecked(productsVendor.edit.virtual); + await this.notToBeVisible(productsVendor.shipping.shippingContainer); } // vendor add variable product @@ -369,24 +373,24 @@ export class ProductsPage extends AdminPage { productPopup ? await this.vendorAddSimpleProduct(product, productPopup) : await this.addProduct(productName); // edit product - await this.selectByValue(selector.vendor.product.edit.productType, product.productType); + await this.selectByValue(productsVendor.edit.productType, product.productType); // add variation - await this.selectByValue(selector.vendor.product.attribute.customProductAttribute, `pa_${product.attribute}`); - await this.click(selector.vendor.product.attribute.addAttribute); - await this.click(selector.vendor.product.attribute.selectAll); - await this.click(selector.vendor.product.attribute.usedForVariations); - await this.click(selector.vendor.product.attribute.saveAttributes); - await this.selectByValue(selector.vendor.product.attribute.addVariations, product.variations.linkAllVariation); - await this.click(selector.vendor.product.attribute.go); - await this.click(selector.vendor.product.attribute.confirmGo); - await this.click(selector.vendor.product.attribute.okSuccessAlertGo); - await this.selectByValue(selector.vendor.product.attribute.addVariations, product.variations.variableRegularPrice); - await this.click(selector.vendor.product.attribute.go); - await this.type(selector.vendor.product.attribute.variationPrice, product.regularPrice()); - await this.click(selector.vendor.product.attribute.okVariationPrice); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.product.saveProduct, 302); - await this.toContainText(selector.vendor.product.updatedSuccessMessage, product.saveSuccessMessage); - await this.toHaveValue(selector.vendor.product.edit.title, productName); + await this.selectByValue(productsVendor.attribute.customProductAttribute, `pa_${product.attribute}`); + await this.click(productsVendor.attribute.addAttribute); + await this.click(productsVendor.attribute.selectAll); + await this.click(productsVendor.attribute.usedForVariations); + await this.click(productsVendor.attribute.saveAttributes); + await this.selectByValue(productsVendor.attribute.addVariations, product.variations.linkAllVariation); + await this.click(productsVendor.attribute.go); + await this.click(productsVendor.attribute.confirmGo); + await this.click(productsVendor.attribute.okSuccessAlertGo); + await this.selectByValue(productsVendor.attribute.addVariations, product.variations.variableRegularPrice); + await this.click(productsVendor.attribute.go); + await this.type(productsVendor.attribute.variationPrice, product.regularPrice()); + await this.click(productsVendor.attribute.okVariationPrice); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, productsVendor.saveProduct, 302); + await this.toContainText(productsVendor.updatedSuccessMessage, product.saveSuccessMessage); + await this.toHaveValue(productsVendor.edit.title, productName); } // vendor add simple subscription product @@ -394,16 +398,16 @@ export class ProductsPage extends AdminPage { const productName = product.productName(); productPopup ? await this.vendorAddSimpleProduct(product, productPopup) : await this.addProduct(productName); // edit product - await this.selectByValue(selector.vendor.product.edit.productType, product.productType); - await this.type(selector.vendor.product.edit.subscriptionPrice, product.subscriptionPrice()); - await this.selectByValue(selector.vendor.product.edit.subscriptionPeriodInterval, product.subscriptionPeriodInterval); - await this.selectByValue(selector.vendor.product.edit.subscriptionPeriod, product.subscriptionPeriod); - await this.selectByValue(selector.vendor.product.edit.expireAfter, product.expireAfter); - await this.type(selector.vendor.product.edit.subscriptionTrialLength, product.subscriptionTrialLength); - await this.selectByValue(selector.vendor.product.edit.subscriptionTrialPeriod, product.subscriptionTrialPeriod); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.product.saveProduct, 302); - await this.toContainText(selector.vendor.product.updatedSuccessMessage, product.saveSuccessMessage); - await this.toHaveValue(selector.vendor.product.edit.title, productName); + await this.selectByValue(productsVendor.edit.productType, product.productType); + await this.type(productsVendor.edit.subscriptionPrice, product.subscriptionPrice()); + await this.selectByValue(productsVendor.edit.subscriptionPeriodInterval, product.subscriptionPeriodInterval); + await this.selectByValue(productsVendor.edit.subscriptionPeriod, product.subscriptionPeriod); + await this.selectByValue(productsVendor.edit.expireAfter, product.expireAfter); + await this.type(productsVendor.edit.subscriptionTrialLength, product.subscriptionTrialLength); + await this.selectByValue(productsVendor.edit.subscriptionTrialPeriod, product.subscriptionTrialPeriod); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, productsVendor.saveProduct, 302); + await this.toContainText(productsVendor.updatedSuccessMessage, product.saveSuccessMessage); + await this.toHaveValue(productsVendor.edit.title, productName); //todo: add more assettions } @@ -412,24 +416,24 @@ export class ProductsPage extends AdminPage { const productName = product.productName(); productPopup ? await this.vendorAddSimpleProduct(product, productPopup) : await this.addProduct(productName); // edit product - await this.selectByValue(selector.vendor.product.edit.productType, product.productType); + await this.selectByValue(productsVendor.edit.productType, product.productType); // add variation - await this.selectByValue(selector.vendor.product.attribute.customProductAttribute, `pa_${product.attribute}`); - await this.click(selector.vendor.product.attribute.addAttribute); - await this.click(selector.vendor.product.attribute.selectAll); - await this.click(selector.vendor.product.attribute.usedForVariations); - await this.click(selector.vendor.product.attribute.saveAttributes); - await this.selectByValue(selector.vendor.product.attribute.addVariations, product.variations.linkAllVariation); - await this.click(selector.vendor.product.attribute.go); - await this.click(selector.vendor.product.attribute.confirmGo); - await this.click(selector.vendor.product.attribute.okSuccessAlertGo); - await this.selectByValue(selector.vendor.product.attribute.addVariations, product.variations.variableRegularPrice); - await this.click(selector.vendor.product.attribute.go); - await this.type(selector.vendor.product.attribute.variationPrice, product.regularPrice()); - await this.click(selector.vendor.product.attribute.okVariationPrice); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.product.saveProduct, 302); - await this.toContainText(selector.vendor.product.updatedSuccessMessage, product.saveSuccessMessage); - await this.toHaveValue(selector.vendor.product.edit.title, productName); + await this.selectByValue(productsVendor.attribute.customProductAttribute, `pa_${product.attribute}`); + await this.click(productsVendor.attribute.addAttribute); + await this.click(productsVendor.attribute.selectAll); + await this.click(productsVendor.attribute.usedForVariations); + await this.click(productsVendor.attribute.saveAttributes); + await this.selectByValue(productsVendor.attribute.addVariations, product.variations.linkAllVariation); + await this.click(productsVendor.attribute.go); + await this.click(productsVendor.attribute.confirmGo); + await this.click(productsVendor.attribute.okSuccessAlertGo); + await this.selectByValue(productsVendor.attribute.addVariations, product.variations.variableRegularPrice); + await this.click(productsVendor.attribute.go); + await this.type(productsVendor.attribute.variationPrice, product.regularPrice()); + await this.click(productsVendor.attribute.okVariationPrice); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, productsVendor.saveProduct, 302); + await this.toContainText(productsVendor.updatedSuccessMessage, product.saveSuccessMessage); + await this.toHaveValue(productsVendor.edit.title, productName); //todo: add more assettions } @@ -438,38 +442,38 @@ export class ProductsPage extends AdminPage { const productName = product.productName(); productPopup ? await this.vendorAddSimpleProduct(product, productPopup) : await this.addProduct(productName); // edit product - await this.selectByValue(selector.vendor.product.edit.productType, product.productType); - await this.type(selector.vendor.product.edit.productUrl, this.getBaseUrl() + product.productUrl); - await this.type(selector.vendor.product.edit.buttonText, product.buttonText); - await this.clearAndType(selector.vendor.product.edit.price, product.regularPrice()); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.product.saveProduct, 302); - await this.toContainText(selector.vendor.product.updatedSuccessMessage, product.saveSuccessMessage); - await this.toHaveValue(selector.vendor.product.edit.title, productName); + await this.selectByValue(productsVendor.edit.productType, product.productType); + await this.type(productsVendor.edit.productUrl, this.getBaseUrl() + product.productUrl); + await this.type(productsVendor.edit.buttonText, product.buttonText); + await this.clearAndType(productsVendor.edit.price, product.regularPrice()); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, productsVendor.saveProduct, 302); + await this.toContainText(productsVendor.updatedSuccessMessage, product.saveSuccessMessage); + await this.toHaveValue(productsVendor.edit.title, productName); //todo: add more assettions } // go to product edit async goToProductEdit(productName: string): Promise { await this.searchProduct(productName); - await this.hover(selector.vendor.product.productCell(productName)); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.product.editProduct(productName)); - await this.toHaveValue(selector.vendor.product.edit.title, productName); + await this.hover(productsVendor.productCell(productName)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, productsVendor.editProduct(productName)); + await this.toHaveValue(productsVendor.edit.title, productName); } // vendor add product category async addProductCategory(category: string): Promise { - const productPopup = await this.isVisible(selector.vendor.product.create.productPopup); - productPopup ? await this.click(selector.vendor.product.category.productCategoryModalOnProductPopup) : await this.click(selector.vendor.product.category.productCategoryModal); - await this.waitForVisibleLocator(selector.vendor.product.category.productCategorySearchInput); - await this.type(selector.vendor.product.category.productCategorySearchInput, category); - await this.toContainText(selector.vendor.product.category.searchedResultText, category); - await this.click(selector.vendor.product.category.productCategorySearchResult); - await this.click(selector.vendor.product.category.productCategoryDone); - - const categoryAlreadySelectedPopup = await this.isVisible(selector.vendor.product.category.productCategoryAlreadySelectedPopup); + const productPopup = await this.isVisible(productsVendor.create.productPopup); + productPopup ? await this.click(productsVendor.category.productCategoryModalOnProductPopup) : await this.click(productsVendor.category.productCategoryModal); + await this.waitForVisibleLocator(productsVendor.category.productCategorySearchInput); + await this.type(productsVendor.category.productCategorySearchInput, category); + await this.toContainText(productsVendor.category.searchedResultText, category); + await this.click(productsVendor.category.productCategorySearchResult); + await this.click(productsVendor.category.productCategoryDone); + + const categoryAlreadySelectedPopup = await this.isVisible(productsVendor.category.productCategoryAlreadySelectedPopup); if (categoryAlreadySelectedPopup) { - await this.click(selector.vendor.product.category.productCategoryAlreadySelectedPopup); - await this.click(selector.vendor.product.category.productCategoryModalClose); + await this.click(productsVendor.category.productCategoryAlreadySelectedPopup); + await this.click(productsVendor.category.productCategoryModalClose); } // todo: add multiple category selection } @@ -478,14 +482,14 @@ export class ProductsPage extends AdminPage { async vendorAddProductCategory(productName: string, category: string): Promise { await this.goToProductEdit(productName); await this.addProductCategory(category); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.product.saveProduct, 302); - await this.toContainText(selector.vendor.product.updatedSuccessMessage, 'Success! The product has been saved successfully.'); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, productsVendor.saveProduct, 302); + await this.toContainText(productsVendor.updatedSuccessMessage, 'Success! The product has been saved successfully.'); } // export product async exportProducts(): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.products); - await this.clickAndWaitForLoadState(selector.vendor.product.importExport.export); + await this.clickAndWaitForLoadState(productsVendor.importExport.export); await this.clickAndWaitForDownload(selector.vendor.vTools.export.csv.generateCsv); } @@ -493,9 +497,9 @@ export class ProductsPage extends AdminPage { async searchProduct(productName: string): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.products); - await this.clearAndType(selector.vendor.product.search.searchInput, productName); - await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.products, selector.vendor.product.search.searchBtn); - await this.toBeVisible(selector.vendor.product.productLink(productName)); + await this.clearAndType(productsVendor.search.searchInput, productName); + await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.products, productsVendor.search.searchBtn); + await this.toBeVisible(productsVendor.productLink(productName)); } // filter products @@ -504,34 +508,34 @@ export class ProductsPage extends AdminPage { switch (filterBy) { case 'by-date': - await this.selectByNumber(selector.vendor.product.filters.filterByDate, value); + await this.selectByNumber(productsVendor.filters.filterByDate, value); break; case 'by-category': - await this.selectByLabel(selector.vendor.product.filters.filterByCategory, value); + await this.selectByLabel(productsVendor.filters.filterByCategory, value); break; case 'by-type': - await this.selectByValue(selector.vendor.product.filters.filterByType, value); + await this.selectByValue(productsVendor.filters.filterByType, value); break; case 'by-other': - await this.selectByValue(selector.vendor.product.filters.filterByOther, value); + await this.selectByValue(productsVendor.filters.filterByOther, value); break; default: break; } - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.product.filters.filter); - await this.notToHaveCount(selector.vendor.product.numberOfRowsFound, 0); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, productsVendor.filters.filter); + await this.notToHaveCount(productsVendor.numberOfRowsFound, 0); } // view product async viewProduct(productName: string): Promise { await this.searchProduct(productName); - await this.hover(selector.vendor.product.productCell(productName)); - await this.clickAndWaitForLoadState(selector.vendor.product.view(productName)); + await this.hover(productsVendor.productCell(productName)); + await this.clickAndWaitForLoadState(productsVendor.view(productName)); await expect(this.page).toHaveURL(data.subUrls.frontend.productDetails(helpers.slugify(productName)) + '/'); const { quantity, addToCart, viewCart, ...productDetails } = selector.customer.cSingleProduct.productDetails; await this.multipleElementVisible(productDetails); @@ -548,12 +552,12 @@ export class ProductsPage extends AdminPage { async editProduct(product: product['simple']): Promise { await this.goToProductEdit(product.editProduct); - await this.clearAndType(selector.vendor.product.edit.title, product.editProduct); // don't update name below test needs same product - await this.clearAndType(selector.vendor.product.edit.price, product.regularPrice()); + await this.clearAndType(productsVendor.edit.title, product.editProduct); // don't update name below test needs same product + await this.clearAndType(productsVendor.edit.price, product.regularPrice()); // todo: add more fields - await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.products, selector.vendor.product.saveProduct, 302); - await this.toContainText(selector.vendor.product.dokanMessage, 'The product has been saved successfully. '); + await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.products, productsVendor.saveProduct, 302); + await this.toContainText(productsVendor.dokanMessage, 'The product has been saved successfully. '); } // product edit @@ -561,171 +565,157 @@ export class ProductsPage extends AdminPage { // add product description async addProductDescription(productName: string, description: product['productInfo']['description']): Promise { await this.goToProductEdit(productName); - await this.typeFrameSelector(selector.vendor.product.shortDescription.shortDescriptionIframe, selector.vendor.product.shortDescription.shortDescriptionHtmlBody, description.shortDescription); - await this.typeFrameSelector(selector.vendor.product.description.descriptionIframe, selector.vendor.product.description.descriptionHtmlBody, description.description); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.product.saveProduct, 302); - await this.toContainText(selector.vendor.product.updatedSuccessMessage, data.product.createUpdateSaveSuccessMessage); + await this.typeFrameSelector(productsVendor.shortDescription.shortDescriptionIframe, productsVendor.shortDescription.shortDescriptionHtmlBody, description.shortDescription); + await this.typeFrameSelector(productsVendor.description.descriptionIframe, productsVendor.description.descriptionHtmlBody, description.description); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, productsVendor.saveProduct, 302); + await this.toContainText(productsVendor.updatedSuccessMessage, data.product.createUpdateSaveSuccessMessage); // todo: add more assertions } // add product quantity discount async addProductQuantityDiscount(productName: string, quantityDiscount: product['productInfo']['quantityDiscount']): Promise { await this.goToProductEdit(productName); - await this.check(selector.vendor.product.discount.enableBulkDiscount); // todo: need to fix - await this.clearAndType(selector.vendor.product.discount.lotMinimumQuantity, quantityDiscount.minimumQuantity); - await this.clearAndType(selector.vendor.product.discount.lotDiscountInPercentage, quantityDiscount.discountPercentage); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.product.saveProduct, 302); - await this.toContainText(selector.vendor.product.updatedSuccessMessage, data.product.createUpdateSaveSuccessMessage); + await this.check(productsVendor.discount.enableBulkDiscount); // todo: need to fix + await this.clearAndType(productsVendor.discount.lotMinimumQuantity, quantityDiscount.minimumQuantity); + await this.clearAndType(productsVendor.discount.lotDiscountInPercentage, quantityDiscount.discountPercentage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, productsVendor.saveProduct, 302); + await this.toContainText(productsVendor.updatedSuccessMessage, data.product.createUpdateSaveSuccessMessage); // todo: add more assertions } // vendor add product rma options async addProductRmaOptions(productName: string, rma: vendor['rma']): Promise { await this.goToProductEdit(productName); - await this.check(selector.vendor.product.rma.overrideYourDefaultRmaSettingsForThisProduct); - await this.clearAndType(selector.vendor.product.rma.label, rma.label); - await this.selectByValue(selector.vendor.product.rma.type, rma.type); - await this.selectByValue(selector.vendor.product.rma.length, rma.rmaLength); + await this.check(productsVendor.rma.overrideYourDefaultRmaSettingsForThisProduct); + await this.clearAndType(productsVendor.rma.label, rma.label); + await this.selectByValue(productsVendor.rma.type, rma.type); + await this.selectByValue(productsVendor.rma.length, rma.rmaLength); // todo: add rma as addon if (rma.rmaLength === 'limited') { - await this.clearAndType(selector.vendor.product.rma.lengthValue, rma.lengthValue); - await this.selectByValue(selector.vendor.product.rma.lengthDuration, rma.lengthDuration); + await this.clearAndType(productsVendor.rma.lengthValue, rma.lengthValue); + await this.selectByValue(productsVendor.rma.lengthDuration, rma.lengthDuration); } - const refundReasonIsVisible = await this.isVisible(selector.vendor.product.rma.refundReasonsFirst); + const refundReasonIsVisible = await this.isVisible(productsVendor.rma.refundReasonsFirst); if (refundReasonIsVisible) { - await this.checkMultiple(selector.vendor.product.rma.refundReasons); + await this.checkMultiple(productsVendor.rma.refundReasons); } - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.product.saveProduct, 302); - await this.toContainText(selector.vendor.product.updatedSuccessMessage, data.product.createUpdateSaveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, productsVendor.saveProduct, 302); + await this.toContainText(productsVendor.updatedSuccessMessage, data.product.createUpdateSaveSuccessMessage); //todo: add more assertions } // add product Wholesale options async addProductWholesaleOptions(productName: string, wholesaleOption: product['productInfo']['wholesaleOption']): Promise { await this.goToProductEdit(productName); - await this.check(selector.vendor.product.wholesale.enableWholeSaleForThisProduct); - await this.clearAndType(selector.vendor.product.wholesale.wholesalePrice, wholesaleOption.wholesalePrice); - await this.clearAndType(selector.vendor.product.wholesale.minimumQuantityForWholesale, wholesaleOption.minimumWholesaleQuantity); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.product.saveProduct, 302); - await this.toContainText(selector.vendor.product.updatedSuccessMessage, data.product.createUpdateSaveSuccessMessage); - await this.toHaveValue(selector.vendor.product.wholesale.wholesalePrice, wholesaleOption.wholesalePrice); - await this.toHaveValue(selector.vendor.product.wholesale.minimumQuantityForWholesale, wholesaleOption.minimumWholesaleQuantity); + await this.check(productsVendor.wholesale.enableWholeSaleForThisProduct); + await this.clearAndType(productsVendor.wholesale.wholesalePrice, wholesaleOption.wholesalePrice); + await this.clearAndType(productsVendor.wholesale.minimumQuantityForWholesale, wholesaleOption.minimumWholesaleQuantity); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, productsVendor.saveProduct, 302); + await this.toContainText(productsVendor.updatedSuccessMessage, data.product.createUpdateSaveSuccessMessage); + await this.toHaveValue(productsVendor.wholesale.wholesalePrice, wholesaleOption.wholesalePrice); + await this.toHaveValue(productsVendor.wholesale.minimumQuantityForWholesale, wholesaleOption.minimumWholesaleQuantity); } // add product min-max options async addProductMinMaxOptions(productName: string, minMaxOption: product['productInfo']['minMax']): Promise { await this.goToProductEdit(productName); - await this.check(selector.vendor.product.minMax.enableMinMaxRulesThisProduct); - await this.clearAndType(selector.vendor.product.minMax.minimumQuantity, minMaxOption.minimumProductQuantity); - await this.clearAndType(selector.vendor.product.minMax.maximumQuantity, minMaxOption.maximumProductQuantity); - await this.clearAndType(selector.vendor.product.minMax.minimumAmount, minMaxOption.minimumAmount); - await this.clearAndType(selector.vendor.product.minMax.maximumAmount, minMaxOption.maximumAmount); - await this.check(selector.vendor.product.minMax.orderRulesDoNotCount); - await this.check(selector.vendor.product.minMax.categoryRulesExclude); - - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.product.saveProduct, 302); - await this.toContainText(selector.vendor.product.updatedSuccessMessage, data.product.createUpdateSaveSuccessMessage); - await this.toBeChecked(selector.vendor.product.minMax.enableMinMaxRulesThisProduct); - await this.toHaveValue(selector.vendor.product.minMax.minimumQuantity, minMaxOption.minimumProductQuantity); - await this.toHaveValue(selector.vendor.product.minMax.maximumQuantity, minMaxOption.maximumProductQuantity); - await this.toHaveValue(selector.vendor.product.minMax.minimumAmount, minMaxOption.minimumAmount); - await this.toHaveValue(selector.vendor.product.minMax.maximumAmount, minMaxOption.maximumAmount); - await this.toBeChecked(selector.vendor.product.minMax.orderRulesDoNotCount); - await this.toBeChecked(selector.vendor.product.minMax.categoryRulesExclude); + await this.check(productsVendor.minMax.enableMinMaxRulesThisProduct); + await this.clearAndType(productsVendor.minMax.minimumQuantity, minMaxOption.minimumProductQuantity); + await this.clearAndType(productsVendor.minMax.maximumQuantity, minMaxOption.maximumProductQuantity); + await this.clearAndType(productsVendor.minMax.minimumAmount, minMaxOption.minimumAmount); + await this.clearAndType(productsVendor.minMax.maximumAmount, minMaxOption.maximumAmount); + await this.check(productsVendor.minMax.orderRulesDoNotCount); + await this.check(productsVendor.minMax.categoryRulesExclude); + + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, productsVendor.saveProduct, 302); + await this.toContainText(productsVendor.updatedSuccessMessage, data.product.createUpdateSaveSuccessMessage); + await this.toBeChecked(productsVendor.minMax.enableMinMaxRulesThisProduct); + await this.toHaveValue(productsVendor.minMax.minimumQuantity, minMaxOption.minimumProductQuantity); + await this.toHaveValue(productsVendor.minMax.maximumQuantity, minMaxOption.maximumProductQuantity); + await this.toHaveValue(productsVendor.minMax.minimumAmount, minMaxOption.minimumAmount); + await this.toHaveValue(productsVendor.minMax.maximumAmount, minMaxOption.maximumAmount); + await this.toBeChecked(productsVendor.minMax.orderRulesDoNotCount); + await this.toBeChecked(productsVendor.minMax.categoryRulesExclude); } // add product other (product status, visibility, purchase note, reviews) options async addProductOtherOptions(productName: string, otherOption: product['productInfo']['otherOptions']): Promise { await this.goToProductEdit(productName); - await this.selectByValue(selector.vendor.product.otherOptions.productStatus, otherOption.productStatus); - await this.selectByValue(selector.vendor.product.otherOptions.visibility, otherOption.visibility); - await this.clearAndType(selector.vendor.product.otherOptions.purchaseNote, otherOption.purchaseNote); - await this.check(selector.vendor.product.otherOptions.enableProductReviews); + await this.selectByValue(productsVendor.otherOptions.productStatus, otherOption.productStatus); + await this.selectByValue(productsVendor.otherOptions.visibility, otherOption.visibility); + await this.clearAndType(productsVendor.otherOptions.purchaseNote, otherOption.purchaseNote); + await this.check(productsVendor.otherOptions.enableProductReviews); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.product.saveProduct, 302); - await this.toContainText(selector.vendor.product.updatedSuccessMessage, data.product.createUpdateSaveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, productsVendor.saveProduct, 302); + await this.toContainText(productsVendor.updatedSuccessMessage, data.product.createUpdateSaveSuccessMessage); //todo: add more assertion - await this.toHaveValue(selector.vendor.product.otherOptions.purchaseNote, otherOption.purchaseNote); - await this.toBeChecked(selector.vendor.product.otherOptions.enableProductReviews); + await this.toHaveValue(productsVendor.otherOptions.purchaseNote, otherOption.purchaseNote); + await this.toBeChecked(productsVendor.otherOptions.enableProductReviews); } // add product description async addCatalogMode(productName: string): Promise { await this.goToProductEdit(productName); - await this.check(selector.vendor.product.catalogMode.removeAddToCart); - await this.check(selector.vendor.product.catalogMode.hideProductPrice); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.product.saveProduct, 302); - await this.toContainText(selector.vendor.product.updatedSuccessMessage, data.product.createUpdateSaveSuccessMessage); - await this.toBeChecked(selector.vendor.product.catalogMode.removeAddToCart); - await this.toBeChecked(selector.vendor.product.catalogMode.hideProductPrice); + await this.check(productsVendor.catalogMode.removeAddToCart); + await this.check(productsVendor.catalogMode.hideProductPrice); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, productsVendor.saveProduct, 302); + await this.toContainText(productsVendor.updatedSuccessMessage, data.product.createUpdateSaveSuccessMessage); + await this.toBeChecked(productsVendor.catalogMode.removeAddToCart); + await this.toBeChecked(productsVendor.catalogMode.hideProductPrice); } // quick edit product async quickEditProduct(product: product['simple']): Promise { await this.searchProduct(product.editProduct); - await this.hover(selector.vendor.product.productCell(product.editProduct)); - await this.click(selector.vendor.product.quickEdit(product.editProduct)); + await this.hover(productsVendor.productCell(product.editProduct)); + await this.click(productsVendor.quickEdit(product.editProduct)); - await this.clearAndType(selector.vendor.product.quickEditProduct.title, product.editProduct); + await this.clearAndType(productsVendor.quickEditProduct.title, product.editProduct); // todo: add more fields - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.product.quickEditProduct.update); + await this.clickAndWaitForResponse(data.subUrls.ajax, productsVendor.quickEditProduct.update); } // duplicate product async duplicateProduct(productName: string): Promise { await this.searchProduct(productName); - await this.hover(selector.vendor.product.productCell(productName)); - await this.clickAndAcceptAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.product.duplicate(productName)); - await this.toContainText(selector.vendor.product.dokanSuccessMessage, 'Product successfully duplicated'); + await this.hover(productsVendor.productCell(productName)); + await this.clickAndAcceptAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, productsVendor.duplicate(productName)); + await this.toContainText(productsVendor.dokanSuccessMessage, 'Product successfully duplicated'); } // permanently delete product async permanentlyDeleteProduct(productName: string): Promise { await this.searchProduct(productName); - await this.hover(selector.vendor.product.productCell(productName)); - await this.click(selector.vendor.product.permanentlyDelete(productName)); - await this.clickAndWaitForLoadState(selector.vendor.product.confirmAction); - await this.toContainText(selector.vendor.product.dokanSuccessMessage, 'Product successfully deleted'); + await this.hover(productsVendor.productCell(productName)); + await this.click(productsVendor.permanentlyDelete(productName)); + await this.clickAndWaitForLoadState(productsVendor.confirmAction); + await this.toContainText(productsVendor.dokanSuccessMessage, 'Product successfully deleted'); } // product bulk action async productBulkAction(action: string, productName?: string): Promise { productName ? await this.searchProduct(productName) : await this.goIfNotThere(data.subUrls.frontend.vDashboard.products); - await this.click(selector.vendor.product.bulkActions.selectAll); + await this.click(productsVendor.bulkActions.selectAll); switch (action) { case 'edit': - await this.selectByValue(selector.vendor.product.bulkActions.selectAction, 'edit'); + await this.selectByValue(productsVendor.bulkActions.selectAction, 'edit'); // todo: break; case 'permanently-delete': - await this.selectByValue(selector.vendor.product.bulkActions.selectAction, 'permanently-delete'); + await this.selectByValue(productsVendor.bulkActions.selectAction, 'permanently-delete'); break; case 'publish': - await this.selectByValue(selector.vendor.product.bulkActions.selectAction, 'publish'); + await this.selectByValue(productsVendor.bulkActions.selectAction, 'publish'); break; default: break; } - await this.clickAndAcceptAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.product.bulkActions.applyAction); - } - - // upload media // todo: move to base-page and merge with wpUploadFile - async uploadMedia(file: string) { - await this.wait(0.5); - const uploadedMediaIsVisible = await this.isVisible(selector.wpMedia.uploadedMediaFirst); - if (uploadedMediaIsVisible) { - await this.click(selector.wpMedia.uploadedMediaFirst); - } else { - await this.uploadFile(selector.wpMedia.selectFilesInput, file); - const isSelectDisabled = await this.isDisabled(selector.wpMedia.select); - isSelectDisabled && (await this.click(selector.wpMedia.selectUploadedMedia)); - await this.click(selector.wpMedia.select); - } + await this.clickAndAcceptAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, productsVendor.bulkActions.applyAction); } } diff --git a/tests/pw/pages/refundsPage.ts b/tests/pw/pages/refundsPage.ts index ee10cfcd97..3cd0f953b5 100644 --- a/tests/pw/pages/refundsPage.ts +++ b/tests/pw/pages/refundsPage.ts @@ -4,6 +4,10 @@ import { selector } from '@pages/selectors'; import { helpers } from '@utils/helpers'; import { data } from '@utils/testData'; +// selectors +const refundsAdmin = selector.admin.dokan.refunds; +const refundsVendor = selector.vendor.orders.refund; + export class RefundsPage extends AdminPage { constructor(page: Page) { super(page); @@ -16,31 +20,31 @@ export class RefundsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.refunds); // refund request text is visible - await this.toBeVisible(selector.admin.dokan.refunds.refundRequestsText); + await this.toBeVisible(refundsAdmin.refundRequestsText); // nav tabs are visible - await this.multipleElementVisible(selector.admin.dokan.refunds.navTabs); + await this.multipleElementVisible(refundsAdmin.navTabs); // bulk action elements are visible - await this.multipleElementVisible(selector.admin.dokan.refunds.bulkActions); + await this.multipleElementVisible(refundsAdmin.bulkActions); // refund request search is visible - await this.toBeVisible(selector.admin.dokan.refunds.search); + await this.toBeVisible(refundsAdmin.search); // refund table elements are visible - await this.multipleElementVisible(selector.admin.dokan.refunds.table); + await this.multipleElementVisible(refundsAdmin.table); } // search refund request async searchRefundRequests(orderOrStore: string) { await this.goIfNotThere(data.subUrls.backend.dokan.refunds); - await this.clearInputField(selector.admin.dokan.refunds.search); + await this.clearInputField(refundsAdmin.search); - await this.typeAndWaitForResponse(data.subUrls.api.dokan.refunds, selector.admin.dokan.refunds.search, String(orderOrStore)); - const count = (await this.getElementText(selector.admin.dokan.refunds.numberOfRowsFound))?.split(' ')[0]; + await this.typeAndWaitForResponse(data.subUrls.api.dokan.refunds, refundsAdmin.search, String(orderOrStore)); + const count = (await this.getElementText(refundsAdmin.numberOfRowsFound))?.split(' ')[0]; if (!isNaN(Number(orderOrStore))) { - await this.toBeVisible(selector.admin.dokan.refunds.refundCell(orderOrStore)); + await this.toBeVisible(refundsAdmin.refundCell(orderOrStore)); expect(Number(count)).toBe(1); } else { expect(Number(count)).toBeGreaterThan(0); @@ -51,14 +55,14 @@ export class RefundsPage extends AdminPage { async updateRefundRequests(orderNumber: string, action: string) { await this.searchRefundRequests(orderNumber); - await this.hover(selector.admin.dokan.refunds.refundCell(orderNumber)); + await this.hover(refundsAdmin.refundCell(orderNumber)); switch (action) { case 'approve': - await this.clickAndWaitForResponse(data.subUrls.api.dokan.refunds, selector.admin.dokan.refunds.approveRefund(orderNumber)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.refunds, refundsAdmin.approveRefund(orderNumber)); break; case 'cancel': - await this.clickAndWaitForResponse(data.subUrls.api.dokan.refunds, selector.admin.dokan.refunds.cancelRefund(orderNumber)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.refunds, refundsAdmin.cancelRefund(orderNumber)); break; default: @@ -72,11 +76,11 @@ export class RefundsPage extends AdminPage { // await this.goIfNotThere(data.subUrls.backend.dokan.refunds); // ensure row exists - await this.notToBeVisible(selector.admin.dokan.refunds.noRowsFound); + await this.notToBeVisible(refundsAdmin.noRowsFound); - await this.click(selector.admin.dokan.refunds.bulkActions.selectAll); - await this.selectByValue(selector.admin.dokan.refunds.bulkActions.selectAction, action); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.refunds, selector.admin.dokan.refunds.bulkActions.applyAction); + await this.click(refundsAdmin.bulkActions.selectAll); + await this.selectByValue(refundsAdmin.bulkActions.selectAction, action); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.refunds, refundsAdmin.bulkActions.applyAction); } // vendor @@ -102,41 +106,41 @@ export class RefundsPage extends AdminPage { await this.goToOrderDetails(orderNumber); // request refund - await this.click(selector.vendor.orders.refund.requestRefund); - const productQuantity = ((await this.getElementText(selector.vendor.orders.refund.productQuantity(productName))) as string).trim(); - const productCost = helpers.price((await this.getElementText(selector.vendor.orders.refund.productCost(productName))) as string); - const productTax = helpers.price((await this.getElementText(selector.vendor.orders.refund.productTax(productName))) as string); + await this.click(refundsVendor.requestRefund); + const productQuantity = ((await this.getElementText(refundsVendor.productQuantity(productName))) as string).trim(); + const productCost = helpers.price((await this.getElementText(refundsVendor.productCost(productName))) as string); + const productTax = helpers.price((await this.getElementText(refundsVendor.productTax(productName))) as string); let shippingCost = 0; let shippingTax = 0; - const isShipping = await this.isVisible(selector.vendor.orders.refund.shippingCost); + const isShipping = await this.isVisible(refundsVendor.shippingCost); if (isShipping) { - shippingCost = helpers.price((await this.getElementText(selector.vendor.orders.refund.shippingCost)) as string); - shippingTax = helpers.price((await this.getElementText(selector.vendor.orders.refund.shippingTax)) as string); + shippingCost = helpers.price((await this.getElementText(refundsVendor.shippingCost)) as string); + shippingTax = helpers.price((await this.getElementText(refundsVendor.shippingTax)) as string); } - await this.clearAndType(selector.vendor.orders.refund.refundProductQuantity(productName), productQuantity); - await this.click(selector.vendor.orders.refund.refundDiv); + await this.clearAndType(refundsVendor.refundProductQuantity(productName), productQuantity); + await this.click(refundsVendor.refundDiv); if (partialRefund) { - await this.clearAndType(selector.vendor.orders.refund.refundProductCostAmount(productName), helpers.priceString(helpers.roundToTwo(productCost / 2), 'ES')); // todo: price style is fixed, make it dynamic - await this.clearAndType(selector.vendor.orders.refund.refundProductTaxAmount(productName), helpers.priceString(helpers.roundToTwo(productTax / 2), 'ES')); + await this.clearAndType(refundsVendor.refundProductCostAmount(productName), helpers.priceString(helpers.roundToTwo(productCost / 2), 'ES')); // todo: price style is fixed, make it dynamic + await this.clearAndType(refundsVendor.refundProductTaxAmount(productName), helpers.priceString(helpers.roundToTwo(productTax / 2), 'ES')); if (isShipping) { - await this.clearAndType(selector.vendor.orders.refund.refundShippingAmount, helpers.priceString(helpers.roundToTwo(shippingCost / 2), 'ES')); - await this.clearAndType(selector.vendor.orders.refund.refundShippingTaxAmount, helpers.priceString(helpers.roundToTwo(shippingTax / 2), 'ES')); + await this.clearAndType(refundsVendor.refundShippingAmount, helpers.priceString(helpers.roundToTwo(shippingCost / 2), 'ES')); + await this.clearAndType(refundsVendor.refundShippingTaxAmount, helpers.priceString(helpers.roundToTwo(shippingTax / 2), 'ES')); } } else { - await this.clearAndType(selector.vendor.orders.refund.refundProductCostAmount(productName), helpers.priceString(productCost, 'ES')); - await this.clearAndType(selector.vendor.orders.refund.refundProductTaxAmount(productName), helpers.priceString(productTax, 'ES')); + await this.clearAndType(refundsVendor.refundProductCostAmount(productName), helpers.priceString(productCost, 'ES')); + await this.clearAndType(refundsVendor.refundProductTaxAmount(productName), helpers.priceString(productTax, 'ES')); if (isShipping) { - await this.clearAndType(selector.vendor.orders.refund.refundShippingAmount, helpers.priceString(shippingCost, 'ES')); - await this.clearAndType(selector.vendor.orders.refund.refundShippingTaxAmount, helpers.priceString(shippingTax, 'ES')); + await this.clearAndType(refundsVendor.refundShippingAmount, helpers.priceString(shippingCost, 'ES')); + await this.clearAndType(refundsVendor.refundShippingTaxAmount, helpers.priceString(shippingTax, 'ES')); } } - await this.clearAndType(selector.vendor.orders.refund.refundReason, 'Defective product'); - await this.click(selector.vendor.orders.refund.refundManually); - await this.click(selector.vendor.orders.refund.confirmRefund); + await this.clearAndType(refundsVendor.refundReason, 'Defective product'); + await this.click(refundsVendor.refundManually); + await this.click(refundsVendor.confirmRefund); - await this.toContainText(selector.vendor.orders.refund.refundRequestSuccessMessage, 'Refund request submitted.'); - await this.click(selector.vendor.orders.refund.refundRequestSuccessMessageOk); + await this.toContainText(refundsVendor.refundRequestSuccessMessage, 'Refund request submitted.'); + await this.click(refundsVendor.refundRequestSuccessMessageOk); } } diff --git a/tests/pw/pages/reportsPage.ts b/tests/pw/pages/reportsPage.ts index c56559bcc9..696c5df1da 100644 --- a/tests/pw/pages/reportsPage.ts +++ b/tests/pw/pages/reportsPage.ts @@ -3,6 +3,9 @@ import { AdminPage } from '@pages/adminPage'; import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; +// selectors +const reportsAdmin = selector.admin.dokan.reports; + export class ReportsPage extends AdminPage { constructor(page: Page) { super(page); @@ -15,22 +18,22 @@ export class ReportsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.reports); // report Menus are visible - await this.multipleElementVisible(selector.admin.dokan.reports.menus); + await this.multipleElementVisible(reportsAdmin.menus); // filter Menus are visible - await this.multipleElementVisible(selector.admin.dokan.reports.reports.filterMenus); + await this.multipleElementVisible(reportsAdmin.reports.filterMenus); // calendar input is visible - await this.toBeVisible(selector.admin.dokan.reports.reports.calendar); + await this.toBeVisible(reportsAdmin.reports.calendar); // show button is visible - await this.toBeVisible(selector.admin.dokan.reports.reports.show); + await this.toBeVisible(reportsAdmin.reports.show); // at a glance elements are visible - await this.multipleElementVisible(selector.admin.dokan.reports.reports.atAGlance); + await this.multipleElementVisible(reportsAdmin.reports.atAGlance); // overview elements are visible - await this.multipleElementVisible(selector.admin.dokan.reports.reports.overview); + await this.multipleElementVisible(reportsAdmin.reports.overview); } // all logs @@ -40,65 +43,67 @@ export class ReportsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.allLogs); // report Menus are visible - await this.multipleElementVisible(selector.admin.dokan.reports.menus); + await this.multipleElementVisible(reportsAdmin.menus); // filter elements are visible - const { filterByStoreInput, filterByStatusInput, searchedResult, ...filters } = selector.admin.dokan.reports.allLogs.filters; + const { filterByStoreInput, filterByStatusInput, searchedResult, ...filters } = reportsAdmin.allLogs.filters; await this.multipleElementVisible(filters); // search is visible - await this.toBeVisible(selector.admin.dokan.reports.allLogs.search); + await this.toBeVisible(reportsAdmin.allLogs.search); // export log is visible - await this.toBeVisible(selector.admin.dokan.reports.allLogs.exportLogs); + await this.toBeVisible(reportsAdmin.allLogs.exportLogs); // all logs table elements are visible - await this.multipleElementVisible(selector.admin.dokan.reports.allLogs.table); + await this.multipleElementVisible(reportsAdmin.allLogs.table); } // search all logs async searchAllLogs(orderId: string) { await this.goIfNotThere(data.subUrls.backend.dokan.allLogs); - await this.clearInputField(selector.admin.dokan.reports.allLogs.search); - await this.typeViaPageAndWaitForResponse(data.subUrls.api.dokan.logs, selector.admin.dokan.reports.allLogs.search, orderId); - await this.toBeVisible(selector.admin.dokan.reports.allLogs.orderIdCell(orderId)); - const count = (await this.getElementText(selector.admin.dokan.reports.allLogs.numberOfRowsFound))?.split(' ')[0]; + await this.clearInputField(reportsAdmin.allLogs.search); + await this.typeAndWaitForResponseAndLoadState(data.subUrls.api.dokan.logs, reportsAdmin.allLogs.search, orderId); + await this.notToBeVisible(selector.admin.dokan.loader); + await this.wait(2); // todo: resolve this + await this.toBeVisible(reportsAdmin.allLogs.orderIdCell(orderId)); + const count = (await this.getElementText(reportsAdmin.allLogs.numberOfRowsFound))?.split(' ')[0]; expect(Number(count)).toBe(1); - // await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.logs, selector.admin.dokan.reports.allLogs.filters.clear); + // await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.logs, reportsAdmin.allLogs.filters.clear); } // export all logs async exportAllLogs(orderId?: string) { orderId && (await this.searchAllLogs(orderId)); - await this.clickAndWaitForDownload(selector.admin.dokan.reports.allLogs.exportLogs); + await this.clickAndWaitForDownload(reportsAdmin.allLogs.exportLogs); } // filter all logs by store async filterAllLogsByStore(storeName: string) { await this.goIfNotThere(data.subUrls.backend.dokan.allLogs); - await this.click(selector.admin.dokan.reports.allLogs.filters.filterByStore); - await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, selector.admin.dokan.reports.allLogs.filters.filterByStoreInput, storeName); + await this.click(reportsAdmin.allLogs.filters.filterByStore); + await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, reportsAdmin.allLogs.filters.filterByStoreInput, storeName); await this.press(data.key.arrowDown); - // await this.toContainText(selector.admin.dokan.reports.allLogs.filters.searchedResult, (storeName)); + // await this.toContainText(reportsAdmin.allLogs.filters.searchedResult, (storeName)); await this.pressAndWaitForResponse(data.subUrls.api.dokan.logs, data.key.enter); - const count = (await this.getElementText(selector.admin.dokan.reports.allLogs.numberOfRowsFound))?.split(' ')[0]; + const count = (await this.getElementText(reportsAdmin.allLogs.numberOfRowsFound))?.split(' ')[0]; expect(Number(count)).toBeGreaterThan(0); - // await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.logs, selector.admin.dokan.reports.allLogs.filters.clear); + // await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.logs, reportsAdmin.allLogs.filters.clear); } // filter all logs by status async filterAllLogsByStatus(orderStatus: string) { await this.goIfNotThere(data.subUrls.backend.dokan.allLogs); - await this.click(selector.admin.dokan.reports.allLogs.filters.filterByStatus); // todo: add multiselect option - await this.type(selector.admin.dokan.reports.allLogs.filters.filterByStatusInput, orderStatus); - // await this.toContainText(selector.admin.dokan.reports.allLogs.filters.searchedResult, (orderStatus)); - await this.clickAndAcceptAndWaitForResponse(data.subUrls.api.dokan.logs, selector.admin.dokan.reports.allLogs.filters.searchedResult); - const count = (await this.getElementText(selector.admin.dokan.reports.allLogs.numberOfRowsFound))?.split(' ')[0]; + await this.click(reportsAdmin.allLogs.filters.filterByStatus); // todo: add multiselect option + await this.type(reportsAdmin.allLogs.filters.filterByStatusInput, orderStatus); + // await this.toContainText(reportsAdmin.allLogs.filters.searchedResult, (orderStatus)); + await this.clickAndAcceptAndWaitForResponse(data.subUrls.api.dokan.logs, reportsAdmin.allLogs.filters.searchedResult); + const count = (await this.getElementText(reportsAdmin.allLogs.numberOfRowsFound))?.split(' ')[0]; expect(Number(count)).toBeGreaterThan(0); - // await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.logs, selector.admin.dokan.reports.allLogs.filters.clear); + // await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.logs, reportsAdmin.allLogs.filters.clear); } } diff --git a/tests/pw/pages/requestForQuotationsPage.ts b/tests/pw/pages/requestForQuotationsPage.ts index 2b66eb303a..7b9cb560f4 100644 --- a/tests/pw/pages/requestForQuotationsPage.ts +++ b/tests/pw/pages/requestForQuotationsPage.ts @@ -6,6 +6,11 @@ import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; import { requestForQuotation } from '@utils/interfaces'; +// selectors +const requestForQuotationAdmin = selector.admin.dokan.requestForQuotation; +const requestForQuotationVendor = selector.vendor.vRequestQuotes; +const requestForQuotationCustomer = selector.customer.cRequestForQuote; + export class RequestForQuotationsPage extends AdminPage { constructor(page: Page) { super(page); @@ -23,58 +28,58 @@ export class RequestForQuotationsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuoteRules); // request for quote menus are visible - await this.multipleElementVisible(selector.admin.dokan.requestForQuotation.menus); + await this.multipleElementVisible(requestForQuotationAdmin.menus); // quote rules text is visible - await this.toBeVisible(selector.admin.dokan.requestForQuotation.quoteRules.quoteRulesText); + await this.toBeVisible(requestForQuotationAdmin.quoteRules.quoteRulesText); // new quote rules is visible - await this.toBeVisible(selector.admin.dokan.requestForQuotation.quoteRules.newQuoteRule); + await this.toBeVisible(requestForQuotationAdmin.quoteRules.newQuoteRule); // nav tabs are visible - await this.multipleElementVisible(selector.admin.dokan.requestForQuotation.quoteRules.navTabs); + await this.multipleElementVisible(requestForQuotationAdmin.quoteRules.navTabs); // bulk action elements are visible - await this.multipleElementVisible(selector.admin.dokan.requestForQuotation.quoteRules.bulkActions); + await this.multipleElementVisible(requestForQuotationAdmin.quoteRules.bulkActions); // quote rules table elements are visible - await this.multipleElementVisible(selector.admin.dokan.requestForQuotation.quoteRules.table); + await this.multipleElementVisible(requestForQuotationAdmin.quoteRules.table); } // update quote rule files async updateQuoteRuleFields(rule: requestForQuotation['quoteRule']) { - await this.clearAndType(selector.admin.dokan.requestForQuotation.quoteRules.addNewQuoteRule.ruleTitle, rule.title); - await this.check(selector.admin.dokan.requestForQuotation.quoteRules.addNewQuoteRule.applyQuoteFor(rule.userRole)); + await this.clearAndType(requestForQuotationAdmin.quoteRules.addNewQuoteRule.ruleTitle, rule.title); + await this.check(requestForQuotationAdmin.quoteRules.addNewQuoteRule.applyQuoteFor(rule.userRole)); // products - await this.click(selector.admin.dokan.requestForQuotation.quoteRules.addNewQuoteRule.applyOnAllProducts); - // await this.click(selector.admin.dokan.requestForQuotation.quoteRules.addNewQuoteRule.selectProductsDropDown); - // await this.typeAndWaitForResponse(data.subUrls.api.dokan.quoteRules, selector.admin.dokan.requestForQuotation.quoteRules.addNewQuoteRule.selectProductsInput, rule.product); + await this.click(requestForQuotationAdmin.quoteRules.addNewQuoteRule.applyOnAllProducts); + // await this.click(requestForQuotationAdmin.quoteRules.addNewQuoteRule.selectProductsDropDown); + // await this.typeAndWaitForResponse(data.subUrls.api.dokan.quoteRules, requestForQuotationAdmin.quoteRules.addNewQuoteRule.selectProductsInput, rule.product); // await this.press(data.key.enter); // category - // await this.check(selector.admin.dokan.requestForQuotation.quoteRules.addNewQuoteRule.selectCategories(rule.category)); + // await this.check(requestForQuotationAdmin.quoteRules.addNewQuoteRule.selectCategories(rule.category)); - await this.selectByValue(selector.admin.dokan.requestForQuotation.quoteRules.addNewQuoteRule.hidePrice, rule.hidePrice); - await this.clearAndType(selector.admin.dokan.requestForQuotation.quoteRules.addNewQuoteRule.hidePriceText, rule.hidePriceText); - await this.selectByValue(selector.admin.dokan.requestForQuotation.quoteRules.addNewQuoteRule.hideAddToCartButton, rule.hideAddToCartButton); - await this.clearAndType(selector.admin.dokan.requestForQuotation.quoteRules.addNewQuoteRule.customButtonLabel, rule.customButtonLabel); + await this.selectByValue(requestForQuotationAdmin.quoteRules.addNewQuoteRule.hidePrice, rule.hidePrice); + await this.clearAndType(requestForQuotationAdmin.quoteRules.addNewQuoteRule.hidePriceText, rule.hidePriceText); + await this.selectByValue(requestForQuotationAdmin.quoteRules.addNewQuoteRule.hideAddToCartButton, rule.hideAddToCartButton); + await this.clearAndType(requestForQuotationAdmin.quoteRules.addNewQuoteRule.customButtonLabel, rule.customButtonLabel); // priority - await this.clearAndType(selector.admin.dokan.requestForQuotation.quoteRules.addNewQuoteRule.priorityOrder, rule.order); + await this.clearAndType(requestForQuotationAdmin.quoteRules.addNewQuoteRule.priorityOrder, rule.order); // publish - await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.quoteRules, selector.admin.dokan.requestForQuotation.quoteRules.addNewQuoteRule.publishRule); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.quoteRules, requestForQuotationAdmin.quoteRules.addNewQuoteRule.publishRule); } // add quote rule async addQuoteRule(rule: requestForQuotation['quoteRule']) { await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuoteRules); - + //todo : move to base page await Promise.all([ this.page.waitForResponse(resp => resp.url().includes(data.subUrls.api.dokan.quotes) && resp.status() === 200), this.page.waitForResponse(resp => resp.url().includes(data.subUrls.api.dokan.products) && resp.status() === 200), - this.page.locator(selector.admin.dokan.requestForQuotation.quoteRules.newQuoteRule).click(), + this.page.locator(requestForQuotationAdmin.quoteRules.newQuoteRule).click(), ]); await this.updateQuoteRuleFields(rule); @@ -83,14 +88,13 @@ export class RequestForQuotationsPage extends AdminPage { // edit quote rule async editQuoteRule(rule: requestForQuotation['quoteRule']) { await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuoteRules); - // await this.goto(data.subUrls.backend.dokan.requestForQuoteRules); - await this.hover(selector.admin.dokan.requestForQuotation.quoteRules.quoteRulesCell(rule.title)); + await this.hover(requestForQuotationAdmin.quoteRules.quoteRulesCell(rule.title)); await Promise.all([ this.page.waitForResponse(resp => resp.url().includes(data.subUrls.api.dokan.quotes) && resp.status() === 200), this.page.waitForResponse(resp => resp.url().includes(data.subUrls.api.dokan.products) && resp.status() === 200), - this.page.locator(selector.admin.dokan.requestForQuotation.quoteRules.quoteRulesEdit(rule.title)).click(), + this.page.locator(requestForQuotationAdmin.quoteRules.quoteRulesEdit(rule.title)).click(), ]); await this.updateQuoteRuleFields(rule); @@ -99,24 +103,24 @@ export class RequestForQuotationsPage extends AdminPage { // update quote rule async updateQuoteRule(quoteTitle: string, action: string) { await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuoteRules); - // await this.goto(data.subUrls.backend.dokan.requestForQuoteRules); switch (action) { case 'trash': - await this.hover(selector.admin.dokan.requestForQuotation.quoteRules.quoteRulesCell(quoteTitle)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.quoteRules, selector.admin.dokan.requestForQuotation.quoteRules.quoteRulesTrash(quoteTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quoteRules, requestForQuotationAdmin.quoteRules.navTabs.published); + await this.hover(requestForQuotationAdmin.quoteRules.quoteRulesCell(quoteTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quoteRules, requestForQuotationAdmin.quoteRules.quoteRulesTrash(quoteTitle)); break; case 'permanently-delete': - await this.clickAndWaitForResponse(data.subUrls.api.dokan.quoteRules, selector.admin.dokan.requestForQuotation.quoteRules.navTabs.trash); - await this.hover(selector.admin.dokan.requestForQuotation.quoteRules.trashedQuoteRulesCell(quoteTitle)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.quoteRules, selector.admin.dokan.requestForQuotation.quoteRules.quoteRulesPermanentlyDelete(quoteTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quoteRules, requestForQuotationAdmin.quoteRules.navTabs.trash); + await this.hover(requestForQuotationAdmin.quoteRules.trashedQuoteRulesCell(quoteTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quoteRules, requestForQuotationAdmin.quoteRules.quoteRulesPermanentlyDelete(quoteTitle)); break; case 'restore': - await this.clickAndWaitForResponse(data.subUrls.api.dokan.quoteRules, selector.admin.dokan.requestForQuotation.quoteRules.navTabs.trash); - await this.hover(selector.admin.dokan.requestForQuotation.quoteRules.trashedQuoteRulesCell(quoteTitle)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.quoteRules, selector.admin.dokan.requestForQuotation.quoteRules.quoteRulesRestore(quoteTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quoteRules, requestForQuotationAdmin.quoteRules.navTabs.trash); + await this.hover(requestForQuotationAdmin.quoteRules.trashedQuoteRulesCell(quoteTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quoteRules, requestForQuotationAdmin.quoteRules.quoteRulesRestore(quoteTitle)); break; default: @@ -126,23 +130,22 @@ export class RequestForQuotationsPage extends AdminPage { // quote rules bulk action async quoteRulesBulkAction(action: string) { - await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuoteRules); - // await this.goto(data.subUrls.backend.dokan.requestForQuoteRules); + await this.goto(data.subUrls.backend.dokan.requestForQuoteRules); // ensure row exists - await this.notToBeVisible(selector.admin.dokan.requestForQuotation.quoteRules.noRowsFound); + await this.notToBeVisible(requestForQuotationAdmin.quoteRules.noRowsFound); - await this.check(selector.admin.dokan.requestForQuotation.quoteRules.bulkActions.selectAll); + await this.check(requestForQuotationAdmin.quoteRules.bulkActions.selectAll); // only to remove flakiness // todo: need diff soln and make generic , don't work need custom soln - // const isDisabled = await this.hasAttribute(selector.admin.dokan.requestForQuotation.quoteRules.bulkActions.applyAction, 'disabled'); + // const isDisabled = await this.hasAttribute(requestForQuotationAdmin.quoteRules.bulkActions.applyAction, 'disabled'); // if(isDisabled){ - // await this.uncheck(selector.admin.dokan.requestForQuotation.quoteRules.bulkActions.selectAll); - // await this.check(selector.admin.dokan.requestForQuotation.quoteRules.bulkActions.selectAll); + // await this.uncheck(requestForQuotationAdmin.quoteRules.bulkActions.selectAll); + // await this.check(requestForQuotationAdmin.quoteRules.bulkActions.selectAll); // } - await this.selectByValue(selector.admin.dokan.requestForQuotation.quoteRules.bulkActions.selectAction, action); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.quoteRules, selector.admin.dokan.requestForQuotation.quoteRules.bulkActions.applyAction); + await this.selectByValue(requestForQuotationAdmin.quoteRules.bulkActions.selectAction, action); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quoteRules, requestForQuotationAdmin.quoteRules.bulkActions.applyAction); } // quotes @@ -152,59 +155,59 @@ export class RequestForQuotationsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuote); // request for quote menus are visible - await this.multipleElementVisible(selector.admin.dokan.requestForQuotation.menus); + await this.multipleElementVisible(requestForQuotationAdmin.menus); // quotes text is visible - await this.toBeVisible(selector.admin.dokan.requestForQuotation.quotesList.quotesText); + await this.toBeVisible(requestForQuotationAdmin.quotesList.quotesText); // new quote is visible - await this.toBeVisible(selector.admin.dokan.requestForQuotation.quotesList.newQuote); + await this.toBeVisible(requestForQuotationAdmin.quotesList.newQuote); // nav tabs are visible - await this.multipleElementVisible(selector.admin.dokan.requestForQuotation.quotesList.navTabs); + await this.multipleElementVisible(requestForQuotationAdmin.quotesList.navTabs); // bulk action elements are visible - await this.multipleElementVisible(selector.admin.dokan.requestForQuotation.quotesList.bulkActions); + await this.multipleElementVisible(requestForQuotationAdmin.quotesList.bulkActions); // quotes table elements are visible - await this.multipleElementVisible(selector.admin.dokan.requestForQuotation.quotesList.table); + await this.multipleElementVisible(requestForQuotationAdmin.quotesList.table); } // update quote fields async updateQuoteFields(quote: requestForQuotation['quote'], action = 'create') { - await this.clearAndType(selector.admin.dokan.requestForQuotation.quotesList.addNewQuote.quoteTitle, quote.title); + await this.clearAndType(requestForQuotationAdmin.quotesList.addNewQuote.quoteTitle, quote.title); // customer information - await this.click(selector.admin.dokan.requestForQuotation.quotesList.addNewQuote.quoteUserDropDown); - await this.typeAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.addNewQuote.quoteUserInput, quote.user); + await this.click(requestForQuotationAdmin.quotesList.addNewQuote.quoteUserDropDown); + await this.typeAndWaitForResponse(data.subUrls.api.dokan.quotes, requestForQuotationAdmin.quotesList.addNewQuote.quoteUserInput, quote.user); await this.press(data.key.enter); - // await this.clearAndType(selector.admin.dokan.requestForQuotation.quotesList.addNewQuote.fullName, quote.fullName); - // await this.clearAndType(selector.admin.dokan.requestForQuotation.quotesList.addNewQuote.email, quote.email); - await this.clearAndType(selector.admin.dokan.requestForQuotation.quotesList.addNewQuote.companyName, quote.companyName); - await this.clearAndType(selector.admin.dokan.requestForQuotation.quotesList.addNewQuote.phoneNumber, quote.phoneNumber); + // await this.clearAndType(requestForQuotationAdmin.quotesList.addNewQuote.fullName, quote.fullName); + // await this.clearAndType(requestForQuotationAdmin.quotesList.addNewQuote.email, quote.email); + await this.clearAndType(requestForQuotationAdmin.quotesList.addNewQuote.companyName, quote.companyName); + await this.clearAndType(requestForQuotationAdmin.quotesList.addNewQuote.phoneNumber, quote.phoneNumber); // quote product if (action === 'create') { - await this.click(selector.admin.dokan.requestForQuotation.quotesList.addNewQuote.addProducts); + await this.click(requestForQuotationAdmin.quotesList.addNewQuote.addProducts); - await this.click(selector.admin.dokan.requestForQuotation.quotesList.addNewQuote.quoteProductDropDown); - await this.typeAndWaitForResponse(data.subUrls.api.dokan.products, selector.admin.dokan.requestForQuotation.quotesList.addNewQuote.quoteProductInput, quote.product); + await this.click(requestForQuotationAdmin.quotesList.addNewQuote.quoteProductDropDown); + await this.typeAndWaitForResponse(data.subUrls.api.dokan.products, requestForQuotationAdmin.quotesList.addNewQuote.quoteProductInput, quote.product); await this.press(data.key.enter); - await this.clearAndType(selector.admin.dokan.requestForQuotation.quotesList.addNewQuote.quoteProductQuantity, quote.quantity); - await this.click(selector.admin.dokan.requestForQuotation.quotesList.addNewQuote.addToQuote); + await this.clearAndType(requestForQuotationAdmin.quotesList.addNewQuote.quoteProductQuantity, quote.quantity); + await this.click(requestForQuotationAdmin.quotesList.addNewQuote.addToQuote); } - await this.clearAndType(selector.admin.dokan.requestForQuotation.quotesList.addNewQuote.offerPrice, quote.offerPrice); - await this.clearAndType(selector.admin.dokan.requestForQuotation.quotesList.addNewQuote.offerProductQuantity, quote.offerProductQuantity); + await this.clearAndType(requestForQuotationAdmin.quotesList.addNewQuote.offerPrice, quote.offerPrice); + await this.clearAndType(requestForQuotationAdmin.quotesList.addNewQuote.offerProductQuantity, quote.offerProductQuantity); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.addNewQuote.publishQuote); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, requestForQuotationAdmin.quotesList.addNewQuote.publishQuote); } // add quote async addQuote(quote: requestForQuotation['quote']) { await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuote); - await this.click(selector.admin.dokan.requestForQuotation.quotesList.newQuote); + await this.click(requestForQuotationAdmin.quotesList.newQuote); await this.updateQuoteFields(quote, 'create'); } @@ -212,32 +215,32 @@ export class RequestForQuotationsPage extends AdminPage { async editQuote(quote: requestForQuotation['quote']) { await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuote); - await this.hover(selector.admin.dokan.requestForQuotation.quotesList.quoteCell(quote.title)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.quoteEdit(quote.title)); + await this.hover(requestForQuotationAdmin.quotesList.quoteCell(quote.title)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, requestForQuotationAdmin.quotesList.quoteEdit(quote.title)); await this.updateQuoteFields(quote, 'update'); } // update quote async updateQuote(quoteTitle: string, action: string) { await this.goto(data.subUrls.backend.dokan.requestForQuote); - // await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuote); switch (action) { case 'trash': - await this.hover(selector.admin.dokan.requestForQuotation.quotesList.quoteCell(quoteTitle)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.quoteTrash(quoteTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, requestForQuotationAdmin.quotesList.navTabs.pending); + await this.hover(requestForQuotationAdmin.quotesList.quoteCell(quoteTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, requestForQuotationAdmin.quotesList.quoteTrash(quoteTitle)); break; case 'permanently-delete': - await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.navTabs.trash); - await this.hover(selector.admin.dokan.requestForQuotation.quotesList.quoteCell(quoteTitle)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.quotePermanentlyDelete(quoteTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, requestForQuotationAdmin.quotesList.navTabs.trash); + await this.hover(requestForQuotationAdmin.quotesList.quoteCell(quoteTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, requestForQuotationAdmin.quotesList.quotePermanentlyDelete(quoteTitle)); break; case 'restore': - await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.navTabs.trash); - await this.hover(selector.admin.dokan.requestForQuotation.quotesList.quoteCell(quoteTitle)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.quoteRestore(quoteTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, requestForQuotationAdmin.quotesList.navTabs.trash); + await this.hover(requestForQuotationAdmin.quotesList.quoteCell(quoteTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, requestForQuotationAdmin.quotesList.quoteRestore(quoteTitle)); break; default: @@ -248,20 +251,18 @@ export class RequestForQuotationsPage extends AdminPage { // approve quote async approveQuote(quoteTitle: string) { await this.goto(data.subUrls.backend.dokan.requestForQuote); - // await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuote); - await this.hover(selector.admin.dokan.requestForQuotation.quotesList.quoteCell(quoteTitle)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.quoteEdit(quoteTitle)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.approveQuote); + await this.hover(requestForQuotationAdmin.quotesList.quoteCell(quoteTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, requestForQuotationAdmin.quotesList.quoteEdit(quoteTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, requestForQuotationAdmin.quotesList.approveQuote); } // convert quote to order async convertQuoteToOrder(quoteTitle: string) { - // await this.approveQuote(quoteTitle); await this.goto(data.subUrls.backend.dokan.requestForQuote); - // await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuote); - await this.hover(selector.admin.dokan.requestForQuotation.quotesList.quoteCell(quoteTitle)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.quoteEdit(quoteTitle)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.convertToOrder); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, requestForQuotationAdmin.quotesList.navTabs.approved); + await this.hover(requestForQuotationAdmin.quotesList.quoteCell(quoteTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, requestForQuotationAdmin.quotesList.quoteEdit(quoteTitle)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, requestForQuotationAdmin.quotesList.convertToOrder); } // quotes bulk action @@ -269,11 +270,11 @@ export class RequestForQuotationsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.requestForQuote); // ensure row exists - await this.notToBeVisible(selector.admin.dokan.requestForQuotation.quotesList.noRowsFound); + await this.notToBeVisible(requestForQuotationAdmin.quotesList.noRowsFound); - await this.click(selector.admin.dokan.requestForQuotation.quotesList.bulkActions.selectAll); - await this.selectByValue(selector.admin.dokan.requestForQuotation.quotesList.bulkActions.selectAction, action); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, selector.admin.dokan.requestForQuotation.quotesList.bulkActions.applyAction); + await this.click(requestForQuotationAdmin.quotesList.bulkActions.selectAll); + await this.selectByValue(requestForQuotationAdmin.quotesList.bulkActions.selectAction, action); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.quotes, requestForQuotationAdmin.quotesList.bulkActions.applyAction); } // vendor @@ -283,62 +284,62 @@ export class RequestForQuotationsPage extends AdminPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.requestQuotes); // request quotes text is visible - await this.toBeVisible(selector.vendor.vRequestQuotes.requestQuotesText); + await this.toBeVisible(requestForQuotationVendor.requestQuotesText); - const noQuoteRequests = await this.isVisible(selector.vendor.vRequestQuotes.noQuoteMessage); + const noQuoteRequests = await this.isVisible(requestForQuotationVendor.noQuoteMessage); if (noQuoteRequests) { // go to shop is visible - await this.toBeVisible(selector.vendor.vRequestQuotes.goToShop); + await this.toBeVisible(requestForQuotationVendor.goToShop); } else { // request quote table elements are visible - await this.multipleElementVisible(selector.vendor.vRequestQuotes.table); + await this.multipleElementVisible(requestForQuotationVendor.table); } } // vendor view request quote details async vendorViewQuoteDetails(quoteTitle: string): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.requestQuotes); - await this.clickAndWaitForLoadState(selector.vendor.vRequestQuotes.viewQuoteDetails(quoteTitle)); + await this.clickAndWaitForLoadState(requestForQuotationVendor.viewQuoteDetails(quoteTitle)); // quote basic details elements are visible - await this.multipleElementVisible(selector.vendor.vRequestQuotes.quoteDetails.basicDetails); + await this.multipleElementVisible(requestForQuotationVendor.quoteDetails.basicDetails); // quote item details elements are visible - await this.toBeVisible(selector.vendor.vRequestQuotes.quoteDetails.quoteItemDetails.quoteDetailsText); - await this.multipleElementVisible(selector.vendor.vRequestQuotes.quoteDetails.quoteItemDetails.table); + await this.toBeVisible(requestForQuotationVendor.quoteDetails.quoteItemDetails.quoteDetailsText); + await this.multipleElementVisible(requestForQuotationVendor.quoteDetails.quoteItemDetails.table); // quote total details elements are visible - await this.multipleElementVisible(selector.vendor.vRequestQuotes.quoteDetails.quoteTotals); + await this.multipleElementVisible(requestForQuotationVendor.quoteDetails.quoteTotals); // update quote is visible - await this.toBeVisible(selector.vendor.vRequestQuotes.quoteDetails.updateQuote); - await this.toBeVisibleAnyOfThem([selector.vendor.vRequestQuotes.quoteDetails.approveThisQuote, selector.vendor.vRequestQuotes.quoteDetails.convertToOrder]); + await this.toBeVisible(requestForQuotationVendor.quoteDetails.updateQuote); + await this.toBeVisibleAnyOfThem([requestForQuotationVendor.quoteDetails.approveThisQuote, requestForQuotationVendor.quoteDetails.convertToOrder]); } // update quote async vendorUpdateQuoteRequest(quoteId: string, quote: requestForQuotation['userQuote']) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.quoteDetails(quoteId)); - await this.clearAndType(selector.vendor.vRequestQuotes.quoteDetails.offeredPriceInput(quote.productName), quote.offeredPrice); - await this.clearAndType(selector.vendor.vRequestQuotes.quoteDetails.quantityInput(quote.productName), quote.quantity); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.quoteDetails(quoteId), selector.vendor.vRequestQuotes.quoteDetails.updateQuote); - await this.toContainText(selector.vendor.vRequestQuotes.quoteDetails.message, 'Your quote has been successfully updated.'); + await this.clearAndType(requestForQuotationVendor.quoteDetails.offeredPriceInput(quote.productName), quote.offeredPrice); + await this.clearAndType(requestForQuotationVendor.quoteDetails.quantityInput(quote.productName), quote.quantity); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.quoteDetails(quoteId), requestForQuotationVendor.quoteDetails.updateQuote); + await this.toContainText(requestForQuotationVendor.quoteDetails.message, 'Your quote has been successfully updated.'); } // approve quote async vendorApproveQuoteRequest(quoteId: string) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.quoteDetails(quoteId)); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.quoteDetails(quoteId), selector.vendor.vRequestQuotes.quoteDetails.approveThisQuote); - await this.toContainText(selector.vendor.vRequestQuotes.quoteDetails.message, 'Your quote has been successfully updated.'); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.quoteDetails(quoteId), requestForQuotationVendor.quoteDetails.approveThisQuote); + await this.toContainText(requestForQuotationVendor.quoteDetails.message, 'Your quote has been successfully updated.'); } // convert quote to order async vendorConvertQuoteToOrder(quoteId: string) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.quoteDetails(quoteId)); - const needApproval = await this.isVisible(selector.vendor.vRequestQuotes.quoteDetails.approveThisQuote); + const needApproval = await this.isVisible(requestForQuotationVendor.quoteDetails.approveThisQuote); needApproval && (await this.vendorApproveQuoteRequest(quoteId)); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.quoteDetails(quoteId), selector.vendor.vRequestQuotes.quoteDetails.convertToOrder); - await this.toContainText(selector.vendor.vRequestQuotes.quoteDetails.message, `Your Quote# ${quoteId} has been converted to Order#`); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.quoteDetails(quoteId), requestForQuotationVendor.quoteDetails.convertToOrder); + await this.toContainText(requestForQuotationVendor.quoteDetails.message, `Your Quote# ${quoteId} has been converted to Order#`); } // customer @@ -347,23 +348,23 @@ export class RequestForQuotationsPage extends AdminPage { async requestForQuoteRenderProperly() { await this.goIfNotThere(data.subUrls.frontend.requestForQuote); - await this.toBeVisible(selector.customer.cRequestForQuote.requestForQuote.requestForQuoteText); + await this.toBeVisible(requestForQuotationCustomer.requestForQuote.requestForQuoteText); - const noQuote = await this.isVisible(selector.customer.cRequestForQuote.requestForQuote.noQuotesFound); + const noQuote = await this.isVisible(requestForQuotationCustomer.requestForQuote.noQuotesFound); if (noQuote) { - await this.toContainText(selector.customer.cRequestForQuote.requestForQuote.noQuotesFound, 'Your quote is currently empty.'); + await this.toContainText(requestForQuotationCustomer.requestForQuote.noQuotesFound, 'Your quote is currently empty.'); console.log('No quotes found on request for quote page'); - await this.toBeVisible(selector.customer.cRequestForQuote.requestForQuote.returnToShop); + await this.toBeVisible(requestForQuotationCustomer.requestForQuote.returnToShop); } else { // quote item table details elements are visible - await this.multipleElementVisible(selector.customer.cRequestForQuote.requestForQuote.quoteItemDetails.table); + await this.multipleElementVisible(requestForQuotationCustomer.requestForQuote.quoteItemDetails.table); // quote total details elements are visible - await this.multipleElementVisible(selector.customer.cRequestForQuote.requestForQuote.quoteTotals); + await this.multipleElementVisible(requestForQuotationCustomer.requestForQuote.quoteTotals); // update quote is visible - await this.toBeVisible(selector.customer.cRequestForQuote.requestForQuote.updateQuote); + await this.toBeVisible(requestForQuotationCustomer.requestForQuote.updateQuote); } } @@ -372,19 +373,19 @@ export class RequestForQuotationsPage extends AdminPage { await this.goIfNotThere(data.subUrls.frontend.requestedQuote); // request quotes text is visible - await this.toBeVisible(selector.customer.cRequestForQuote.requestedQuote.requestedQuoteText); + await this.toBeVisible(requestForQuotationCustomer.requestedQuote.requestedQuoteText); - const noQuoteRequests = await this.isVisible(selector.customer.cRequestForQuote.requestedQuote.noQuoteMessage); + const noQuoteRequests = await this.isVisible(requestForQuotationCustomer.requestedQuote.noQuoteMessage); if (noQuoteRequests) { // go to shop is visible - await this.toBeVisible(selector.customer.cRequestForQuote.requestedQuote.goToShop); + await this.toBeVisible(requestForQuotationCustomer.requestedQuote.goToShop); } else { // request quote table elements are visible - await this.multipleElementVisible(selector.customer.cRequestForQuote.requestedQuote.table); + await this.multipleElementVisible(requestForQuotationCustomer.requestedQuote.table); // pagination is visible - // await this.toBeVisible(selector.customer.cRequestForQuote.requestedQuote.pagination); + // await this.toBeVisible(requestForQuotationCustomer.requestedQuote.pagination); } } @@ -392,36 +393,36 @@ export class RequestForQuotationsPage extends AdminPage { async customerViewRequestedQuoteDetails(quoteTitle: string): Promise { await this.goIfNotThere(data.subUrls.frontend.requestedQuote); - await this.clickAndWaitForLoadState(selector.customer.cRequestForQuote.requestedQuote.viewQuoteDetails(quoteTitle)); + await this.clickAndWaitForLoadState(requestForQuotationCustomer.requestedQuote.viewQuoteDetails(quoteTitle)); // quote basic details elements are visible - await this.multipleElementVisible(selector.customer.cRequestForQuote.requestedQuote.requestedQuoteDetails.basicDetails); + await this.multipleElementVisible(requestForQuotationCustomer.requestedQuote.requestedQuoteDetails.basicDetails); // quote item details elements are visible - await this.toBeVisible(selector.customer.cRequestForQuote.requestedQuote.requestedQuoteDetails.quoteItemDetails.quoteDetailsText); - await this.multipleElementVisible(selector.customer.cRequestForQuote.requestedQuote.requestedQuoteDetails.quoteItemDetails.table); + await this.toBeVisible(requestForQuotationCustomer.requestedQuote.requestedQuoteDetails.quoteItemDetails.quoteDetailsText); + await this.multipleElementVisible(requestForQuotationCustomer.requestedQuote.requestedQuoteDetails.quoteItemDetails.table); // quote total details elements are visible - await this.multipleElementVisible(selector.customer.cRequestForQuote.requestedQuote.requestedQuoteDetails.quoteTotals); + await this.multipleElementVisible(requestForQuotationCustomer.requestedQuote.requestedQuoteDetails.quoteTotals); // update quote is visible - await this.toBeVisible(selector.customer.cRequestForQuote.requestedQuote.requestedQuoteDetails.updateQuote); + await this.toBeVisible(requestForQuotationCustomer.requestedQuote.requestedQuoteDetails.updateQuote); } // customer update requested quote async customerUpdateRequestedQuote(quoteId: string, quote: requestForQuotation['userQuote']) { await this.goIfNotThere(data.subUrls.frontend.quoteDetails(quoteId)); - await this.clearAndType(selector.customer.cRequestForQuote.requestedQuote.requestedQuoteDetails.offeredPriceInput(quote.productName), quote.offeredPrice); - await this.clearAndType(selector.customer.cRequestForQuote.requestedQuote.requestedQuoteDetails.quantityInput(quote.productName), quote.quantity); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.quoteDetails(quoteId), selector.customer.cRequestForQuote.requestedQuote.requestedQuoteDetails.updateQuote); - await this.toContainText(selector.customer.cRequestForQuote.requestedQuote.requestedQuoteDetails.message, 'Your quote has been successfully updated.'); + await this.clearAndType(requestForQuotationCustomer.requestedQuote.requestedQuoteDetails.offeredPriceInput(quote.productName), quote.offeredPrice); + await this.clearAndType(requestForQuotationCustomer.requestedQuote.requestedQuoteDetails.quantityInput(quote.productName), quote.quantity); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.quoteDetails(quoteId), requestForQuotationCustomer.requestedQuote.requestedQuoteDetails.updateQuote); + await this.toContainText(requestForQuotationCustomer.requestedQuote.requestedQuoteDetails.message, 'Your quote has been successfully updated.'); } // customer pay converted quote async payConvertedQuote(quoteId: string) { await this.goto(data.subUrls.frontend.quoteDetails(quoteId)); - await this.clickAndWaitForLoadState(selector.customer.cRequestForQuote.requestedQuote.requestedQuoteDetails.viewOrder); - await this.toBeVisible(selector.customer.cRequestForQuote.orderDetails.quoteNoteOnOrderDetails); + await this.clickAndWaitForLoadState(requestForQuotationCustomer.requestedQuote.requestedQuoteDetails.viewOrder); + await this.toBeVisible(requestForQuotationCustomer.orderDetails.quoteNoteOnOrderDetails); const orderId = (await this.getElementText(selector.customer.cOrderDetails.orderDetails.orderNumber)) as string; await this.customerMyOrders.payPendingOrder(orderId, 'bank'); } @@ -430,30 +431,30 @@ export class RequestForQuotationsPage extends AdminPage { async customerQuoteProduct(quote: requestForQuotation['userQuote'], guest?: requestForQuotation['guest']): Promise { await this.customerPage.goToProductDetails(quote.productName); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.customer.cRequestForQuote.singleProductDetails.addToQuote); - const viewQuoteIsVisible = await this.isVisible(selector.customer.cRequestForQuote.singleProductDetails.viewQuote); + await this.clickAndWaitForResponse(data.subUrls.ajax, requestForQuotationCustomer.singleProductDetails.addToQuote); + const viewQuoteIsVisible = await this.isVisible(requestForQuotationCustomer.singleProductDetails.viewQuote); if (viewQuoteIsVisible) { - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.requestForQuote, selector.customer.cRequestForQuote.singleProductDetails.viewQuote); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.requestForQuote, requestForQuotationCustomer.singleProductDetails.viewQuote); } else { await this.goIfNotThere(data.subUrls.frontend.requestForQuote); } - await this.clearAndType(selector.customer.cRequestForQuote.requestForQuote.offeredPriceInput(quote.productName), quote.offeredPrice); - await this.clearAndType(selector.customer.cRequestForQuote.requestForQuote.quantityInput(quote.productName), quote.quantity); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.customer.cRequestForQuote.requestForQuote.updateQuote); - await this.toContainText(selector.customer.cRequestForQuote.requestForQuote.message, 'Quote updated'); + await this.clearAndType(requestForQuotationCustomer.requestForQuote.offeredPriceInput(quote.productName), quote.offeredPrice); + await this.clearAndType(requestForQuotationCustomer.requestForQuote.quantityInput(quote.productName), quote.quantity); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, requestForQuotationCustomer.requestForQuote.updateQuote); + await this.toContainText(requestForQuotationCustomer.requestForQuote.message, 'Quote updated'); if (guest) { - await this.clearAndType(selector.customer.cRequestForQuote.requestForQuote.guest.fullName, guest.fullName); - await this.clearAndType(selector.customer.cRequestForQuote.requestForQuote.guest.email, guest.email); - await this.clearAndType(selector.customer.cRequestForQuote.requestForQuote.guest.companyName, guest.companyName); - await this.clearAndType(selector.customer.cRequestForQuote.requestForQuote.guest.phoneNumber, guest.phoneNumber); + await this.clearAndType(requestForQuotationCustomer.requestForQuote.guest.fullName, guest.fullName); + await this.clearAndType(requestForQuotationCustomer.requestForQuote.guest.email, guest.email); + await this.clearAndType(requestForQuotationCustomer.requestForQuote.guest.companyName, guest.companyName); + await this.clearAndType(requestForQuotationCustomer.requestForQuote.guest.phoneNumber, guest.phoneNumber); } - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.requestForQuote, selector.customer.cRequestForQuote.requestForQuote.placeQuote, 302); - await this.toBeVisible(selector.customer.cRequestForQuote.requestedQuote.requestedQuoteDetails.requestedQuoteText); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.requestForQuote, requestForQuotationCustomer.requestForQuote.placeQuote, 302); + await this.toBeVisible(requestForQuotationCustomer.requestedQuote.requestedQuoteDetails.requestedQuoteText); if (!guest) { - const quoteId = (await this.getElementText(selector.customer.cRequestForQuote.requestedQuote.requestedQuoteDetails.basicDetails.quoteNumberValue))?.trim() as string; + const quoteId = (await this.getElementText(requestForQuotationCustomer.requestedQuote.requestedQuoteDetails.basicDetails.quoteNumberValue))?.trim() as string; return quoteId; } } diff --git a/tests/pw/pages/reverseWithdrawsPage.ts b/tests/pw/pages/reverseWithdrawsPage.ts index b7aaf1b598..bf1af6c1e4 100644 --- a/tests/pw/pages/reverseWithdrawsPage.ts +++ b/tests/pw/pages/reverseWithdrawsPage.ts @@ -5,6 +5,10 @@ import { data } from '@utils/testData'; import { helpers } from '@utils/helpers'; import { reverseWithdraw, date } from '@utils/interfaces'; +// selectors +const reverseWithdrawAdmin = selector.admin.dokan.reverseWithdraw; +const reverseWithdrawVendor = selector.vendor.vReverseWithdrawal; + export class ReverseWithdrawsPage extends CustomerPage { constructor(page: Page) { super(page); @@ -25,62 +29,62 @@ export class ReverseWithdrawsPage extends CustomerPage { await this.goIfNotThere(data.subUrls.backend.dokan.reverseWithdraws); // reverse withdraw text is visible - await this.toBeVisible(selector.admin.dokan.reverseWithdraw.reverseWithdrawText); + await this.toBeVisible(reverseWithdrawAdmin.reverseWithdrawText); // add new reverse withdrawal is visible - await this.toBeVisible(selector.admin.dokan.reverseWithdraw.addNewReverseWithdrawal); + await this.toBeVisible(reverseWithdrawAdmin.addNewReverseWithdrawal); // fact cards elements are visible - await this.multipleElementVisible(selector.admin.dokan.reverseWithdraw.reverseWithdrawFactCards); + await this.multipleElementVisible(reverseWithdrawAdmin.reverseWithdrawFactCards); // filter elements are visible - const { filterInput, clearFilter, filteredResult, ...filters } = selector.admin.dokan.reverseWithdraw.filters; + const { filterInput, clearFilter, filteredResult, ...filters } = reverseWithdrawAdmin.filters; await this.multipleElementVisible(filters); // reverse withdraw table elements are visible - await this.multipleElementVisible(selector.admin.dokan.reverseWithdraw.table); + await this.multipleElementVisible(reverseWithdrawAdmin.table); } // filter reverse withdraws async filterReverseWithdraws(vendorName: string) { await this.goIfNotThere(data.subUrls.backend.dokan.reverseWithdraws); - await this.clickIfVisible(selector.admin.dokan.reverseWithdraw.filters.clearFilter); + await this.clickIfVisible(reverseWithdrawAdmin.filters.clearFilter); - await this.click(selector.admin.dokan.reverseWithdraw.filters.filterByStore); - await this.typeAndWaitForResponse(data.subUrls.api.dokan.reverseWithdraws, selector.admin.dokan.reverseWithdraw.filters.filterInput, vendorName); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.reverseWithdraws, selector.admin.dokan.reverseWithdraw.filters.filteredResult(vendorName)); - await this.toBeVisible(selector.admin.dokan.reverseWithdraw.reverseWithdrawCell(vendorName)); + await this.click(reverseWithdrawAdmin.filters.filterByStore); + await this.typeAndWaitForResponse(data.subUrls.api.dokan.reverseWithdraws, reverseWithdrawAdmin.filters.filterInput, vendorName); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.reverseWithdraws, reverseWithdrawAdmin.filters.filteredResult(vendorName)); + await this.toBeVisible(reverseWithdrawAdmin.reverseWithdrawCell(vendorName)); } // add new reverse withdrawal async addReverseWithdrawal(reverseWithdrawal: reverseWithdraw) { await this.goIfNotThere(data.subUrls.backend.dokan.reverseWithdraws); - await this.click(selector.admin.dokan.reverseWithdraw.addNewReverseWithdrawal); + await this.click(reverseWithdrawAdmin.addNewReverseWithdrawal); - await this.click(selector.admin.dokan.reverseWithdraw.addReverseWithdrawal.selectVendorDropdown); - await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, selector.admin.dokan.reverseWithdraw.addReverseWithdrawal.selectVendorInput, reverseWithdrawal.store); - await this.click(selector.admin.dokan.reverseWithdraw.addReverseWithdrawal.selectOption(reverseWithdrawal.store)); + await this.click(reverseWithdrawAdmin.addReverseWithdrawal.selectVendorDropdown); + await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, reverseWithdrawAdmin.addReverseWithdrawal.selectVendorInput, reverseWithdrawal.store); + await this.click(reverseWithdrawAdmin.addReverseWithdrawal.selectOption(reverseWithdrawal.store)); - // await this.toContainText(selector.admin.dokan.reverseWithdraw.addReverseWithdrawal.searchedResult, reverseWithdrawal.store); + // await this.toContainText(reverseWithdrawAdmin.addReverseWithdrawal.searchedResult, reverseWithdrawal.store); // await this.press(data.key.arrowDown); // await this.press(data.key.enter); - await this.click(selector.admin.dokan.reverseWithdraw.addReverseWithdrawal.transactionType(reverseWithdrawal.transactionType)); + await this.click(reverseWithdrawAdmin.addReverseWithdrawal.transactionType(reverseWithdrawal.transactionType)); - await this.click(selector.admin.dokan.reverseWithdraw.addReverseWithdrawal.selectProductDropdown); - await this.typeAndWaitForResponse(data.subUrls.api.dokan.products, selector.admin.dokan.reverseWithdraw.addReverseWithdrawal.selectProductInput, reverseWithdrawal.product); - await this.click(selector.admin.dokan.reverseWithdraw.addReverseWithdrawal.selectOption(reverseWithdrawal.product)); - // await this.toContainText(selector.admin.dokan.reverseWithdraw.addReverseWithdrawal.searchedResult, reverseWithdrawal.product); + await this.click(reverseWithdrawAdmin.addReverseWithdrawal.selectProductDropdown); + await this.typeAndWaitForResponse(data.subUrls.api.dokan.products, reverseWithdrawAdmin.addReverseWithdrawal.selectProductInput, reverseWithdrawal.product); + await this.click(reverseWithdrawAdmin.addReverseWithdrawal.selectOption(reverseWithdrawal.product)); + // await this.toContainText(reverseWithdrawAdmin.addReverseWithdrawal.searchedResult, reverseWithdrawal.product); // await this.press(data.key.enter); - await this.click(selector.admin.dokan.reverseWithdraw.addReverseWithdrawal.withdrawalBalanceType(reverseWithdrawal.withdrawalBalanceType)); + await this.click(reverseWithdrawAdmin.addReverseWithdrawal.withdrawalBalanceType(reverseWithdrawal.withdrawalBalanceType)); - await this.clearAndType(selector.admin.dokan.reverseWithdraw.addReverseWithdrawal.reverseWithdrawalAmount, reverseWithdrawal.amount); - await this.clearAndType(selector.admin.dokan.reverseWithdraw.addReverseWithdrawal.note, reverseWithdrawal.note); + await this.clearAndType(reverseWithdrawAdmin.addReverseWithdrawal.reverseWithdrawalAmount, reverseWithdrawal.amount); + await this.clearAndType(reverseWithdrawAdmin.addReverseWithdrawal.note, reverseWithdrawal.note); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.reverseWithdraws, selector.admin.dokan.reverseWithdraw.addReverseWithdrawal.save); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.reverseWithdraws, reverseWithdrawAdmin.addReverseWithdrawal.save); } // vendor @@ -90,28 +94,28 @@ export class ReverseWithdrawsPage extends CustomerPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.reverseWithdrawal); // reverse withdrawal text is visible - await this.toBeVisible(selector.vendor.vReverseWithdrawal.reverseWithdrawalText); + await this.toBeVisible(reverseWithdrawVendor.reverseWithdrawalText); // reverse balance section elements are visible - await this.multipleElementVisible(selector.vendor.vReverseWithdrawal.reverseBalanceSection); + await this.multipleElementVisible(reverseWithdrawVendor.reverseBalanceSection); // filter elements are visible - await this.toBeVisible(selector.vendor.vReverseWithdrawal.filters.dateRangeInput); - await this.toBeVisible(selector.vendor.vReverseWithdrawal.filters.filter); + await this.toBeVisible(reverseWithdrawVendor.filters.dateRangeInput); + await this.toBeVisible(reverseWithdrawVendor.filters.filter); // reverse withdrawal table elements are visible - await this.multipleElementVisible(selector.vendor.vReverseWithdrawal.table); + await this.multipleElementVisible(reverseWithdrawVendor.table); // opening balance row is visible - await this.toBeVisible(selector.vendor.vReverseWithdrawal.openingBalanceRow); + await this.toBeVisible(reverseWithdrawVendor.openingBalanceRow); } // reverse withdraw notice render properly async vendorViewReverseWithdrawalNotice() { await this.goIfNotThere(data.subUrls.frontend.vDashboard.reverseWithdrawal); - await this.toBeVisible(selector.vendor.vReverseWithdrawal.reverseWithdrawalNotice.noticeText); - // const noticeText = await this.getElementText(selector.vendor.vReverseWithdrawal.reverseWithdrawalNotice.noticeText); + await this.toBeVisible(reverseWithdrawVendor.reverseWithdrawalNotice.noticeText); + // const noticeText = await this.getElementText(reverseWithdrawVendor.reverseWithdrawalNotice.noticeText); // expect(noticeText).toContain('Your products add to cart will be hidden. Hence users will not be able to purchase any of your products.'); // expect(noticeText).toContain('Withdraw menu will be hidden. Hence you will not be able to make any withdraw request from your account.'); @@ -133,19 +137,19 @@ export class ReverseWithdrawsPage extends CustomerPage { async vendorFilterReverseWithdrawals(inputValue: date['dateRange']) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.reverseWithdrawal); - await this.setAttributeValue(selector.vendor.vReverseWithdrawal.filters.dateRangeInput, 'value', helpers.dateFormatFYJ(inputValue.startDate) + ' - ' + helpers.dateFormatFYJ(inputValue.endDate)); - await this.setAttributeValue(selector.vendor.vReverseWithdrawal.filters.startDateInput, 'value', inputValue.startDate); - await this.setAttributeValue(selector.vendor.vReverseWithdrawal.filters.endDateInput, 'value', inputValue.endDate); - await this.clickAndWaitForLoadState(selector.vendor.vReverseWithdrawal.filters.filter); - await this.notToHaveCount(selector.vendor.vReverseWithdrawal.numberOfRowsFound, 3); + await this.setAttributeValue(reverseWithdrawVendor.filters.dateRangeInput, 'value', helpers.dateFormatFYJ(inputValue.startDate) + ' - ' + helpers.dateFormatFYJ(inputValue.endDate)); + await this.setAttributeValue(reverseWithdrawVendor.filters.startDateInput, 'value', inputValue.startDate); + await this.setAttributeValue(reverseWithdrawVendor.filters.endDateInput, 'value', inputValue.endDate); + await this.clickAndWaitForLoadState(reverseWithdrawVendor.filters.filter); + await this.notToHaveCount(reverseWithdrawVendor.numberOfRowsFound, 3); } // pay reverse pay balance async vendorPayReversePayBalance() { await this.goIfNotThere(data.subUrls.frontend.vDashboard.reverseWithdrawal); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vReverseWithdrawal.payNow); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.checkout, selector.vendor.vReverseWithdrawal.confirmAction); + await this.clickAndWaitForResponse(data.subUrls.ajax, reverseWithdrawVendor.payNow); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.checkout, reverseWithdrawVendor.confirmAction); const orderId = await this.paymentOrder(); return orderId; } diff --git a/tests/pw/pages/selectors.ts b/tests/pw/pages/selectors.ts index f9bc95148e..e839dc87ef 100644 --- a/tests/pw/pages/selectors.ts +++ b/tests/pw/pages/selectors.ts @@ -33,13 +33,20 @@ export const selector = { // User Forget Password resetPasswordEmail: '#user_login', resetPasswordBtn: '.woocommerce-Button.button', + + // page not found + pageNotFound: '//h1[text()="Oops! That page can’t be found."]', }, backend: { + // page not found + pageNotFound: '//h1[text()="Oops! That page can’t be found."]', + // setup alreadyInstalled: '//h1[contains(text(), "Already Installed")]', languageContinue: '#language-continue', letsGo: '//a[contains(text(), "go!")]', + // db setup dbName: '#dbname', dbUserName: '#uname', @@ -48,6 +55,7 @@ export const selector = { dbTablePrefix: '#prefix', submit: '.step input', runTheInstallation: '.step a', + // site info siteTitle: '#weblog_title', adminUserName: '#user_login', @@ -64,11 +72,14 @@ export const selector = { login: '#wp-submit', dashboardMenu: '.wp-first-item > .wp-menu-name', dashboardText: '.wrap h1', + // Admin Logout userMenu: '#wp-admin-bar-my-account', logout: '#wp-admin-bar-logout a', + // Logout Message logoutSuccessMessage: '#login p', + // Login Error loginError: '#login_error', }, @@ -215,6 +226,9 @@ export const selector = { closePromoBanner: '.close-banner', }, + //table loader + loader: 'div.table-loader', + // Dashboard dashboard: { // admin header @@ -1512,6 +1526,94 @@ export const selector = { }, }, + // Product QA + productQA: { + productQuestionAnswersText: '.product-questions-answers h1', + + unreadQuestionCount: '//a[contains(text(),"Product Q&A")]/..//span[@class="pending-count"]', + + // Nav Tabs + navTabs: { + all: '//ul[@class="subsubsub"]//li//a[contains(text(),"All")]', + unread: '//ul[@class="subsubsub"]//li//a[contains(text(),"Unread")]', + read: '//ul[@class="subsubsub"]//li//a[contains(text(),"Read")]', + unanswered: '//ul[@class="subsubsub"]//li//a[contains(text(),"Unanswered")]', + answered: '//ul[@class="subsubsub"]//li//a[contains(text(),"Answered")]', + }, + + // Bulk Actions + bulkActions: { + selectAll: 'thead .manage-column input', + selectAction: '.tablenav.top #bulk-action-selector-top', // read, unread, delete + applyAction: '.tablenav.top .button.action', + confirmAction: '.swal2-actions .swal2-confirm', + bulkActionSuccessMessage: '//h2[text()="Bulk action successful."]', + }, + + // Filters + filters: { + filterByVendors: '(//select[@id="filter-vendors"]/..//span[@class="select2-selection__arrow"])[1]', + filterByProducts: '(//select[@id="filter-products"]/..//span[@class="select2-selection__arrow"])[2]', + resetFilterByVensors: '//select[@id="filter-products"]/..//button[@class="button"]', + filterInput: '.select2-search.select2-search--dropdown .select2-search__field', + result: 'li.select2-results__option.select2-results__option--highlighted', + }, + + // Table + table: { + questionColumn: 'thead th.question', + productColumn: 'thead th.product', + vendorColumn: 'thead th.vendor', + dateColumn: 'thead th.created', + statusColumn: 'thead th.status', + }, + + numberOfRowsFound: '.tablenav.top .displaying-num', + noRowsFound: '//td[normalize-space()="No question found."]', + productQuestionCell: (input: string) => `//strong[contains(text(), '${input}')]/..`, + productQuestionFirstCell: '(//tbody//tr//td//a)[1]', + + // question details + questionDetails: { + productQuestionAnswersText: '//h2[text()="Product Questions & Answers"]', + + goBack: '//a[contains(text(),"← Go Back")]', + + questionDetails: { + editQuestion: '(//button[normalize-space()="Edit"])[1]', + questionInput: 'textarea#comment.block', + saveQuestion: '(//button[normalize-space()="Save"])[1]', + questionText: 'div.break-words', + }, + + status: { + visibleStatus: '//dd[text()[normalize-space()="Visible"]]', + hiddenStatus: '//dd[text()[normalize-space()="Hidden"]]', + hideFromProductPage: '//button[normalize-space()="Hide From Product Page"]', + showInProductPage: '//button[normalize-space()="Show In Product Page"]', + deleteQuestion: '(//button[normalize-space()="Delete"])[1]', + }, + + answer: { + questionAnswerIframe: '//iframe[contains(@id, "dokan-product-qa-admin-answer-editor")]', + questionAnswerHtmlBody: '#tinymce', + saveAnswer: '//button[normalize-space()="Save"]', + editAnswer: '(//button[normalize-space()="Edit"])[2]', + answerText: 'div.prose p', + deleteAnswer: '(//button[normalize-space()="Delete"])[2]', + }, + + confirmAction: '.swal2-actions .swal2-confirm', + + visibilityStatusSaveSuccessMessage: '//h2[text()="Visibility status changed successfully."]', + questionSaveSuccessMessage: '//h2[text()="Question updated successfully."]', + answerSaveSuccessMessage: '//h2[text()="Answer created successfully."]', + answerUpdateSuccessMessage: '//h2[text()="Answer updated successfully."]', + answerDeleteSuccessMessage: '//h2[text()="Answer deleted successfully."]', + questionDeleteSuccessMessage: '//h2[text()="Question deleted successfully."]', + }, + }, + // Verifications verifications: { verificationRequestsText: '//h2[normalize-space()="Verification Requests"]', @@ -2252,7 +2354,7 @@ export const selector = { }, // Dokan Setup Wizard - dokanSetupWizard: { + setupWizard: { letsGo: '.button-primary', notWrightNow: '//a[contains(text(),"Not right now")]', @@ -3122,6 +3224,9 @@ export const selector = { // Vendor Setup Wizard vSetup: { // Intro + setupLogo: 'h1#wc-logo', + setupLogoImage: 'h1#wc-logo img', + setupwizardContent: '//div[@class="wc-setup-content"]//div//p', letsGo: '.lets-go-btn', notRightNow: '.not-right-now-btn', @@ -3180,6 +3285,8 @@ export const selector = { // Vendor Dashboard vDashboard: { + dokanAlert: '.dokan-alert.dokan-alert-warning', + // Dashboard Menus menus: { dashboard: '.dashboard a', @@ -3192,6 +3299,7 @@ export const selector = { reviews: '.reviews a', withdraw: '.withdraw a', badges: '.seller-badge a', + productQA: '.product-questions-answers a', returnRequest: '.return-request a', staff: '.staffs a', followers: '.followers a', @@ -3358,7 +3466,7 @@ export const selector = { // Product Sub Options numberOfRowsFound: '#dokan-product-list-table tbody tr', - productCell: (productName: string) => `//a[contains(text(),'${productName}')]/../..`, + productCell: (productName: string) => `//strong//a[contains(text(),'${productName}')]/../..`, productLink: (productName: string) => `//strong//a[contains(text(),'${productName}')]`, editProduct: (productName: string) => `//a[contains(text(),'${productName}')]/../..//span[@class="edit"]//a`, buyAdvertisement: (productName: string) => `//a[contains(text(),'${productName}')]/../../..//td[@class="product-advertisement-td"]//span`, @@ -3951,7 +4059,7 @@ export const selector = { approveThisQuote: 'button[name="approved_by_vendor_button"]', convertToOrder: 'button[name="dokan_convert_to_order_customer"]', - message: '.woocommerce .is-success', + message: '.woocommerce-message', }, }, @@ -4286,6 +4394,78 @@ export const selector = { }, }, + // product question and answeres + vProductQA: { + productQuestionAnswersText: '.dokan-dashboard-header h1.entry-title', + + // filters + filters: { + filterByProducts: '.dokan-product-qa-filter-form span.select2-selection__arrow', + filterInput: '.select2-search.select2-search--dropdown .select2-search__field', + result: 'li.select2-results__option.select2-results__option--highlighted', + filter: 'input[value="Filter"]', + reset: '.dokan-product-qa-filter-form a', + }, + + // table + table: { + table: '.product-qa-listing-table', + questionColumn: '//th[normalize-space()="Question"]', + productsColumn: '//th[normalize-space()="Products"]', + dateColumn: '//th[normalize-space()="Date"]', + actionColumn: '//th[normalize-space()="Action"]', + }, + + noQuestionFound: '//td[contains(text(), "No question found.")]', + questionLink: (question: string) => `//a[contains(.,'${question}')]`, + firstQuestionLink: '(//table[contains(@class,"product-qa-listing-table")]//tbody//tr//a)[1]', + questionCell: (question: string) => `//a[contains(.,'${question}')]/..`, + questionDetailsView: (question: string) => `//a[contains(.,'${question}')]/../..//a[@data-original-title='View']`, + + questionDetails: { + questionDetails: { + questionDetailsDiv: '.dokan-product-qa-single-left-content .dokan-panel', + questionDetailsTitle: '//div[normalize-space()="Question Details"]', + ProductTitle: '//strong[text()="Product:"]', + QuestionerTitle: '//strong[text()="Questioner:"]', + QuestionTitle: '//strong[text()="Question:"]', + + ProductValue: '//strong[text()="Product:"]/../..//td[2]', + QuestionerValue: '//strong[text()="Questioner:"]/../..//td[2]', + QuestionValue: '//strong[text()="Question:"]/../..//td[2]', + }, + + status: { + statusDiv: '.dokan-product-qa-single-right-content .dokan-panel', + statusTitle: '//div[normalize-space()="Status"]', + statusDetails: '.dokan-product-qa-single-right-content .dokan-panel .dokan-panel-body p', + + deleteQuestion: 'button.dokan-product-qa-delete-question', + }, + + answer: { + answerDiv: '//div[normalize-space()="Answer"]/..', + answerTitle: '//div[normalize-space()="Answer"]', + + addMedia: 'button#insert-media-button', + visualButton: 'button#dokan-product-qa-answer-tmce', + textButton: 'button#dokan-product-qa-answer-html', + + questionAnswerIframe: 'iframe#dokan-product-qa-answer_ifr', + questionAnswerHtmlBody: '#tinymce', + saveAnswer: 'button#dokan_product_qa_save_answer', + }, + + editAnswer: 'button#dokan_product_qa_edit_answer', + answerDetails: 'div.details-value p', + deleteAnswer: 'button#dokan_product_qa_delete_answer', + confirmAction: '.swal2-actions .swal2-confirm', + answerSaveSuccessMessage: '//div[text()="Answer saved successfully."]', + answerDeleteSuccessMessage: '//div[text()="Answer deleted successfully."]', + questionDeleteSuccessMessage: '//div[text()="Question deleted successfully."]', + }, + }, + // reverse withdrawal vReverseWithdrawal: { reverseWithdrawalText: '//h1[normalize-space()="Reverse Withdrawal"]', @@ -4832,7 +5012,7 @@ export const selector = { addBooking: 'input[value="Add Booking"][type="submit"]', - successMessage: '.woocommerce .is-success', + successMessage: '.woocommerce-message', }, // Manage Booking @@ -5514,6 +5694,7 @@ export const selector = { name: '#addon-reference', priority: '#addon-priority', productCategories: '.select2-search__field', + result: 'li.select2-results__option.select2-results__option--highlighted', // Addon fields addonFieldsRow: (addonField: string) => `//h3[@class="wc-pao-addon-name" and contains(text(), "${addonField}")]/../..//span[@class="wc-pao-addon-toggle"]`, @@ -6137,7 +6318,7 @@ export const selector = { billingEmailAddress: '#billing_email', billingSaveAddress: '//button[@name="save_address"]', // Success Message - successMessage: '.woocommerce .is-success', + successMessage: '.woocommerce-message', }, // Shipping Address @@ -6161,7 +6342,7 @@ export const selector = { shippingSaveAddress: '//button[@name="save_address"]', // Success Message - successMessage: '.woocommerce .is-success', + successMessage: '.woocommerce-message', }, }, @@ -6402,24 +6583,16 @@ export const selector = { description: '.tabs description_tab a', shipping: '.tabs .shipping_tab a', reviews: '.tabs .reviews_tab a', + questionsAnswers: '.tabs .product_qa_tab a', vendorInfo: '.tabs .seller_tab a', location: '.tabs .geolocation_tab a', moreProducts: '.tabs .more_seller_product_tab a', warrantyPolicy: '.tabs .refund_policy_tab a', productEnquiry: '.tabs .seller_enquiry_form_tab a', - - // description: '#tab-title-description a', - // reviews: '#tab-title-reviews', - // vendorInfo: '#tab-title-seller a', - // location: '#tab-title-geolocation a', - // moreProducts: '#tab-title-more_seller_product a', - // warrantyPolicy: '#tab-title-refund_policy a', - // productEnquiry: '#tab-title-seller_enquiry_form a', }, // Product description description: { - // descriptionHeading: '//h2[normalize-space()="Description"]', // todo: storefrontOnly content: 'div[id="tab-description"] p', }, @@ -6431,7 +6604,6 @@ export const selector = { // Product Reviews reviews: { - // reviewsHeading: '//h2[normalize-space()="Reviews"]', // todo: storefrontOnly noReviews: '.woocommerce-noreviews', ratings: '.comment-form-rating .stars', rating: (star: string) => `.star-${star}`, @@ -6444,9 +6616,21 @@ export const selector = { backFromDuplicateCommentAlert: '//a[contains(text(),"« Back")]', }, + // question and answeres + questionsAnswers: { + searchInput: 'input[placeholder="Search Questions & Answers"]', + loginPostQuestion: '//button[text()="Login to post your Question"]', + postQuestion: '//button[text()="Post your Question"]', + questionInput: 'textarea#comment.block', + cacelButton: '//span[text()="Close"]//..', + cancelPost: '//button[text()="Cancel"]', + post: '//button[text()="Post"]', + clearResult: '//button[text()="Clear Result"]', + matchingResult: 'h3.text-black.text-base', + }, + // Product vendor info vendorInfo: { - // vendorInfoHeading:'//h2[normalize-space()="Vendor Information"]', // todo: storefrontOnly storeName: '.store-name', vendor: '.seller-name', storeAddress: '.store-address', @@ -6454,13 +6638,13 @@ export const selector = { // Product Location location: { - // locationHeading: '//h2[normalize-space()="Product Location"]', // todo: storefrontOnly productLocation: 'div[id="tab-geolocation"] address', map: '#dokan-geolocation-locations-map', }, // More Products moreProducts: { + noProductsDiv: 'div#tab-more_seller_product', moreProductsDiv: '#tab-more_seller_product .products', product: '#tab-more_seller_product .product', }, @@ -6672,6 +6856,7 @@ export const selector = { // Customer Single Store cSingleStore: { + singleStoreDiv: 'div.dokan-single-store', // Store Profile Summary storeProfile: { storeProfileSummary: '.dokan-single-store .profile-info-summery', @@ -6901,7 +7086,7 @@ export const selector = { phoneNumber: 'input[name="phone_field"]', }, - message: '.woocommerce .is-success', + message: '.woocommerce-message', }, // requested quote @@ -6973,7 +7158,7 @@ export const selector = { updateQuote: 'button[name="dokan_update_quote"]', - message: '.woocommerce .is-success', + message: '.woocommerce-message', }, }, }, @@ -7284,10 +7469,10 @@ export const selector = { }, cWooSelector: { - wooCommerceSuccessMessage: '.woocommerce .is-success', - wooCommerceError: '.woocommerce .is-error', - wooCommerceInfo: '.woocommerce .is-info', - wooCommerceNoriceBanner: 'div.wc-block-components-notice-banner.is-info', // todo: .is-info might not be needed + wooCommerceSuccessMessage: '.woocommerce-message', + wooCommerceError: '.woocommerce-error', + wooCommerceInfo: '.woocommerce-info', + wooCommerceNoriceBanner: 'div.wc-block-components-notice-banner', wooCommerceNoriceBannerContent: 'div.wc-block-components-notice-banner__content', }, }, diff --git a/tests/pw/pages/sellerBadgesPage.ts b/tests/pw/pages/sellerBadgesPage.ts index 35b4f17aa4..5ee3670b67 100644 --- a/tests/pw/pages/sellerBadgesPage.ts +++ b/tests/pw/pages/sellerBadgesPage.ts @@ -5,6 +5,10 @@ import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; import { sellerBadge } from '@utils/interfaces'; +// selectors +const sellerBadgeAdmin = selector.admin.dokan.sellerBadge; +const sellerBadgeVendor = selector.vendor.vBadges; + export class SellerBadgesPage extends AdminPage { constructor(page: Page) { super(page); @@ -19,52 +23,52 @@ export class SellerBadgesPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.sellerBadge); // seller badge text is visible - await this.toBeVisible(selector.admin.dokan.sellerBadge.sellerBadgeText); + await this.toBeVisible(sellerBadgeAdmin.sellerBadgeText); // create badge is visible - await this.toBeVisible(selector.admin.dokan.sellerBadge.createBadge); + await this.toBeVisible(sellerBadgeAdmin.createBadge); // nav tabs are visible - await this.multipleElementVisible(selector.admin.dokan.sellerBadge.navTabs); + await this.multipleElementVisible(sellerBadgeAdmin.navTabs); // bulk action elements are visible - await this.multipleElementVisible(selector.admin.dokan.sellerBadge.bulkActions); + await this.multipleElementVisible(sellerBadgeAdmin.bulkActions); // search seller badge is visible - await this.toBeVisible(selector.admin.dokan.sellerBadge.search); + await this.toBeVisible(sellerBadgeAdmin.search); // seller badge table elements are visible - await this.multipleElementVisible(selector.admin.dokan.sellerBadge.table); + await this.multipleElementVisible(sellerBadgeAdmin.table); } // search seller badge async searchSellerBadge(badgeName: string) { await this.goIfNotThere(data.subUrls.backend.dokan.sellerBadge); - await this.clearInputField(selector.admin.dokan.sellerBadge.search); - await this.typeAndWaitForResponseAndLoadState(data.subUrls.api.dokan.sellerBadge, selector.admin.dokan.sellerBadge.search, badgeName); - await this.toBeVisible(selector.admin.dokan.sellerBadge.sellerBadgeCell(badgeName)); + await this.clearInputField(sellerBadgeAdmin.search); + await this.typeAndWaitForResponseAndLoadState(data.subUrls.api.dokan.sellerBadge, sellerBadgeAdmin.search, badgeName); + await this.toBeVisible(sellerBadgeAdmin.sellerBadgeCell(badgeName)); } // view seller badge async viewSellerBadge(badgeName: string) { await this.searchSellerBadge(badgeName); - await this.hover(selector.admin.dokan.sellerBadge.sellerBadgeRow(badgeName)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.sellerBadge, selector.admin.dokan.sellerBadge.sellerBadgeEdit(badgeName)); + await this.hover(sellerBadgeAdmin.sellerBadgeRow(badgeName)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.sellerBadge, sellerBadgeAdmin.sellerBadgeEdit(badgeName)); // badge condition box is visible - await this.toBeVisible(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.badgeConditionBox); + await this.toBeVisible(sellerBadgeAdmin.badgeDetails.badgeCondition.badgeConditionBox); // badge event elements are visible - const { badgeEvent, badgePublishedStatus, ...badgeEvents } = selector.admin.dokan.sellerBadge.badgeDetails.badgeEvents; + const { badgeEvent, badgePublishedStatus, ...badgeEvents } = sellerBadgeAdmin.badgeDetails.badgeEvents; await this.multipleElementVisible(badgeEvents); // badge photo elements are visible - await this.multipleElementVisible(selector.admin.dokan.sellerBadge.badgeDetails.badgePhoto); + await this.multipleElementVisible(sellerBadgeAdmin.badgeDetails.badgePhoto); // badge status elements are visible - const { create, ...badgeStatus } = selector.admin.dokan.sellerBadge.badgeDetails.badgeStatus; + const { create, ...badgeStatus } = sellerBadgeAdmin.badgeDetails.badgeStatus; await this.multipleElementVisible(badgeStatus); } @@ -72,117 +76,117 @@ export class SellerBadgesPage extends AdminPage { async createSellerBadge(badge: sellerBadge) { await this.goIfNotThere(data.subUrls.backend.dokan.sellerBadge); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.sellerBadgeEvent, selector.admin.dokan.sellerBadge.createBadge); - await this.click(selector.admin.dokan.sellerBadge.badgeDetails.badgeEvents.badgeEventDropdown); - const isPublished = await this.isVisible(selector.admin.dokan.sellerBadge.badgeDetails.badgeEvents.badgePublishedStatus(badge.badgeName)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.sellerBadgeEvent, sellerBadgeAdmin.createBadge); + await this.click(sellerBadgeAdmin.badgeDetails.badgeEvents.badgeEventDropdown); + const isPublished = await this.isVisible(sellerBadgeAdmin.badgeDetails.badgeEvents.badgePublishedStatus(badge.badgeName)); if (isPublished) { console.log('Badge is already published'); test.skip(); // throw new Error('Badge is already published'); } - await this.click(selector.admin.dokan.sellerBadge.badgeDetails.badgeEvents.badgeEvent(badge.badgeName)); - await this.clearAndType(selector.admin.dokan.sellerBadge.badgeDetails.badgeEvents.badgeName, badge.badgeName); + await this.click(sellerBadgeAdmin.badgeDetails.badgeEvents.badgeEvent(badge.badgeName)); + await this.clearAndType(sellerBadgeAdmin.badgeDetails.badgeEvents.badgeName, badge.badgeName); - const isLevelExists = await this.isVisible(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.startingLevelValue); + const isLevelExists = await this.isVisible(sellerBadgeAdmin.badgeDetails.badgeCondition.startingLevelValue); if (isLevelExists) { - await this.clearAndType(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.startingLevelValue, badge.startingLevelValue); + await this.clearAndType(sellerBadgeAdmin.badgeDetails.badgeCondition.startingLevelValue, badge.startingLevelValue); for (let i = 1; i < badge.maxLevel; i++) { - await this.click(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.addBadgeLevel); + await this.click(sellerBadgeAdmin.badgeDetails.badgeCondition.addBadgeLevel); } } else { if (badge.badgeName === 'Trending Product') { - await this.selectByValue(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.trendingProductPeriod, badge.trendingProductPeriod); - await this.clearAndType(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.trendingProductTopBestSellingProduct, badge.trendingProductTopBestSellingProduct); + await this.selectByValue(sellerBadgeAdmin.badgeDetails.badgeCondition.trendingProductPeriod, badge.trendingProductPeriod); + await this.clearAndType(sellerBadgeAdmin.badgeDetails.badgeCondition.trendingProductTopBestSellingProduct, badge.trendingProductTopBestSellingProduct); } if (badge.badgeName === 'Verified Seller') { - // await this.selectByValue(selector.admin.dokan.sellerBadge.badgeDetails.verifiedSellerMethod, badge.verificationMethod); + // await this.selectByValue(sellerBadgeAdmin.badgeDetails.verifiedSellerMethod, badge.verificationMethod); const methods: string[] = Object.values(badge.verifiedSellerMethod); for (let i = 1; i <= methods.length; i++) { - await this.selectByValue(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.verifiedSellerMethod1(i), methods[i - 1] as string); + await this.selectByValue(sellerBadgeAdmin.badgeDetails.badgeCondition.verifiedSellerMethod1(i), methods[i - 1] as string); if (i === methods.length) { continue; } - await this.click(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.addBadgeLevel); + await this.click(sellerBadgeAdmin.badgeDetails.badgeCondition.addBadgeLevel); } } } - await this.selectByValue(selector.admin.dokan.sellerBadge.badgeDetails.badgeStatus.badgeStatus, badge.badgeStatus); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.sellerBadge, selector.admin.dokan.sellerBadge.badgeDetails.badgeStatus.create); - await this.click(selector.admin.dokan.sellerBadge.badgeDetails.badgeAddedSuccessfully); + await this.selectByValue(sellerBadgeAdmin.badgeDetails.badgeStatus.badgeStatus, badge.badgeStatus); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.sellerBadge, sellerBadgeAdmin.badgeDetails.badgeStatus.create); + await this.click(sellerBadgeAdmin.badgeDetails.badgeAddedSuccessfully); } // edit seller badge async editSellerBadge(badge: sellerBadge) { await this.searchSellerBadge(badge.badgeName); - await this.hover(selector.admin.dokan.sellerBadge.sellerBadgeRow(badge.badgeName)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.sellerBadge, selector.admin.dokan.sellerBadge.sellerBadgeEdit(badge.badgeName)); + await this.hover(sellerBadgeAdmin.sellerBadgeRow(badge.badgeName)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.sellerBadge, sellerBadgeAdmin.sellerBadgeEdit(badge.badgeName)); - await this.clearAndType(selector.admin.dokan.sellerBadge.badgeDetails.badgeEvents.badgeName, badge.badgeName); + await this.clearAndType(sellerBadgeAdmin.badgeDetails.badgeEvents.badgeName, badge.badgeName); - const isLevelExists = await this.isVisible(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.startingLevelValue); + const isLevelExists = await this.isVisible(sellerBadgeAdmin.badgeDetails.badgeCondition.startingLevelValue); if (isLevelExists) { // remove previous badge level - const maxLevel = await this.countLocator(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.badgeLevel); + const maxLevel = await this.countLocator(sellerBadgeAdmin.badgeDetails.badgeCondition.badgeLevel); for (let i = 1; i < maxLevel; i++) { - await this.click(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.removeBadgeLevel); + await this.click(sellerBadgeAdmin.badgeDetails.badgeCondition.removeBadgeLevel); } // add badge level - await this.clearAndType(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.startingLevelValue, badge.startingLevelValue); + await this.clearAndType(sellerBadgeAdmin.badgeDetails.badgeCondition.startingLevelValue, badge.startingLevelValue); for (let i = 1; i < badge.maxLevel; i++) { - await this.click(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.addBadgeLevel); + await this.click(sellerBadgeAdmin.badgeDetails.badgeCondition.addBadgeLevel); } } else { if (badge.badgeName === 'Trending Product') { - await this.selectByValue(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.trendingProductPeriod, badge.trendingProductPeriod); - await this.clearAndType(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.trendingProductTopBestSellingProduct, badge.trendingProductTopBestSellingProduct); + await this.selectByValue(sellerBadgeAdmin.badgeDetails.badgeCondition.trendingProductPeriod, badge.trendingProductPeriod); + await this.clearAndType(sellerBadgeAdmin.badgeDetails.badgeCondition.trendingProductTopBestSellingProduct, badge.trendingProductTopBestSellingProduct); } if (badge.badgeName === 'Verified Seller') { - // await this.selectByValue(selector.admin.dokan.sellerBadge.badgeDetails.verifiedSellerMethod, badge.verificationMethod); + // await this.selectByValue(sellerBadgeAdmin.badgeDetails.verifiedSellerMethod, badge.verificationMethod); // remove previous badge level - await this.waitForSelector(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.badgeLevel); - const maxLevel = await this.countLocator(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.badgeLevel); + await this.waitForSelector(sellerBadgeAdmin.badgeDetails.badgeCondition.badgeLevel); + const maxLevel = await this.countLocator(sellerBadgeAdmin.badgeDetails.badgeCondition.badgeLevel); for (let i = 1; i < maxLevel; i++) { - await this.click(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.removeBadgeLevel); + await this.click(sellerBadgeAdmin.badgeDetails.badgeCondition.removeBadgeLevel); } // add badge level const methods: string[] = Object.values(badge.verifiedSellerMethod); for (let i = 1; i <= methods.length; i++) { - await this.selectByValue(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.verifiedSellerMethod1(i), methods[i - 1] as string); + await this.selectByValue(sellerBadgeAdmin.badgeDetails.badgeCondition.verifiedSellerMethod1(i), methods[i - 1] as string); if (i === methods.length) { continue; } - await this.click(selector.admin.dokan.sellerBadge.badgeDetails.badgeCondition.addBadgeLevel); + await this.click(sellerBadgeAdmin.badgeDetails.badgeCondition.addBadgeLevel); } } } - await this.selectByValue(selector.admin.dokan.sellerBadge.badgeDetails.badgeStatus.badgeStatus, badge.badgeStatus); - await this.click(selector.admin.dokan.sellerBadge.badgeDetails.badgeStatus.update); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.sellerBadge, selector.admin.dokan.sellerBadge.badgeDetails.confirmBadgeUpdate); - await this.click(selector.admin.dokan.sellerBadge.badgeDetails.badgeAddedSuccessfully); + await this.selectByValue(sellerBadgeAdmin.badgeDetails.badgeStatus.badgeStatus, badge.badgeStatus); + await this.click(sellerBadgeAdmin.badgeDetails.badgeStatus.update); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.sellerBadge, sellerBadgeAdmin.badgeDetails.confirmBadgeUpdate); + await this.click(sellerBadgeAdmin.badgeDetails.badgeAddedSuccessfully); } // preview seller badge async previewSellerBadge(badgeName: string) { await this.searchSellerBadge(badgeName); - const badgeLevel = await this.getElementText(selector.admin.dokan.sellerBadge.sellerBadgeLevel(badgeName)); + const badgeLevel = await this.getElementText(sellerBadgeAdmin.sellerBadgeLevel(badgeName)); - await this.hover(selector.admin.dokan.sellerBadge.sellerBadgeRow(badgeName)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.sellerBadge, selector.admin.dokan.sellerBadge.sellerBadgePreview(badgeName)); + await this.hover(sellerBadgeAdmin.sellerBadgeRow(badgeName)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.sellerBadge, sellerBadgeAdmin.sellerBadgePreview(badgeName)); // badge preview modal is visible - await this.toBeVisible(selector.admin.dokan.sellerBadge.previewBadgeDetails.modal); + await this.toBeVisible(sellerBadgeAdmin.previewBadgeDetails.modal); // badge preview header elements are visible - await this.multipleElementVisible(selector.admin.dokan.sellerBadge.previewBadgeDetails.modalHeader); + await this.multipleElementVisible(sellerBadgeAdmin.previewBadgeDetails.modalHeader); - await this.toHaveCount(selector.admin.dokan.sellerBadge.previewBadgeDetails.levelBox, Number(badgeLevel)); + await this.toHaveCount(sellerBadgeAdmin.previewBadgeDetails.levelBox, Number(badgeLevel)); - await this.click(selector.admin.dokan.sellerBadge.previewBadgeDetails.modalHeader.modalClose); + await this.click(sellerBadgeAdmin.previewBadgeDetails.modalHeader.modalClose); } // filter vendors by badge @@ -200,8 +204,8 @@ export class SellerBadgesPage extends AdminPage { async sellerBadgeVendors(badgeName: string) { await this.searchSellerBadge(badgeName); - await this.hover(selector.admin.dokan.sellerBadge.sellerBadgeRow(badgeName)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.sellerBadge, selector.admin.dokan.sellerBadge.sellerBadgeVendors(badgeName)); + await this.hover(sellerBadgeAdmin.sellerBadgeRow(badgeName)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.sellerBadge, sellerBadgeAdmin.sellerBadgeVendors(badgeName)); // await this.toBeVisible(selector.admin.dokan.vendors.vendorCell(badgeName)); const count = (await this.getElementText(selector.admin.dokan.vendors.numberOfRowsFound))?.split(' ')[0]; expect(Number(count)).toBeGreaterThan(0); @@ -220,27 +224,27 @@ export class SellerBadgesPage extends AdminPage { async updateSellerBadge(badgeName: string, status: string) { await this.searchSellerBadge(badgeName); - await this.hover(selector.admin.dokan.sellerBadge.sellerBadgeRow(badgeName)); + await this.hover(sellerBadgeAdmin.sellerBadgeRow(badgeName)); switch (status) { case 'publish': - await this.click(selector.admin.dokan.sellerBadge.sellerBadgePublish(badgeName)); + await this.click(sellerBadgeAdmin.sellerBadgePublish(badgeName)); break; case 'draft': - await this.click(selector.admin.dokan.sellerBadge.sellerBadgeDraft(badgeName)); + await this.click(sellerBadgeAdmin.sellerBadgeDraft(badgeName)); break; case 'delete': - await this.click(selector.admin.dokan.sellerBadge.sellerBadgeDelete(badgeName)); + await this.click(sellerBadgeAdmin.sellerBadgeDelete(badgeName)); break; default: break; } - await this.clickAndWaitForResponse(data.subUrls.api.dokan.sellerBadge, selector.admin.dokan.sellerBadge.confirmAction); - await this.click(selector.admin.dokan.sellerBadge.successMessage); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.sellerBadge, sellerBadgeAdmin.confirmAction); + await this.click(sellerBadgeAdmin.successMessage); } // seller badge bulk action @@ -248,13 +252,13 @@ export class SellerBadgesPage extends AdminPage { badgeName ? await this.searchSellerBadge(badgeName) : await this.goIfNotThere(data.subUrls.backend.dokan.sellerBadge); // ensure row exists - await this.notToBeVisible(selector.admin.dokan.sellerBadge.noRowsFound); + await this.notToBeVisible(sellerBadgeAdmin.noRowsFound); - await this.click(selector.admin.dokan.sellerBadge.bulkActions.selectAll); - await this.selectByValue(selector.admin.dokan.sellerBadge.bulkActions.selectAction, action); - await this.click(selector.admin.dokan.sellerBadge.bulkActions.applyAction); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.sellerBadge, selector.admin.dokan.sellerBadge.confirmAction); - await this.click(selector.admin.dokan.sellerBadge.successMessage); + await this.click(sellerBadgeAdmin.bulkActions.selectAll); + await this.selectByValue(sellerBadgeAdmin.bulkActions.selectAction, action); + await this.click(sellerBadgeAdmin.bulkActions.applyAction); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.sellerBadge, sellerBadgeAdmin.confirmAction); + await this.click(sellerBadgeAdmin.successMessage); } // vendor seller badge render properly @@ -262,31 +266,31 @@ export class SellerBadgesPage extends AdminPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.badges); // badges text is visible - await this.toBeVisible(selector.vendor.vBadges.badgesText); + await this.toBeVisible(sellerBadgeVendor.badgesText); // badge description text is visible - await this.toBeVisible(selector.vendor.vBadges.description); + await this.toBeVisible(sellerBadgeVendor.description); // badge search is visible - await this.toBeVisible(selector.vendor.vBadges.search); + await this.toBeVisible(sellerBadgeVendor.search); // badge filter is visible - await this.toBeVisible(selector.vendor.vBadges.filterBadges); + await this.toBeVisible(sellerBadgeVendor.filterBadges); // seller badge table elements are visible - await this.multipleElementVisible(selector.vendor.vBadges.table); + await this.multipleElementVisible(sellerBadgeVendor.table); } // vendor achieved badges congrats popup async sellerBadgeCongratsPopup() { await this.goIfNotThere(data.subUrls.frontend.vDashboard.badges); - const congratsModalIsVisible = await this.isVisible(selector.vendor.vBadges.congratsModal.sellerBadgeModal); + const congratsModalIsVisible = await this.isVisible(sellerBadgeVendor.congratsModal.sellerBadgeModal); if (congratsModalIsVisible) { // seller badge congrats modal elements are visible - await this.multipleElementVisible(selector.vendor.vBadges.congratsModal); + await this.multipleElementVisible(sellerBadgeVendor.congratsModal); - await this.clickIfVisible(selector.vendor.vBadges.congratsModal.closeModal); + await this.clickIfVisible(sellerBadgeVendor.congratsModal.closeModal); } else { console.log('No Congrats message appeared'); } @@ -294,19 +298,19 @@ export class SellerBadgesPage extends AdminPage { // vendor search seller badge async vendorSearchSellerBadge(badgeName: string) { - await this.clickIfVisible(selector.vendor.vBadges.congratsModal.closeModal); + await this.clickIfVisible(sellerBadgeVendor.congratsModal.closeModal); await this.goIfNotThere(data.subUrls.frontend.vDashboard.badges); - await this.clearAndType(selector.vendor.vBadges.search, badgeName); - await this.toBeVisible(selector.vendor.vBadges.sellerBadgeCell(badgeName)); + await this.clearAndType(sellerBadgeVendor.search, badgeName); + await this.toBeVisible(sellerBadgeVendor.sellerBadgeCell(badgeName)); } // vendor filter seller badge async filterSellerBadges(option: string) { - await this.clickIfVisible(selector.vendor.vBadges.congratsModal.closeModal); + await this.clickIfVisible(sellerBadgeVendor.congratsModal.closeModal); await this.goIfNotThere(data.subUrls.frontend.vDashboard.badges); - await this.selectByValue(selector.vendor.vBadges.filterBadges, option); - const count = (await this.getElementText(selector.vendor.vBadges.numberOfBadgesFound))?.split(' ')[0]; + await this.selectByValue(sellerBadgeVendor.filterBadges, option); + const count = (await this.getElementText(sellerBadgeVendor.numberOfBadgesFound))?.split(' ')[0]; expect(Number(count)).toBeGreaterThan(0); } } diff --git a/tests/pw/pages/settingPage.ts b/tests/pw/pages/settingPage.ts new file mode 100644 index 0000000000..cc3a7b4db4 --- /dev/null +++ b/tests/pw/pages/settingPage.ts @@ -0,0 +1,137 @@ +import { Page } from '@playwright/test'; +import { AdminPage } from '@pages/adminPage'; +import { LoginPage } from '@pages/loginPage'; +import { VendorPage } from '@pages/vendorPage'; +import { OrdersPage } from '@pages/ordersPage'; +import { selector } from '@pages/selectors'; +import { data } from '@utils/testData'; +import { helpers } from '@utils/helpers'; + +export class SettingPage extends AdminPage { + constructor(page: Page) { + super(page); + } + + loginPage = new LoginPage(this.page); + vendorPage = new VendorPage(this.page); + ordersPage = new OrdersPage(this.page); + + // navigation + + async goToMyAccount(): Promise { + await this.goto(data.subUrls.frontend.myAccount); + } + + async goToProductDetails(productName: string): Promise { + await this.goto(data.subUrls.frontend.productDetails(helpers.slugify(productName))); + } + + // general settings + + async vendorStoreUrlSetting(storeName: string, storeUrl: string) { + // previous url + await this.goto(data.subUrls.frontend.vendorDetails(storeName)); + await this.toBeVisible(selector.frontend.pageNotFound); + + // new url + await this.goto(`${storeUrl}/${storeName}`); + await this.toBeVisible(selector.customer.cSingleStore.singleStoreDiv); + } + + async vendorSetupWizardLogoAndMessageSetting(logoUrl: string, setupWizardMessage: string) { + await this.goIfNotThere(data.subUrls.frontend.vDashboard.setupWizard); + await this.toHaveAttribute(selector.vendor.vSetup.setupLogoImage, 'src', logoUrl); + await this.toContainText(selector.vendor.vSetup.setupwizardContent, setupWizardMessage); + } + + async disableVendorSetupWizardSetting() { + await this.vendorPage.vendorRegister(data.vendor.vendorInfo, { ...data.vendorSetupWizard, setupWizardEnabled: false, choice: false }); + await this.toBeVisible(selector.vendor.vDashboard.menus.dashboard); + } + + async setStoreTermsAndConditions(status: string) { + await this.goto(data.subUrls.frontend.vDashboard.settingsStore); + if (status == 'on') { + await this.toBeVisible(selector.vendor.vStoreSettings.termsAndConditions); + await this.toBeVisible(selector.vendor.vStoreSettings.termsAndConditionsIframe); + } else { + await this.notToBeVisible(selector.vendor.vStoreSettings.termsAndConditions); + await this.notToBeVisible(selector.vendor.vStoreSettings.termsAndConditionsIframe); + } + } + + async setStoreProductsPerPage(storeName: string, count: number) { + await this.goto(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName))); + await this.toHaveCount(selector.customer.cSingleStore.productCard.card, count); + } + + async enableAddressFieldsOnRegistration(status: string) { + await this.vendorPage.openVendorRegistrationForm(); + if (status == 'on') { + await this.toBeVisible(selector.vendor.vRegistration.street1); + await this.toBeVisible(selector.vendor.vRegistration.street2); + await this.toBeVisible(selector.vendor.vRegistration.city); + await this.toBeVisible(selector.vendor.vRegistration.zipCode); + await this.toBeVisible(selector.vendor.vRegistration.country); + } else { + await this.notToBeVisible(selector.vendor.vRegistration.street1); + await this.notToBeVisible(selector.vendor.vRegistration.street2); + await this.notToBeVisible(selector.vendor.vRegistration.city); + await this.notToBeVisible(selector.vendor.vRegistration.zipCode); + await this.notToBeVisible(selector.vendor.vRegistration.country); + } + } + + async enableStoreTermsAndConditionsOnRegistration(status: string) { + await this.vendorPage.openVendorRegistrationForm(); + status == 'on' ? await this.toBeVisible(selector.customer.cDashboard.termsAndConditions) : await this.notToBeVisible(selector.customer.cDashboard.termsAndConditions); + } + + async setShowVendorInfo(productName: string, status: string) { + await this.goToProductDetails(productName); + if (status == 'on') { + await this.toBeVisible(selector.customer.cSingleProduct.menus.vendorInfo); + await this.click(selector.customer.cSingleProduct.menus.vendorInfo); + await this.multipleElementVisible(selector.customer.cSingleProduct.vendorInfo); + } else { + await this.notToBeVisible(selector.customer.cSingleProduct.menus.vendorInfo); + } + } + + async enableMoreProductsTab(productName: string, status: string) { + await this.goToProductDetails(productName); + if (status == 'on') { + await this.click(selector.customer.cSingleProduct.menus.moreProducts); + const hasMoreProducts = await this.isVisible(selector.customer.cSingleProduct.moreProducts.moreProductsDiv); + if (hasMoreProducts) { + await this.toBeVisible(selector.customer.cSingleProduct.moreProducts.moreProductsDiv); + await this.notToHaveCount(selector.customer.cSingleProduct.moreProducts.product, 0); + } else { + await this.toContainText(selector.customer.cSingleProduct.moreProducts.noProductsDiv, 'No product has been found!'); + } + } else { + await this.notToBeVisible(selector.customer.cSingleProduct.menus.moreProducts); + } + } + + // selling settings + + async enableVendorSelling(status: string) { + await this.vendorPage.vendorRegister(data.vendor.vendorInfo, { ...data.vendorSetupWizard, choice: false }); + if (status == 'on') { + await this.notToBeVisible(selector.vendor.vDashboard.dokanAlert); + } else { + await this.toBeVisible(selector.vendor.vDashboard.dokanAlert); + await this.toContainText(selector.vendor.vDashboard.dokanAlert, 'Error! Your account is not enabled for selling, please contact the admin'); + } + } + + async setOrderStatusChangeCapability(orderNumber: string, status: string): Promise { + await this.ordersPage.goToOrderDetails(orderNumber); + if (status == 'on') { + await this.toBeVisible(selector.vendor.orders.status.edit); + } else { + await this.notToBeVisible(selector.vendor.orders.status.edit); + } + } +} diff --git a/tests/pw/pages/settingsPage.ts b/tests/pw/pages/settingsPage.ts index d7003e7a7f..27eb76f2d1 100644 --- a/tests/pw/pages/settingsPage.ts +++ b/tests/pw/pages/settingsPage.ts @@ -6,6 +6,9 @@ import { dokanSettings } from '@utils/interfaces'; const { DOKAN_PRO } = process.env; +// selectors +const settingsAdmin = selector.admin.dokan.settings; + export class SettingsPage extends AdminPage { constructor(page: Page) { super(page); @@ -18,28 +21,28 @@ export class SettingsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.settings); // settings text is visible - await this.toBeVisible(selector.admin.dokan.settings.settingsText); + await this.toBeVisible(settingsAdmin.settingsText); // settings section elements are visible - await this.multipleElementVisible(selector.admin.dokan.settings.sections); + await this.multipleElementVisible(settingsAdmin.sections); // settings header elements are visible - await this.multipleElementVisible(selector.admin.dokan.settings.header); + await this.multipleElementVisible(settingsAdmin.header); // settings field is visible - await this.toBeVisible(selector.admin.dokan.settings.fields); + await this.toBeVisible(settingsAdmin.fields); // settings save Changes is visible - await this.toBeVisible(selector.admin.dokan.settings.saveChanges); + await this.toBeVisible(settingsAdmin.saveChanges); } // search settings async searchSettings(settings: string) { await this.goIfNotThere(data.subUrls.backend.dokan.settings); - await this.clearAndType(selector.admin.dokan.settings.search.input, settings); - await this.toBeVisible(selector.admin.dokan.settings.fields); - await this.click(selector.admin.dokan.settings.search.close); + await this.clearAndType(settingsAdmin.search.input, settings); + await this.toBeVisible(settingsAdmin.fields); + await this.click(settingsAdmin.search.close); } // scroll to top settings @@ -47,7 +50,7 @@ export class SettingsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.settings); await this.scrollToBottom(); - await this.toBeVisible(selector.admin.dokan.settings.backToTop); + await this.toBeVisible(settingsAdmin.backToTop); } // dokan settings @@ -55,506 +58,506 @@ export class SettingsPage extends AdminPage { // admin set dokan general settings async setDokanGeneralSettings(general: dokanSettings['general']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.general); + await this.click(settingsAdmin.menus.general); // site options - await this.enableSwitcher(selector.admin.dokan.settings.general.adminAreaAccess); - await this.clearAndType(selector.admin.dokan.settings.general.vendorStoreUrl, general.vendorStoreUrl); - await this.typeFrameSelector(selector.admin.dokan.settings.general.setupWizardMessageIframe, selector.admin.dokan.settings.general.setupWizardMessageHtmlBody, general.setupWizardMessage); - DOKAN_PRO && (await this.click(selector.admin.dokan.settings.general.sellingProductTypes(general.sellingProductTypes))); + await this.enableSwitcher(settingsAdmin.general.adminAreaAccess); + await this.clearAndType(settingsAdmin.general.vendorStoreUrl, general.vendorStoreUrl); + await this.typeFrameSelector(settingsAdmin.general.setupWizardMessageIframe, settingsAdmin.general.setupWizardMessageHtmlBody, general.setupWizardMessage); + DOKAN_PRO && (await this.click(settingsAdmin.general.sellingProductTypes(general.sellingProductTypes))); // vendor store options - await this.enableSwitcher(selector.admin.dokan.settings.general.storeTermsAndConditions); - await this.clearAndType(selector.admin.dokan.settings.general.storeProductPerPage, general.storeProductPerPage); + await this.enableSwitcher(settingsAdmin.general.storeTermsAndConditions); + await this.clearAndType(settingsAdmin.general.storeProductPerPage, general.storeProductPerPage); if (DOKAN_PRO) { - await this.enableSwitcher(selector.admin.dokan.settings.general.enableTermsAndCondition); - await this.click(selector.admin.dokan.settings.general.storCategory(general.storCategory)); + await this.enableSwitcher(settingsAdmin.general.enableTermsAndCondition); + await this.click(settingsAdmin.general.storCategory(general.storCategory)); } // product page settings - await this.enableSwitcher(selector.admin.dokan.settings.general.showVendorInfo); - await this.enableSwitcher(selector.admin.dokan.settings.general.enableMoreProductsTab); + await this.enableSwitcher(settingsAdmin.general.showVendorInfo); + await this.enableSwitcher(settingsAdmin.general.enableMoreProductsTab); // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.general.generalSaveChanges); - await this.toContainText(selector.admin.dokan.settings.dokanUpdateSuccessMessage, general.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.general.generalSaveChanges); + await this.toContainText(settingsAdmin.dokanUpdateSuccessMessage, general.saveSuccessMessage); } // admin set dokan selling settings async setDokanSellingSettings(selling: dokanSettings['selling']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.sellingOptions); + await this.click(settingsAdmin.menus.sellingOptions); // commission settings - await this.selectByValue(selector.admin.dokan.settings.selling.commissionType, selling.commissionType); - await this.clearAndType(selector.admin.dokan.settings.selling.adminCommission, selling.adminCommission); - // await this.click(selector.admin.dokan.settings.selling.shippingFeeRecipient(selling.shippingFeeRecipient)); //todo: makes test flaky - await this.click(selector.admin.dokan.settings.selling.productTaxFeeRecipient(selling.productTaxFeeRecipient)); - await this.click(selector.admin.dokan.settings.selling.shippingTaxFeeRecipient(selling.shippingTaxFeeRecipient)); + await this.selectByValue(settingsAdmin.selling.commissionType, selling.commissionType); + await this.clearAndType(settingsAdmin.selling.adminCommission, selling.adminCommission); + // await this.click(settingsAdmin.selling.shippingFeeRecipient(selling.shippingFeeRecipient)); //todo: makes test flaky + await this.click(settingsAdmin.selling.productTaxFeeRecipient(selling.productTaxFeeRecipient)); + await this.click(settingsAdmin.selling.shippingTaxFeeRecipient(selling.shippingTaxFeeRecipient)); // vendor capabilities - await this.enableSwitcher(selector.admin.dokan.settings.selling.enableSelling); - await this.enableSwitcher(selector.admin.dokan.settings.selling.onePageProductCreate); - await this.enableSwitcher(selector.admin.dokan.settings.selling.orderStatusChange); - await this.enableSwitcher(selector.admin.dokan.settings.selling.selectAnyCategory); + await this.enableSwitcher(settingsAdmin.selling.enableSelling); + await this.enableSwitcher(settingsAdmin.selling.onePageProductCreate); + await this.enableSwitcher(settingsAdmin.selling.orderStatusChange); + await this.enableSwitcher(settingsAdmin.selling.selectAnyCategory); if (DOKAN_PRO) { - await this.click(selector.admin.dokan.settings.selling.newProductStatus(selling.newProductStatus)); - await this.enableSwitcher(selector.admin.dokan.settings.selling.duplicateProduct); - await this.click(selector.admin.dokan.settings.selling.productCategorySelection(selling.productCategorySelection)); - await this.enableSwitcher(selector.admin.dokan.settings.selling.vendorsCanCreateTags); - await this.enableSwitcher(selector.admin.dokan.settings.selling.orderDiscount); - await this.enableSwitcher(selector.admin.dokan.settings.selling.productDiscount); - await this.enableSwitcher(selector.admin.dokan.settings.selling.vendorProductReviewStatusChange); - await this.enableSwitcher(selector.admin.dokan.settings.selling.guestProductEnquiry); - await this.enableSwitcher(selector.admin.dokan.settings.selling.newVendorEnableAuction); // todo: add condition for simple auction plugin enabled - await this.enableSwitcher(selector.admin.dokan.settings.selling.enableMinMaxQuantities); - await this.enableSwitcher(selector.admin.dokan.settings.selling.enableMinMaxAmount); + await this.click(settingsAdmin.selling.newProductStatus(selling.newProductStatus)); + await this.enableSwitcher(settingsAdmin.selling.duplicateProduct); + await this.click(settingsAdmin.selling.productCategorySelection(selling.productCategorySelection)); + await this.enableSwitcher(settingsAdmin.selling.vendorsCanCreateTags); + await this.enableSwitcher(settingsAdmin.selling.orderDiscount); + await this.enableSwitcher(settingsAdmin.selling.productDiscount); + await this.enableSwitcher(settingsAdmin.selling.vendorProductReviewStatusChange); + await this.enableSwitcher(settingsAdmin.selling.guestProductEnquiry); + await this.enableSwitcher(settingsAdmin.selling.newVendorEnableAuction); // todo: add condition for simple auction plugin enabled + await this.enableSwitcher(settingsAdmin.selling.enableMinMaxQuantities); + await this.enableSwitcher(settingsAdmin.selling.enableMinMaxAmount); } // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.selling.sellingOptionsSaveChanges); - await this.toHaveValue(selector.admin.dokan.settings.selling.adminCommission, selling.adminCommission); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.selling.sellingOptionsSaveChanges); + await this.toHaveValue(settingsAdmin.selling.adminCommission, selling.adminCommission); } // Admin Set Dokan Withdraw Settings async setDokanWithdrawSettings(withdraw: dokanSettings['withdraw']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.withdrawOptions); + await this.click(settingsAdmin.menus.withdrawOptions); // Withdraw Options - await this.enableSwitcher(selector.admin.dokan.settings.withdraw.withdrawMethodsPaypal); - await this.enableSwitcher(selector.admin.dokan.settings.withdraw.withdrawMethodsBankTransfer); + await this.enableSwitcher(settingsAdmin.withdraw.withdrawMethodsPaypal); + await this.enableSwitcher(settingsAdmin.withdraw.withdrawMethodsBankTransfer); if (DOKAN_PRO) { - await this.enableSwitcher(selector.admin.dokan.settings.withdraw.withdrawMethodsDokanCustom); - await this.enableSwitcher(selector.admin.dokan.settings.withdraw.withdrawMethodsSkrill); - await this.clearAndType(selector.admin.dokan.settings.withdraw.customMethodName, withdraw.customMethodName); - await this.clearAndType(selector.admin.dokan.settings.withdraw.customMethodType, withdraw.customMethodType); + await this.enableSwitcher(settingsAdmin.withdraw.withdrawMethodsDokanCustom); + await this.enableSwitcher(settingsAdmin.withdraw.withdrawMethodsSkrill); + await this.clearAndType(settingsAdmin.withdraw.customMethodName, withdraw.customMethodName); + await this.clearAndType(settingsAdmin.withdraw.customMethodType, withdraw.customMethodType); } // Withdraw Charge - await this.clearAndType(selector.admin.dokan.settings.withdraw.payPalChargePercentage, withdraw.charge.paypal); - await this.clearAndType(selector.admin.dokan.settings.withdraw.bankTransferChargeFixed, withdraw.charge.bank); + await this.clearAndType(settingsAdmin.withdraw.payPalChargePercentage, withdraw.charge.paypal); + await this.clearAndType(settingsAdmin.withdraw.bankTransferChargeFixed, withdraw.charge.bank); if (DOKAN_PRO) { - await this.clearAndType(selector.admin.dokan.settings.withdraw.skrillChargePercentage, withdraw.charge.skrill); - await this.clearAndType(selector.admin.dokan.settings.withdraw.customChargePercentage, withdraw.charge.custom); + await this.clearAndType(settingsAdmin.withdraw.skrillChargePercentage, withdraw.charge.skrill); + await this.clearAndType(settingsAdmin.withdraw.customChargePercentage, withdraw.charge.custom); } - await this.clearAndType(selector.admin.dokan.settings.withdraw.minimumWithdrawAmount, withdraw.minimumWithdrawAmount); - await this.enableSwitcher(selector.admin.dokan.settings.withdraw.orderStatusForWithdrawCompleted); - await this.enableSwitcher(selector.admin.dokan.settings.withdraw.orderStatusForWithdrawProcessing); + await this.clearAndType(settingsAdmin.withdraw.minimumWithdrawAmount, withdraw.minimumWithdrawAmount); + await this.enableSwitcher(settingsAdmin.withdraw.orderStatusForWithdrawCompleted); + await this.enableSwitcher(settingsAdmin.withdraw.orderStatusForWithdrawProcessing); // Withdraw Charge if (DOKAN_PRO) { - await this.clearAndType(selector.admin.dokan.settings.withdraw.withdrawThreshold, withdraw.withdrawThreshold); + await this.clearAndType(settingsAdmin.withdraw.withdrawThreshold, withdraw.withdrawThreshold); // Disbursement Schedule Settings - await this.enableSwitcher(selector.admin.dokan.settings.withdraw.withdrawDisbursementManual); - await this.enableSwitcher(selector.admin.dokan.settings.withdraw.withdrawDisbursementAuto); + await this.enableSwitcher(settingsAdmin.withdraw.withdrawDisbursementManual); + await this.enableSwitcher(settingsAdmin.withdraw.withdrawDisbursementAuto); // Disbursement Schedule - await this.enableSwitcher(selector.admin.dokan.settings.withdraw.disburseMentQuarterlySchedule); - await this.enableSwitcher(selector.admin.dokan.settings.withdraw.disburseMentMonthlySchedule); - await this.enableSwitcher(selector.admin.dokan.settings.withdraw.disburseMentBiweeklySchedule); - await this.enableSwitcher(selector.admin.dokan.settings.withdraw.disburseMentWeeklySchedule); + await this.enableSwitcher(settingsAdmin.withdraw.disburseMentQuarterlySchedule); + await this.enableSwitcher(settingsAdmin.withdraw.disburseMentMonthlySchedule); + await this.enableSwitcher(settingsAdmin.withdraw.disburseMentBiweeklySchedule); + await this.enableSwitcher(settingsAdmin.withdraw.disburseMentWeeklySchedule); // Quarterly Schedule - await this.selectByValue(selector.admin.dokan.settings.withdraw.quarterlyScheduleMonth, withdraw.quarterlyScheduleMonth); - await this.selectByValue(selector.admin.dokan.settings.withdraw.quarterlyScheduleWeek, withdraw.quarterlyScheduleWeek); - await this.selectByValue(selector.admin.dokan.settings.withdraw.quarterlyScheduleDay, withdraw.quarterlyScheduleDay); + await this.selectByValue(settingsAdmin.withdraw.quarterlyScheduleMonth, withdraw.quarterlyScheduleMonth); + await this.selectByValue(settingsAdmin.withdraw.quarterlyScheduleWeek, withdraw.quarterlyScheduleWeek); + await this.selectByValue(settingsAdmin.withdraw.quarterlyScheduleDay, withdraw.quarterlyScheduleDay); // Monthly Schedule - await this.selectByValue(selector.admin.dokan.settings.withdraw.monthlyScheduleWeek, withdraw.monthlyScheduleWeek); - await this.selectByValue(selector.admin.dokan.settings.withdraw.monthlyScheduleDay, withdraw.monthlyScheduleDay); + await this.selectByValue(settingsAdmin.withdraw.monthlyScheduleWeek, withdraw.monthlyScheduleWeek); + await this.selectByValue(settingsAdmin.withdraw.monthlyScheduleDay, withdraw.monthlyScheduleDay); // Biweekly Schedule - await this.selectByValue(selector.admin.dokan.settings.withdraw.biweeklyScheduleWeek, withdraw.biweeklyScheduleWeek); - await this.selectByValue(selector.admin.dokan.settings.withdraw.biweeklyScheduleDay, withdraw.biweeklyScheduleDay); + await this.selectByValue(settingsAdmin.withdraw.biweeklyScheduleWeek, withdraw.biweeklyScheduleWeek); + await this.selectByValue(settingsAdmin.withdraw.biweeklyScheduleDay, withdraw.biweeklyScheduleDay); // Weekly Schedule - await this.selectByValue(selector.admin.dokan.settings.withdraw.weeklyScheduleDay, withdraw.weeklyScheduleDay); + await this.selectByValue(settingsAdmin.withdraw.weeklyScheduleDay, withdraw.weeklyScheduleDay); } // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.withdraw.withdrawSaveChanges); - await this.toHaveValue(selector.admin.dokan.settings.withdraw.minimumWithdrawAmount, withdraw.minimumWithdrawAmount); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.withdraw.withdrawSaveChanges); + await this.toHaveValue(settingsAdmin.withdraw.minimumWithdrawAmount, withdraw.minimumWithdrawAmount); } // Admin Set Dokan Reverse Withdraw Settings async setDokanReverseWithdrawSettings(reverseWithdraw: dokanSettings['reverseWithdraw']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.reverseWithdrawal); + await this.click(settingsAdmin.menus.reverseWithdrawal); // reverse withdraw options - await this.enableSwitcher(selector.admin.dokan.settings.reverseWithdraw.enableReverseWithdrawal); - await this.enableSwitcher(selector.admin.dokan.settings.reverseWithdraw.enableReverseWithdrawalForThisGateway); + await this.enableSwitcher(settingsAdmin.reverseWithdraw.enableReverseWithdrawal); + await this.enableSwitcher(settingsAdmin.reverseWithdraw.enableReverseWithdrawalForThisGateway); - await this.selectByValue(selector.admin.dokan.settings.reverseWithdraw.billingType, reverseWithdraw.billingType); - await this.clearAndType(selector.admin.dokan.settings.reverseWithdraw.reverseBalanceThreshold, reverseWithdraw.reverseBalanceThreshold); - await this.clearAndType(selector.admin.dokan.settings.reverseWithdraw.gracePeriod, reverseWithdraw.gracePeriod); + await this.selectByValue(settingsAdmin.reverseWithdraw.billingType, reverseWithdraw.billingType); + await this.clearAndType(settingsAdmin.reverseWithdraw.reverseBalanceThreshold, reverseWithdraw.reverseBalanceThreshold); + await this.clearAndType(settingsAdmin.reverseWithdraw.gracePeriod, reverseWithdraw.gracePeriod); - await this.enableSwitcher(selector.admin.dokan.settings.reverseWithdraw.disableAddToCartButton); - await this.enableSwitcher(selector.admin.dokan.settings.reverseWithdraw.hideWithdrawMenu); - await this.enableSwitcher(selector.admin.dokan.settings.reverseWithdraw.MakeVendorStatusInactive); + await this.enableSwitcher(settingsAdmin.reverseWithdraw.disableAddToCartButton); + await this.enableSwitcher(settingsAdmin.reverseWithdraw.hideWithdrawMenu); + await this.enableSwitcher(settingsAdmin.reverseWithdraw.MakeVendorStatusInactive); - await this.enableSwitcher(selector.admin.dokan.settings.reverseWithdraw.displayNoticeDuringGracePeriod); - DOKAN_PRO && (await this.enableSwitcher(selector.admin.dokan.settings.reverseWithdraw.sendAnnouncement)); + await this.enableSwitcher(settingsAdmin.reverseWithdraw.displayNoticeDuringGracePeriod); + DOKAN_PRO && (await this.enableSwitcher(settingsAdmin.reverseWithdraw.sendAnnouncement)); // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.reverseWithdraw.reverseWithdrawSaveChanges); - await this.toHaveValue(selector.admin.dokan.settings.reverseWithdraw.reverseBalanceThreshold, reverseWithdraw.reverseBalanceThreshold); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.reverseWithdraw.reverseWithdrawSaveChanges); + await this.toHaveValue(settingsAdmin.reverseWithdraw.reverseBalanceThreshold, reverseWithdraw.reverseBalanceThreshold); } // Admin Set Dokan Page Settings async setPageSettings(page: dokanSettings['page']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.pageSettings); + await this.click(settingsAdmin.menus.pageSettings); - await this.selectByLabel(selector.admin.dokan.settings.page.dashboard, page.dashboard); - await this.selectByLabel(selector.admin.dokan.settings.page.myOrders, page.myOrders); - await this.selectByLabel(selector.admin.dokan.settings.page.storeListing, page.storeListing); - await this.selectByLabel(selector.admin.dokan.settings.page.termsAndConditions, page.termsAndConditions); + await this.selectByLabel(settingsAdmin.page.dashboard, page.dashboard); + await this.selectByLabel(settingsAdmin.page.myOrders, page.myOrders); + await this.selectByLabel(settingsAdmin.page.storeListing, page.storeListing); + await this.selectByLabel(settingsAdmin.page.termsAndConditions, page.termsAndConditions); // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.page.pageSaveChanges); - await this.toContainText(selector.admin.dokan.settings.dokanUpdateSuccessMessage, page.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.page.pageSaveChanges); + await this.toContainText(settingsAdmin.dokanUpdateSuccessMessage, page.saveSuccessMessage); } // Admin Set Dokan Appearance Settings async setDokanAppearanceSettings(appearance: dokanSettings['appearance']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.appearance); + await this.click(settingsAdmin.menus.appearance); // Appearance Settings - await this.enableSwitcher(selector.admin.dokan.settings.appearance.showMapOnStorePage); - await this.click(selector.admin.dokan.settings.appearance.mapApiSourceGoogleMaps); - await this.clearAndType(selector.admin.dokan.settings.appearance.googleMapApiKey, appearance.googleMapApiKey); - await this.enableSwitcher(selector.admin.dokan.settings.appearance.showContactFormOnStorePage); - await this.click(selector.admin.dokan.settings.appearance.storeHeaderTemplate2); - await this.click(selector.admin.dokan.settings.appearance.storeHeaderTemplate1); + await this.enableSwitcher(settingsAdmin.appearance.showMapOnStorePage); + await this.click(settingsAdmin.appearance.mapApiSourceGoogleMaps); + await this.clearAndType(settingsAdmin.appearance.googleMapApiKey, appearance.googleMapApiKey); + await this.enableSwitcher(settingsAdmin.appearance.showContactFormOnStorePage); + await this.click(settingsAdmin.appearance.storeHeaderTemplate2); + await this.click(settingsAdmin.appearance.storeHeaderTemplate1); if (DOKAN_PRO) { - await this.clearAndType(selector.admin.dokan.settings.appearance.storeBannerWidth, appearance.storeBannerWidth); - await this.clearAndType(selector.admin.dokan.settings.appearance.storeBannerHeight, appearance.storeBannerHeight); - await this.enableSwitcher(selector.admin.dokan.settings.appearance.storeOpeningClosingTimeWidget); + await this.clearAndType(settingsAdmin.appearance.storeBannerWidth, appearance.storeBannerWidth); + await this.clearAndType(settingsAdmin.appearance.storeBannerHeight, appearance.storeBannerHeight); + await this.enableSwitcher(settingsAdmin.appearance.storeOpeningClosingTimeWidget); } // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.appearance.appearanceSaveChanges); - await this.toHaveValue(selector.admin.dokan.settings.appearance.googleMapApiKey, appearance.googleMapApiKey); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.appearance.appearanceSaveChanges); + await this.toHaveValue(settingsAdmin.appearance.googleMapApiKey, appearance.googleMapApiKey); } // Admin Set Dokan Privacy Policy Settings async setDokanPrivacyPolicySettings(privacyPolicy: dokanSettings['privacyPolicy']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.privacyPolicy); + await this.click(settingsAdmin.menus.privacyPolicy); // Privacy Policy Settings - await this.enableSwitcher(selector.admin.dokan.settings.privacyPolicy.enablePrivacyPolicy); - await this.selectByValue(selector.admin.dokan.settings.privacyPolicy.privacyPage, privacyPolicy.privacyPage); - await this.typeFrameSelector(selector.admin.dokan.settings.privacyPolicy.privacyPolicyIframe, selector.admin.dokan.settings.privacyPolicy.privacyPolicyHtmlBody, privacyPolicy.privacyPolicyContent); + await this.enableSwitcher(settingsAdmin.privacyPolicy.enablePrivacyPolicy); + await this.selectByValue(settingsAdmin.privacyPolicy.privacyPage, privacyPolicy.privacyPage); + await this.typeFrameSelector(settingsAdmin.privacyPolicy.privacyPolicyIframe, settingsAdmin.privacyPolicy.privacyPolicyHtmlBody, privacyPolicy.privacyPolicyContent); // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.privacyPolicy.privacyPolicySaveChanges); - await this.toContainText(selector.admin.dokan.settings.dokanUpdateSuccessMessage, privacyPolicy.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.privacyPolicy.privacyPolicySaveChanges); + await this.toContainText(settingsAdmin.dokanUpdateSuccessMessage, privacyPolicy.saveSuccessMessage); } // Admin Set Dokan Color Settings async setDokanColorSettings(colors: dokanSettings['colors']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.colors); + await this.click(settingsAdmin.menus.colors); // Colors Settings if (colors.paletteChoice === 'pre-defined') { - await this.click(selector.admin.dokan.settings.colors.predefineColorPalette); - await this.click(selector.admin.dokan.settings.colors.colorPalette[colors.colorPalette as keyof typeof selector.admin.dokan.settings.colors.colorPalette]); + await this.click(settingsAdmin.colors.predefineColorPalette); + await this.click(settingsAdmin.colors.colorPalette[colors.colorPalette as keyof typeof settingsAdmin.colors.colorPalette]); } // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.colors.colorsSaveChanges); - await this.toContainText(selector.admin.dokan.settings.dokanUpdateSuccessMessage, colors.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.colors.colorsSaveChanges); + await this.toContainText(settingsAdmin.dokanUpdateSuccessMessage, colors.saveSuccessMessage); } // Admin Set Dokan Live Search Settings async setDokanLiveSearchSettings(liveSearch: dokanSettings['liveSearch']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.liveSearch); + await this.click(settingsAdmin.menus.liveSearch); // Live Search Settings - await this.selectByValue(selector.admin.dokan.settings.liveSearch.liveSearchOptions, liveSearch.liveSearchOption); + await this.selectByValue(settingsAdmin.liveSearch.liveSearchOptions, liveSearch.liveSearchOption); // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.liveSearch.liveSearchSaveChanges); - await this.toContainText(selector.admin.dokan.settings.dokanUpdateSuccessMessage, liveSearch.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.liveSearch.liveSearchSaveChanges); + await this.toContainText(settingsAdmin.dokanUpdateSuccessMessage, liveSearch.saveSuccessMessage); } // Admin Set Dokan Store Support Settings async setDokanStoreSupportSettings(storeSupport: dokanSettings['storeSupport']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.storeSupport); + await this.click(settingsAdmin.menus.storeSupport); // Store Support Settings - await this.enableSwitcher(selector.admin.dokan.settings.storeSupport.displayOnOrderDetails); - await this.selectByValue(selector.admin.dokan.settings.storeSupport.displayOnSingleProductPage, storeSupport.displayOnSingleProductPage); - await this.clearAndType(selector.admin.dokan.settings.storeSupport.supportButtonLabel, storeSupport.supportButtonLabel); + await this.enableSwitcher(settingsAdmin.storeSupport.displayOnOrderDetails); + await this.selectByValue(settingsAdmin.storeSupport.displayOnSingleProductPage, storeSupport.displayOnSingleProductPage); + await this.clearAndType(settingsAdmin.storeSupport.supportButtonLabel, storeSupport.supportButtonLabel); // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.storeSupport.storeSupportSaveChanges); - await this.toContainText(selector.admin.dokan.settings.dokanUpdateSuccessMessage, storeSupport.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.storeSupport.storeSupportSaveChanges); + await this.toContainText(settingsAdmin.dokanUpdateSuccessMessage, storeSupport.saveSuccessMessage); } // Admin Set Dokan Email Verification Settings async setDokanEmailVerificationSettings(emailVerification: dokanSettings['emailVerification']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.emailVerification); + await this.click(settingsAdmin.menus.emailVerification); // Email Verification Settings - await this.enableSwitcher(selector.admin.dokan.settings.emailVerification.enableEmailVerification); - await this.clearAndType(selector.admin.dokan.settings.emailVerification.registrationNotice, emailVerification.registrationNotice); - await this.clearAndType(selector.admin.dokan.settings.emailVerification.loginNotice, emailVerification.loginNotice); + await this.enableSwitcher(settingsAdmin.emailVerification.enableEmailVerification); + await this.clearAndType(settingsAdmin.emailVerification.registrationNotice, emailVerification.registrationNotice); + await this.clearAndType(settingsAdmin.emailVerification.loginNotice, emailVerification.loginNotice); // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.emailVerification.emailVerificationSaveChanges); - await this.toContainText(selector.admin.dokan.settings.dokanUpdateSuccessMessage, emailVerification.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.emailVerification.emailVerificationSaveChanges); + await this.toContainText(settingsAdmin.dokanUpdateSuccessMessage, emailVerification.saveSuccessMessage); } // Admin Set Dokan Shipping Status Settings async setDokanShippingStatusSettings(shippingStatus: dokanSettings['shippingStatus']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.shippingStatus); + await this.click(settingsAdmin.menus.shippingStatus); // Shipping Status Settings - await this.enableSwitcher(selector.admin.dokan.settings.shippingStatus.allowShipmentTracking); + await this.enableSwitcher(settingsAdmin.shippingStatus.allowShipmentTracking); // shipping status - await this.enableSwitcher(selector.admin.dokan.settings.shippingStatus.shippingProviders.australiaPost); - await this.enableSwitcher(selector.admin.dokan.settings.shippingStatus.shippingProviders.canadaPost); - await this.enableSwitcher(selector.admin.dokan.settings.shippingStatus.shippingProviders.cityLink); + await this.enableSwitcher(settingsAdmin.shippingStatus.shippingProviders.australiaPost); + await this.enableSwitcher(settingsAdmin.shippingStatus.shippingProviders.canadaPost); + await this.enableSwitcher(settingsAdmin.shippingStatus.shippingProviders.cityLink); - await this.clearAndType(selector.admin.dokan.settings.shippingStatus.customShippingStatusInput, shippingStatus.customShippingStatus); - await this.click(selector.admin.dokan.settings.shippingStatus.customShippingStatusAdd); + await this.clearAndType(settingsAdmin.shippingStatus.customShippingStatusInput, shippingStatus.customShippingStatus); + await this.click(settingsAdmin.shippingStatus.customShippingStatusAdd); // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.shippingStatus.shippingStatusSaveChanges); - await this.toContainText(selector.admin.dokan.settings.dokanUpdateSuccessMessage, shippingStatus.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.shippingStatus.shippingStatusSaveChanges); + await this.toContainText(settingsAdmin.dokanUpdateSuccessMessage, shippingStatus.saveSuccessMessage); } // Admin Set Dokan Quote Settings async setDokanQuoteSettings(quote: dokanSettings['quote']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.quote); + await this.click(settingsAdmin.menus.quote); // Live Search Settings - await this.enableSwitcher(selector.admin.dokan.settings.quote.enableQuoteForOutOfStockProducts); - await this.enableSwitcher(selector.admin.dokan.settings.quote.enableAjaxAddToQuote); - await this.enableSwitcher(selector.admin.dokan.settings.quote.redirectToQuotePage); + await this.enableSwitcher(settingsAdmin.quote.enableQuoteForOutOfStockProducts); + await this.enableSwitcher(settingsAdmin.quote.enableAjaxAddToQuote); + await this.enableSwitcher(settingsAdmin.quote.redirectToQuotePage); - await this.clearAndType(selector.admin.dokan.settings.quote.decreaseOfferedPrice, quote.decreaseOfferedPrice); - // await this.enableSwitcher(selector.admin.dokan.settings.quote.enableConvertToOrder); - // await this.enableSwitcher(selector.admin.dokan.settings.quote.enableQuoteConverterDisplay); + await this.clearAndType(settingsAdmin.quote.decreaseOfferedPrice, quote.decreaseOfferedPrice); + // await this.enableSwitcher(settingsAdmin.quote.enableConvertToOrder); + // await this.enableSwitcher(settingsAdmin.quote.enableQuoteConverterDisplay); // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.quote.quoteSaveChanges); - await this.toContainText(selector.admin.dokan.settings.dokanUpdateSuccessMessage, quote.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.quote.quoteSaveChanges); + await this.toContainText(settingsAdmin.dokanUpdateSuccessMessage, quote.saveSuccessMessage); } // Admin Set Dokan Rma Settings async setDokanRmaSettings(rma: dokanSettings['rma']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.rma); + await this.click(settingsAdmin.menus.rma); // Rma Settings - await this.selectByValue(selector.admin.dokan.settings.rma.orderStatus, rma.orderStatus); - await this.enableSwitcher(selector.admin.dokan.settings.rma.enableRefundRequests); - await this.enableSwitcher(selector.admin.dokan.settings.rma.enableCouponRequests); + await this.selectByValue(settingsAdmin.rma.orderStatus, rma.orderStatus); + await this.enableSwitcher(settingsAdmin.rma.enableRefundRequests); + await this.enableSwitcher(settingsAdmin.rma.enableCouponRequests); for (const rmaReason of rma.rmaReasons) { - await this.deleteIfExists(selector.admin.dokan.settings.rma.reasonsForRmaSingle(rmaReason)); - await this.clearAndType(selector.admin.dokan.settings.rma.reasonsForRmaInput, rmaReason); - await this.click(selector.admin.dokan.settings.rma.reasonsForRmaAdd); + await this.deleteIfExists(settingsAdmin.rma.reasonsForRmaSingle(rmaReason)); + await this.clearAndType(settingsAdmin.rma.reasonsForRmaInput, rmaReason); + await this.click(settingsAdmin.rma.reasonsForRmaAdd); } - await this.typeFrameSelector(selector.admin.dokan.settings.rma.refundPolicyIframe, selector.admin.dokan.settings.rma.refundPolicyHtmlBody, rma.refundPolicyHtmlBody); + await this.typeFrameSelector(settingsAdmin.rma.refundPolicyIframe, settingsAdmin.rma.refundPolicyHtmlBody, rma.refundPolicyHtmlBody); // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.rma.rmaSaveChanges); - await this.toContainText(selector.admin.dokan.settings.dokanUpdateSuccessMessage, rma.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.rma.rmaSaveChanges); + await this.toContainText(settingsAdmin.dokanUpdateSuccessMessage, rma.saveSuccessMessage); } // Admin Set Dokan Wholesale Settings async setDokanWholesaleSettings(wholesale: dokanSettings['wholesale']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.wholesale); + await this.click(settingsAdmin.menus.wholesale); // Wholesale Settings - await this.click(selector.admin.dokan.settings.wholesale.whoCanSeeWholesalePrice(wholesale.whoCanSeeWholesalePrice)); - await this.enableSwitcher(selector.admin.dokan.settings.wholesale.showWholesalePriceOnShopArchive); - await this.disableSwitcher(selector.admin.dokan.settings.wholesale.needApprovalForCustomer); + await this.click(settingsAdmin.wholesale.whoCanSeeWholesalePrice(wholesale.whoCanSeeWholesalePrice)); + await this.enableSwitcher(settingsAdmin.wholesale.showWholesalePriceOnShopArchive); + await this.disableSwitcher(settingsAdmin.wholesale.needApprovalForCustomer); // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.wholesale.wholesaleSaveChanges); - await this.toContainText(selector.admin.dokan.settings.dokanUpdateSuccessMessage, wholesale.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.wholesale.wholesaleSaveChanges); + await this.toContainText(settingsAdmin.dokanUpdateSuccessMessage, wholesale.saveSuccessMessage); } // Admin Set Dokan Eu Compliance Settings async setDokanEuComplianceSettings(euCompliance: dokanSettings['euCompliance']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.euComplianceFields); + await this.click(settingsAdmin.menus.euComplianceFields); // Eu Compliance Settings - await this.enableSwitcher(selector.admin.dokan.settings.euCompliance.vendorExtraFieldsCompanyName); - await this.enableSwitcher(selector.admin.dokan.settings.euCompliance.vendorExtraFieldsCompanyIdOrEuidNumber); - await this.enableSwitcher(selector.admin.dokan.settings.euCompliance.vendorExtraFieldsVatOrTaxNumber); - await this.enableSwitcher(selector.admin.dokan.settings.euCompliance.vendorExtraFieldsNameOfBank); - await this.enableSwitcher(selector.admin.dokan.settings.euCompliance.vendorExtraFieldsBankIban); - await this.enableSwitcher(selector.admin.dokan.settings.euCompliance.displayInVendorRegistrationForm); - await this.enableSwitcher(selector.admin.dokan.settings.euCompliance.customerExtraFieldsCompanyIdOrEuidNumber); - await this.enableSwitcher(selector.admin.dokan.settings.euCompliance.customerExtraFieldsVatOrTaxNumber); - await this.enableSwitcher(selector.admin.dokan.settings.euCompliance.customerExtraFieldsNameOfBank); - await this.enableSwitcher(selector.admin.dokan.settings.euCompliance.customerExtraFieldsBankIban); - await this.enableSwitcher(selector.admin.dokan.settings.euCompliance.enableGermanizedSupportForVendors); - await this.enableSwitcher(selector.admin.dokan.settings.euCompliance.vendorsWillBeAbleToOverrideInvoiceNumber); + await this.enableSwitcher(settingsAdmin.euCompliance.vendorExtraFieldsCompanyName); + await this.enableSwitcher(settingsAdmin.euCompliance.vendorExtraFieldsCompanyIdOrEuidNumber); + await this.enableSwitcher(settingsAdmin.euCompliance.vendorExtraFieldsVatOrTaxNumber); + await this.enableSwitcher(settingsAdmin.euCompliance.vendorExtraFieldsNameOfBank); + await this.enableSwitcher(settingsAdmin.euCompliance.vendorExtraFieldsBankIban); + await this.enableSwitcher(settingsAdmin.euCompliance.displayInVendorRegistrationForm); + await this.enableSwitcher(settingsAdmin.euCompliance.customerExtraFieldsCompanyIdOrEuidNumber); + await this.enableSwitcher(settingsAdmin.euCompliance.customerExtraFieldsVatOrTaxNumber); + await this.enableSwitcher(settingsAdmin.euCompliance.customerExtraFieldsNameOfBank); + await this.enableSwitcher(settingsAdmin.euCompliance.customerExtraFieldsBankIban); + await this.enableSwitcher(settingsAdmin.euCompliance.enableGermanizedSupportForVendors); + await this.enableSwitcher(settingsAdmin.euCompliance.vendorsWillBeAbleToOverrideInvoiceNumber); // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.euCompliance.euComplianceFieldsSaveChanges); - await this.toContainText(selector.admin.dokan.settings.dokanUpdateSuccessMessage, euCompliance.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.euCompliance.euComplianceFieldsSaveChanges); + await this.toContainText(settingsAdmin.dokanUpdateSuccessMessage, euCompliance.saveSuccessMessage); } // Admin Set Dokan Delivery Time Settings async setDokanDeliveryTimeSettings(deliveryTime: dokanSettings['deliveryTime']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.deliveryTime); + await this.click(settingsAdmin.menus.deliveryTime); // Delivery Time Settings - await this.enableSwitcher(selector.admin.dokan.settings.deliveryTime.allowVendorSettings); - await this.enableSwitcher(selector.admin.dokan.settings.deliveryTime.homeDelivery); - await this.enableSwitcher(selector.admin.dokan.settings.deliveryTime.storePickup); - await this.clearAndType(selector.admin.dokan.settings.deliveryTime.deliveryDateLabel, deliveryTime.deliveryDateLabel); - await this.clearAndType(selector.admin.dokan.settings.deliveryTime.deliveryBlockedBuffer, deliveryTime.deliveryBlockedBuffer); - await this.clearAndType(selector.admin.dokan.settings.deliveryTime.timeSlot, deliveryTime.timeSlot); - await this.clearAndType(selector.admin.dokan.settings.deliveryTime.orderPerSlot, deliveryTime.orderPerSlot); - await this.clearAndType(selector.admin.dokan.settings.deliveryTime.deliveryBoxInfo, deliveryTime.deliveryBoxInfo); - await this.disableSwitcher(selector.admin.dokan.settings.deliveryTime.requireDeliveryDateAndTime); + await this.enableSwitcher(settingsAdmin.deliveryTime.allowVendorSettings); + await this.enableSwitcher(settingsAdmin.deliveryTime.homeDelivery); + await this.enableSwitcher(settingsAdmin.deliveryTime.storePickup); + await this.clearAndType(settingsAdmin.deliveryTime.deliveryDateLabel, deliveryTime.deliveryDateLabel); + await this.clearAndType(settingsAdmin.deliveryTime.deliveryBlockedBuffer, deliveryTime.deliveryBlockedBuffer); + await this.clearAndType(settingsAdmin.deliveryTime.timeSlot, deliveryTime.timeSlot); + await this.clearAndType(settingsAdmin.deliveryTime.orderPerSlot, deliveryTime.orderPerSlot); + await this.clearAndType(settingsAdmin.deliveryTime.deliveryBoxInfo, deliveryTime.deliveryBoxInfo); + await this.disableSwitcher(settingsAdmin.deliveryTime.requireDeliveryDateAndTime); for (const day of deliveryTime.days) { - await this.enableSwitcher(selector.admin.dokan.settings.deliveryTime.deliveryDay(day)); + await this.enableSwitcher(settingsAdmin.deliveryTime.deliveryDay(day)); if (deliveryTime.choice === 'full-day') { - await this.click(selector.admin.dokan.settings.deliveryTime.openingTime(day)); + await this.click(settingsAdmin.deliveryTime.openingTime(day)); await this.page.getByRole('listitem').filter({ hasText: 'Full day' }).click(); } else { await this.page.getByRole('listitem').filter({ hasText: deliveryTime.openingTime }).click(); - await this.click(selector.admin.dokan.settings.deliveryTime.closingTime(day)); + await this.click(settingsAdmin.deliveryTime.closingTime(day)); await this.page.getByRole('listitem').filter({ hasText: deliveryTime.closingTime }).click(); } } // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.deliveryTime.deliveryTimeSaveChanges); - await this.toContainText(selector.admin.dokan.settings.dokanUpdateSuccessMessage, deliveryTime.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.deliveryTime.deliveryTimeSaveChanges); + await this.toContainText(settingsAdmin.dokanUpdateSuccessMessage, deliveryTime.saveSuccessMessage); } // Admin Set Dokan Product Advertising Settings async setDokanProductAdvertisingSettings(productAdvertising: dokanSettings['productAdvertising']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.productAdvertising); + await this.click(settingsAdmin.menus.productAdvertising); // Product Advertising Settings - await this.clearAndType(selector.admin.dokan.settings.productAdvertising.noOfAvailableSlot, productAdvertising.noOfAvailableSlot); - await this.clearAndType(selector.admin.dokan.settings.productAdvertising.expireAfterDays, productAdvertising.expireAfterDays); - await this.enableSwitcher(selector.admin.dokan.settings.productAdvertising.vendorCanPurchaseAdvertisement); - await this.clearAndType(selector.admin.dokan.settings.productAdvertising.advertisementCost, productAdvertising.advertisementCost); - await this.enableSwitcher(selector.admin.dokan.settings.productAdvertising.enableAdvertisementInSubscription); - await this.enableSwitcher(selector.admin.dokan.settings.productAdvertising.markAdvertisedProductAsFeatured); - await this.enableSwitcher(selector.admin.dokan.settings.productAdvertising.displayAdvertisedProductOnTop); - await this.enableSwitcher(selector.admin.dokan.settings.productAdvertising.outOfStockVisibility); + await this.clearAndType(settingsAdmin.productAdvertising.noOfAvailableSlot, productAdvertising.noOfAvailableSlot); + await this.clearAndType(settingsAdmin.productAdvertising.expireAfterDays, productAdvertising.expireAfterDays); + await this.enableSwitcher(settingsAdmin.productAdvertising.vendorCanPurchaseAdvertisement); + await this.clearAndType(settingsAdmin.productAdvertising.advertisementCost, productAdvertising.advertisementCost); + await this.enableSwitcher(settingsAdmin.productAdvertising.enableAdvertisementInSubscription); + await this.enableSwitcher(settingsAdmin.productAdvertising.markAdvertisedProductAsFeatured); + await this.enableSwitcher(settingsAdmin.productAdvertising.displayAdvertisedProductOnTop); + await this.enableSwitcher(settingsAdmin.productAdvertising.outOfStockVisibility); // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.productAdvertising.productAdvertisingSaveChanges); - await this.toContainText(selector.admin.dokan.settings.dokanUpdateSuccessMessage, productAdvertising.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.productAdvertising.productAdvertisingSaveChanges); + await this.toContainText(settingsAdmin.dokanUpdateSuccessMessage, productAdvertising.saveSuccessMessage); } // Admin Set Dokan Geolocation Settings async setDokanGeolocationSettings(geolocation: dokanSettings['geolocation']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.geolocation); + await this.click(settingsAdmin.menus.geolocation); // Geolocation Settings - await this.click(selector.admin.dokan.settings.geolocation.locationMapPosition(geolocation.locationMapPosition)); - await this.click(selector.admin.dokan.settings.geolocation.showMap(geolocation.showMap)); - await this.enableSwitcher(selector.admin.dokan.settings.geolocation.showFiltersBeforeLocationMap); - await this.enableSwitcher(selector.admin.dokan.settings.geolocation.productLocationTab); - await this.click(selector.admin.dokan.settings.geolocation.radiusSearchUnit(geolocation.radiusSearchUnit)); - await this.clearAndType(selector.admin.dokan.settings.geolocation.radiusSearchMinimumDistance, geolocation.radiusSearchMinimumDistance); - await this.clearAndType(selector.admin.dokan.settings.geolocation.radiusSearchMaximumDistance, geolocation.radiusSearchMaximumDistance); - await this.clearAndType(selector.admin.dokan.settings.geolocation.mapZoomLevel, geolocation.mapZoomLevel); - await this.focus(selector.admin.dokan.settings.geolocation.defaultLocation); - await this.typeAndWaitForResponse(data.subUrls.gmap, selector.admin.dokan.settings.geolocation.defaultLocation, geolocation.defaultLocation); + await this.click(settingsAdmin.geolocation.locationMapPosition(geolocation.locationMapPosition)); + await this.click(settingsAdmin.geolocation.showMap(geolocation.showMap)); + await this.enableSwitcher(settingsAdmin.geolocation.showFiltersBeforeLocationMap); + await this.enableSwitcher(settingsAdmin.geolocation.productLocationTab); + await this.click(settingsAdmin.geolocation.radiusSearchUnit(geolocation.radiusSearchUnit)); + await this.clearAndType(settingsAdmin.geolocation.radiusSearchMinimumDistance, geolocation.radiusSearchMinimumDistance); + await this.clearAndType(settingsAdmin.geolocation.radiusSearchMaximumDistance, geolocation.radiusSearchMaximumDistance); + await this.clearAndType(settingsAdmin.geolocation.mapZoomLevel, geolocation.mapZoomLevel); + await this.focus(settingsAdmin.geolocation.defaultLocation); + await this.typeAndWaitForResponse(data.subUrls.gmap, settingsAdmin.geolocation.defaultLocation, geolocation.defaultLocation); // await this.press(data.key.arrowDown); // await this.press(data.key.enter); - await this.click(selector.admin.dokan.settings.geolocation.mapResultFirst); + await this.click(settingsAdmin.geolocation.mapResultFirst); // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.geolocation.geolocationSaveChanges); - await this.toContainText(selector.admin.dokan.settings.dokanUpdateSuccessMessage, geolocation.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.geolocation.geolocationSaveChanges); + await this.toContainText(settingsAdmin.dokanUpdateSuccessMessage, geolocation.saveSuccessMessage); } // Admin Set Dokan Product Report Abuse Settings async setDokanProductReportAbuseSettings(productReportAbuse: dokanSettings['productReportAbuse']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.productReportAbuse); + await this.click(settingsAdmin.menus.productReportAbuse); // Product Report Abuse Settings - await this.deleteIfExists(selector.admin.dokan.settings.productReportAbuse.reasonsForAbuseReportSingle(productReportAbuse.reasonsForAbuseReport)); - await this.clearAndType(selector.admin.dokan.settings.productReportAbuse.reasonsForAbuseReportInput, productReportAbuse.reasonsForAbuseReport); - await this.click(selector.admin.dokan.settings.productReportAbuse.reasonsForAbuseReportAdd); + await this.deleteIfExists(settingsAdmin.productReportAbuse.reasonsForAbuseReportSingle(productReportAbuse.reasonsForAbuseReport)); + await this.clearAndType(settingsAdmin.productReportAbuse.reasonsForAbuseReportInput, productReportAbuse.reasonsForAbuseReport); + await this.click(settingsAdmin.productReportAbuse.reasonsForAbuseReportAdd); // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.productReportAbuse.productReportAbuseSaveChanges); - await this.toContainText(selector.admin.dokan.settings.dokanUpdateSuccessMessage, productReportAbuse.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.productReportAbuse.productReportAbuseSaveChanges); + await this.toContainText(settingsAdmin.dokanUpdateSuccessMessage, productReportAbuse.saveSuccessMessage); } // Admin Set Dokan Spmv Settings async setDokanSpmvSettings(spmv: dokanSettings['spmv']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.singleProductMultiVendor); + await this.click(settingsAdmin.menus.singleProductMultiVendor); - await this.enableSwitcher(selector.admin.dokan.settings.spmv.enableSingleProductMultipleVendor); - await this.clearAndType(selector.admin.dokan.settings.spmv.sellItemButtonText, spmv.sellItemButtonText); - await this.clearAndType(selector.admin.dokan.settings.spmv.availableVendorDisplayAreaTitle, spmv.availableVendorDisplayAreaTitle); - await this.selectByValue(selector.admin.dokan.settings.spmv.availableVendorSectionDisplayPosition, spmv.availableVendorSectionDisplayPosition); - await this.selectByValue(selector.admin.dokan.settings.spmv.showSpmvProducts, spmv.showSpmvProducts); + await this.enableSwitcher(settingsAdmin.spmv.enableSingleProductMultipleVendor); + await this.clearAndType(settingsAdmin.spmv.sellItemButtonText, spmv.sellItemButtonText); + await this.clearAndType(settingsAdmin.spmv.availableVendorDisplayAreaTitle, spmv.availableVendorDisplayAreaTitle); + await this.selectByValue(settingsAdmin.spmv.availableVendorSectionDisplayPosition, spmv.availableVendorSectionDisplayPosition); + await this.selectByValue(settingsAdmin.spmv.showSpmvProducts, spmv.showSpmvProducts); // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.spmv.singleProductMultiVendorSaveChanges); - await this.toContainText(selector.admin.dokan.settings.dokanUpdateSuccessMessage, spmv.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.spmv.singleProductMultiVendorSaveChanges); + await this.toContainText(settingsAdmin.dokanUpdateSuccessMessage, spmv.saveSuccessMessage); } // Admin Set Dokan Vendor Subscription Settings async setDokanVendorSubscriptionSettings(subscription: dokanSettings['vendorSubscription']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.vendorSubscription); + await this.click(settingsAdmin.menus.vendorSubscription); // Vendor Subscription Settings - await this.selectByLabel(selector.admin.dokan.settings.vendorSubscriptions.subscription, subscription.displayPage); - await this.enableSwitcher(selector.admin.dokan.settings.vendorSubscriptions.enableProductSubscription); - await this.enableSwitcher(selector.admin.dokan.settings.vendorSubscriptions.enableSubscriptionInRegistrationForm); - await this.enableSwitcher(selector.admin.dokan.settings.vendorSubscriptions.enableEmailNotification); - await this.clearAndType(selector.admin.dokan.settings.vendorSubscriptions.noOfDays, subscription.noOfDays); - await this.selectByValue(selector.admin.dokan.settings.vendorSubscriptions.productStatus, subscription.productStatus); - await this.clearAndType(selector.admin.dokan.settings.vendorSubscriptions.cancellingEmailSubject, subscription.cancellingEmailSubject); - await this.clearAndType(selector.admin.dokan.settings.vendorSubscriptions.cancellingEmailBody, subscription.cancellingEmailBody); - await this.clearAndType(selector.admin.dokan.settings.vendorSubscriptions.alertEmailSubject, subscription.alertEmailSubject); - await this.clearAndType(selector.admin.dokan.settings.vendorSubscriptions.alertEmailBody, subscription.alertEmailBody); + await this.selectByLabel(settingsAdmin.vendorSubscriptions.subscription, subscription.displayPage); + await this.enableSwitcher(settingsAdmin.vendorSubscriptions.enableProductSubscription); + await this.enableSwitcher(settingsAdmin.vendorSubscriptions.enableSubscriptionInRegistrationForm); + await this.enableSwitcher(settingsAdmin.vendorSubscriptions.enableEmailNotification); + await this.clearAndType(settingsAdmin.vendorSubscriptions.noOfDays, subscription.noOfDays); + await this.selectByValue(settingsAdmin.vendorSubscriptions.productStatus, subscription.productStatus); + await this.clearAndType(settingsAdmin.vendorSubscriptions.cancellingEmailSubject, subscription.cancellingEmailSubject); + await this.clearAndType(settingsAdmin.vendorSubscriptions.cancellingEmailBody, subscription.cancellingEmailBody); + await this.clearAndType(settingsAdmin.vendorSubscriptions.alertEmailSubject, subscription.alertEmailSubject); + await this.clearAndType(settingsAdmin.vendorSubscriptions.alertEmailBody, subscription.alertEmailBody); // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.vendorSubscriptions.vendorSubscriptionSaveChanges); - await this.toContainText(selector.admin.dokan.settings.dokanUpdateSuccessMessage, subscription.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.vendorSubscriptions.vendorSubscriptionSaveChanges); + await this.toContainText(settingsAdmin.dokanUpdateSuccessMessage, subscription.saveSuccessMessage); } // disable dokan vendor subscription async disableDokanVendorSubscription(subscription: dokanSettings['vendorSubscription']) { await this.goToDokanSettings(); - await this.click(selector.admin.dokan.settings.menus.vendorSubscription); + await this.click(settingsAdmin.menus.vendorSubscription); // Disabling Vendor Subscription - await this.disableSwitcher(selector.admin.dokan.settings.vendorSubscriptions.enableProductSubscription); + await this.disableSwitcher(settingsAdmin.vendorSubscriptions.enableProductSubscription); // save settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.settings.vendorSubscriptions.vendorSubscriptionSaveChanges); - await this.toContainText(selector.admin.dokan.settings.dokanUpdateSuccessMessage, subscription.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.vendorSubscriptions.vendorSubscriptionSaveChanges); + await this.toContainText(settingsAdmin.dokanUpdateSuccessMessage, subscription.saveSuccessMessage); } } diff --git a/tests/pw/pages/shippingPage.ts b/tests/pw/pages/shippingPage.ts index d0817620d2..610c590b17 100644 --- a/tests/pw/pages/shippingPage.ts +++ b/tests/pw/pages/shippingPage.ts @@ -5,7 +5,10 @@ import { data } from '@utils/testData'; import { helpers } from '@utils/helpers'; // import { shipping } from '@utils/interfaces'; -export class shippingPage extends AdminPage { +// selectors +const woocommerceSettings = selector.admin.wooCommerce.settings; + +export class ShippingPage extends AdminPage { constructor(page: Page) { super(page); } @@ -27,116 +30,116 @@ export class shippingPage extends AdminPage { // Enable-Disable Shipping async enableShipping(enable = true) { await this.goToWooCommerceSettings(); - await this.click(selector.admin.wooCommerce.settings.enableShipping); + await this.click(woocommerceSettings.enableShipping); enable - ? await this.setDropdownOptionSpan(selector.admin.wooCommerce.settings.enableShippingValues, data.shipping.enableShipping) - : await this.setDropdownOptionSpan(selector.admin.wooCommerce.settings.enableShippingValues, data.shipping.disableShipping); - await this.click(selector.admin.wooCommerce.settings.generalSaveChanges); - await this.toContainText(selector.admin.wooCommerce.settings.updatedSuccessMessage, data.shipping.saveSuccessMessage); + ? await this.setDropdownOptionSpan(woocommerceSettings.enableShippingValues, data.shipping.enableShipping) + : await this.setDropdownOptionSpan(woocommerceSettings.enableShippingValues, data.shipping.disableShipping); + await this.click(woocommerceSettings.generalSaveChanges); + await this.toContainText(woocommerceSettings.updatedSuccessMessage, data.shipping.saveSuccessMessage); } // Admin Add Shipping Method async addShippingMethod(shipping: any) { await this.goToWooCommerceSettings(); - await this.click(selector.admin.wooCommerce.settings.shipping); + await this.click(woocommerceSettings.shipping); - const zoneIsVisible = await this.isVisible(selector.admin.wooCommerce.settings.shippingZoneCell(shipping.shippingZone)); + const zoneIsVisible = await this.isVisible(woocommerceSettings.shippingZoneCell(shipping.shippingZone)); if (!zoneIsVisible) { // Add Shipping Zone - await this.click(selector.admin.wooCommerce.settings.addShippingZone); - await this.clearAndType(selector.admin.wooCommerce.settings.zoneName, shipping.shippingZone); - // await this.selectByValue(selector.admin.wooCommerce.settings.zoneRegions, shippingCountry) //use select values 'country:US', - await this.click(selector.admin.wooCommerce.settings.zoneRegions); - await this.type(selector.admin.wooCommerce.settings.zoneRegions, shipping.shippingCountry); + await this.click(woocommerceSettings.addShippingZone); + await this.clearAndType(woocommerceSettings.zoneName, shipping.shippingZone); + // await this.selectByValue(woocommerceSettings.zoneRegions, shippingCountry) //use select values 'country:US', + await this.click(woocommerceSettings.zoneRegions); + await this.type(woocommerceSettings.zoneRegions, shipping.shippingCountry); await this.press(data.key.enter); } else { // Edit Shipping Zone - await this.hover(selector.admin.wooCommerce.settings.shippingZoneCell(shipping.shippingZone)); - await this.click(selector.admin.wooCommerce.settings.editShippingMethod(shipping.shippingZone)); + await this.hover(woocommerceSettings.shippingZoneCell(shipping.shippingZone)); + await this.click(woocommerceSettings.editShippingMethod(shipping.shippingZone)); } - const methodIsVisible = await this.isVisible(selector.admin.wooCommerce.settings.shippingMethodCell(helpers.replaceAndCapitalize(shipping.shippingMethod))); + const methodIsVisible = await this.isVisible(woocommerceSettings.shippingMethodCell(helpers.replaceAndCapitalize(shipping.shippingMethod))); if (!methodIsVisible) { // Add Shipping Method - await this.click(selector.admin.wooCommerce.settings.addShippingMethods); - await this.selectByValue(selector.admin.wooCommerce.settings.shippingMethod, shipping.selectShippingMethod); - await this.click(selector.admin.wooCommerce.settings.addShippingMethod); + await this.click(woocommerceSettings.addShippingMethods); + await this.selectByValue(woocommerceSettings.shippingMethod, shipping.selectShippingMethod); + await this.click(woocommerceSettings.addShippingMethod); } // Edit Shipping Method Options - await this.hover(selector.admin.wooCommerce.settings.shippingMethodCell(shipping.shippingMethod)); - await this.click(selector.admin.wooCommerce.settings.editShippingMethod(shipping.shippingMethod)); + await this.hover(woocommerceSettings.shippingMethodCell(shipping.shippingMethod)); + await this.click(woocommerceSettings.editShippingMethod(shipping.shippingMethod)); switch (shipping.selectShippingMethod) { // Flat Rate case 'flat_rate': - await this.clearAndType(selector.admin.wooCommerce.settings.flatRateMethodTitle, shipping.shippingMethod); - await this.selectByValue(selector.admin.wooCommerce.settings.flatRateTaxStatus, shipping.taxStatus); - await this.clearAndType(selector.admin.wooCommerce.settings.flatRateCost, shipping.shippingCost); + await this.clearAndType(woocommerceSettings.flatRateMethodTitle, shipping.shippingMethod); + await this.selectByValue(woocommerceSettings.flatRateTaxStatus, shipping.taxStatus); + await this.clearAndType(woocommerceSettings.flatRateCost, shipping.shippingCost); break; // Free Shipping case 'free_shipping': - await this.clearAndType(selector.admin.wooCommerce.settings.freeShippingTitle, shipping.shippingMethod); - // await this.selectByValue(selector.admin.wooCommerce.settings.freeShippingRequires, shipping.freeShippingRequires) - // await this.clearAndType(selector.admin.wooCommerce.settings.freeShippingMinimumOrderAmount,shipping.freeShippingMinimumOrderAmount) - // await this.check(selector.admin.wooCommerce.settings.freeShippingCouponsDiscounts) + await this.clearAndType(woocommerceSettings.freeShippingTitle, shipping.shippingMethod); + // await this.selectByValue(woocommerceSettings.freeShippingRequires, shipping.freeShippingRequires) + // await this.clearAndType(woocommerceSettings.freeShippingMinimumOrderAmount,shipping.freeShippingMinimumOrderAmount) + // await this.check(woocommerceSettings.freeShippingCouponsDiscounts) break; // Local Pickup case 'local_pickup': - await this.clearAndType(selector.admin.wooCommerce.settings.localPickupTitle, shipping.shippingMethod); - await this.selectByValue(selector.admin.wooCommerce.settings.localPickupTaxStatus, shipping.taxStatus); - await this.clearAndType(selector.admin.wooCommerce.settings.localPickupCost, shipping.shippingCost); + await this.clearAndType(woocommerceSettings.localPickupTitle, shipping.shippingMethod); + await this.selectByValue(woocommerceSettings.localPickupTaxStatus, shipping.taxStatus); + await this.clearAndType(woocommerceSettings.localPickupCost, shipping.shippingCost); break; // Dokan Table Rate Shipping case 'dokan_table_rate_shipping': - await this.clearAndType(selector.admin.wooCommerce.settings.dokanTableRateShippingMethodTitle, shipping.shippingMethod); + await this.clearAndType(woocommerceSettings.dokanTableRateShippingMethodTitle, shipping.shippingMethod); break; // Dokan Distance Rate Shipping case 'dokan_distance_rate_shipping': - await this.clearAndType(selector.admin.wooCommerce.settings.dokanDistanceRateShippingMethodTitle, shipping.shippingMethod); + await this.clearAndType(woocommerceSettings.dokanDistanceRateShippingMethodTitle, shipping.shippingMethod); break; // Vendor Shipping case 'dokan_vendor_shipping': - await this.clearAndType(selector.admin.wooCommerce.settings.vendorShippingMethodTitle, shipping.shippingMethod); - await this.selectByValue(selector.admin.wooCommerce.settings.vendorShippingTaxStatus, shipping.taxStatus); + await this.clearAndType(woocommerceSettings.vendorShippingMethodTitle, shipping.shippingMethod); + await this.selectByValue(woocommerceSettings.vendorShippingTaxStatus, shipping.taxStatus); break; default: break; } - await this.click(selector.admin.wooCommerce.settings.shippingMethodSaveChanges); - await this.toBeVisible(selector.admin.wooCommerce.settings.shippingMethodCell(shipping.shippingMethod)); + await this.click(woocommerceSettings.shippingMethodSaveChanges); + await this.toBeVisible(woocommerceSettings.shippingMethodCell(shipping.shippingMethod)); } // Admin Delete Shipping Zone async deleteShippingZone(shippingZone: string) { - await this.click(selector.admin.wooCommerce.settings.shipping); + await this.click(woocommerceSettings.shipping); - await this.hover(selector.admin.wooCommerce.settings.shippingZoneCell(shippingZone)); - await this.clickAndAccept(selector.admin.wooCommerce.settings.deleteShippingZone(shippingZone)); + await this.hover(woocommerceSettings.shippingZoneCell(shippingZone)); + await this.clickAndAccept(woocommerceSettings.deleteShippingZone(shippingZone)); - const shippingZoneIsVisible = await this.isVisible(selector.admin.wooCommerce.settings.shippingZoneCell(shippingZone)); + const shippingZoneIsVisible = await this.isVisible(woocommerceSettings.shippingZoneCell(shippingZone)); expect(shippingZoneIsVisible).toBe(false); } // Admin Delete Shipping Method async deleteShippingMethod(shipping: any) { - await this.click(selector.admin.wooCommerce.settings.shipping); + await this.click(woocommerceSettings.shipping); - await this.hover(selector.admin.wooCommerce.settings.shippingZoneCell(shipping.shippingZone)); - await this.click(selector.admin.wooCommerce.settings.editShippingZone(shipping.shippingZone)); - await this.hover(selector.admin.wooCommerce.settings.shippingMethodCell(shipping.shippingMethod)); - await this.click(selector.admin.wooCommerce.settings.deleteShippingMethod(shipping.shippingMethod)); - await this.click(selector.admin.wooCommerce.settings.shippingZoneSaveChanges); + await this.hover(woocommerceSettings.shippingZoneCell(shipping.shippingZone)); + await this.click(woocommerceSettings.editShippingZone(shipping.shippingZone)); + await this.hover(woocommerceSettings.shippingMethodCell(shipping.shippingMethod)); + await this.click(woocommerceSettings.deleteShippingMethod(shipping.shippingMethod)); + await this.click(woocommerceSettings.shippingZoneSaveChanges); - const shippingMethodIsVisible = await this.isVisible(selector.admin.wooCommerce.settings.shippingMethodCell(shipping.shippingMethod)); + const shippingMethodIsVisible = await this.isVisible(woocommerceSettings.shippingMethodCell(shipping.shippingMethod)); expect(shippingMethodIsVisible).toBe(false); } } diff --git a/tests/pw/pages/shopPage.ts b/tests/pw/pages/shopPage.ts index d1865db586..128d402c6a 100644 --- a/tests/pw/pages/shopPage.ts +++ b/tests/pw/pages/shopPage.ts @@ -5,6 +5,9 @@ import { data } from '@utils/testData'; const { DOKAN_PRO } = process.env; +// selectors +const shopCustomer = selector.customer.cShop; + export class ShopPage extends CustomerPage { constructor(page: Page) { super(page); @@ -17,42 +20,42 @@ export class ShopPage extends CustomerPage { await this.goIfNotThere(data.subUrls.frontend.shop); // shop text is visible - await this.toBeVisible(selector.customer.cShop.shopText); + await this.toBeVisible(shopCustomer.shopText); if (DOKAN_PRO) { // map elements are visible - const { productOnMap, ...map } = selector.customer.cShop.map; + const { productOnMap, ...map } = shopCustomer.map; await this.multipleElementVisible(map); // product filter elements are visible - await this.multipleElementVisible(selector.customer.cShop.filters); + await this.multipleElementVisible(shopCustomer.filters); } // product card elements are visible - await this.notToHaveCount(selector.customer.cShop.productCard.card, 0); - await this.notToHaveCount(selector.customer.cShop.productCard.productDetailsLink, 0); - await this.notToHaveCount(selector.customer.cShop.productCard.productTitle, 0); - await this.notToHaveCount(selector.customer.cShop.productCard.productPrice, 0); - await this.notToHaveCount(selector.customer.cShop.productCard.addToCart, 0); + await this.notToHaveCount(shopCustomer.productCard.card, 0); + await this.notToHaveCount(shopCustomer.productCard.productDetailsLink, 0); + await this.notToHaveCount(shopCustomer.productCard.productTitle, 0); + await this.notToHaveCount(shopCustomer.productCard.productPrice, 0); + await this.notToHaveCount(shopCustomer.productCard.addToCart, 0); } // sort products async sortProducts(sortBy: string) { await this.goIfNotThere(data.subUrls.frontend.shop); - await this.selectByValueAndWaitForResponse(data.subUrls.frontend.shop, selector.customer.cShop.sort, sortBy); + await this.selectByValueAndWaitForResponse(data.subUrls.frontend.shop, shopCustomer.sort, sortBy); } // search product async searchProduct(productName: string): Promise { await this.goIfNotThere(data.subUrls.frontend.shop); if (!DOKAN_PRO) { - await this.clearAndType(selector.customer.cShop.searchProductLite, productName); + await this.clearAndType(shopCustomer.searchProductLite, productName); await this.pressAndWaitForLoadState(data.key.enter); await this.toContainText(selector.customer.cSingleProduct.productDetails.productTitle, productName); } else { - await this.clearAndType(selector.customer.cShop.filters.searchProduct, productName); - await this.clickAndWaitForLoadState(selector.customer.cShop.filters.search); - await this.toContainText(selector.customer.cShop.productCard.productTitle, productName); + await this.clearAndType(shopCustomer.filters.searchProduct, productName); + await this.clickAndWaitForLoadState(shopCustomer.filters.search); + await this.toContainText(shopCustomer.productCard.productTitle, productName); } } @@ -62,45 +65,42 @@ export class ShopPage extends CustomerPage { switch (filterBy) { case 'by-location': - await this.typeAndWaitForResponse(data.subUrls.gmap, selector.customer.cShop.filters.location, value); + await this.typeAndWaitForResponse(data.subUrls.gmap, shopCustomer.filters.location, value); await this.press(data.key.arrowDown); await this.pressAndWaitForResponse(data.subUrls.gmap, data.key.enter); break; case 'by-category': - await this.selectByValue(selector.customer.cShop.filters.selectCategory, value); + await this.selectByValue(shopCustomer.filters.selectCategory, value); break; default: break; } - await this.clickAndWaitForLoadState(selector.customer.cShop.filters.search); - await this.notToHaveCount(selector.customer.cShop.productCard.card, 0); + await this.clickAndWaitForLoadState(shopCustomer.filters.search); + await this.notToHaveCount(shopCustomer.productCard.card, 0); } // products on map - async productOnMap(productName?: string) { + async productOnMap() { await this.goIfNotThere(data.subUrls.frontend.shop); - // await this.click(selector.customer.cShop.map.productOnMap.productOnMap); - // await this.toBeVisibleAnyOfThem([selector.customer.cShop.map.productOnMap.productPopup, selector.customer.cShop.map.productOnMap.productListPopup]); // implement this instead of if-else soln - const storePinIsVisible = await this.isVisible(selector.customer.cShop.map.productOnMap.productPin); + const storePinIsVisible = await this.isVisible(shopCustomer.map.productOnMap.productPin); if (storePinIsVisible) { - await this.click(selector.customer.cShop.map.productOnMap.productPin); - await this.toBeVisible(selector.customer.cShop.map.productOnMap.productPopup); + await this.click(shopCustomer.map.productOnMap.productPin); + await this.toBeVisible(shopCustomer.map.productOnMap.productPopup); } else { - await this.click(selector.customer.cShop.map.productOnMap.productCluster); - await this.toBeVisible(selector.customer.cShop.map.productOnMap.productListPopup); - await this.click(selector.customer.cShop.map.productOnMap.closePopup); + await this.click(shopCustomer.map.productOnMap.productCluster); + await this.toBeVisible(shopCustomer.map.productOnMap.productListPopup); + await this.click(shopCustomer.map.productOnMap.closePopup); } - productName && (await this.toBeVisible(selector.customer.cShop.map.productOnMap.productOnList(productName))); } // go to product details async goToProductDetailsFromShop(productName: string): Promise { await this.searchProduct(productName); if (DOKAN_PRO) { - await this.clickAndWaitForResponse(data.subUrls.frontend.productCustomerPage, selector.customer.cShop.productCard.productDetailsLink); + await this.clickAndWaitForResponse(data.subUrls.frontend.productCustomerPage, shopCustomer.productCard.productDetailsLink); await this.toContainText(selector.customer.cSingleProduct.productDetails.productTitle, productName); } } diff --git a/tests/pw/pages/singleProductPage.ts b/tests/pw/pages/singleProductPage.ts index 4d05815e88..0ba4446bc7 100644 --- a/tests/pw/pages/singleProductPage.ts +++ b/tests/pw/pages/singleProductPage.ts @@ -6,6 +6,9 @@ import { product } from '@utils/interfaces'; const { DOKAN_PRO } = process.env; +// selectors +const singleProductCustomer = selector.customer.cSingleProduct; + export class SingleProductPage extends CustomerPage { constructor(page: Page) { super(page); @@ -18,57 +21,57 @@ export class SingleProductPage extends CustomerPage { await this.goToProductDetails(productName); // basic details are visible - const { viewCart, ...productDetails } = selector.customer.cSingleProduct.productDetails; + const { viewCart, ...productDetails } = singleProductCustomer.productDetails; await this.multipleElementVisible(productDetails); // description elements are visible - // await this.click(selector.customer.cSingleProduct.menus.description); - await this.multipleElementVisible(selector.customer.cSingleProduct.description); + // await this.click(singleProductCustomer.menus.description); + await this.multipleElementVisible(singleProductCustomer.description); // review elements are visible - await this.click(selector.customer.cSingleProduct.menus.reviews); + await this.click(singleProductCustomer.menus.reviews); - await this.toBeVisible(selector.customer.cSingleProduct.reviews.ratings); - await this.toBeVisible(selector.customer.cSingleProduct.reviews.reviewMessage); - await this.toBeVisible(selector.customer.cSingleProduct.reviews.submitReview); + await this.toBeVisible(singleProductCustomer.reviews.ratings); + await this.toBeVisible(singleProductCustomer.reviews.reviewMessage); + await this.toBeVisible(singleProductCustomer.reviews.submitReview); // vendor info elements are visible - await this.click(selector.customer.cSingleProduct.menus.vendorInfo); - await this.multipleElementVisible(selector.customer.cSingleProduct.vendorInfo); + await this.click(singleProductCustomer.menus.vendorInfo); + await this.multipleElementVisible(singleProductCustomer.vendorInfo); // more products elements are visible - await this.click(selector.customer.cSingleProduct.menus.moreProducts); - await this.toBeVisible(selector.customer.cSingleProduct.moreProducts.moreProductsDiv); - await this.notToHaveCount(selector.customer.cSingleProduct.moreProducts.product, 0); + await this.click(singleProductCustomer.menus.moreProducts); + await this.toBeVisible(singleProductCustomer.moreProducts.moreProductsDiv); + await this.notToHaveCount(singleProductCustomer.moreProducts.product, 0); // related products elements are visible - await this.multipleElementVisible(selector.customer.cSingleProduct.relatedProducts); + await this.multipleElementVisible(singleProductCustomer.relatedProducts); if (DOKAN_PRO) { // get support is visible - await this.toBeVisible(selector.customer.cSingleProduct.getSupport.getSupport); + await this.toBeVisible(singleProductCustomer.getSupport.getSupport); // report abuse is visible - await this.toBeVisible(selector.customer.cSingleProduct.reportAbuse.reportAbuse); + await this.toBeVisible(singleProductCustomer.reportAbuse.reportAbuse); // vendor highlighted info elements are visible - await this.multipleElementVisible(selector.customer.cSingleProduct.vendorHighlightedInfo); + await this.multipleElementVisible(singleProductCustomer.vendorHighlightedInfo); // product shipping elements are visible - // await this.click(selector.customer.cSingleProduct.menus.shipping); - // await this.multipleElementVisible(selector.customer.cSingleProduct.shipping); // todo: need vendor shipping + // await this.click(singleProductCustomer.menus.shipping); + // await this.multipleElementVisible(singleProductCustomer.shipping); // todo: need vendor shipping // product location elements are visible - await this.click(selector.customer.cSingleProduct.menus.location); - await this.multipleElementVisible(selector.customer.cSingleProduct.location); + await this.click(singleProductCustomer.menus.location); + await this.multipleElementVisible(singleProductCustomer.location); // // warranty policy is visible - // await this.click(selector.customer.cSingleProduct.menus.warrantyPolicy); - // await this.multipleElementVisible(selector.customer.cSingleProduct.warrantyPolicy); // todo: need warranty policy + // await this.click(singleProductCustomer.menus.warrantyPolicy); + // await this.multipleElementVisible(singleProductCustomer.warrantyPolicy); // todo: need warranty policy // product enquiry is visible - await this.click(selector.customer.cSingleProduct.menus.productEnquiry); - const { submitEnquirySuccessMessage, guest, ...productEnquiry } = selector.customer.cSingleProduct.productEnquiry; + await this.click(singleProductCustomer.menus.productEnquiry); + const { submitEnquirySuccessMessage, guest, ...productEnquiry } = singleProductCustomer.productEnquiry; await this.multipleElementVisible(productEnquiry); } } @@ -77,52 +80,51 @@ export class SingleProductPage extends CustomerPage { async reviewProduct(productName: string, review: product['review']): Promise { await this.goToProductDetails(productName); const reviewMessage = review.reviewMessage(); - await this.click(selector.customer.cSingleProduct.menus.reviews); - await this.click(selector.customer.cSingleProduct.reviews.rating(review.rating)); - await this.clearAndType(selector.customer.cSingleProduct.reviews.reviewMessage, reviewMessage); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.productReview, selector.customer.cSingleProduct.reviews.submitReview, 302); - await this.toContainText(selector.customer.cSingleProduct.reviews.submittedReview(reviewMessage), reviewMessage); + await this.click(singleProductCustomer.menus.reviews); + await this.click(singleProductCustomer.reviews.rating(review.rating)); + await this.clearAndType(singleProductCustomer.reviews.reviewMessage, reviewMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.productReview, singleProductCustomer.reviews.submitReview, 302); + await this.toContainText(singleProductCustomer.reviews.submittedReview(reviewMessage), reviewMessage); } // product vendor info async productVendorInfo(productName: string) { await this.goToProductDetails(productName); - await this.click(selector.customer.cSingleProduct.menus.vendorInfo); - await this.multipleElementVisible(selector.customer.cSingleProduct.vendorInfo); + await this.click(singleProductCustomer.menus.vendorInfo); + await this.multipleElementVisible(singleProductCustomer.vendorInfo); } // product location async productLocation(productName: string) { await this.goToProductDetails(productName); - await this.click(selector.customer.cSingleProduct.menus.location); - await this.multipleElementVisible(selector.customer.cSingleProduct.location); + await this.click(singleProductCustomer.menus.location); + await this.multipleElementVisible(singleProductCustomer.location); } // product warranty policy async productWarrantyPolicy(productName: string) { await this.goToProductDetails(productName); - await this.click(selector.customer.cSingleProduct.menus.warrantyPolicy); - await this.multipleElementVisible(selector.customer.cSingleProduct.warrantyPolicy); + await this.click(singleProductCustomer.menus.warrantyPolicy); + await this.multipleElementVisible(singleProductCustomer.warrantyPolicy); } // view vendor more product async viewMoreProducts(productName: string) { await this.goToProductDetails(productName); - await this.click(selector.customer.cSingleProduct.menus.moreProducts); - - await this.toBeVisible(selector.customer.cSingleProduct.moreProducts.moreProductsDiv); - await this.notToHaveCount(selector.customer.cSingleProduct.moreProducts.product, 0); + await this.click(singleProductCustomer.menus.moreProducts); + await this.toBeVisible(singleProductCustomer.moreProducts.moreProductsDiv); + await this.notToHaveCount(singleProductCustomer.moreProducts.product, 0); } // view vendor more product async viewRelatedProducts(productName: string) { await this.goToProductDetails(productName); - await this.multipleElementVisible(selector.customer.cSingleProduct.relatedProducts); + await this.multipleElementVisible(singleProductCustomer.relatedProducts); } // view highlighted vendor info async viewHighlightedVendorInfo(productName: string) { await this.goToProductDetails(productName); - await this.multipleElementVisible(selector.customer.cSingleProduct.vendorHighlightedInfo); + await this.multipleElementVisible(singleProductCustomer.vendorHighlightedInfo); } } diff --git a/tests/pw/pages/singleStorePage.ts b/tests/pw/pages/singleStorePage.ts index fa91551540..f78d3952f5 100644 --- a/tests/pw/pages/singleStorePage.ts +++ b/tests/pw/pages/singleStorePage.ts @@ -6,6 +6,9 @@ import { data } from '@utils/testData'; const { DOKAN_PRO } = process.env; +// selectors +const singleStoreCustomer = selector.customer.cSingleStore; + export class SingleStorePage extends CustomerPage { constructor(page: Page) { super(page); @@ -19,78 +22,78 @@ export class SingleStorePage extends CustomerPage { await this.goIfNotThere(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName))); // store profile elements are visible - await this.multipleElementVisible(selector.customer.cSingleStore.storeProfile); + await this.multipleElementVisible(singleStoreCustomer.storeProfile); // store tab elements are visible if (!DOKAN_PRO) { - await this.toBeVisible(selector.customer.cSingleStore.storeTabs.products); - // await this.toBeVisible(selector.customer.cSingleStore.storeTabs.toc); // todo: need vendor toc + await this.toBeVisible(singleStoreCustomer.storeTabs.products); + // await this.toBeVisible(singleStoreCustomer.storeTabs.toc); // todo: need vendor toc } else { - const { toc, ...storeTabs } = selector.customer.cSingleStore.storeTabs; + const { toc, ...storeTabs } = singleStoreCustomer.storeTabs; await this.multipleElementVisible(storeTabs); } // search elements are visible - await this.multipleElementVisible(selector.customer.cSingleStore.search); + await this.multipleElementVisible(singleStoreCustomer.search); // sortby element is visible - await this.toBeVisible(selector.customer.cSingleStore.sortBy); + await this.toBeVisible(singleStoreCustomer.sortBy); // store products are visible - await this.toBeVisible(selector.customer.cSingleStore.storeProducts); + await this.toBeVisible(singleStoreCustomer.storeProducts); // product card elements are visible - await this.notToHaveCount(selector.customer.cSingleStore.productCard.card, 0); - await this.notToHaveCount(selector.customer.cSingleStore.productCard.productDetailsLink, 0); - await this.notToHaveCount(selector.customer.cSingleStore.productCard.productTitle, 0); - await this.notToHaveCount(selector.customer.cSingleStore.productCard.productPrice, 0); - await this.notToHaveCount(selector.customer.cSingleStore.productCard.addToCart, 0); + await this.notToHaveCount(singleStoreCustomer.productCard.card, 0); + await this.notToHaveCount(singleStoreCustomer.productCard.productDetailsLink, 0); + await this.notToHaveCount(singleStoreCustomer.productCard.productTitle, 0); + await this.notToHaveCount(singleStoreCustomer.productCard.productPrice, 0); + await this.notToHaveCount(singleStoreCustomer.productCard.addToCart, 0); // store social icons are visible - await this.multipleElementVisible(selector.customer.cSingleStore.storeSocialIcons); + await this.multipleElementVisible(singleStoreCustomer.storeSocialIcons); } // sort products on single store async singleStoreSortProducts(storeName: string, sortBy: string) { await this.goIfNotThere(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName))); - await this.selectByValueAndWaitForResponse(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName)), selector.customer.cSingleStore.sortBy, sortBy); + await this.selectByValueAndWaitForResponse(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName)), singleStoreCustomer.sortBy, sortBy); } // search product on single store async singleStoreSearchProduct(storeName: string, productName: string): Promise { await this.goIfNotThere(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName))); - await this.clearAndType(selector.customer.cSingleStore.search.input, productName); - await this.clickAndWaitForResponse(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName)), selector.customer.cSingleStore.search.button); - await this.toContainText(selector.customer.cSingleStore.productCard.productTitle, productName); + await this.clearAndType(singleStoreCustomer.search.input, productName); + await this.clickAndWaitForResponse(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName)), singleStoreCustomer.search.button); + await this.toContainText(singleStoreCustomer.productCard.productTitle, productName); } // store open close async storeOpenCloseTime(storeName: string): Promise { await this.goIfNotThere(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName))); - await this.hover(selector.customer.cSingleStore.storeTime.storeTimeDropDown); + await this.hover(singleStoreCustomer.storeTime.storeTimeDropDown); - await this.toBeVisible(selector.customer.cSingleStore.storeTime.storeTimeDiv); - await this.toBeVisible(selector.customer.cSingleStore.storeTime.storeTimeHeading); + await this.toBeVisible(singleStoreCustomer.storeTime.storeTimeDiv); + await this.toBeVisible(singleStoreCustomer.storeTime.storeTimeHeading); - await this.toHaveCount(selector.customer.cSingleStore.storeTime.storeDays, 7); - await this.toHaveCount(selector.customer.cSingleStore.storeTime.storeTimes, 7); + await this.toHaveCount(singleStoreCustomer.storeTime.storeDays, 7); + await this.toHaveCount(singleStoreCustomer.storeTime.storeTimes, 7); } // store terms and condition async storeTermsAndCondition(storeName: string, toc: string): Promise { await this.goIfNotThere(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName))); - await this.clickAndWaitForResponse(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName)), selector.customer.cSingleStore.storeTabs.toc); - await this.toContainText(selector.customer.cSingleStore.toc.tocContent, toc); + await this.clickAndWaitForResponse(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName)), singleStoreCustomer.storeTabs.toc); + await this.toContainText(singleStoreCustomer.toc.tocContent, toc); } // store share async storeShare(storeName: string, site: string): Promise { await this.goIfNotThere(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName))); - await this.click(selector.customer.cSingleStore.storeTabs.share); + await this.click(singleStoreCustomer.storeTabs.share); // ensure page suppose to open on new tab - await this.toHaveAttribute(selector.customer.cSingleStore.sharePlatForms[site as keyof typeof selector.customer.cSingleStore.sharePlatForms], 'target', '_blank'); + await this.toHaveAttribute(singleStoreCustomer.sharePlatForms[site as keyof typeof singleStoreCustomer.sharePlatForms], 'target', '_blank'); // force page to open on same tab - await this.setAttributeValue(selector.customer.cSingleStore.sharePlatForms[site as keyof typeof selector.customer.cSingleStore.sharePlatForms], 'target', '_self'); - await this.clickAndWaitForUrl(new RegExp('.*' + site + '.*'), selector.customer.cSingleStore.sharePlatForms[site as keyof typeof selector.customer.cSingleStore.sharePlatForms]); + await this.setAttributeValue(singleStoreCustomer.sharePlatForms[site as keyof typeof singleStoreCustomer.sharePlatForms], 'target', '_self'); + await this.clickAndWaitForUrl(new RegExp('.*' + site + '.*'), singleStoreCustomer.sharePlatForms[site as keyof typeof singleStoreCustomer.sharePlatForms]); } } diff --git a/tests/pw/pages/spmvPage.ts b/tests/pw/pages/spmvPage.ts index fcf381efa3..bf4b0cf6b0 100644 --- a/tests/pw/pages/spmvPage.ts +++ b/tests/pw/pages/spmvPage.ts @@ -4,6 +4,11 @@ import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; import { helpers } from '@utils/helpers'; +// selectors +const spmvAdmin = selector.admin.dokan.spmv; +const spmvVendor = selector.vendor.vSpmv; +const spmvCustomer = selector.customer.cSpmv; + export class SpmvPage extends VendorPage { constructor(page: Page) { super(page); @@ -14,16 +19,16 @@ export class SpmvPage extends VendorPage { async assignSpmvProduct(productId: string, storeName: string) { await this.goIfNotThere(data.subUrls.backend.wc.productDetails(productId)); - await this.focus(selector.admin.dokan.spmv.searchVendor); + await this.focus(spmvAdmin.searchVendor); - const alreadyAssigned = await this.isVisible(selector.admin.dokan.spmv.unassignVendor(storeName)); - alreadyAssigned && (await this.clickAndAcceptAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.spmv.unassignVendor(storeName))); + const alreadyAssigned = await this.isVisible(spmvAdmin.unassignVendor(storeName)); + alreadyAssigned && (await this.clickAndAcceptAndWaitForResponseAndLoadState(data.subUrls.ajax, spmvAdmin.unassignVendor(storeName))); - await this.typeViaPageAndWaitForResponse(data.subUrls.ajax, selector.admin.dokan.spmv.searchVendor, storeName); - await this.toContainText(selector.admin.dokan.spmv.highlightedResult, storeName); - await this.click(selector.admin.dokan.spmv.searchedResult(storeName)); - await this.click(selector.admin.dokan.spmv.spmvDiv); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.spmv.assignVendor); + await this.typeViaPageAndWaitForResponse(data.subUrls.ajax, spmvAdmin.searchVendor, storeName); + await this.toContainText(spmvAdmin.highlightedResult, storeName); + await this.click(spmvAdmin.searchedResult(storeName)); + await this.click(spmvAdmin.spmvDiv); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, spmvAdmin.assignVendor); await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, selector.admin.products.product.publish, 302); await this.toContainText(selector.admin.products.product.updatedSuccessMessage, data.product.updateSuccessMessage); @@ -36,17 +41,17 @@ export class SpmvPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.spmv); // search box elements are visible - const { toggleBtn, ...search } = selector.vendor.vSpmv.search; + const { toggleBtn, ...search } = spmvVendor.search; await this.multipleElementVisible(search); // table elements are visible - await this.multipleElementVisible(selector.vendor.vSpmv.table); + await this.multipleElementVisible(spmvVendor.table); // number of elements found is visible - await this.toBeVisible(selector.vendor.vSpmv.resultCount); + await this.toBeVisible(spmvVendor.resultCount); // sort is visible - await this.toBeVisible(selector.vendor.vSpmv.sortProduct); + await this.toBeVisible(spmvVendor.sortProduct); } // vendor search similar product @@ -55,19 +60,19 @@ export class SpmvPage extends VendorPage { case 'popup': await this.goIfNotThere(data.subUrls.frontend.vDashboard.products); await this.click(selector.vendor.product.create.addNewProduct); - await this.click(selector.vendor.vSpmv.search.toggleBtn); + await this.click(spmvVendor.search.toggleBtn); break; case 'booking': await this.goIfNotThere(data.subUrls.frontend.vDashboard.booking); await this.click(selector.vendor.vBooking.addNewBookingProduct); - await this.click(selector.vendor.vSpmv.search.toggleBtn); + await this.click(spmvVendor.search.toggleBtn); break; case 'auction': await this.goIfNotThere(data.subUrls.frontend.vDashboard.auction); await this.clickAndWaitForLoadState(selector.vendor.vAuction.addNewActionProduct); - await this.click(selector.vendor.vSpmv.search.toggleBtn); + await this.click(spmvVendor.search.toggleBtn); break; case 'spmv': @@ -78,43 +83,43 @@ export class SpmvPage extends VendorPage { break; } - const searchInputIsVisible = await this.isVisible(selector.vendor.vSpmv.search.searchInput); + const searchInputIsVisible = await this.isVisible(spmvVendor.search.searchInput); if (!searchInputIsVisible) { // forcing spmv search section to open via removing class - const spmvSearchDiv = (await this.getClassValue(selector.vendor.vSpmv.search.searchDiv))!; - await this.setAttributeValue(selector.vendor.vSpmv.search.searchDiv, 'class', spmvSearchDiv.replace('section-closed', '')); + const spmvSearchDiv = (await this.getClassValue(spmvVendor.search.searchDiv))!; + await this.setAttributeValue(spmvVendor.search.searchDiv, 'class', spmvSearchDiv.replace('section-closed', '')); } - await this.clearAndType(selector.vendor.vSpmv.search.searchInput, productName); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.spmv, selector.vendor.vSpmv.search.search); - await this.toContainText(selector.vendor.vSpmv.resultCount, 'Showing the single result'); + await this.clearAndType(spmvVendor.search.searchInput, productName); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.spmv, spmvVendor.search.search); + await this.toContainText(spmvVendor.resultCount, 'Showing the single result'); } // got to product edit from spmv - async goToProductEditFromSPMV(productName: string): Promise { + async goToProductEditFromSpmv(productName: string): Promise { await this.searchSimilarProduct(productName, 'spmv'); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.vSpmv.editProduct(productName)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, spmvVendor.editProduct(productName)); await this.toHaveValue(selector.vendor.product.edit.title, productName); } // sort spmv product async sortSpmvProduct(sortBy: string): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.spmv); - await this.selectByValueAndWaitForResponse(data.subUrls.frontend.vDashboard.spmv, selector.vendor.vSpmv.sortProduct, sortBy); - await this.notToHaveCount(selector.vendor.vSpmv.numberOfRowsFound, 0); + await this.selectByValueAndWaitForResponse(data.subUrls.frontend.vDashboard.spmv, spmvVendor.sortProduct, sortBy); + await this.notToHaveCount(spmvVendor.numberOfRowsFound, 0); } // clone product async cloneProduct(productName: string): Promise { await this.searchSimilarProduct(productName, 'spmv'); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.vSpmv.addToStore); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, spmvVendor.addToStore); await this.toHaveValue(selector.vendor.product.edit.title, productName); } // clone product via sell item button async cloneProductViaSellItemButton(productName: string): Promise { await this.goToProductDetails(productName); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.vSpmv.productDetails.sellThisItem); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, spmvVendor.productDetails.sellThisItem); await this.toHaveValue(selector.vendor.product.edit.title, productName); } @@ -123,30 +128,30 @@ export class SpmvPage extends VendorPage { await this.goToProductDetails(productName); // if display inside product tab - await this.clickIfVisible(selector.customer.cSpmv.otherVendorAvailableTab); + await this.clickIfVisible(spmvCustomer.otherVendorAvailableTab); - await this.toBeVisible(selector.customer.cSpmv.otherAvailableVendorDiv); - await this.toBeVisible(selector.customer.cSpmv.availableVendorDisplayAreaTitle); - await this.toBeVisible(selector.customer.cSpmv.availableVendorTable); + await this.toBeVisible(spmvCustomer.otherAvailableVendorDiv); + await this.toBeVisible(spmvCustomer.availableVendorDisplayAreaTitle); + await this.toBeVisible(spmvCustomer.availableVendorTable); // vendor - await this.notToHaveCount(selector.customer.cSpmv.availableVendorDetails.vendor.vendorCell, 0); - await this.notToHaveCount(selector.customer.cSpmv.availableVendorDetails.vendor.avatar, 0); - await this.notToHaveCount(selector.customer.cSpmv.availableVendorDetails.vendor.vendorLink, 0); + await this.notToHaveCount(spmvCustomer.availableVendorDetails.vendor.vendorCell, 0); + await this.notToHaveCount(spmvCustomer.availableVendorDetails.vendor.avatar, 0); + await this.notToHaveCount(spmvCustomer.availableVendorDetails.vendor.vendorLink, 0); // price - await this.notToHaveCount(selector.customer.cSpmv.availableVendorDetails.price.priceCell, 0); - await this.notToHaveCount(selector.customer.cSpmv.availableVendorDetails.price.priceAmount, 0); + await this.notToHaveCount(spmvCustomer.availableVendorDetails.price.priceCell, 0); + await this.notToHaveCount(spmvCustomer.availableVendorDetails.price.priceAmount, 0); // rating - await this.notToHaveCount(selector.customer.cSpmv.availableVendorDetails.rating.ratingCell, 0); - await this.notToHaveCount(selector.customer.cSpmv.availableVendorDetails.rating.rating, 0); + await this.notToHaveCount(spmvCustomer.availableVendorDetails.rating.ratingCell, 0); + await this.notToHaveCount(spmvCustomer.availableVendorDetails.rating.rating, 0); // actions - await this.notToHaveCount(selector.customer.cSpmv.availableVendorDetails.actions.actionsCell, 0); - await this.notToHaveCount(selector.customer.cSpmv.availableVendorDetails.actions.viewStore, 0); - await this.notToHaveCount(selector.customer.cSpmv.availableVendorDetails.actions.viewProduct, 0); - await this.notToHaveCount(selector.customer.cSpmv.availableVendorDetails.actions.addToCart, 0); + await this.notToHaveCount(spmvCustomer.availableVendorDetails.actions.actionsCell, 0); + await this.notToHaveCount(spmvCustomer.availableVendorDetails.actions.viewStore, 0); + await this.notToHaveCount(spmvCustomer.availableVendorDetails.actions.viewProduct, 0); + await this.notToHaveCount(spmvCustomer.availableVendorDetails.actions.addToCart, 0); } // view other available vendor @@ -154,9 +159,9 @@ export class SpmvPage extends VendorPage { await this.goToProductDetails(productName); // if display inside product tab - await this.clickIfVisible(selector.customer.cSpmv.otherVendorAvailableTab); + await this.clickIfVisible(spmvCustomer.otherVendorAvailableTab); - await this.clickAndWaitForLoadState(selector.customer.cSpmv.availableVendorDetails.actions.viewStoreByVendor(storeName)); + await this.clickAndWaitForLoadState(spmvCustomer.availableVendorDetails.actions.viewStoreByVendor(storeName)); await expect(this.page).toHaveURL(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName)) + '/'); } @@ -165,9 +170,9 @@ export class SpmvPage extends VendorPage { await this.goToProductDetails(productName); // if display inside product tab - await this.clickIfVisible(selector.customer.cSpmv.otherVendorAvailableTab); + await this.clickIfVisible(spmvCustomer.otherVendorAvailableTab); - await this.clickAndWaitForLoadState(selector.customer.cSpmv.availableVendorDetails.actions.viewProductByVendor(storeName)); + await this.clickAndWaitForLoadState(spmvCustomer.availableVendorDetails.actions.viewProductByVendor(storeName)); await this.toContainText(selector.customer.cSingleProduct.productDetails.productTitle, productName); } @@ -176,9 +181,9 @@ export class SpmvPage extends VendorPage { await this.goToProductDetails(productName); // if display inside product tab - await this.clickIfVisible(selector.customer.cSpmv.otherVendorAvailableTab); + await this.clickIfVisible(spmvCustomer.otherVendorAvailableTab); - await this.clickAndWaitForLoadState(selector.customer.cSpmv.availableVendorDetails.actions.addToCartByVendor(storeName)); + await this.clickAndWaitForLoadState(spmvCustomer.availableVendorDetails.actions.addToCartByVendor(storeName)); await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, `“${productName}” has been added to your cart.`); } } diff --git a/tests/pw/pages/storeAppearance.ts b/tests/pw/pages/storeAppearance.ts index fa54667819..b1188ecd7e 100644 --- a/tests/pw/pages/storeAppearance.ts +++ b/tests/pw/pages/storeAppearance.ts @@ -4,6 +4,9 @@ import { selector } from '@pages/selectors'; import { helpers } from '@utils/helpers'; import { data } from '@utils/testData'; +// selectors +const singleStoreCustomer = selector.customer.cSingleStore; + export class StoreAppearance extends BasePage { constructor(page: Page) { super(page); @@ -11,16 +14,16 @@ export class StoreAppearance extends BasePage { async disableMapOnStoreSidebar(storeName: string) { await this.goIfNotThere(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName))); - await this.notToBeVisible(selector.customer.cSingleStore.storeMap); + await this.notToBeVisible(singleStoreCustomer.storeMap); } async disableStoreOpenCloseTimeOnStoreSidebar(storeName: string) { await this.goto(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName))); - await this.notToBeVisible(selector.customer.cSingleStore.storeOpenCloseTime); + await this.notToBeVisible(singleStoreCustomer.storeOpenCloseTime); } async disableVendorInfoOnSingleStorePage(storeName: string) { await this.goto(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName))); - await this.notToBeVisible(selector.customer.cSingleStore.storeOpenCloseTime); + await this.notToBeVisible(singleStoreCustomer.storeOpenCloseTime); } } diff --git a/tests/pw/pages/storeCategoriesPage.ts b/tests/pw/pages/storeCategoriesPage.ts index 680718ca01..72b1a891eb 100644 --- a/tests/pw/pages/storeCategoriesPage.ts +++ b/tests/pw/pages/storeCategoriesPage.ts @@ -4,6 +4,10 @@ import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; import { storeCategory } from '@utils/interfaces'; +// selectors +const storeCategoryAdmin = selector.admin.dokan.vendors.storeCategory; +const storeCategoryVendor = selector.vendor.vStoreSettings.storeCategories; + export class StoreCategoriesPage extends AdminPage { constructor(page: Page) { super(page); @@ -17,13 +21,13 @@ export class StoreCategoriesPage extends AdminPage { await this.click(selector.admin.dokan.vendors.storeCategories); // add new category elements are visible - await this.multipleElementVisible(selector.admin.dokan.vendors.storeCategory.addNewCategory); + await this.multipleElementVisible(storeCategoryAdmin.addNewCategory); // search category input is visible - await this.toBeVisible(selector.admin.dokan.vendors.storeCategory.search); + await this.toBeVisible(storeCategoryAdmin.search); // store category table elements are visible - await this.multipleElementVisible(selector.admin.dokan.vendors.storeCategory.table); + await this.multipleElementVisible(storeCategoryAdmin.table); } // add store category @@ -31,9 +35,9 @@ export class StoreCategoriesPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.vendors); await this.click(selector.admin.dokan.vendors.storeCategories); - await this.clearAndType(selector.admin.dokan.vendors.storeCategory.addNewCategory.name, storeCategory.name); - await this.clearAndType(selector.admin.dokan.vendors.storeCategory.addNewCategory.description, storeCategory.description); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeCategories, selector.admin.dokan.vendors.storeCategory.addNewCategory.addNewCategory); + await this.clearAndType(storeCategoryAdmin.addNewCategory.name, storeCategory.name); + await this.clearAndType(storeCategoryAdmin.addNewCategory.description, storeCategory.description); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeCategories, storeCategoryAdmin.addNewCategory.addNewCategory); } // search store category @@ -41,36 +45,36 @@ export class StoreCategoriesPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.storeCategories); // await this.click(selector.admin.dokan.vendors.storeCategories); - await this.clearInputField(selector.admin.dokan.vendors.storeCategory.search); + await this.clearInputField(storeCategoryAdmin.search); - await this.typeAndWaitForResponse(data.subUrls.api.dokan.storeCategories, selector.admin.dokan.vendors.storeCategory.search, categoryName); - await this.toBeVisible(selector.admin.dokan.vendors.storeCategory.storeCategoryCell(categoryName)); + await this.typeAndWaitForResponse(data.subUrls.api.dokan.storeCategories, storeCategoryAdmin.search, categoryName); + await this.toBeVisible(storeCategoryAdmin.storeCategoryCell(categoryName)); } // edit store category async editStoreCategory(storeCategory: storeCategory) { await this.searchStoreCategory(storeCategory.name); - await this.hover(selector.admin.dokan.vendors.storeCategory.storeCategoryCell(storeCategory.name)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeCategories, selector.admin.dokan.vendors.storeCategory.storeCategoryEdit(storeCategory.name)); - await this.clearAndType(selector.admin.dokan.vendors.storeCategory.editCategory.name, storeCategory.name); - await this.clearAndType(selector.admin.dokan.vendors.storeCategory.editCategory.description, storeCategory.description); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeCategories, selector.admin.dokan.vendors.storeCategory.editCategory.update); + await this.hover(storeCategoryAdmin.storeCategoryCell(storeCategory.name)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeCategories, storeCategoryAdmin.storeCategoryEdit(storeCategory.name)); + await this.clearAndType(storeCategoryAdmin.editCategory.name, storeCategory.name); + await this.clearAndType(storeCategoryAdmin.editCategory.description, storeCategory.description); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeCategories, storeCategoryAdmin.editCategory.update); } // update store category async updateStoreCategory(categoryName: string, action: string) { await this.searchStoreCategory(categoryName); - await this.hover(selector.admin.dokan.vendors.storeCategory.storeCategoryCell(categoryName)); + await this.hover(storeCategoryAdmin.storeCategoryCell(categoryName)); switch (action) { case 'set-default': - await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeCategories, selector.admin.dokan.vendors.storeCategory.storeCategorySetDefault(categoryName)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeCategories, storeCategoryAdmin.storeCategorySetDefault(categoryName)); break; case 'delete': - await this.clickAndAcceptAndWaitForResponse(data.subUrls.api.dokan.storeCategories, selector.admin.dokan.vendors.storeCategory.storeCategoryDelete(categoryName)); + await this.clickAndAcceptAndWaitForResponse(data.subUrls.api.dokan.storeCategories, storeCategoryAdmin.storeCategoryDelete(categoryName)); break; default: @@ -83,14 +87,14 @@ export class StoreCategoriesPage extends AdminPage { // vendor update store category async vendorUpdateStoreCategory(category: string) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsStore); - const isSingleCategory = await this.isVisible(selector.vendor.vStoreSettings.storeCategories.storeCategoryDropDown); + const isSingleCategory = await this.isVisible(storeCategoryVendor.storeCategoryDropDown); if (isSingleCategory) { - await this.click(selector.vendor.vStoreSettings.storeCategories.storeCategoryDropDown); - await this.clearAndType(selector.vendor.vStoreSettings.storeCategories.storeCategoryInput, category); + await this.click(storeCategoryVendor.storeCategoryDropDown); + await this.clearAndType(storeCategoryVendor.storeCategoryInput, category); } else { - await this.clearAndType(selector.vendor.vStoreSettings.storeCategories.storeCategoriesInput, category); + await this.clearAndType(storeCategoryVendor.storeCategoriesInput, category); } - await this.toContainText(selector.vendor.vStoreSettings.storeCategories.result, category); + await this.toContainText(storeCategoryVendor.result, category); await this.press(data.key.enter); await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.vendor.vStoreSettings.updateSettings); await this.toContainText(selector.vendor.vStoreSettings.updateSettingsSuccessMessage, 'Your information has been saved successfully'); diff --git a/tests/pw/pages/storeListingPage.ts b/tests/pw/pages/storeListingPage.ts index 2b254ecdac..bdcc630616 100644 --- a/tests/pw/pages/storeListingPage.ts +++ b/tests/pw/pages/storeListingPage.ts @@ -6,6 +6,9 @@ import { data } from '@utils/testData'; const { DOKAN_PRO } = process.env; +// selectors +const storeList = selector.customer.cStoreList; + export class StoreListingPage extends CustomerPage { constructor(page: Page) { super(page); @@ -18,52 +21,52 @@ export class StoreListingPage extends CustomerPage { await this.goIfNotThere(data.subUrls.frontend.storeListing); // store list text is visible - await this.toBeVisible(selector.customer.cStoreList.storeListText); + await this.toBeVisible(storeList.storeListText); // map elements are visible if (DOKAN_PRO) { - const { storeOnMap, ...map } = selector.customer.cStoreList.map; + const { storeOnMap, ...map } = storeList.map; await this.multipleElementVisible(map); } // store filter elements are visible - const { filterDetails, ...filters } = selector.customer.cStoreList.filters; + const { filterDetails, ...filters } = storeList.filters; await this.multipleElementVisible(filters); // click filter button to view filter details - await this.click(selector.customer.cStoreList.filters.filterButton); + await this.click(storeList.filters.filterButton); // store filter detail elements are visible if (!DOKAN_PRO) { - await this.toBeVisible(selector.customer.cStoreList.filters.filterDetails.searchVendor); - await this.toBeVisible(selector.customer.cStoreList.filters.filterDetails.apply); + await this.toBeVisible(storeList.filters.filterDetails.searchVendor); + await this.toBeVisible(storeList.filters.filterDetails.apply); } else { - const { rating, ...filterDetails } = selector.customer.cStoreList.filters.filterDetails; + const { rating, ...filterDetails } = storeList.filters.filterDetails; await this.multipleElementVisible(filterDetails); } // store card elements are visible - await this.notToHaveCount(selector.customer.cStoreList.storeCard.storeCardDiv, 0); + await this.notToHaveCount(storeList.storeCard.storeCardDiv, 0); // card header - await this.notToHaveCount(selector.customer.cStoreList.storeCard.storeCardHeader, 0); - await this.notToHaveCount(selector.customer.cStoreList.storeCard.storeBanner, 0); + await this.notToHaveCount(storeList.storeCard.storeCardHeader, 0); + await this.notToHaveCount(storeList.storeCard.storeBanner, 0); // card content - await this.notToHaveCount(selector.customer.cStoreList.storeCard.storeCardContent, 0); - await this.notToHaveCount(selector.customer.cStoreList.storeCard.storeData, 0); + await this.notToHaveCount(storeList.storeCard.storeCardContent, 0); + await this.notToHaveCount(storeList.storeCard.storeData, 0); // card footer - await this.notToHaveCount(selector.customer.cStoreList.storeCard.storeCardFooter, 0); - await this.notToHaveCount(selector.customer.cStoreList.storeCard.storeAvatar, 0); - await this.notToHaveCount(selector.customer.cStoreList.storeCard.visitStore, 0); - DOKAN_PRO && (await this.notToHaveCount(selector.customer.cStoreList.storeCard.followUnFollowButton, 0)); + await this.notToHaveCount(storeList.storeCard.storeCardFooter, 0); + await this.notToHaveCount(storeList.storeCard.storeAvatar, 0); + await this.notToHaveCount(storeList.storeCard.visitStore, 0); + DOKAN_PRO && (await this.notToHaveCount(storeList.storeCard.followUnFollowButton, 0)); } // sort store async sortStores(sortBy: string) { await this.goIfNotThere(data.subUrls.frontend.storeListing); - await this.selectByValueAndWaitForResponse(data.subUrls.frontend.storeListing, selector.customer.cStoreList.filters.sortBy, sortBy); + await this.selectByValueAndWaitForResponse(data.subUrls.frontend.storeListing, storeList.filters.sortBy, sortBy); } // store view layout @@ -72,85 +75,85 @@ export class StoreListingPage extends CustomerPage { switch (style) { case 'grid': - await this.click(selector.customer.cStoreList.filters.gridView); + await this.click(storeList.filters.gridView); break; case 'list': - await this.click(selector.customer.cStoreList.filters.listView); + await this.click(storeList.filters.listView); break; default: break; } - await this.toHaveClass(selector.customer.cStoreList.currentLayout, style + '-view'); + await this.toHaveClass(storeList.currentLayout, style + '-view'); } // search store async searchStore(storeName: string): Promise { await this.goIfNotThere(data.subUrls.frontend.storeListing); - await this.click(selector.customer.cStoreList.filters.filterButton); - await this.clearAndType(selector.customer.cStoreList.filters.filterDetails.searchVendor, storeName); - await this.clickAndWaitForResponse(data.subUrls.frontend.storeListing, selector.customer.cStoreList.filters.filterDetails.apply); - await this.toBeVisible(selector.customer.cStoreList.visitStore(storeName)); + await this.click(storeList.filters.filterButton); + await this.clearAndType(storeList.filters.filterDetails.searchVendor, storeName); + await this.clickAndWaitForResponse(data.subUrls.frontend.storeListing, storeList.filters.filterDetails.apply); + await this.toBeVisible(storeList.visitStore(storeName)); } // filter stores async filterStores(filterBy: string, value?: string): Promise { await this.goIfNotThere(data.subUrls.frontend.storeListing); - await this.click(selector.customer.cStoreList.filters.filterButton); + await this.click(storeList.filters.filterButton); switch (filterBy) { case 'by-location': - await this.typeAndWaitForResponse(data.subUrls.gmap, selector.customer.cStoreList.filters.filterDetails.location, value!); - await this.click(selector.customer.cStoreList.mapResultFirst); + await this.typeAndWaitForResponse(data.subUrls.gmap, storeList.filters.filterDetails.location, value!); + await this.click(storeList.mapResultFirst); // await this.press(data.key.arrowDown); // await this.pressAndWaitForResponse(data.subUrls.gmap, data.key.enter); break; case 'by-category': - await this.click(selector.customer.cStoreList.filters.filterDetails.categoryInput); - await this.click(selector.customer.cStoreList.category(value!)); + await this.click(storeList.filters.filterDetails.categoryInput); + await this.click(storeList.category(value!)); break; case 'by-ratings': - await this.click(selector.customer.cStoreList.filters.filterDetails.rating(value!)); + await this.click(storeList.filters.filterDetails.rating(value!)); break; case 'featured': - await this.click(selector.customer.cStoreList.filters.filterDetails.featured); + await this.click(storeList.filters.filterDetails.featured); break; case 'open-now': - await this.click(selector.customer.cStoreList.filters.filterDetails.openNow); + await this.click(storeList.filters.filterDetails.openNow); break; default: break; } - await this.clickAndWaitForResponse(data.subUrls.frontend.storeListing, selector.customer.cStoreList.filters.filterDetails.apply); - await this.notToHaveCount(selector.customer.cStoreList.storeCard.storeCardDiv, 0); + await this.clickAndWaitForResponse(data.subUrls.frontend.storeListing, storeList.filters.filterDetails.apply); + await this.notToHaveCount(storeList.storeCard.storeCardDiv, 0); } // stores on map async storeOnMap(storeName?: string) { await this.goIfNotThere(data.subUrls.frontend.storeListing); - const storePinIsVisible = await this.isVisible(selector.customer.cStoreList.map.storeOnMap.storePin); + const storePinIsVisible = await this.isVisible(storeList.map.storeOnMap.storePin); if (storePinIsVisible) { - await this.click(selector.customer.cStoreList.map.storeOnMap.storePin); - await this.toBeVisible(selector.customer.cStoreList.map.storeOnMap.storePopup); + await this.click(storeList.map.storeOnMap.storePin); + await this.toBeVisible(storeList.map.storeOnMap.storePopup); } else { - await this.click(selector.customer.cStoreList.map.storeOnMap.storeCluster); - await this.toBeVisible(selector.customer.cStoreList.map.storeOnMap.storeListPopup); - await this.click(selector.customer.cStoreList.map.storeOnMap.closePopup); + await this.click(storeList.map.storeOnMap.storeCluster); + await this.toBeVisible(storeList.map.storeOnMap.storeListPopup); + await this.click(storeList.map.storeOnMap.closePopup); } - storeName && (await this.toBeVisible(selector.customer.cStoreList.map.storeOnMap.storeOnList(storeName))); + storeName && (await this.toBeVisible(storeList.map.storeOnMap.storeOnList(storeName))); } // go to single store from store listing async goToSingleStoreFromStoreListing(storeName: string): Promise { await this.searchStore(storeName); - await this.clickAndWaitForLoadState(selector.customer.cStoreList.storeCard.visitStore); + await this.clickAndWaitForLoadState(storeList.storeCard.visitStore); const storeUrl = this.isCurrentUrl(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName))); expect(storeUrl).toBeTruthy(); } diff --git a/tests/pw/pages/storeReviewsPage.ts b/tests/pw/pages/storeReviewsPage.ts index ee782c82ec..a60efcc379 100644 --- a/tests/pw/pages/storeReviewsPage.ts +++ b/tests/pw/pages/storeReviewsPage.ts @@ -5,6 +5,10 @@ import { helpers } from '@utils/helpers'; import { data } from '@utils/testData'; import { storeReview } from '@utils/interfaces'; +// selectors +const storeReviewsAdmin = selector.admin.dokan.storeReviews; +const storeReviewsCustomer = selector.customer.cSingleStore.review; + export class StoreReviewsPage extends AdminPage { constructor(page: Page) { super(page); @@ -17,20 +21,20 @@ export class StoreReviewsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.storeReviews); // store reviews text is visible - await this.toBeVisible(selector.admin.dokan.storeReviews.storeReviewsText); + await this.toBeVisible(storeReviewsAdmin.storeReviewsText); // nav tabs are visible - await this.multipleElementVisible(selector.admin.dokan.storeReviews.navTabs); + await this.multipleElementVisible(storeReviewsAdmin.navTabs); // bulk action elements are visible - await this.multipleElementVisible(selector.admin.dokan.storeReviews.bulkActions); + await this.multipleElementVisible(storeReviewsAdmin.bulkActions); // filter elements are visible - const { filterInput, filterClear, ...filters } = selector.admin.dokan.storeReviews.filters; + const { filterInput, filterClear, ...filters } = storeReviewsAdmin.filters; await this.multipleElementVisible(filters); // store reviews table elements are visible - await this.multipleElementVisible(selector.admin.dokan.storeReviews.table); + await this.multipleElementVisible(storeReviewsAdmin.table); } // filter store reviews @@ -38,57 +42,58 @@ export class StoreReviewsPage extends AdminPage { await this.goto(data.subUrls.backend.dokan.storeReviews); // filter by vendor - await this.click(selector.admin.dokan.storeReviews.filters.filterByVendor); - await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, selector.admin.dokan.storeReviews.filters.filterInput, vendorName); + await this.click(storeReviewsAdmin.filters.filterByVendor); + await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, storeReviewsAdmin.filters.filterInput, vendorName); await this.pressAndWaitForResponse(data.subUrls.api.dokan.storeReviews, data.key.enter); } // view store review async viewStoreReview() { await this.goto(data.subUrls.backend.dokan.storeReviews); - await this.click(selector.admin.dokan.storeReviews.storeReviewFirstLink); - const { rating, ...editReview } = selector.admin.dokan.storeReviews.editReview; + await this.click(storeReviewsAdmin.storeReviewFirstLink); + const { rating, ...editReview } = storeReviewsAdmin.editReview; await this.multipleElementVisible(editReview); - await this.click(selector.admin.dokan.storeReviews.editReview.modalClose); + await this.click(storeReviewsAdmin.editReview.modalClose); } // edit store review async editStoreReview(review: storeReview['review']) { await this.goto(data.subUrls.backend.dokan.storeReviews); - await this.hover(selector.admin.dokan.storeReviews.storeReviewFirstCell); - await this.click(selector.admin.dokan.storeReviews.storeReviewEdit); + await this.hover(storeReviewsAdmin.storeReviewFirstCell); + await this.click(storeReviewsAdmin.storeReviewEdit); - await this.click(selector.admin.dokan.storeReviews.editReview.rating(review.rating)); - await this.clearAndType(selector.admin.dokan.storeReviews.editReview.title, review.title); - await this.clearAndType(selector.admin.dokan.storeReviews.editReview.content, review.content); + await this.click(storeReviewsAdmin.editReview.rating(review.rating)); + await this.clearAndType(storeReviewsAdmin.editReview.title, review.title); + await this.clearAndType(storeReviewsAdmin.editReview.content, review.content); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeReviews, selector.admin.dokan.storeReviews.editReview.update); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeReviews, storeReviewsAdmin.editReview.update); } - // delete store review - async deleteStoreReview() { + async updateStoreReview(action: string) { await this.goto(data.subUrls.backend.dokan.storeReviews); - await this.hover(selector.admin.dokan.storeReviews.storeReviewFirstCell); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.storeReviews, selector.admin.dokan.storeReviews.storeReviewDelete); - } - // restore store review - async restoreStoreReview() { - await this.goto(data.subUrls.backend.dokan.storeReviews); - // await this.goIfNotThere(data.subUrls.backend.dokan.storeReviews); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeReviews, selector.admin.dokan.storeReviews.navTabs.trash); + switch (action) { + case 'trash': + await this.hover(storeReviewsAdmin.storeReviewFirstCell); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.storeReviews, storeReviewsAdmin.storeReviewDelete); + break; - await this.hover(selector.admin.dokan.storeReviews.storeReviewFirstCell); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeReviews, selector.admin.dokan.storeReviews.storeReviewRestore); - } + case 'permanently-delete': + await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeReviews, storeReviewsAdmin.navTabs.trash); + await this.hover(storeReviewsAdmin.storeReviewFirstCell); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeReviews, storeReviewsAdmin.storeReviewPermanentlyDelete); - // permanently delete store review - async permanentlyDeleteStoreReview() { - await this.goto(data.subUrls.backend.dokan.storeReviews); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeReviews, selector.admin.dokan.storeReviews.navTabs.trash); + break; + + case 'restore': + await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeReviews, storeReviewsAdmin.navTabs.trash); + await this.hover(storeReviewsAdmin.storeReviewFirstCell); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeReviews, storeReviewsAdmin.storeReviewRestore); + break; - await this.hover(selector.admin.dokan.storeReviews.storeReviewFirstCell); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeReviews, selector.admin.dokan.storeReviews.storeReviewPermanentlyDelete); + default: + break; + } } // store reviews bulk action @@ -96,42 +101,40 @@ export class StoreReviewsPage extends AdminPage { await this.goto(data.subUrls.backend.dokan.storeReviews); // ensure row exists - await this.notToBeVisible(selector.admin.dokan.storeReviews.noRowsFound); + await this.notToBeVisible(storeReviewsAdmin.noRowsFound); - await this.click(selector.admin.dokan.storeReviews.bulkActions.selectAll); - await this.selectByValue(selector.admin.dokan.storeReviews.bulkActions.selectAction, action); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeReviews, selector.admin.dokan.storeReviews.bulkActions.applyAction); + await this.click(storeReviewsAdmin.bulkActions.selectAll); + await this.selectByValue(storeReviewsAdmin.bulkActions.selectAction, action); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeReviews, storeReviewsAdmin.bulkActions.applyAction); } // customer review store async reviewStore(storeName: string, review: storeReview['review'], action: string): Promise { await this.goIfNotThere(data.subUrls.frontend.storeReviews(helpers.slugify(storeName))); - // await this.goIfNotThere(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName))); - // await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.storeReviews(helpers.slugify(storeName)), selector.customer.cSingleStore.storeTabs.reviews); // write new or edit previous review if (action === 'create') { - await this.click(selector.customer.cSingleStore.review.write); + await this.click(storeReviewsCustomer.write); } else { - await this.click(selector.customer.cSingleStore.review.edit); + await this.click(storeReviewsCustomer.edit); } - await this.setAttributeValue(selector.customer.cSingleStore.review.rating, 'style', review.ratingByWidth); - await this.clearAndType(selector.customer.cSingleStore.review.title, review.title); - await this.clearAndType(selector.customer.cSingleStore.review.message, review.content); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.customer.cSingleStore.review.submit); - await this.toContainText(selector.customer.cSingleStore.review.submittedReview(review.content), review.content); + await this.setAttributeValue(storeReviewsCustomer.rating, 'style', review.ratingByWidth); + await this.clearAndType(storeReviewsCustomer.title, review.title); + await this.clearAndType(storeReviewsCustomer.message, review.content); + await this.clickAndWaitForResponse(data.subUrls.ajax, storeReviewsCustomer.submit); + await this.toContainText(storeReviewsCustomer.submittedReview(review.content), review.content); } // view own review async viewOwnReview(storeName: string): Promise { await this.goIfNotThere(data.subUrls.frontend.storeReviews(helpers.slugify(storeName))); - await this.multipleElementVisible(selector.customer.cSingleStore.review.reviewDetails); + await this.multipleElementVisible(storeReviewsCustomer.reviewDetails); } // cant review own store async cantReviewOwnStore(storeName: string): Promise { await this.goIfNotThere(data.subUrls.frontend.storeReviews(helpers.slugify(storeName))); - await this.notToBeVisible(selector.customer.cSingleStore.review.write); - await this.notToBeVisible(selector.customer.cSingleStore.review.edit); + await this.notToBeVisible(storeReviewsCustomer.write); + await this.notToBeVisible(storeReviewsCustomer.edit); } } diff --git a/tests/pw/pages/storeSupportsPage.ts b/tests/pw/pages/storeSupportsPage.ts index 79b0eaef3b..7dbf38998a 100644 --- a/tests/pw/pages/storeSupportsPage.ts +++ b/tests/pw/pages/storeSupportsPage.ts @@ -6,6 +6,12 @@ import { helpers } from '@utils/helpers'; import { data } from '@utils/testData'; import { customer, date } from '@utils/interfaces'; +// selectors +const storeSupportsAdmin = selector.admin.dokan.storeSupport; +const storeSupportsVendor = selector.vendor.vSupport; +const storeSupportsCustomer = selector.customer.cSingleStore.getSupport; +const supportsTicketsCustomer = selector.customer.cSupportTickets; + export class StoreSupportsPage extends AdminPage { constructor(page: Page) { super(page); @@ -20,55 +26,55 @@ export class StoreSupportsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.storeSupport); // store support text is visible - await this.toBeVisible(selector.admin.dokan.storeSupport.storeSupportText); + await this.toBeVisible(storeSupportsAdmin.storeSupportText); // nav tabs are visible - await this.multipleElementVisible(selector.admin.dokan.storeSupport.navTabs); + await this.multipleElementVisible(storeSupportsAdmin.navTabs); // bulk action elements are visible - await this.multipleElementVisible(selector.admin.dokan.storeSupport.bulkActions); + await this.multipleElementVisible(storeSupportsAdmin.bulkActions); // filter elements are visible - const { filterInput, result, ...filters } = selector.admin.dokan.storeSupport.filters; + const { filterInput, result, ...filters } = storeSupportsAdmin.filters; await this.multipleElementVisible(filters); // search store support is visible - await this.toBeVisible(selector.admin.dokan.storeSupport.searchTicket); + await this.toBeVisible(storeSupportsAdmin.searchTicket); // store support table elements are visible - await this.multipleElementVisible(selector.admin.dokan.storeSupport.table); + await this.multipleElementVisible(storeSupportsAdmin.table); } // admin view support ticket details async adminViewSupportTicketDetails(supportTicketId: string) { await this.searchSupportTicket(supportTicketId); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.storeSupport, selector.admin.dokan.storeSupport.supportTicketLink(supportTicketId)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.storeSupport, storeSupportsAdmin.supportTicketLink(supportTicketId)); - await this.toBeVisible(selector.admin.dokan.storeSupport.supportTicketDetails.backToTickets); + await this.toBeVisible(storeSupportsAdmin.supportTicketDetails.backToTickets); // chat elements are visible - await this.toBeVisible(selector.admin.dokan.storeSupport.supportTicketDetails.ticketTitle); - await this.toBeVisible(selector.admin.dokan.storeSupport.supportTicketDetails.chatStatus); - await this.toBeVisible(selector.admin.dokan.storeSupport.supportTicketDetails.chatBox); - await this.toBeVisible(selector.admin.dokan.storeSupport.supportTicketDetails.chatAuthor); - await this.toBeVisible(selector.admin.dokan.storeSupport.supportTicketDetails.chatReply); - await this.toBeVisible(selector.admin.dokan.storeSupport.supportTicketDetails.sendReply); + await this.toBeVisible(storeSupportsAdmin.supportTicketDetails.ticketTitle); + await this.toBeVisible(storeSupportsAdmin.supportTicketDetails.chatStatus); + await this.toBeVisible(storeSupportsAdmin.supportTicketDetails.chatBox); + await this.toBeVisible(storeSupportsAdmin.supportTicketDetails.chatAuthor); + await this.toBeVisible(storeSupportsAdmin.supportTicketDetails.chatReply); + await this.toBeVisible(storeSupportsAdmin.supportTicketDetails.sendReply); // ticket summary elements are visible - const { reopenTicket, ...ticketSummary } = selector.admin.dokan.storeSupport.supportTicketDetails.ticketSummary; + const { reopenTicket, ...ticketSummary } = storeSupportsAdmin.supportTicketDetails.ticketSummary; await this.multipleElementVisible(ticketSummary); } // search support ticket async searchSupportTicket(idOrTitle: string, closed?: boolean) { await this.goIfNotThere(data.subUrls.backend.dokan.storeSupport); - closed && (await this.clickAndWaitForLoadState(selector.admin.dokan.storeSupport.navTabs.closed)); // go to closed tab + closed && (await this.clickAndWaitForLoadState(storeSupportsAdmin.navTabs.closed)); // go to closed tab - await this.clearInputField(selector.admin.dokan.storeSupport.searchTicket); - await this.typeAndWaitForResponseAndLoadState(data.subUrls.api.dokan.storeSupport, selector.admin.dokan.storeSupport.searchTicket, idOrTitle); - const count = (await this.getElementText(selector.admin.dokan.storeSupport.numberOfRowsFound))?.split(' ')[0]; + await this.clearInputField(storeSupportsAdmin.searchTicket); + await this.typeAndWaitForResponseAndLoadState(data.subUrls.api.dokan.storeSupport, storeSupportsAdmin.searchTicket, idOrTitle); + const count = (await this.getElementText(storeSupportsAdmin.numberOfRowsFound))?.split(' ')[0]; if (!isNaN(Number(idOrTitle))) { - await this.toBeVisible(selector.admin.dokan.storeSupport.supportTicketCell(idOrTitle)); + await this.toBeVisible(storeSupportsAdmin.supportTicketCell(idOrTitle)); } else { expect(Number(count)).toBeGreaterThan(0); } @@ -77,11 +83,11 @@ export class StoreSupportsPage extends AdminPage { // decrease unread support ticket count async decreaseUnreadSupportTicketCount(supportTicketId: string) { await this.goIfNotThere(data.subUrls.backend.dokan.storeSupport); - const getUnreadCount = Number(await this.getElementText(selector.admin.dokan.storeSupport.unreadTicketCount)); + const unreadCount = Number(await this.getElementText(storeSupportsAdmin.unreadTicketCount)); await this.searchSupportTicket(supportTicketId); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.storeSupport, selector.admin.dokan.storeSupport.supportTicketLink(supportTicketId)); - const getNewUnreadCount = Number(await this.getElementText(selector.admin.dokan.storeSupport.unreadTicketCount)); - expect(getNewUnreadCount).toEqual(getUnreadCount - 1); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.storeSupport, storeSupportsAdmin.supportTicketLink(supportTicketId)); + const getNewUnreadCount = Number(await this.getElementText(storeSupportsAdmin.unreadTicketCount)); + expect(getNewUnreadCount).toEqual(unreadCount - 1); } // filter store supports @@ -90,54 +96,54 @@ export class StoreSupportsPage extends AdminPage { switch (filterBy) { case 'by-vendor': - await this.click(selector.admin.dokan.storeSupport.filters.filterByVendors); - await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, selector.admin.dokan.storeSupport.filters.filterInput, input); - await this.toContainText(selector.admin.dokan.storeSupport.filters.result, input); + await this.click(storeSupportsAdmin.filters.filterByVendors); + await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, storeSupportsAdmin.filters.filterInput, input); + await this.toContainText(storeSupportsAdmin.filters.result, input); await this.press(data.key.enter); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeSupport, selector.admin.dokan.storeSupport.filters.filterButton); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeSupport, storeSupportsAdmin.filters.filterButton); break; case 'by-customer': - await this.click(selector.admin.dokan.storeSupport.filters.filterByCustomers); - await this.typeAndWaitForResponse(data.subUrls.api.dokan.storeSupport, selector.admin.dokan.storeSupport.filters.filterInput, input); - await this.toContainText(selector.admin.dokan.storeSupport.filters.result, input); + await this.click(storeSupportsAdmin.filters.filterByCustomers); + await this.typeAndWaitForResponse(data.subUrls.api.dokan.storeSupport, storeSupportsAdmin.filters.filterInput, input); + await this.toContainText(storeSupportsAdmin.filters.result, input); await this.press(data.key.enter); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeSupport, selector.admin.dokan.storeSupport.filters.filterButton); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeSupport, storeSupportsAdmin.filters.filterButton); break; default: break; } - const count = (await this.getElementText(selector.admin.dokan.storeSupport.numberOfRowsFound))?.split(' ')[0]; + const count = (await this.getElementText(storeSupportsAdmin.numberOfRowsFound))?.split(' ')[0]; expect(Number(count)).toBeGreaterThan(0); } // reply to support ticket async replySupportTicket(supportTicketId: string, replyMessage: string, replier = 'admin') { await this.searchSupportTicket(supportTicketId); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.storeSupport, selector.admin.dokan.storeSupport.supportTicketLink(supportTicketId)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.storeSupport, storeSupportsAdmin.supportTicketLink(supportTicketId)); if (replier === 'vendor') { - await this.selectByValue(selector.admin.dokan.storeSupport.supportTicketDetails.chatAuthor, 'vendor'); + await this.selectByValue(storeSupportsAdmin.supportTicketDetails.chatAuthor, 'vendor'); } - await this.clearAndType(selector.admin.dokan.storeSupport.supportTicketDetails.chatReply, replyMessage); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeSupport, selector.admin.dokan.storeSupport.supportTicketDetails.sendReply); + await this.clearAndType(storeSupportsAdmin.supportTicketDetails.chatReply, replyMessage); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeSupport, storeSupportsAdmin.supportTicketDetails.sendReply); } // update support ticket email notification async updateSupportTicketEmailNotification(supportTicketId: string, action: string) { await this.searchSupportTicket(supportTicketId); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.storeSupport, selector.admin.dokan.storeSupport.supportTicketLink(supportTicketId)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.storeSupport, storeSupportsAdmin.supportTicketLink(supportTicketId)); switch (action) { case 'enable': - await this.enableSwitcherAndWaitForResponse(data.subUrls.api.dokan.storeSupport, selector.admin.dokan.storeSupport.supportTicketDetails.ticketSummary.emailNotification); + await this.enableSwitcherAndWaitForResponse(data.subUrls.api.dokan.storeSupport, storeSupportsAdmin.supportTicketDetails.ticketSummary.emailNotification); break; case 'disable': - await this.disableSwitcherAndWaitForResponse(data.subUrls.api.dokan.storeSupport, selector.admin.dokan.storeSupport.supportTicketDetails.ticketSummary.emailNotification); + await this.disableSwitcherAndWaitForResponse(data.subUrls.api.dokan.storeSupport, storeSupportsAdmin.supportTicketDetails.ticketSummary.emailNotification); break; default: @@ -148,15 +154,15 @@ export class StoreSupportsPage extends AdminPage { // close support ticket async closeSupportTicket(supportTicketId: string) { await this.searchSupportTicket(supportTicketId); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.storeSupport, selector.admin.dokan.storeSupport.supportTicketLink(supportTicketId)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeSupport, selector.admin.dokan.storeSupport.supportTicketDetails.ticketSummary.closeTicket); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.storeSupport, storeSupportsAdmin.supportTicketLink(supportTicketId)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeSupport, storeSupportsAdmin.supportTicketDetails.ticketSummary.closeTicket); } // reopen support ticket async reopenSupportTicket(supportTicketId: string) { await this.searchSupportTicket(supportTicketId, true); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.storeSupport, selector.admin.dokan.storeSupport.supportTicketLink(supportTicketId)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeSupport, selector.admin.dokan.storeSupport.supportTicketDetails.ticketSummary.reopenTicket); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.storeSupport, storeSupportsAdmin.supportTicketLink(supportTicketId)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.storeSupport, storeSupportsAdmin.supportTicketDetails.ticketSummary.reopenTicket); } // store support bulk action @@ -165,11 +171,11 @@ export class StoreSupportsPage extends AdminPage { supportTicketId && (await this.searchSupportTicket(supportTicketId)); // ensure row exists - await this.notToBeVisible(selector.admin.dokan.storeSupport.noRowsFound); + await this.notToBeVisible(storeSupportsAdmin.noRowsFound); - await this.click(selector.admin.dokan.storeSupport.bulkActions.selectAll); - await this.selectByValue(selector.admin.dokan.storeSupport.bulkActions.selectAction, action); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.storeSupport, selector.admin.dokan.storeSupport.bulkActions.applyAction); + await this.click(storeSupportsAdmin.bulkActions.selectAll); + await this.selectByValue(storeSupportsAdmin.bulkActions.selectAction, action); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.dokan.storeSupport, storeSupportsAdmin.bulkActions.applyAction); } // vendor @@ -179,41 +185,41 @@ export class StoreSupportsPage extends AdminPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.storeSupport); // store support menu elements are visible - await this.multipleElementVisible(selector.vendor.vSupport.menus); + await this.multipleElementVisible(storeSupportsVendor.menus); - const { filterByCustomerInput, filterByDate, result, ...filters } = selector.vendor.vSupport.filters; - await this.toBeVisible(selector.vendor.vSupport.filters.filterByDate.dateRangeInput); + const { filterByCustomerInput, filterByDate, result, ...filters } = storeSupportsVendor.filters; + await this.toBeVisible(storeSupportsVendor.filters.filterByDate.dateRangeInput); await this.multipleElementVisible(filters); - const noSupportTicket = await this.isVisible(selector.vendor.vSupport.noSupportTicketFound); + const noSupportTicket = await this.isVisible(storeSupportsVendor.noSupportTicketFound); if (noSupportTicket) { console.log('No Support Tickets Found!!'); return; } // store support table elements are visible - await this.multipleElementVisible(selector.vendor.vSupport.table); + await this.multipleElementVisible(storeSupportsVendor.table); } // vendor view support ticket details async vendorViewSupportTicketDetails(supportTicketId: string) { await this.vendorSearchSupportTicket('id', supportTicketId); - await this.clickAndWaitForLoadState(selector.vendor.vSupport.storeSupportLink(supportTicketId)); + await this.clickAndWaitForLoadState(storeSupportsVendor.storeSupportLink(supportTicketId)); - await this.toBeVisible(selector.vendor.vSupport.supportTicketDetails.backToTickets); + await this.toBeVisible(storeSupportsVendor.supportTicketDetails.backToTickets); // basic details elements are visible - await this.multipleElementVisible(selector.vendor.vSupport.supportTicketDetails.basicDetails); + await this.multipleElementVisible(storeSupportsVendor.supportTicketDetails.basicDetails); // chat status is visible - await this.toBeVisible(selector.vendor.vSupport.supportTicketDetails.chatStatus.status); + await this.toBeVisible(storeSupportsVendor.supportTicketDetails.chatStatus.status); // first chat is visible - await this.toBeVisible(selector.vendor.vSupport.supportTicketDetails.chatBox.mainChat); + await this.toBeVisible(storeSupportsVendor.supportTicketDetails.chatBox.mainChat); // chat reply box elements are visible - const ticketIsOpen = await this.isVisible(selector.vendor.vSupport.supportTicketDetails.chatStatus.open); - const { addReplyText, closeTicketText, ...replyBox } = selector.vendor.vSupport.supportTicketDetails.replyBox; + const ticketIsOpen = await this.isVisible(storeSupportsVendor.supportTicketDetails.chatStatus.open); + const { addReplyText, closeTicketText, ...replyBox } = storeSupportsVendor.supportTicketDetails.replyBox; ticketIsOpen && (await this.toBeVisible(addReplyText)); !ticketIsOpen && (await this.multipleElementVisible(closeTicketText)); await this.multipleElementVisible(replyBox); @@ -225,46 +231,46 @@ export class StoreSupportsPage extends AdminPage { switch (filterBy) { case 'by-customer': - await this.click(selector.vendor.vSupport.filters.filterByCustomer); - // await this.clearAndType(selector.vendor.vSupport.filters.filterByCustomerInput, input); - await this.typeAndWaitForResponse(data.subUrls.ajax, selector.vendor.vSupport.filters.filterByCustomerInput, inputValue as string); - await this.toContainText(selector.vendor.vSupport.filters.result, inputValue as string); - await this.clickAndWaitForLoadState(selector.vendor.vSupport.filters.search); - await this.notToHaveCount(selector.vendor.vSupport.storeSupportsCellByCustomer(inputValue as string), 0); + await this.click(storeSupportsVendor.filters.filterByCustomer); + // await this.clearAndType(storeSupportsVendor.filters.filterByCustomerInput, input); + await this.typeAndWaitForResponse(data.subUrls.ajax, storeSupportsVendor.filters.filterByCustomerInput, inputValue as string); + await this.toContainText(storeSupportsVendor.filters.result, inputValue as string); + await this.clickAndWaitForLoadState(storeSupportsVendor.filters.search); + await this.notToHaveCount(storeSupportsVendor.storeSupportsCellByCustomer(inputValue as string), 0); break; case 'by-date': if (typeof inputValue !== 'string') { - await this.setAttributeValue(selector.vendor.vSupport.filters.filterByDate.dateRangeInput, 'value', helpers.dateFormatFYJ(inputValue.startDate) + ' - ' + helpers.dateFormatFYJ(inputValue.endDate)); - await this.setAttributeValue(selector.vendor.vSupport.filters.filterByDate.startDateInput, 'value', inputValue.startDate); - await this.setAttributeValue(selector.vendor.vSupport.filters.filterByDate.endDateInput, 'value', inputValue.endDate); - await this.clickAndWaitForLoadState(selector.vendor.vSupport.filters.search); + await this.setAttributeValue(storeSupportsVendor.filters.filterByDate.dateRangeInput, 'value', helpers.dateFormatFYJ(inputValue.startDate) + ' - ' + helpers.dateFormatFYJ(inputValue.endDate)); + await this.setAttributeValue(storeSupportsVendor.filters.filterByDate.startDateInput, 'value', inputValue.startDate); + await this.setAttributeValue(storeSupportsVendor.filters.filterByDate.endDateInput, 'value', inputValue.endDate); + await this.clickAndWaitForLoadState(storeSupportsVendor.filters.search); } break; default: break; } - await this.notToHaveCount(selector.vendor.vSupport.numOfRowsFound, 0); + await this.notToHaveCount(storeSupportsVendor.numOfRowsFound, 0); } // vendor search support ticket async vendorSearchSupportTicket(searchBy: string, input: string, closed?: boolean) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.storeSupport); if (closed) { - await this.clickAndWaitForLoadState(selector.vendor.vSupport.menus.closedTickets); + await this.clickAndWaitForLoadState(storeSupportsVendor.menus.closedTickets); } - await this.clearAndType(selector.vendor.vSupport.filters.tickedIdOrKeyword, input); - await this.clickAndWaitForLoadState(selector.vendor.vSupport.filters.search); + await this.clearAndType(storeSupportsVendor.filters.tickedIdOrKeyword, input); + await this.clickAndWaitForLoadState(storeSupportsVendor.filters.search); switch (searchBy) { case 'id': - await this.toBeVisible(selector.vendor.vSupport.storeSupportCellById(input)); + await this.toBeVisible(storeSupportsVendor.storeSupportCellById(input)); break; case 'title': - await this.notToHaveCount(selector.vendor.vSupport.storeSupportCellByTitle(input), 0); + await this.notToHaveCount(storeSupportsVendor.storeSupportCellByTitle(input), 0); break; default: @@ -275,44 +281,44 @@ export class StoreSupportsPage extends AdminPage { // vendor reply to support ticket async vendorReplySupportTicket(supportTicketId: string, replyMessage: string) { await this.vendorSearchSupportTicket('id', supportTicketId); - await this.clickAndWaitForLoadState(selector.vendor.vSupport.storeSupportLink(supportTicketId)); - await this.clearAndType(selector.vendor.vSupport.chatReply, replyMessage); - await this.clickAndWaitForResponse('wp-comments-post.php', selector.vendor.vSupport.submitReply, 302); + await this.clickAndWaitForLoadState(storeSupportsVendor.storeSupportLink(supportTicketId)); + await this.clearAndType(storeSupportsVendor.chatReply, replyMessage); + await this.clickAndWaitForResponse('wp-comments-post.php', storeSupportsVendor.submitReply, 302); } // vendor close support ticket async vendorCloseSupportTicket(supportTicketId: string) { await this.vendorSearchSupportTicket('id', supportTicketId); - await this.click(selector.vendor.vSupport.closeTicket); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.storeSupport, selector.vendor.vSupport.confirmCloseTicket); + await this.click(storeSupportsVendor.closeTicket); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.storeSupport, storeSupportsVendor.confirmCloseTicket); } // vendor reopen support ticket async vendorReopenSupportTicket(supportTicketId: string) { await this.vendorSearchSupportTicket('id', supportTicketId, true); - await this.click(selector.vendor.vSupport.reOpenTicket); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.storeSupport, selector.vendor.vSupport.confirmCloseTicket); + await this.click(storeSupportsVendor.reOpenTicket); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.storeSupport, storeSupportsVendor.confirmCloseTicket); } // vendor close support ticket with a reply async vendorCloseSupportTicketWithReply(supportTicketId: string, replyMessage: string) { await this.vendorSearchSupportTicket('id', supportTicketId); - await this.clickAndWaitForLoadState(selector.vendor.vSupport.storeSupportLink(supportTicketId)); - await this.toContainText(selector.vendor.vSupport.ticketStatus, 'Open'); - await this.selectByValue(selector.vendor.vSupport.changeStatus, '1'); - await this.clearAndType(selector.vendor.vSupport.chatReply, replyMessage); - await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.storeSupport, selector.vendor.vSupport.submitReply); - await this.toContainText(selector.vendor.vSupport.ticketStatus, 'Closed'); + await this.clickAndWaitForLoadState(storeSupportsVendor.storeSupportLink(supportTicketId)); + await this.toContainText(storeSupportsVendor.ticketStatus, 'Open'); + await this.selectByValue(storeSupportsVendor.changeStatus, '1'); + await this.clearAndType(storeSupportsVendor.chatReply, replyMessage); + await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.storeSupport, storeSupportsVendor.submitReply); + await this.toContainText(storeSupportsVendor.ticketStatus, 'Closed'); } // vendor reopen support ticket with a reply async vendorReopenSupportTicketWithReply(supportTicketId: string, replyMessage: string) { await this.vendorSearchSupportTicket('id', supportTicketId, true); - await this.clickAndWaitForLoadState(selector.vendor.vSupport.storeSupportLink(supportTicketId)); - await this.toContainText(selector.vendor.vSupport.ticketStatus, 'Closed'); - await this.clearAndType(selector.vendor.vSupport.chatReply, replyMessage); - await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.storeSupport, selector.vendor.vSupport.submitReply); - await this.toContainText(selector.vendor.vSupport.ticketStatus, 'Open'); + await this.clickAndWaitForLoadState(storeSupportsVendor.storeSupportLink(supportTicketId)); + await this.toContainText(storeSupportsVendor.ticketStatus, 'Closed'); + await this.clearAndType(storeSupportsVendor.chatReply, replyMessage); + await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.storeSupport, storeSupportsVendor.submitReply); + await this.toContainText(storeSupportsVendor.ticketStatus, 'Open'); } // customer @@ -322,43 +328,43 @@ export class StoreSupportsPage extends AdminPage { await this.goIfNotThere(data.subUrls.frontend.supportTickets); // menu elements are visible - await this.multipleElementVisible(selector.customer.cSupportTickets.menus); - const noSupportTicket = await this.isVisible(selector.customer.cSupportTickets.noSupportTicketFound); + await this.multipleElementVisible(supportsTicketsCustomer.menus); + const noSupportTicket = await this.isVisible(supportsTicketsCustomer.noSupportTicketFound); if (noSupportTicket) { console.log('No Support Tickets Found!!'); return; } // store support table elements are visible - await this.multipleElementVisible(selector.customer.cSupportTickets.table); + await this.multipleElementVisible(supportsTicketsCustomer.table); } // customer view support ticket details async customerViewSupportTicketDetails(supportTicketId: string) { await this.goIfNotThere(data.subUrls.frontend.supportTickets); - const supportTicketIdIsVisible = await this.isVisible(selector.customer.cSupportTickets.supportTicketLink(supportTicketId)); + const supportTicketIdIsVisible = await this.isVisible(supportsTicketsCustomer.supportTicketLink(supportTicketId)); if (supportTicketIdIsVisible) { - await this.clickAndWaitForLoadState(selector.customer.cSupportTickets.supportTicketLink(supportTicketId)); + await this.clickAndWaitForLoadState(supportsTicketsCustomer.supportTicketLink(supportTicketId)); } else { await this.goIfNotThere(data.subUrls.frontend.supportTicketDetails(supportTicketId)); } - await this.toBeVisible(selector.customer.cSupportTickets.supportTicketDetails.backToTickets); + await this.toBeVisible(supportsTicketsCustomer.supportTicketDetails.backToTickets); // basic details elements are visible - await this.multipleElementVisible(selector.customer.cSupportTickets.supportTicketDetails.basicDetails); + await this.multipleElementVisible(supportsTicketsCustomer.supportTicketDetails.basicDetails); // chat status is visible - await this.toBeVisible(selector.customer.cSupportTickets.supportTicketDetails.chatStatus.status); + await this.toBeVisible(supportsTicketsCustomer.supportTicketDetails.chatStatus.status); // first chat is visible - await this.toBeVisible(selector.customer.cSupportTickets.supportTicketDetails.chatBox.mainChat); + await this.toBeVisible(supportsTicketsCustomer.supportTicketDetails.chatBox.mainChat); // chat reply box elements are visible is ticket is open - const ticketIsOpen = await this.isVisible(selector.customer.cSupportTickets.supportTicketDetails.chatStatus.open); - ticketIsOpen && (await this.multipleElementVisible(selector.customer.cSupportTickets.supportTicketDetails.replyBox)); + const ticketIsOpen = await this.isVisible(supportsTicketsCustomer.supportTicketDetails.chatStatus.open); + ticketIsOpen && (await this.multipleElementVisible(supportsTicketsCustomer.supportTicketDetails.replyBox)); // closed ticket elements are visible is ticket is close - !ticketIsOpen && (await this.multipleElementVisible(selector.customer.cSupportTickets.supportTicketDetails.closedTicket)); + !ticketIsOpen && (await this.multipleElementVisible(supportsTicketsCustomer.supportTicketDetails.closedTicket)); } // customer ask for store support @@ -387,43 +393,43 @@ export class StoreSupportsPage extends AdminPage { } await this.clickAndWaitForResponse(data.subUrls.ajax, selector.customer.cSingleStore.storeTabs.getSupport); - const isGuest = await this.isVisible(selector.customer.cSingleStore.getSupport.userName); + const isGuest = await this.isVisible(storeSupportsCustomer.userName); if (isGuest) { - await this.clearAndType(selector.customer.cSingleStore.getSupport.userName, getSupport.username); - await this.clearAndType(selector.customer.cSingleStore.getSupport.userPassword, getSupport.userPassword); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.customer.cSingleStore.getSupport.login); + await this.clearAndType(storeSupportsCustomer.userName, getSupport.username); + await this.clearAndType(storeSupportsCustomer.userPassword, getSupport.userPassword); + await this.clickAndWaitForResponse(data.subUrls.ajax, storeSupportsCustomer.login); } - await this.clearAndType(selector.customer.cSingleStore.getSupport.subject, getSupport.subject); - getSupport.orderId && (await this.selectByValue(selector.customer.cSingleStore.getSupport.orderId, getSupport.orderId)); - await this.clearAndType(selector.customer.cSingleStore.getSupport.message, getSupport.message); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.customer.cSingleStore.getSupport.submit); + await this.clearAndType(storeSupportsCustomer.subject, getSupport.subject); + getSupport.orderId && (await this.selectByValue(storeSupportsCustomer.orderId, getSupport.orderId)); + await this.clearAndType(storeSupportsCustomer.message, getSupport.message); + await this.clickAndWaitForResponse(data.subUrls.ajax, storeSupportsCustomer.submit); await this.toContainText(selector.customer.cDokanSelector.dokanAlertSuccessMessage, getSupport.supportSubmitSuccessMessage); // close popup - await this.click(selector.customer.cSingleStore.getSupport.close); + await this.click(storeSupportsCustomer.close); } // customer cant send message to closed support ticket async viewOrderReferenceNumberOnSupportTicket(supportTicketId: string, orderId: string): Promise { await this.goIfNotThere(data.subUrls.frontend.supportTicketDetails(supportTicketId)); - await this.toBeVisible(selector.customer.cSupportTickets.supportTicketDetails.orderReference.orderReferenceSpan); - await this.toBeVisible(selector.customer.cSupportTickets.supportTicketDetails.orderReference.orderReferenceText(orderId)); - await this.toBeVisible(selector.customer.cSupportTickets.supportTicketDetails.orderReference.orderReferenceLink(orderId)); + await this.toBeVisible(supportsTicketsCustomer.supportTicketDetails.orderReference.orderReferenceSpan); + await this.toBeVisible(supportsTicketsCustomer.supportTicketDetails.orderReference.orderReferenceText(orderId)); + await this.toBeVisible(supportsTicketsCustomer.supportTicketDetails.orderReference.orderReferenceLink(orderId)); } // customer send message to support ticket async sendMessageToSupportTicket(supportTicketId: string, supportTicket: customer['supportTicket']): Promise { const message = supportTicket.message(); await this.goIfNotThere(data.subUrls.frontend.supportTicketDetails(supportTicketId)); - await this.clearAndType(selector.customer.cSupportTickets.supportTicketDetails.replyBox.addReply, message); - await this.clickAndWaitForResponse(data.subUrls.frontend.submitSupport, selector.customer.cSupportTickets.supportTicketDetails.replyBox.submitReply, 302); - await this.toBeVisible(selector.customer.cSupportTickets.supportTicketDetails.chatText(message)); + await this.clearAndType(supportsTicketsCustomer.supportTicketDetails.replyBox.addReply, message); + await this.clickAndWaitForResponse(data.subUrls.frontend.submitSupport, supportsTicketsCustomer.supportTicketDetails.replyBox.submitReply, 302); + await this.toBeVisible(supportsTicketsCustomer.supportTicketDetails.chatText(message)); } // customer can't send message to closed support ticket async cantSendMessageToSupportTicket(supportTicketId: string): Promise { await this.goIfNotThere(data.subUrls.frontend.supportTicketDetails(supportTicketId)); - await this.toBeVisible(selector.customer.cSupportTickets.supportTicketDetails.chatStatus.closed); - await this.toBeVisible(selector.customer.cSupportTickets.supportTicketDetails.closedTicket.closedTicketHeading); - await this.toContainText(selector.customer.cSupportTickets.supportTicketDetails.closedTicket.closedTicketMessage, 'This ticket has been closed. Open a new support ticket if you have any further query.'); + await this.toBeVisible(supportsTicketsCustomer.supportTicketDetails.chatStatus.closed); + await this.toBeVisible(supportsTicketsCustomer.supportTicketDetails.closedTicket.closedTicketHeading); + await this.toContainText(supportsTicketsCustomer.supportTicketDetails.closedTicket.closedTicketMessage, 'This ticket has been closed. Open a new support ticket if you have any further query.'); } } diff --git a/tests/pw/pages/storesPage.ts b/tests/pw/pages/storesPage.ts index 9944e6e7b4..1f7700677a 100644 --- a/tests/pw/pages/storesPage.ts +++ b/tests/pw/pages/storesPage.ts @@ -6,6 +6,10 @@ import { vendor } from '@utils/interfaces'; const { DOKAN_PRO } = process.env; +// selectors +const vendors = selector.admin.dokan.vendors; +const userInfo = selector.admin.users.userInfo; + export class StoresPage extends AdminPage { constructor(page: Page) { super(page); @@ -18,22 +22,22 @@ export class StoresPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.vendors); // vendor text is visible - await this.toBeVisible(selector.admin.dokan.vendors.vendorsText); + await this.toBeVisible(vendors.vendorsText); // and new vendor is visible - await this.toBeVisible(selector.admin.dokan.vendors.addNewVendor); + await this.toBeVisible(vendors.addNewVendor); // nav tabs are visible - await this.multipleElementVisible(selector.admin.dokan.vendors.navTabs); + await this.multipleElementVisible(vendors.navTabs); // bulk action elements are visible - await this.multipleElementVisible(selector.admin.dokan.vendors.bulkActions); + await this.multipleElementVisible(vendors.bulkActions); // search vendor input is visible - await this.toBeVisible(selector.admin.dokan.vendors.search); + await this.toBeVisible(vendors.search); // vendor table elements are visible - const { categoryColumn, ...table } = selector.admin.dokan.vendors.table; + const { categoryColumn, ...table } = vendors.table; await this.multipleElementVisible(table); } @@ -42,35 +46,35 @@ export class StoresPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.vendorDetails(storeName)); // profile info elements are visible - const { featuredVendor, storeRating, storeCategory, ...profileInfo } = selector.admin.dokan.vendors.vendorDetails.profileInfo; + const { featuredVendor, storeRating, storeCategory, ...profileInfo } = vendors.vendorDetails.profileInfo; await this.multipleElementVisible(profileInfo); // profile banner elements are visible - await this.multipleElementVisible(selector.admin.dokan.vendors.vendorDetails.profileBanner); + await this.multipleElementVisible(vendors.vendorDetails.profileBanner); // badges acquired elements are visible - const badgesAcquired = await this.isVisible(selector.admin.dokan.vendors.vendorDetails.vendorSummary.badgesAcquired.badgesAcquired); - badgesAcquired && (await this.toBeVisible(selector.admin.dokan.vendors.vendorDetails.vendorSummary.badgesAcquired.badgesAcquired)); + const badgesAcquired = await this.isVisible(vendors.vendorDetails.vendorSummary.badgesAcquired.badgesAcquired); + badgesAcquired && (await this.toBeVisible(vendors.vendorDetails.vendorSummary.badgesAcquired.badgesAcquired)); // product & revenue elements are visible - await this.toBeVisible(selector.admin.dokan.vendors.vendorDetails.vendorSummary.productRevenue.productRevenueSection); - await this.multipleElementVisible(selector.admin.dokan.vendors.vendorDetails.vendorSummary.productRevenue.products); - await this.multipleElementVisible(selector.admin.dokan.vendors.vendorDetails.vendorSummary.productRevenue.revenue); - await this.multipleElementVisible(selector.admin.dokan.vendors.vendorDetails.vendorSummary.productRevenue.others); + await this.toBeVisible(vendors.vendorDetails.vendorSummary.productRevenue.productRevenueSection); + await this.multipleElementVisible(vendors.vendorDetails.vendorSummary.productRevenue.products); + await this.multipleElementVisible(vendors.vendorDetails.vendorSummary.productRevenue.revenue); + await this.multipleElementVisible(vendors.vendorDetails.vendorSummary.productRevenue.others); // vendor info elements are visible - await this.multipleElementVisible(selector.admin.dokan.vendors.vendorDetails.vendorSummary.vendorInfo); + await this.multipleElementVisible(vendors.vendorDetails.vendorSummary.vendorInfo); } // email vendor async emailVendor(storeName: string, email: vendor['vendorInfo']['sendEmail']) { await this.goIfNotThere(data.subUrls.backend.dokan.vendorDetails(storeName)); - await this.click(selector.admin.dokan.vendors.vendorDetails.profileInfo.sendEmail); + await this.click(vendors.vendorDetails.profileInfo.sendEmail); - await this.clearAndType(selector.admin.dokan.vendors.vendorDetails.sendEmail.subject, email.subject); - await this.clearAndType(selector.admin.dokan.vendors.vendorDetails.sendEmail.message, email.message); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.stores, selector.admin.dokan.vendors.vendorDetails.sendEmail.sendEmail); + await this.clearAndType(vendors.vendorDetails.sendEmail.subject, email.subject); + await this.clearAndType(vendors.vendorDetails.sendEmail.message, email.message); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.stores, vendors.vendorDetails.sendEmail.sendEmail); } // admin add new vendors @@ -83,229 +87,231 @@ export class StoresPage extends AdminPage { const username = firstName + vendorInfo.nanoid; // add new vendor - await this.click(selector.admin.dokan.vendors.addNewVendor); + await this.click(vendors.addNewVendor); // account info - await this.type(selector.admin.dokan.vendors.newVendor.firstName, firstName); - await this.type(selector.admin.dokan.vendors.newVendor.lastName, vendorInfo.lastName()); - await this.type(selector.admin.dokan.vendors.newVendor.storeName, shopName); - await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, selector.admin.dokan.vendors.newVendor.storeUrl, shopName); - await this.type(selector.admin.dokan.vendors.newVendor.phoneNumber, vendorInfo.phoneNumber); - await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, selector.admin.dokan.vendors.newVendor.email, email); - await this.click(selector.admin.dokan.vendors.newVendor.generatePassword); - await this.clearAndType(selector.admin.dokan.vendors.newVendor.password, vendorInfo.password); - await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, selector.admin.dokan.vendors.newVendor.username, username); + await this.type(vendors.newVendor.firstName, firstName); + await this.type(vendors.newVendor.lastName, vendorInfo.lastName()); + await this.type(vendors.newVendor.storeName, shopName); + await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, vendors.newVendor.storeUrl, shopName); + await this.type(vendors.newVendor.phoneNumber, vendorInfo.phoneNumber); + await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, vendors.newVendor.email, email); + await this.click(vendors.newVendor.generatePassword); + await this.clearAndType(vendors.newVendor.password, vendorInfo.password); + await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, vendors.newVendor.username, username); if (DOKAN_PRO) { - await this.type(selector.admin.dokan.vendors.newVendor.companyName, vendorInfo.companyName); - await this.type(selector.admin.dokan.vendors.newVendor.companyIdEuidNumber, vendorInfo.companyId); - await this.type(selector.admin.dokan.vendors.newVendor.vatOrTaxNumber, vendorInfo.vatNumber); - await this.type(selector.admin.dokan.vendors.newVendor.nameOfBank, vendorInfo.bankName); - await this.type(selector.admin.dokan.vendors.newVendor.bankIban, vendorInfo.bankIban); + await this.type(vendors.newVendor.companyName, vendorInfo.companyName); + await this.type(vendors.newVendor.companyIdEuidNumber, vendorInfo.companyId); + await this.type(vendors.newVendor.vatOrTaxNumber, vendorInfo.vatNumber); + await this.type(vendors.newVendor.nameOfBank, vendorInfo.bankName); + await this.type(vendors.newVendor.bankIban, vendorInfo.bankIban); } - await this.click(selector.admin.dokan.vendors.newVendor.next); + await this.click(vendors.newVendor.next); // address - await this.type(selector.admin.dokan.vendors.newVendor.street1, vendorInfo.street1); - await this.type(selector.admin.dokan.vendors.newVendor.street2, vendorInfo.street2); - await this.type(selector.admin.dokan.vendors.newVendor.city, vendorInfo.city); - await this.type(selector.admin.dokan.vendors.newVendor.zip, vendorInfo.zipCode); - await this.click(selector.admin.dokan.vendors.newVendor.country); - await this.type(selector.admin.dokan.vendors.newVendor.countryInput, vendorInfo.country); + await this.waitForVisibleLocator(vendors.newVendor.street1); + await this.type(vendors.newVendor.street1, vendorInfo.street1); + await this.type(vendors.newVendor.street2, vendorInfo.street2); + await this.type(vendors.newVendor.city, vendorInfo.city); + await this.type(vendors.newVendor.zip, vendorInfo.zipCode); + await this.click(vendors.newVendor.country); + await this.type(vendors.newVendor.countryInput, vendorInfo.country); await this.press(data.key.enter); - await this.click(selector.admin.dokan.vendors.newVendor.state); - await this.type(selector.admin.dokan.vendors.newVendor.stateInput, vendorInfo.state); + await this.click(vendors.newVendor.state); + await this.type(vendors.newVendor.stateInput, vendorInfo.state); await this.press(data.key.enter); - await this.click(selector.admin.dokan.vendors.newVendor.next); + await this.click(vendors.newVendor.next); // payment options - await this.type(selector.admin.dokan.vendors.newVendor.accountName, vendorInfo.accountName); - await this.type(selector.admin.dokan.vendors.newVendor.accountNumber, vendorInfo.accountNumber); - await this.type(selector.admin.dokan.vendors.newVendor.bankName, vendorInfo.bankName); - await this.type(selector.admin.dokan.vendors.newVendor.bankAddress, vendorInfo.bankAddress); - await this.type(selector.admin.dokan.vendors.newVendor.routingNumber, vendorInfo.routingNumber); - await this.type(selector.admin.dokan.vendors.newVendor.iban, vendorInfo.iban); - await this.type(selector.admin.dokan.vendors.newVendor.swift, vendorInfo.swiftCode); - await this.fill(selector.admin.dokan.vendors.newVendor.payPalEmail, vendorInfo.email()); - await this.check(selector.admin.dokan.vendors.newVendor.enableSelling); - await this.check(selector.admin.dokan.vendors.newVendor.publishProductDirectly); - await this.check(selector.admin.dokan.vendors.newVendor.makeVendorFeature); + await this.type(vendors.newVendor.accountName, vendorInfo.accountName); + await this.type(vendors.newVendor.accountNumber, vendorInfo.accountNumber); + await this.type(vendors.newVendor.bankName, vendorInfo.bankName); + await this.type(vendors.newVendor.bankAddress, vendorInfo.bankAddress); + await this.type(vendors.newVendor.routingNumber, vendorInfo.routingNumber); + await this.type(vendors.newVendor.iban, vendorInfo.iban); + await this.type(vendors.newVendor.swift, vendorInfo.swiftCode); + await this.fill(vendors.newVendor.payPalEmail, vendorInfo.email()); + await this.check(vendors.newVendor.enableSelling); + await this.check(vendors.newVendor.publishProductDirectly); + await this.check(vendors.newVendor.makeVendorFeature); // create vendor - await this.clickAndWaitForResponse(data.subUrls.api.dokan.stores, selector.admin.dokan.vendors.newVendor.createVendor); - await this.toContainText(selector.admin.dokan.vendors.sweetAlertTitle, 'Vendor Created'); - await this.click(selector.admin.dokan.vendors.closeSweetAlert); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.stores, vendors.newVendor.createVendor); + await this.toContainText(vendors.sweetAlertTitle, 'Vendor Created'); + await this.click(vendors.closeSweetAlert); } // edit vendor async editVendor(vendor: vendor) { await this.searchVendor(vendor.storeName); - await this.hover(selector.admin.dokan.vendors.vendorRow(vendor.storeName)); - await this.clickAndWaitForLoadState(selector.admin.dokan.vendors.vendorEdit(vendor.storeName)); + await this.hover(vendors.vendorRow(vendor.storeName)); + await this.clickAndWaitForLoadState(vendors.vendorEdit(vendor.storeName)); if (!DOKAN_PRO) { // basic info - await this.selectByValue(selector.admin.users.userInfo.role, vendor.vendorInfo.role); - await this.clearAndType(selector.admin.users.userInfo.firstName, vendor.username); - await this.clearAndType(selector.admin.users.userInfo.lastName, vendor.lastname); - await this.clearAndType(selector.admin.users.userInfo.nickname, vendor.username); + await this.selectByValue(userInfo.role, vendor.vendorInfo.role); + await this.clearAndType(userInfo.firstName, vendor.username); + await this.clearAndType(userInfo.lastName, vendor.lastname); + await this.clearAndType(userInfo.nickname, vendor.username); // contact info - await this.clearAndType(selector.admin.users.userInfo.email, vendor.username + data.vendor.vendorInfo.emailDomain); + await this.clearAndType(userInfo.email, vendor.username + data.vendor.vendorInfo.emailDomain); // About the user - await this.clearAndType(selector.admin.users.userInfo.biographicalInfo, vendor.vendorInfo.biography); + await this.clearAndType(userInfo.biographicalInfo, vendor.vendorInfo.biography); // vendor address // billing - await this.clearAndType(selector.admin.users.userInfo.billingAddress.firstName, vendor.username); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.lastName, vendor.lastname); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.company, vendor.vendorInfo.companyName); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.address1, vendor.vendorInfo.street1); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.address2, vendor.vendorInfo.street2); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.city, vendor.vendorInfo.city); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.postcode, vendor.vendorInfo.zipCode); - await this.click(selector.admin.users.userInfo.billingAddress.country); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.countryInput, vendor.vendorInfo.country); + await this.clearAndType(userInfo.billingAddress.firstName, vendor.username); + await this.clearAndType(userInfo.billingAddress.lastName, vendor.lastname); + await this.clearAndType(userInfo.billingAddress.company, vendor.vendorInfo.companyName); + await this.clearAndType(userInfo.billingAddress.address1, vendor.vendorInfo.street1); + await this.clearAndType(userInfo.billingAddress.address2, vendor.vendorInfo.street2); + await this.clearAndType(userInfo.billingAddress.city, vendor.vendorInfo.city); + await this.clearAndType(userInfo.billingAddress.postcode, vendor.vendorInfo.zipCode); + await this.click(userInfo.billingAddress.country); + await this.clearAndType(userInfo.billingAddress.countryInput, vendor.vendorInfo.country); await this.press(data.key.enter); - await this.click(selector.admin.users.userInfo.billingAddress.state); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.stateInput, vendor.vendorInfo.state); + await this.click(userInfo.billingAddress.state); + await this.clearAndType(userInfo.billingAddress.stateInput, vendor.vendorInfo.state); await this.press(data.key.enter); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.phone, vendor.vendorInfo.phoneNumber); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.email, vendor.username + data.vendor.vendorInfo.emailDomain); + await this.clearAndType(userInfo.billingAddress.phone, vendor.vendorInfo.phoneNumber); + await this.clearAndType(userInfo.billingAddress.email, vendor.username + data.vendor.vendorInfo.emailDomain); // pro edit user - // await this.clearAndType(selector.admin.users.userInfo.billingAddress.companyIdOrEuidNumber, vendor.vendorInfo.companyId); - // await this.clearAndType(selector.admin.users.userInfo.billingAddress.vatOrTaxNumber, vendor.vendorInfo.vatNumber); - // await this.clearAndType(selector.admin.users.userInfo.billingAddress.bank, vendor.vendorInfo.bankName); - // await this.clearAndType(selector.admin.users.userInfo.billingAddress.bankIban, vendor.vendorInfo.bankIban); + // await this.clearAndType(userInfo.billingAddress.companyIdOrEuidNumber, vendor.vendorInfo.companyId); + // await this.clearAndType(userInfo.billingAddress.vatOrTaxNumber, vendor.vendorInfo.vatNumber); + // await this.clearAndType(userInfo.billingAddress.bank, vendor.vendorInfo.bankName); + // await this.clearAndType(userInfo.billingAddress.bankIban, vendor.vendorInfo.bankIban); // shipping - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.firstName, vendor.username); - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.lastName, vendor.lastname); - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.company, vendor.vendorInfo.companyName); - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.address1, vendor.vendorInfo.street1); - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.address2, vendor.vendorInfo.street2); - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.city, vendor.vendorInfo.city); - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.postcode, vendor.vendorInfo.zipCode); - await this.click(selector.admin.users.userInfo.shippingAddress.country); - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.countryInput, vendor.vendorInfo.country); + await this.clearAndType(userInfo.shippingAddress.firstName, vendor.username); + await this.clearAndType(userInfo.shippingAddress.lastName, vendor.lastname); + await this.clearAndType(userInfo.shippingAddress.company, vendor.vendorInfo.companyName); + await this.clearAndType(userInfo.shippingAddress.address1, vendor.vendorInfo.street1); + await this.clearAndType(userInfo.shippingAddress.address2, vendor.vendorInfo.street2); + await this.clearAndType(userInfo.shippingAddress.city, vendor.vendorInfo.city); + await this.clearAndType(userInfo.shippingAddress.postcode, vendor.vendorInfo.zipCode); + await this.click(userInfo.shippingAddress.country); + await this.clearAndType(userInfo.shippingAddress.countryInput, vendor.vendorInfo.country); await this.press(data.key.enter); - await this.click(selector.admin.users.userInfo.shippingAddress.state); - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.stateInput, vendor.vendorInfo.state); + await this.click(userInfo.shippingAddress.state); + await this.clearAndType(userInfo.shippingAddress.stateInput, vendor.vendorInfo.state); await this.press(data.key.enter); - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.phone, vendor.vendorInfo.phoneNumber); + await this.clearAndType(userInfo.shippingAddress.phone, vendor.vendorInfo.phoneNumber); // dokan options - await this.clearAndType(selector.admin.users.userInfo.dokanOptions.storeName, vendor.vendorInfo.storeName); - await this.clearAndType(selector.admin.users.userInfo.dokanOptions.storeUrl, vendor.vendorInfo.storeName); + await this.clearAndType(userInfo.dokanOptions.storeName, vendor.vendorInfo.storeName); + await this.clearAndType(userInfo.dokanOptions.storeUrl, vendor.vendorInfo.storeName); // store address - await this.clearAndType(selector.admin.users.userInfo.dokanOptions.address1, vendor.vendorInfo.street1); - await this.clearAndType(selector.admin.users.userInfo.dokanOptions.address2, vendor.vendorInfo.street2); - await this.clearAndType(selector.admin.users.userInfo.dokanOptions.city, vendor.vendorInfo.city); - await this.clearAndType(selector.admin.users.userInfo.dokanOptions.postcode, vendor.vendorInfo.zipCode); - await this.click(selector.admin.users.userInfo.dokanOptions.country); - await this.clearAndType(selector.admin.users.userInfo.dokanOptions.countryInput, vendor.vendorInfo.country); + await this.clearAndType(userInfo.dokanOptions.address1, vendor.vendorInfo.street1); + await this.clearAndType(userInfo.dokanOptions.address2, vendor.vendorInfo.street2); + await this.clearAndType(userInfo.dokanOptions.city, vendor.vendorInfo.city); + await this.clearAndType(userInfo.dokanOptions.postcode, vendor.vendorInfo.zipCode); + await this.click(userInfo.dokanOptions.country); + await this.clearAndType(userInfo.dokanOptions.countryInput, vendor.vendorInfo.country); await this.press(data.key.enter); - await this.click(selector.admin.users.userInfo.dokanOptions.state); - await this.clearAndType(selector.admin.users.userInfo.dokanOptions.stateInput, vendor.vendorInfo.state); + await this.click(userInfo.dokanOptions.state); + await this.clearAndType(userInfo.dokanOptions.stateInput, vendor.vendorInfo.state); await this.press(data.key.enter); - await this.clearAndType(selector.admin.users.userInfo.dokanOptions.phone, vendor.vendorInfo.phoneNumber); + await this.clearAndType(userInfo.dokanOptions.phone, vendor.vendorInfo.phoneNumber); // pro edit user - // await this.clearAndType(selector.admin.users.userInfo.dokanOptions.companyName, vendor.vendorInfo.companyName); - // await this.clearAndType(selector.admin.users.userInfo.dokanOptions.companyIdOrEuidNumber, vendor.vendorInfo.companyId); - // await this.clearAndType(selector.admin.users.userInfo.dokanOptions.vatOrTaxNumber, vendor.vendorInfo.vatNumber); - // await this.clearAndType(selector.admin.users.userInfo.dokanOptions.bank, vendor.vendorInfo.bankName); - // await this.clearAndType(selector.admin.users.userInfo.dokanOptions.bankIban, vendor.vendorInfo.bankIban); + // await this.clearAndType(userInfo.dokanOptions.companyName, vendor.vendorInfo.companyName); + // await this.clearAndType(userInfo.dokanOptions.companyIdOrEuidNumber, vendor.vendorInfo.companyId); + // await this.clearAndType(userInfo.dokanOptions.vatOrTaxNumber, vendor.vendorInfo.vatNumber); + // await this.clearAndType(userInfo.dokanOptions.bank, vendor.vendorInfo.bankName); + // await this.clearAndType(userInfo.dokanOptions.bankIban, vendor.vendorInfo.bankIban); // social profiles - await this.clearAndType(selector.admin.users.userInfo.dokanOptions.facebook, vendor.vendorInfo.socialProfileUrls.facebook); - await this.clearAndType(selector.admin.users.userInfo.dokanOptions.twitter, vendor.vendorInfo.socialProfileUrls.twitter); - await this.clearAndType(selector.admin.users.userInfo.dokanOptions.pinterest, vendor.vendorInfo.socialProfileUrls.pinterest); - await this.clearAndType(selector.admin.users.userInfo.dokanOptions.linkedin, vendor.vendorInfo.socialProfileUrls.linkedin); - await this.clearAndType(selector.admin.users.userInfo.dokanOptions.youtube, vendor.vendorInfo.socialProfileUrls.youtube); - await this.clearAndType(selector.admin.users.userInfo.dokanOptions.instagram, vendor.vendorInfo.socialProfileUrls.instagram); - await this.clearAndType(selector.admin.users.userInfo.dokanOptions.flickr, vendor.vendorInfo.socialProfileUrls.flickr); + await this.clearAndType(userInfo.dokanOptions.facebook, vendor.vendorInfo.socialProfileUrls.facebook); + await this.clearAndType(userInfo.dokanOptions.twitter, vendor.vendorInfo.socialProfileUrls.twitter); + await this.clearAndType(userInfo.dokanOptions.pinterest, vendor.vendorInfo.socialProfileUrls.pinterest); + await this.clearAndType(userInfo.dokanOptions.linkedin, vendor.vendorInfo.socialProfileUrls.linkedin); + await this.clearAndType(userInfo.dokanOptions.youtube, vendor.vendorInfo.socialProfileUrls.youtube); + await this.clearAndType(userInfo.dokanOptions.instagram, vendor.vendorInfo.socialProfileUrls.instagram); + await this.clearAndType(userInfo.dokanOptions.flickr, vendor.vendorInfo.socialProfileUrls.flickr); // other settings - await this.check(selector.admin.users.userInfo.dokanOptions.selling); - await this.check(selector.admin.users.userInfo.dokanOptions.publishing); - await this.check(selector.admin.users.userInfo.dokanOptions.featuredVendor); + await this.check(userInfo.dokanOptions.selling); + await this.check(userInfo.dokanOptions.publishing); + await this.check(userInfo.dokanOptions.featuredVendor); // update user await this.clickAndWaitForResponse(data.subUrls.backend.user, selector.admin.users.updateUser, 302); await this.toContainText(selector.admin.users.updateSuccessMessage, 'User updated.'); } else { // basic - await this.clearAndType(selector.admin.dokan.vendors.editVendor.firstName, vendor.username); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.lastName, vendor.lastname); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.storeName, vendor.vendorInfo.storeName); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.phoneNumber, vendor.vendorInfo.phone); // todo: change input after fix - await this.clearAndType(selector.admin.dokan.vendors.editVendor.email, vendor.username + data.vendor.vendorInfo.emailDomain); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.companyName, vendor.vendorInfo.companyName); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.companyIdEuidNumber, vendor.vendorInfo.companyId); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.vatOrTaxNumber, vendor.vendorInfo.vatNumber); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.nameOfBank, vendor.vendorInfo.bankName); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.bankIban, vendor.vendorInfo.bankIban); + await this.clearAndType(vendors.editVendor.firstName, vendor.username); + await this.clearAndType(vendors.editVendor.lastName, vendor.lastname); + await this.clearAndType(vendors.editVendor.storeName, vendor.vendorInfo.storeName); + await this.clearAndType(vendors.editVendor.phoneNumber, vendor.vendorInfo.phone); // todo: change input after fix + await this.clearAndType(vendors.editVendor.email, vendor.username + data.vendor.vendorInfo.emailDomain); + await this.clearAndType(vendors.editVendor.companyName, vendor.vendorInfo.companyName); + await this.clearAndType(vendors.editVendor.companyIdEuidNumber, vendor.vendorInfo.companyId); + await this.clearAndType(vendors.editVendor.vatOrTaxNumber, vendor.vendorInfo.vatNumber); + await this.clearAndType(vendors.editVendor.nameOfBank, vendor.vendorInfo.bankName); + await this.clearAndType(vendors.editVendor.bankIban, vendor.vendorInfo.bankIban); // address - await this.clearAndType(selector.admin.dokan.vendors.editVendor.street1, vendor.vendorInfo.street1); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.street2, vendor.vendorInfo.street2); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.city, vendor.vendorInfo.city); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.zipCode, vendor.vendorInfo.zipCode); - await this.click(selector.admin.dokan.vendors.editVendor.country); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.countryInput, vendor.vendorInfo.country); + await this.clearAndType(vendors.editVendor.street1, vendor.vendorInfo.street1); + await this.clearAndType(vendors.editVendor.street2, vendor.vendorInfo.street2); + await this.clearAndType(vendors.editVendor.city, vendor.vendorInfo.city); + await this.clearAndType(vendors.editVendor.zipCode, vendor.vendorInfo.zipCode); + await this.click(vendors.editVendor.country); + await this.clearAndType(vendors.editVendor.countryInput, vendor.vendorInfo.country); await this.press(data.key.enter); - await this.click(selector.admin.dokan.vendors.editVendor.state); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.stateInput, vendor.vendorInfo.state); + await this.click(vendors.editVendor.state); + await this.clearAndType(vendors.editVendor.stateInput, vendor.vendorInfo.state); await this.press(data.key.enter); // social options - await this.clearAndType(selector.admin.dokan.vendors.editVendor.facebook, vendor.vendorInfo.socialProfileUrls.facebook); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.flickr, vendor.vendorInfo.socialProfileUrls.flickr); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.twitter, vendor.vendorInfo.socialProfileUrls.twitter); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.youtube, vendor.vendorInfo.socialProfileUrls.youtube); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.linkedin, vendor.vendorInfo.socialProfileUrls.linkedin); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.pinterest, vendor.vendorInfo.socialProfileUrls.pinterest); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.instagram, vendor.vendorInfo.socialProfileUrls.instagram); + await this.clearAndType(vendors.editVendor.facebook, vendor.vendorInfo.socialProfileUrls.facebook); + await this.clearAndType(vendors.editVendor.flickr, vendor.vendorInfo.socialProfileUrls.flickr); + await this.clearAndType(vendors.editVendor.twitter, vendor.vendorInfo.socialProfileUrls.twitter); + await this.clearAndType(vendors.editVendor.youtube, vendor.vendorInfo.socialProfileUrls.youtube); + await this.clearAndType(vendors.editVendor.linkedin, vendor.vendorInfo.socialProfileUrls.linkedin); + await this.clearAndType(vendors.editVendor.pinterest, vendor.vendorInfo.socialProfileUrls.pinterest); + await this.clearAndType(vendors.editVendor.instagram, vendor.vendorInfo.socialProfileUrls.instagram); // payment options // bank - await this.clearAndType(selector.admin.dokan.vendors.editVendor.accountName, vendor.vendorInfo.payment.bankAccountName); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.accountNumber, vendor.vendorInfo.payment.bankAccountNumber); - await this.selectByValue(selector.admin.dokan.vendors.editVendor.accountType, vendor.vendorInfo.payment.bankAccountType); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.bankName, vendor.vendorInfo.payment.bankName); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.bankAddress, vendor.vendorInfo.payment.bankAddress); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.routingNumber, vendor.vendorInfo.payment.bankRoutingNumber); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.iban, vendor.vendorInfo.payment.bankIban); - await this.clearAndType(selector.admin.dokan.vendors.editVendor.swift, vendor.vendorInfo.payment.bankSwiftCode); + await this.clearAndType(vendors.editVendor.accountName, vendor.vendorInfo.payment.bankAccountName); + await this.clearAndType(vendors.editVendor.accountNumber, vendor.vendorInfo.payment.bankAccountNumber); + await this.selectByValue(vendors.editVendor.accountType, vendor.vendorInfo.payment.bankAccountType); + await this.clearAndType(vendors.editVendor.bankName, vendor.vendorInfo.payment.bankName); + await this.clearAndType(vendors.editVendor.bankAddress, vendor.vendorInfo.payment.bankAddress); + await this.clearAndType(vendors.editVendor.routingNumber, vendor.vendorInfo.payment.bankRoutingNumber); + await this.clearAndType(vendors.editVendor.iban, vendor.vendorInfo.payment.bankIban); + await this.clearAndType(vendors.editVendor.swift, vendor.vendorInfo.payment.bankSwiftCode); // paypal - await this.clearAndType(selector.admin.dokan.vendors.editVendor.payPalEmail, vendor.vendorInfo.payment.email()); + await this.clearAndType(vendors.editVendor.payPalEmail, vendor.vendorInfo.payment.email()); // todo: admin commission // todo: vendor subscription // other settings - await this.enableSwitcher(selector.admin.dokan.vendors.editVendor.enableSelling); - await this.enableSwitcher(selector.admin.dokan.vendors.editVendor.publishProductDirectly); - await this.enableSwitcher(selector.admin.dokan.vendors.editVendor.makeVendorFeature); + await this.enableSwitcher(vendors.editVendor.enableSelling); + await this.enableSwitcher(vendors.editVendor.publishProductDirectly); + await this.enableSwitcher(vendors.editVendor.makeVendorFeature); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.stores, selector.admin.dokan.vendors.editVendor.saveChanges); - await this.click(selector.admin.dokan.vendors.editVendor.confirmSaveChanges); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.stores, vendors.editVendor.saveChanges); + await this.click(vendors.editVendor.confirmSaveChanges); } } // search vendor - async searchVendor(vendorName: string) { + async searchVendor(vendorName: string, neg: boolean = false) { await this.goIfNotThere(data.subUrls.backend.dokan.vendors); - await this.clearInputField(selector.admin.dokan.vendors.search); - - await this.typeAndWaitForResponseAndLoadState(data.subUrls.api.dokan.stores, selector.admin.dokan.vendors.search, vendorName); - await this.toBeVisible(selector.admin.dokan.vendors.vendorCell(vendorName)); + await this.clearInputField(vendors.search); + await this.typeAndWaitForResponseAndLoadState(data.subUrls.api.dokan.stores, vendors.search, vendorName); + await this.toBeVisible(vendors.vendorCell(vendorName)); // negative scenario - // await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, selector.admin.dokan.vendors.search, vendorName + 'abcdefgh'); - // await this.toBeVisible(selector.admin.dokan.vendors.noRowsFound); + if (neg) { + await this.typeAndWaitForResponse(data.subUrls.api.dokan.stores, vendors.search, vendorName + 'abcdefgh'); + await this.toBeVisible(vendors.noRowsFound); + } } // update vendor @@ -314,11 +320,11 @@ export class StoresPage extends AdminPage { switch (action) { case 'enable': - await this.enableSwitcherAndWaitForResponse(data.subUrls.api.dokan.stores, selector.admin.dokan.vendors.statusSlider(vendorName)); + await this.enableSwitcherAndWaitForResponse(data.subUrls.api.dokan.stores, vendors.statusSlider(vendorName)); break; case 'disable': - await this.disableSwitcherAndWaitForResponse(data.subUrls.api.dokan.stores, selector.admin.dokan.vendors.statusSlider(vendorName)); + await this.disableSwitcherAndWaitForResponse(data.subUrls.api.dokan.stores, vendors.statusSlider(vendorName)); break; default: @@ -330,22 +336,22 @@ export class StoresPage extends AdminPage { async viewVendor(vendorName: string, action: string) { await this.searchVendor(vendorName); - await this.hover(selector.admin.dokan.vendors.vendorRow(vendorName)); + await this.hover(vendors.vendorRow(vendorName)); switch (action) { case 'products': - await this.clickAndWaitForLoadState(selector.admin.dokan.vendors.vendorProducts(vendorName)); + await this.clickAndWaitForLoadState(vendors.vendorProducts(vendorName)); break; case 'orders': - await this.clickAndWaitForLoadState(selector.admin.dokan.vendors.vendorOrders(vendorName)); + await this.clickAndWaitForLoadState(vendors.vendorOrders(vendorName)); break; default: break; } - const count = (await this.getElementText(selector.admin.dokan.vendors.numberOfRowsFound))?.split(' ')[0]; + const count = (await this.getElementText(vendors.numberOfRowsFound))?.split(' ')[0]; expect(Number(count)).toBeGreaterThan(0); } @@ -354,10 +360,10 @@ export class StoresPage extends AdminPage { vendorName ? await this.searchVendor(vendorName) : await this.goIfNotThere(data.subUrls.backend.dokan.vendors); // ensure row exists - await this.notToBeVisible(selector.admin.dokan.vendors.noRowsFound); + await this.notToBeVisible(vendors.noRowsFound); - await this.click(selector.admin.dokan.vendors.bulkActions.selectAll); - await this.selectByValue(selector.admin.dokan.vendors.bulkActions.selectAction, action); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.stores, selector.admin.dokan.vendors.bulkActions.applyAction); + await this.click(vendors.bulkActions.selectAll); + await this.selectByValue(vendors.bulkActions.selectAction, action); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.stores, vendors.bulkActions.applyAction); } } diff --git a/tests/pw/pages/taxPage.ts b/tests/pw/pages/taxPage.ts index 961fa2143d..e80e2ca874 100644 --- a/tests/pw/pages/taxPage.ts +++ b/tests/pw/pages/taxPage.ts @@ -4,6 +4,9 @@ import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; import { tax } from '@utils/interfaces'; +// selectors +const woocommerceSettings = selector.admin.wooCommerce.settings; + export class TaxPage extends AdminPage { constructor(page: Page) { super(page); @@ -14,9 +17,9 @@ export class TaxPage extends AdminPage { // Admin Enable-Disable Tax async enableTax(enable = true) { await this.goToWooCommerceSettings(); - enable ? await this.check(selector.admin.wooCommerce.settings.enableTaxes) : await this.uncheck(selector.admin.wooCommerce.settings.enableTaxes); - await this.click(selector.admin.wooCommerce.settings.generalSaveChanges); - await this.toContainText(selector.admin.wooCommerce.settings.updatedSuccessMessage, data.tax.saveSuccessMessage); + enable ? await this.check(woocommerceSettings.enableTaxes) : await this.uncheck(woocommerceSettings.enableTaxes); + await this.click(woocommerceSettings.generalSaveChanges); + await this.toContainText(woocommerceSettings.updatedSuccessMessage, data.tax.saveSuccessMessage); } // Admin Add Standard Tax Rate @@ -27,18 +30,18 @@ export class TaxPage extends AdminPage { await this.enableTax(); // Set Tax Rate - await this.click(selector.admin.wooCommerce.settings.tax); - await this.click(selector.admin.wooCommerce.settings.standardRates); - const taxIsVisible = await this.isVisible(selector.admin.wooCommerce.settings.taxRate); + await this.click(woocommerceSettings.tax); + await this.click(woocommerceSettings.standardRates); + const taxIsVisible = await this.isVisible(woocommerceSettings.taxRate); if (!taxIsVisible) { - await this.click(selector.admin.wooCommerce.settings.insertRow); + await this.click(woocommerceSettings.insertRow); } - await this.clearAndType(selector.admin.wooCommerce.settings.taxRate, tax.taxRate); - await this.click(selector.admin.wooCommerce.settings.taxTable); + await this.clearAndType(woocommerceSettings.taxRate, tax.taxRate); + await this.click(woocommerceSettings.taxTable); - await this.click(selector.admin.wooCommerce.settings.taxRateSaveChanges); + await this.click(woocommerceSettings.taxRateSaveChanges); - const newTaxRate = await this.getElementValue(selector.admin.wooCommerce.settings.taxRate); + const newTaxRate = await this.getElementValue(woocommerceSettings.taxRate); // expect(newTaxRate).toBe(String(Number(tax.taxRate).toPrecision(5))) expect(newTaxRate).toBe(tax.taxRate); } diff --git a/tests/pw/pages/toolsPage.ts b/tests/pw/pages/toolsPage.ts index d8a241f96e..7f211bcb60 100644 --- a/tests/pw/pages/toolsPage.ts +++ b/tests/pw/pages/toolsPage.ts @@ -4,6 +4,9 @@ import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; import { tools } from '@utils/interfaces'; +// selectors +const toolsAdmin = selector.admin.dokan.tools; + export class ToolsPage extends AdminPage { constructor(page: Page) { super(page); @@ -16,28 +19,28 @@ export class ToolsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.tools); // tools text is visible - await this.toBeVisible(selector.admin.dokan.tools.toolsText); + await this.toBeVisible(toolsAdmin.toolsText); // Page Installation elements are visible - await this.multipleElementVisible(selector.admin.dokan.tools.pageInstallation); + await this.multipleElementVisible(toolsAdmin.pageInstallation); // Check For Regenerate Order commission are visible - await this.multipleElementVisible(selector.admin.dokan.tools.regenerateOrderCommission); + await this.multipleElementVisible(toolsAdmin.regenerateOrderCommission); // Check For Duplicate Orders are visible - await this.multipleElementVisible(selector.admin.dokan.tools.checkForDuplicateOrders); + await this.multipleElementVisible(toolsAdmin.checkForDuplicateOrders); // Dokan Setup Wizard elements are visible - await this.multipleElementVisible(selector.admin.dokan.tools.dokanSetupWizard); + await this.multipleElementVisible(toolsAdmin.dokanSetupWizard); // Regenerate Variable Product Variations Author Ids elements are visible elements are visible - await this.multipleElementVisible(selector.admin.dokan.tools.regenerateVariableProductVariationsAuthorIds); + await this.multipleElementVisible(toolsAdmin.regenerateVariableProductVariationsAuthorIds); // Import Dummy Data elements are visible - await this.multipleElementVisible(selector.admin.dokan.tools.importDummyData); + await this.multipleElementVisible(toolsAdmin.importDummyData); // Test Distance Matrix API (Google MAP) elements are visible - const { enabledSuccess, ...testDistanceMatrixApi } = selector.admin.dokan.tools.testDistanceMatrixApi; + const { enabledSuccess, ...testDistanceMatrixApi } = toolsAdmin.testDistanceMatrixApi; await this.multipleElementVisible(testDistanceMatrixApi); } @@ -46,34 +49,34 @@ export class ToolsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.tools); // all page created button should be disabled - await this.hasClass(selector.admin.dokan.tools.pageInstallation.allPagesCreated, 'button-disabled'); + await this.hasClass(toolsAdmin.pageInstallation.allPagesCreated, 'button-disabled'); // todo: enable the button then install pages again - // await this.setAttributeValue(selector.admin.dokan.tools.pageInstallation.allPagesCreated, 'class', 'button button-primary'); - // await this.clickAndWaitForResponse(data.subUrls.ajax, selector.admin.dokan.tools.pageInstallation.allPagesCreated); + // await this.setAttributeValue(toolsAdmin.pageInstallation.allPagesCreated, 'class', 'button button-primary'); + // await this.clickAndWaitForResponse(data.subUrls.ajax, toolsAdmin.pageInstallation.allPagesCreated); } // regenerate variable product variations author IDs async regenerateOrderCommission() { await this.goIfNotThere(data.subUrls.backend.dokan.tools); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.admin.dokan.tools.regenerateOrderCommission.regenerate); + await this.clickAndWaitForResponse(data.subUrls.ajax, toolsAdmin.regenerateOrderCommission.regenerate); } // check for duplicate order async checkForDuplicateOrders() { await this.goIfNotThere(data.subUrls.backend.dokan.tools); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.admin.dokan.tools.checkForDuplicateOrders.checkOrders); + await this.clickAndWaitForResponse(data.subUrls.ajax, toolsAdmin.checkForDuplicateOrders.checkOrders); } // regenerate variable product variations author IDs async regenerateVariableProductVariationsAuthorIds() { await this.goIfNotThere(data.subUrls.backend.dokan.tools); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.admin.dokan.tools.regenerateVariableProductVariationsAuthorIds.regenerate); + await this.clickAndWaitForResponse(data.subUrls.ajax, toolsAdmin.regenerateVariableProductVariationsAuthorIds.regenerate); } // clear dummy data async clearDummyData() { await this.goIfNotThere(data.subUrls.backend.dokan.tools); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.dummyData, selector.admin.dokan.tools.importDummyData.import); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.dummyData, toolsAdmin.importDummyData.import); await this.click(selector.admin.dokan.dummyData.clearDummyData); await this.clickAndWaitForResponse(data.subUrls.api.dokan.dummyData, selector.admin.dokan.dummyData.confirmClearDummyData); } @@ -81,7 +84,7 @@ export class ToolsPage extends AdminPage { // import dummy data async importDummyData() { await this.goIfNotThere(data.subUrls.backend.dokan.tools); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.dummyData, selector.admin.dokan.tools.importDummyData.import); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.dummyData, toolsAdmin.importDummyData.import); // await this.clickAndWaitForResponse(data.subUrls.api.dokan.dummyData, selector.admin.dokan.dummyData.runTheImporter); // todo: wait for multiple request one after another // const subUrls = [[data.subUrls.api.dokan.dummyData], [data.subUrls.api.dokan.dummyData], [data.subUrls.api.dokan.dummyData], [data.subUrls.api.dokan.dummyData], [data.subUrls.api.dokan.dummyData]]; @@ -93,9 +96,9 @@ export class ToolsPage extends AdminPage { async testDistanceMatrixApi(address: tools['distanceMatrixApi']) { await this.goIfNotThere(data.subUrls.backend.dokan.tools); - await this.clearAndType(selector.admin.dokan.tools.testDistanceMatrixApi.address1, address.address3); - await this.clearAndType(selector.admin.dokan.tools.testDistanceMatrixApi.address2, address.address4); - await this.click(selector.admin.dokan.tools.testDistanceMatrixApi.getDistance); - await this.toContainText(selector.admin.dokan.tools.testDistanceMatrixApi.enabledSuccess, 'Distance Matrix API is enabled.'); + await this.clearAndType(toolsAdmin.testDistanceMatrixApi.address1, address.address3); + await this.clearAndType(toolsAdmin.testDistanceMatrixApi.address2, address.address4); + await this.click(toolsAdmin.testDistanceMatrixApi.getDistance); + await this.toContainText(toolsAdmin.testDistanceMatrixApi.enabledSuccess, 'Distance Matrix API is enabled.'); } } diff --git a/tests/pw/pages/vendorAnalyticsPage.ts b/tests/pw/pages/vendorAnalyticsPage.ts index b474cdc504..fbb9c7d437 100644 --- a/tests/pw/pages/vendorAnalyticsPage.ts +++ b/tests/pw/pages/vendorAnalyticsPage.ts @@ -3,6 +3,9 @@ import { VendorPage } from '@pages/vendorPage'; import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; +// selectors +const vendorAnalytics = selector.vendor.vAnalytics; + export class VendorAnalyticsPage extends VendorPage { constructor(page: Page) { super(page); @@ -15,28 +18,28 @@ export class VendorAnalyticsPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.analytics); // analytics text is visible - await this.toBeVisible(selector.vendor.vAnalytics.analyticsText); + await this.toBeVisible(vendorAnalytics.analyticsText); // analytics menu elements are visible - await this.multipleElementVisible(selector.vendor.vAnalytics.menus); + await this.multipleElementVisible(vendorAnalytics.menus); // date-picker elements are visible - const { dateRangePickerinput, show } = selector.vendor.vAnalytics.datePicker; + const { dateRangePickerinput, show } = vendorAnalytics.datePicker; await this.multipleElementVisible({ dateRangePickerinput, show }); - await this.clickAndWaitForLoadState(selector.vendor.vAnalytics.menus.topPages); - await this.toBeVisible(selector.vendor.vAnalytics.noAnalyticsFound); + await this.clickAndWaitForLoadState(vendorAnalytics.menus.topPages); + await this.toBeVisible(vendorAnalytics.noAnalyticsFound); - await this.clickAndWaitForLoadState(selector.vendor.vAnalytics.menus.location); - await this.toBeVisible(selector.vendor.vAnalytics.noAnalyticsFound); + await this.clickAndWaitForLoadState(vendorAnalytics.menus.location); + await this.toBeVisible(vendorAnalytics.noAnalyticsFound); - await this.clickAndWaitForLoadState(selector.vendor.vAnalytics.menus.system); - await this.toBeVisible(selector.vendor.vAnalytics.noAnalyticsFound); + await this.clickAndWaitForLoadState(vendorAnalytics.menus.system); + await this.toBeVisible(vendorAnalytics.noAnalyticsFound); - await this.clickAndWaitForLoadState(selector.vendor.vAnalytics.menus.promotions); - await this.toBeVisible(selector.vendor.vAnalytics.noAnalyticsFound); + await this.clickAndWaitForLoadState(vendorAnalytics.menus.promotions); + await this.toBeVisible(vendorAnalytics.noAnalyticsFound); - await this.clickAndWaitForLoadState(selector.vendor.vAnalytics.menus.keyword); - await this.toBeVisible(selector.vendor.vAnalytics.noAnalyticsFound); + await this.clickAndWaitForLoadState(vendorAnalytics.menus.keyword); + await this.toBeVisible(vendorAnalytics.noAnalyticsFound); } } diff --git a/tests/pw/pages/vendorAuctionsPage.ts b/tests/pw/pages/vendorAuctionsPage.ts index 1eb9d77e1a..04472bb328 100644 --- a/tests/pw/pages/vendorAuctionsPage.ts +++ b/tests/pw/pages/vendorAuctionsPage.ts @@ -6,6 +6,10 @@ import { data } from '@utils/testData'; import { helpers } from '@utils/helpers'; import { product, date } from '@utils/interfaces'; +// selectors +const auctionProductsAdmin = selector.admin.products; +const auctionProductsVendor = selector.vendor.vAuction; + export class AuctionsPage extends VendorPage { constructor(page: Page) { super(page); @@ -20,28 +24,28 @@ export class AuctionsPage extends VendorPage { await this.goIfNotThere(data.subUrls.backend.wc.addNewProducts); // Name - await this.clearAndType(selector.admin.products.product.productName, product.productName()); - await this.selectByValue(selector.admin.products.product.productType, product.productType); - await this.click(selector.admin.products.product.auction); - await this.selectByValue(selector.admin.products.product.itemCondition, product.itemCondition); - await this.selectByValue(selector.admin.products.product.auctionType, product.auctionType); - await this.clearAndType(selector.admin.products.product.startPrice, product.regularPrice()); - await this.clearAndType(selector.admin.products.product.bidIncrement, product.bidIncrement()); - await this.clearAndType(selector.admin.products.product.reservedPrice, product.reservedPrice()); - await this.clearAndType(selector.admin.products.product.buyItNowPrice, product.buyItNowPrice()); - await this.clearAndType(selector.admin.products.product.auctionDatesFrom, product.startDate); - await this.clearAndType(selector.admin.products.product.auctionDatesTo, product.endDate); + await this.clearAndType(auctionProductsAdmin.product.productName, product.productName()); + await this.selectByValue(auctionProductsAdmin.product.productType, product.productType); + await this.click(auctionProductsAdmin.product.auction); + await this.selectByValue(auctionProductsAdmin.product.itemCondition, product.itemCondition); + await this.selectByValue(auctionProductsAdmin.product.auctionType, product.auctionType); + await this.clearAndType(auctionProductsAdmin.product.startPrice, product.regularPrice()); + await this.clearAndType(auctionProductsAdmin.product.bidIncrement, product.bidIncrement()); + await this.clearAndType(auctionProductsAdmin.product.reservedPrice, product.reservedPrice()); + await this.clearAndType(auctionProductsAdmin.product.buyItNowPrice, product.buyItNowPrice()); + await this.clearAndType(auctionProductsAdmin.product.auctionDatesFrom, product.startDate); + await this.clearAndType(auctionProductsAdmin.product.auctionDatesTo, product.endDate); // Category - await this.click(selector.admin.products.product.category(product.category)); + await this.click(auctionProductsAdmin.product.category(product.category)); // Vendor Store Name - await this.select2ByText(selector.admin.products.product.storeName, selector.admin.products.product.storeNameInput, product.storeName); + await this.select2ByText(auctionProductsAdmin.product.storeName, auctionProductsAdmin.product.storeNameInput, product.storeName); await this.scrollToTop(); // Publish - await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, selector.admin.products.product.publish, 302); - await this.toContainText(selector.admin.products.product.updatedSuccessMessage, data.product.publishSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, auctionProductsAdmin.product.publish, 302); + await this.toContainText(auctionProductsAdmin.product.updatedSuccessMessage, data.product.publishSuccessMessage); } // vendor auction render properly @@ -49,94 +53,94 @@ export class AuctionsPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.auction); // auctions menu elements are visible - await this.multipleElementVisible(selector.vendor.vAuction.menus); + await this.multipleElementVisible(auctionProductsVendor.menus); // add new auction product button is visible - await this.toBeVisible(selector.vendor.vAuction.addNewActionProduct); + await this.toBeVisible(auctionProductsVendor.addNewActionProduct); // auction activity button is visible - await this.toBeVisible(selector.vendor.vAuction.actionsActivity); + await this.toBeVisible(auctionProductsVendor.actionsActivity); // filter elements are visible - await this.multipleElementVisible(selector.vendor.vAuction.filters); + await this.multipleElementVisible(auctionProductsVendor.filters); // search element is visible - await this.toBeVisible(selector.vendor.vAuction.search); + await this.toBeVisible(auctionProductsVendor.search); // auction product table elements are visible - await this.multipleElementVisible(selector.vendor.vAuction.table); + await this.multipleElementVisible(auctionProductsVendor.table); } // vendor // update auction product fields async updateAuctionProductFields(product: product['auction']) { - await this.clearAndType(selector.vendor.vAuction.auction.productName, product.name); + await this.clearAndType(auctionProductsVendor.auction.productName, product.name); // await this.addProductCategory(product.category); - await this.selectByValue(selector.vendor.vAuction.auction.itemCondition, product.itemCondition); - await this.selectByValue(selector.vendor.vAuction.auction.auctionType, product.auctionType); - await this.clearAndType(selector.vendor.vAuction.auction.startPrice, product.regularPrice()); - await this.clearAndType(selector.vendor.vAuction.auction.bidIncrement, product.bidIncrement()); - await this.clearAndType(selector.vendor.vAuction.auction.reservedPrice, product.reservedPrice()); - await this.clearAndType(selector.vendor.vAuction.auction.buyItNowPrice, product.buyItNowPrice()); - await this.removeAttribute(selector.vendor.vAuction.auction.auctionStartDate, 'readonly'); - await this.removeAttribute(selector.vendor.vAuction.auction.auctionEndDate, 'readonly'); - await this.clearAndType(selector.vendor.vAuction.auction.auctionStartDate, product.startDate); - await this.clearAndType(selector.vendor.vAuction.auction.auctionEndDate, product.endDate); + await this.selectByValue(auctionProductsVendor.auction.itemCondition, product.itemCondition); + await this.selectByValue(auctionProductsVendor.auction.auctionType, product.auctionType); + await this.clearAndType(auctionProductsVendor.auction.startPrice, product.regularPrice()); + await this.clearAndType(auctionProductsVendor.auction.bidIncrement, product.bidIncrement()); + await this.clearAndType(auctionProductsVendor.auction.reservedPrice, product.reservedPrice()); + await this.clearAndType(auctionProductsVendor.auction.buyItNowPrice, product.buyItNowPrice()); + await this.removeAttribute(auctionProductsVendor.auction.auctionStartDate, 'readonly'); + await this.removeAttribute(auctionProductsVendor.auction.auctionEndDate, 'readonly'); + await this.clearAndType(auctionProductsVendor.auction.auctionStartDate, product.startDate); + await this.clearAndType(auctionProductsVendor.auction.auctionEndDate, product.endDate); // todo: add more fields } // add auction product async addAuctionProduct(product: product['auction']) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.auction); - await this.clickAndWaitForLoadState(selector.vendor.vAuction.addNewActionProduct); + await this.clickAndWaitForLoadState(auctionProductsVendor.addNewActionProduct); await this.updateAuctionProductFields(product); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.productAuction, selector.vendor.vAuction.auction.addAuctionProduct, 302); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.productAuction, auctionProductsVendor.auction.addAuctionProduct, 302); await this.toContainText(selector.vendor.product.updatedSuccessMessage, product.saveSuccessMessage); } // edit auction product async editAuctionProduct(product: product['auction']) { await this.searchAuctionProduct(product.name); - await this.hover(selector.vendor.vAuction.productCell(product.name)); - await this.clickAndWaitForLoadState(selector.vendor.vAuction.edit(product.name)); + await this.hover(auctionProductsVendor.productCell(product.name)); + await this.clickAndWaitForLoadState(auctionProductsVendor.edit(product.name)); await this.updateAuctionProductFields(product); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.auction, selector.vendor.vAuction.auction.updateAuctionProduct, 302); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.auction, auctionProductsVendor.auction.updateAuctionProduct, 302); await this.toContainText(selector.vendor.product.updatedSuccessMessage, product.saveSuccessMessage); } // view auction product async viewAuctionProduct(productName: string) { await this.searchAuctionProduct(productName); - await this.hover(selector.vendor.vAuction.productCell(productName)); - await this.clickAndWaitForLoadState(selector.vendor.vAuction.view(productName)); + await this.hover(auctionProductsVendor.productCell(productName)); + await this.clickAndWaitForLoadState(auctionProductsVendor.view(productName)); // auction product elements are visible - const { bidQuantity, bidButton, ...viewAuction } = selector.vendor.vAuction.viewAuction; + const { bidQuantity, bidButton, ...viewAuction } = auctionProductsVendor.viewAuction; await this.multipleElementVisible(viewAuction); } // vendor can't bid own auction product async cantBidOwnProduct(productName: string) { await this.goToProductDetails(productName); - await this.toBeVisible(selector.vendor.vAuction.viewAuction.noBidOption); + await this.toBeVisible(auctionProductsVendor.viewAuction.noBidOption); } // search auction product async searchAuctionProduct(productName: string) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.auction); - await this.clearAndType(selector.vendor.vAuction.search, productName); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.auction, selector.vendor.vAuction.filters.filter); - await this.toBeVisible(selector.vendor.vAuction.productCell(productName)); + await this.clearAndType(auctionProductsVendor.search, productName); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.auction, auctionProductsVendor.filters.filter); + await this.toBeVisible(auctionProductsVendor.productCell(productName)); } // delete auction product async deleteAuctionProduct(productName: string) { await this.searchAuctionProduct(productName); - await this.hover(selector.vendor.vAuction.productCell(productName)); - await this.click(selector.vendor.vAuction.permanentlyDelete(productName)); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.auction, selector.vendor.vAuction.confirmDelete); - await this.toContainText(selector.vendor.vAuction.dokanSuccessMessage, 'Product successfully deleted'); + await this.hover(auctionProductsVendor.productCell(productName)); + await this.click(auctionProductsVendor.permanentlyDelete(productName)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.auction, auctionProductsVendor.confirmDelete); + await this.toContainText(auctionProductsVendor.dokanSuccessMessage, 'Product successfully deleted'); } // vendor auction activity render properly @@ -144,46 +148,46 @@ export class AuctionsPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.auctionActivity); // auction activity text is visible - await this.toBeVisible(selector.vendor.vAuction.actionActivity.actionActivityText); + await this.toBeVisible(auctionProductsVendor.actionActivity.actionActivityText); // back to auctions is visible - await this.toBeVisible(selector.vendor.vAuction.actionActivity.backToActions); + await this.toBeVisible(auctionProductsVendor.actionActivity.backToActions); // filter elements are visible - const { filterByDate, ...filters } = selector.vendor.vAuction.actionActivity.filters; + const { filterByDate, ...filters } = auctionProductsVendor.actionActivity.filters; await this.multipleElementVisible(filters); await this.toBeVisible(filterByDate.dateRangeInput); // search elements are visible - await this.multipleElementVisible(selector.vendor.vAuction.actionActivity.search); + await this.multipleElementVisible(auctionProductsVendor.actionActivity.search); // auction activity table elements are visible - await this.multipleElementVisible(selector.vendor.vAuction.actionActivity.table); + await this.multipleElementVisible(auctionProductsVendor.actionActivity.table); } // filter auction activity async filterAuctionActivity(inputValue: date['dateRange']) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.auctionActivity); - await this.setAttributeValue(selector.vendor.vAuction.actionActivity.filters.filterByDate.dateRangeInput, 'value', helpers.dateFormatFYJ(inputValue.startDate) + ' - ' + helpers.dateFormatFYJ(inputValue.endDate)); - await this.setAttributeValue(selector.vendor.vAuction.actionActivity.filters.filterByDate.startDateInput, 'value', inputValue.startDate); - await this.setAttributeValue(selector.vendor.vAuction.actionActivity.filters.filterByDate.endDateInput, 'value', inputValue.endDate); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.auctionActivity, selector.vendor.vAuction.actionActivity.filters.filter); - await this.notToHaveCount(selector.vendor.vAuction.actionActivity.numOfRowsFound, 0); + await this.setAttributeValue(auctionProductsVendor.actionActivity.filters.filterByDate.dateRangeInput, 'value', helpers.dateFormatFYJ(inputValue.startDate) + ' - ' + helpers.dateFormatFYJ(inputValue.endDate)); + await this.setAttributeValue(auctionProductsVendor.actionActivity.filters.filterByDate.startDateInput, 'value', inputValue.startDate); + await this.setAttributeValue(auctionProductsVendor.actionActivity.filters.filterByDate.endDateInput, 'value', inputValue.endDate); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.auctionActivity, auctionProductsVendor.actionActivity.filters.filter); + await this.notToHaveCount(auctionProductsVendor.actionActivity.numOfRowsFound, 0); } // search auction activity async searchAuctionActivity(input: string) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.auctionActivity); - await this.clearAndType(selector.vendor.vAuction.actionActivity.search.searchInput, input); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.auctionActivity, selector.vendor.vAuction.actionActivity.search.search); - await this.notToHaveCount(selector.vendor.vAuction.actionActivity.numOfRowsFound, 0); + await this.clearAndType(auctionProductsVendor.actionActivity.search.searchInput, input); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.auctionActivity, auctionProductsVendor.actionActivity.search.search); + await this.notToHaveCount(auctionProductsVendor.actionActivity.numOfRowsFound, 0); } // customer async bidAuctionProduct(productName: string) { await this.goToProductDetails(productName); - await this.click(selector.vendor.vAuction.viewAuction.bidButton); + await this.click(auctionProductsVendor.viewAuction.bidButton); } async buyAuctionProduct(productName: string) { diff --git a/tests/pw/pages/vendorBookingPage.ts b/tests/pw/pages/vendorBookingPage.ts index 1053c1bc92..2c2481fff2 100644 --- a/tests/pw/pages/vendorBookingPage.ts +++ b/tests/pw/pages/vendorBookingPage.ts @@ -6,6 +6,10 @@ import { data } from '@utils/testData'; import { helpers } from '@utils/helpers'; import { product, bookings, bookingResource } from '@utils/interfaces'; +// selectors +const bookingProductsAdmin = selector.admin.products; +const bookingProductsVendor = selector.vendor.vBooking; + export class BookingPage extends VendorPage { constructor(page: Page) { super(page); @@ -20,28 +24,28 @@ export class BookingPage extends VendorPage { await this.goIfNotThere(data.subUrls.backend.wc.addNewProducts); // Name - await this.clearAndType(selector.admin.products.product.productName, product.productName()); - await this.selectByValue(selector.admin.products.product.productType, product.productType); - await this.click(selector.admin.products.product.general); - await this.selectByValue(selector.admin.products.product.bookingDurationType, product.bookingDurationType); - await this.clearAndType(selector.admin.products.product.bookingDurationMax, product.bookingDurationMax); - await this.selectByValue(selector.admin.products.product.calendarDisplayMode, product.calendarDisplayMode); + await this.clearAndType(bookingProductsAdmin.product.productName, product.productName()); + await this.selectByValue(bookingProductsAdmin.product.productType, product.productType); + await this.click(bookingProductsAdmin.product.general); + await this.selectByValue(bookingProductsAdmin.product.bookingDurationType, product.bookingDurationType); + await this.clearAndType(bookingProductsAdmin.product.bookingDurationMax, product.bookingDurationMax); + await this.selectByValue(bookingProductsAdmin.product.calendarDisplayMode, product.calendarDisplayMode); // Costs - await this.click(selector.admin.products.product.bookingCosts); - await this.clearAndType(selector.admin.products.product.baseCost, product.baseCost); - await this.clearAndType(selector.admin.products.product.blockCost, product.blockCost); + await this.click(bookingProductsAdmin.product.bookingCosts); + await this.clearAndType(bookingProductsAdmin.product.baseCost, product.baseCost); + await this.clearAndType(bookingProductsAdmin.product.blockCost, product.blockCost); // Category - await this.click(selector.admin.products.product.category(product.category)); + await this.click(bookingProductsAdmin.product.category(product.category)); // Vendor Store Name - await this.select2ByText(selector.admin.products.product.storeName, selector.admin.products.product.storeNameInput, product.storeName); + await this.select2ByText(bookingProductsAdmin.product.storeName, bookingProductsAdmin.product.storeNameInput, product.storeName); await this.scrollToTop(); // Publish - await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, selector.admin.products.product.publish, 302); - await this.toContainText(selector.admin.products.product.updatedSuccessMessage, data.product.publishSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, bookingProductsAdmin.product.publish, 302); + await this.toContainText(bookingProductsAdmin.product.updatedSuccessMessage, data.product.publishSuccessMessage); } // vendor @@ -51,25 +55,25 @@ export class BookingPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.booking); // add booking product text is visible - await this.toBeVisible(selector.vendor.vBooking.allBookingProductText); + await this.toBeVisible(bookingProductsVendor.allBookingProductText); // booking menu elements are visible - await this.multipleElementVisible(selector.vendor.vBooking.menus); + await this.multipleElementVisible(bookingProductsVendor.menus); // add new booking product button is visible - await this.toBeVisible(selector.vendor.vBooking.addNewBookingProduct); + await this.toBeVisible(bookingProductsVendor.addNewBookingProduct); // add booking button is visible - await this.toBeVisible(selector.vendor.vBooking.addBookingBtn); + await this.toBeVisible(bookingProductsVendor.addBookingBtn); // filter elements are visible - await this.multipleElementVisible(selector.vendor.vBooking.filters); + await this.multipleElementVisible(bookingProductsVendor.filters); // search elements are visible - await this.multipleElementVisible(selector.vendor.vBooking.search); + await this.multipleElementVisible(bookingProductsVendor.search); // booking product table elements are visible - await this.multipleElementVisible(selector.vendor.vBooking.table); + await this.multipleElementVisible(bookingProductsVendor.table); } // vendor manage booking render properly @@ -77,12 +81,12 @@ export class BookingPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.manageBooking); // manage booking text is visible - await this.toBeVisible(selector.vendor.vBooking.manageBookings.manageBookingsText); + await this.toBeVisible(bookingProductsVendor.manageBookings.manageBookingsText); // manage booking menu elements are visible - await this.toBeVisible(selector.vendor.vBooking.manageBookings.menus.all); + await this.toBeVisible(bookingProductsVendor.manageBookings.menus.all); - const noBookingsFound = await this.isVisible(selector.vendor.vBooking.manageBookings.noBookingsFound); + const noBookingsFound = await this.isVisible(bookingProductsVendor.manageBookings.noBookingsFound); if (noBookingsFound) { return; } @@ -94,21 +98,21 @@ export class BookingPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.bookingCalendar); // manage booking text is visible - await this.toBeVisible(selector.vendor.vBooking.calendar.calendarText); + await this.toBeVisible(bookingProductsVendor.calendar.calendarText); // calendar is visible - await this.toBeVisible(selector.vendor.vBooking.calendar.calendar); + await this.toBeVisible(bookingProductsVendor.calendar.calendar); // calendar filterBookings is visible - await this.toBeVisible(selector.vendor.vBooking.calendar.filterBookings); + await this.toBeVisible(bookingProductsVendor.calendar.filterBookings); // calendar month view elements are visible - await this.multipleElementVisible(selector.vendor.vBooking.calendar.month); + await this.multipleElementVisible(bookingProductsVendor.calendar.month); - await this.clickAndWaitForLoadState(selector.vendor.vBooking.calendar.month.dayView); + await this.clickAndWaitForLoadState(bookingProductsVendor.calendar.month.dayView); // calendar day view elements are visible - await this.multipleElementVisible(selector.vendor.vBooking.calendar.day); + await this.multipleElementVisible(bookingProductsVendor.calendar.day); } // vendor manage booking render properly @@ -116,15 +120,15 @@ export class BookingPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.manageResources); // manage resource text is visible - await this.toBeVisible(selector.vendor.vBooking.manageResources.manageResourcesText); + await this.toBeVisible(bookingProductsVendor.manageResources.manageResourcesText); // add new resource is visible - await this.toBeVisible(selector.vendor.vBooking.manageResources.addNewResource); + await this.toBeVisible(bookingProductsVendor.manageResources.addNewResource); // booking product table elements are visible - await this.multipleElementVisible(selector.vendor.vBooking.manageResources.table); + await this.multipleElementVisible(bookingProductsVendor.manageResources.table); - const noBookingsFound = await this.isVisible(selector.vendor.vBooking.manageResources.noResourceFound); + const noBookingsFound = await this.isVisible(bookingProductsVendor.manageResources.noResourceFound); if (noBookingsFound) { return; } @@ -133,55 +137,55 @@ export class BookingPage extends VendorPage { // update booking product fields async updateBookingProductFields(product: product['booking']) { - await this.clearAndType(selector.vendor.vBooking.booking.productName, product.name); + await this.clearAndType(bookingProductsVendor.booking.productName, product.name); // await this.addProductCategory(product.category); // general booking options - await this.selectByValue(selector.vendor.vBooking.booking.bookingDurationType, product.bookingDurationType); - await this.clearAndType(selector.vendor.vBooking.booking.bookingDurationMin, product.bookingDurationMin); - await this.clearAndType(selector.vendor.vBooking.booking.bookingDurationMax, product.bookingDurationMax); - await this.selectByValue(selector.vendor.vBooking.booking.bookingDurationUnit, product.bookingDurationUnit); + await this.selectByValue(bookingProductsVendor.booking.bookingDurationType, product.bookingDurationType); + await this.clearAndType(bookingProductsVendor.booking.bookingDurationMin, product.bookingDurationMin); + await this.clearAndType(bookingProductsVendor.booking.bookingDurationMax, product.bookingDurationMax); + await this.selectByValue(bookingProductsVendor.booking.bookingDurationUnit, product.bookingDurationUnit); // calendar display mode - await this.selectByValue(selector.vendor.vBooking.booking.calendarDisplayMode, product.calendarDisplayMode); - await this.check(selector.vendor.vBooking.booking.enableCalendarRangePicker); + await this.selectByValue(bookingProductsVendor.booking.calendarDisplayMode, product.calendarDisplayMode); + await this.check(bookingProductsVendor.booking.enableCalendarRangePicker); // availability - await this.clearAndType(selector.vendor.vBooking.booking.maxBookingsPerBlock, product.maxBookingsPerBlock); - await this.clearAndType(selector.vendor.vBooking.booking.minimumBookingWindowIntoTheFutureDate, product.minimumBookingWindowIntoTheFutureDate); - await this.selectByValue(selector.vendor.vBooking.booking.minimumBookingWindowIntoTheFutureDateUnit, product.minimumBookingWindowIntoTheFutureDateUnit); - await this.clearAndType(selector.vendor.vBooking.booking.maximumBookingWindowIntoTheFutureDate, product.maximumBookingWindowIntoTheFutureDate); - await this.selectByValue(selector.vendor.vBooking.booking.maximumBookingWindowIntoTheFutureDateUnit, product.maximumBookingWindowIntoTheFutureDateUnit); + await this.clearAndType(bookingProductsVendor.booking.maxBookingsPerBlock, product.maxBookingsPerBlock); + await this.clearAndType(bookingProductsVendor.booking.minimumBookingWindowIntoTheFutureDate, product.minimumBookingWindowIntoTheFutureDate); + await this.selectByValue(bookingProductsVendor.booking.minimumBookingWindowIntoTheFutureDateUnit, product.minimumBookingWindowIntoTheFutureDateUnit); + await this.clearAndType(bookingProductsVendor.booking.maximumBookingWindowIntoTheFutureDate, product.maximumBookingWindowIntoTheFutureDate); + await this.selectByValue(bookingProductsVendor.booking.maximumBookingWindowIntoTheFutureDateUnit, product.maximumBookingWindowIntoTheFutureDateUnit); // costs - await this.clearAndType(selector.vendor.vBooking.booking.baseCost, product.baseCost); - await this.clearAndType(selector.vendor.vBooking.booking.blockCost, product.blockCost); + await this.clearAndType(bookingProductsVendor.booking.baseCost, product.baseCost); + await this.clearAndType(bookingProductsVendor.booking.blockCost, product.blockCost); // todo: add more fields } // vendor add booking product async addBookingProduct(product: product['booking']): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.booking); - await this.clickAndWaitForLoadState(selector.vendor.vBooking.addNewBookingProduct); + await this.clickAndWaitForLoadState(bookingProductsVendor.addNewBookingProduct); await this.updateBookingProductFields(product); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.productBooking, selector.vendor.vBooking.booking.saveProduct, 302); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.productBooking, bookingProductsVendor.booking.saveProduct, 302); await this.toContainText(selector.vendor.product.updatedSuccessMessage, product.saveSuccessMessage); } // edit booking product async editBookingProduct(product: product['booking']) { await this.searchBookingProduct(product.name); - await this.hover(selector.vendor.vBooking.productCell(product.name)); - await this.clickAndWaitForLoadState(selector.vendor.vBooking.edit(product.name)); + await this.hover(bookingProductsVendor.productCell(product.name)); + await this.clickAndWaitForLoadState(bookingProductsVendor.edit(product.name)); await this.updateBookingProductFields(product); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.booking, selector.vendor.vBooking.booking.saveProduct, 302); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.booking, bookingProductsVendor.booking.saveProduct, 302); await this.toContainText(selector.vendor.product.updatedSuccessMessage, product.saveSuccessMessage); } // view booking product async viewBookingProduct(productName: string) { await this.searchBookingProduct(productName); - await this.hover(selector.vendor.vBooking.productCell(productName)); - await this.clickAndWaitForLoadState(selector.vendor.vBooking.view(productName)); + await this.hover(bookingProductsVendor.productCell(productName)); + await this.clickAndWaitForLoadState(bookingProductsVendor.view(productName)); // booking product elements are visible - const { bookingCalendar, bookNow, getSupport, ...viewBooking } = selector.vendor.vBooking.viewBooking; + const { bookingCalendar, bookNow, getSupport, ...viewBooking } = bookingProductsVendor.viewBooking; await this.multipleElementVisible(viewBooking); // todo: actual value can be asserted } @@ -189,8 +193,8 @@ export class BookingPage extends VendorPage { // vendor can't buy own booking product async cantBuyOwnBookingProduct(productName: string) { await this.goToProductDetails(productName); - await this.notToBeVisible(selector.vendor.vBooking.viewBooking.bookingCalendar); - await this.notToBeVisible(selector.vendor.vBooking.viewBooking.bookNow); + await this.notToBeVisible(bookingProductsVendor.viewBooking.bookingCalendar); + await this.notToBeVisible(bookingProductsVendor.viewBooking.bookNow); } // filter products @@ -199,76 +203,76 @@ export class BookingPage extends VendorPage { switch (filterBy) { case 'by-date': - await this.selectByNumber(selector.vendor.vBooking.filters.filterByDate, value); + await this.selectByNumber(bookingProductsVendor.filters.filterByDate, value); break; case 'by-category': - await this.selectByLabel(selector.vendor.vBooking.filters.filterByCategory, value); + await this.selectByLabel(bookingProductsVendor.filters.filterByCategory, value); break; case 'by-other': - await this.selectByValue(selector.vendor.vBooking.filters.filterByOther, value); + await this.selectByValue(bookingProductsVendor.filters.filterByOther, value); break; default: break; } - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.booking, selector.vendor.vBooking.filters.filter); - await this.notToHaveCount(selector.vendor.vBooking.numberOfRowsFound, 0); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.booking, bookingProductsVendor.filters.filter); + await this.notToHaveCount(bookingProductsVendor.numberOfRowsFound, 0); } // search booking product async searchBookingProduct(productName: string) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.booking); - await this.clearAndType(selector.vendor.vBooking.search.searchInput, productName); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.booking, selector.vendor.vBooking.search.search); - await this.toBeVisible(selector.vendor.vBooking.productCell(productName)); + await this.clearAndType(bookingProductsVendor.search.searchInput, productName); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.booking, bookingProductsVendor.search.search); + await this.toBeVisible(bookingProductsVendor.productCell(productName)); } // delete booking product async duplicateBookingProduct(productName: string) { await this.searchBookingProduct(productName); - await this.hover(selector.vendor.vBooking.productCell(productName)); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.booking, selector.vendor.vBooking.duplicate(productName)); - await this.toContainText(selector.vendor.vBooking.dokanSuccessMessage, 'Product successfully duplicated'); + await this.hover(bookingProductsVendor.productCell(productName)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.booking, bookingProductsVendor.duplicate(productName)); + await this.toContainText(bookingProductsVendor.dokanSuccessMessage, 'Product successfully duplicated'); } // delete booking product async deleteBookingProduct(productName: string) { await this.searchBookingProduct(productName); - await this.hover(selector.vendor.vBooking.productCell(productName)); - await this.click(selector.vendor.vBooking.permanentlyDelete(productName)); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.booking, selector.vendor.vBooking.confirmDelete); - await this.toContainText(selector.vendor.vBooking.dokanSuccessMessage, 'Product successfully deleted'); + await this.hover(bookingProductsVendor.productCell(productName)); + await this.click(bookingProductsVendor.permanentlyDelete(productName)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.booking, bookingProductsVendor.confirmDelete); + await this.toContainText(bookingProductsVendor.dokanSuccessMessage, 'Product successfully deleted'); } // add booking resource async addBookingResource(resourceName: string) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.manageResources); - await this.clickAndWaitForLoadState(selector.vendor.vBooking.manageResources.addNewResource); - await this.clearAndType(selector.vendor.vBooking.manageResources.resource.resourceName, resourceName); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.vendor.vBooking.manageResources.resource.confirmAddNewResource); - await this.toBeVisible(selector.vendor.vBooking.manageResources.resource.resourceCell(resourceName)); + await this.clickAndWaitForLoadState(bookingProductsVendor.manageResources.addNewResource); + await this.clearAndType(bookingProductsVendor.manageResources.resource.resourceName, resourceName); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, bookingProductsVendor.manageResources.resource.confirmAddNewResource); + await this.toBeVisible(bookingProductsVendor.manageResources.resource.resourceCell(resourceName)); } // add booking resource async editBookingResource(resource: bookingResource) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.manageResources); - await this.clickAndWaitForLoadState(selector.vendor.vBooking.manageResources.resource.editResource(resource.name)); + await this.clickAndWaitForLoadState(bookingProductsVendor.manageResources.resource.editResource(resource.name)); - await this.clearAndType(selector.vendor.vBooking.manageResources.resource.resourceTitle, resource.name); - await this.clearAndType(selector.vendor.vBooking.manageResources.resource.availableQuantity, resource.quantity); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.manageResources, selector.vendor.vBooking.manageResources.resource.saveResource); + await this.clearAndType(bookingProductsVendor.manageResources.resource.resourceTitle, resource.name); + await this.clearAndType(bookingProductsVendor.manageResources.resource.availableQuantity, resource.quantity); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.manageResources, bookingProductsVendor.manageResources.resource.saveResource); await this.toContainText(selector.vendor.product.updatedSuccessMessage, 'Success! The Resource has been updated successfully.'); } // delete booking resource async deleteBookingResource(resourceName: string) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.manageResources); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.vendor.vBooking.manageResources.resource.deleteResource(resourceName)); - await this.notToBeVisible(selector.vendor.vBooking.manageResources.resource.resourceCell(resourceName)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, bookingProductsVendor.manageResources.resource.deleteResource(resourceName)); + await this.notToBeVisible(bookingProductsVendor.manageResources.resource.resourceCell(resourceName)); } // add booking @@ -276,22 +280,22 @@ export class BookingPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.addBooking); if (customerName) { - await this.click(selector.vendor.vBooking.addBooking.selectCustomerDropdown); - await this.typeAndWaitForResponse(data.subUrls.ajax, selector.vendor.vBooking.addBooking.selectCustomerInput, customerName); - await this.toContainText(selector.vendor.vBooking.addBooking.searchedResult, customerName); + await this.click(bookingProductsVendor.addBooking.selectCustomerDropdown); + await this.typeAndWaitForResponse(data.subUrls.ajax, bookingProductsVendor.addBooking.selectCustomerInput, customerName); + await this.toContainText(bookingProductsVendor.addBooking.searchedResult, customerName); await this.press(data.key.arrowDown); await this.press(data.key.enter); } - await this.click(selector.vendor.vBooking.addBooking.selectABookableProductDropdown); - await this.click(selector.vendor.vBooking.addBooking.selectABookableProduct(productName)); + await this.click(bookingProductsVendor.addBooking.selectABookableProductDropdown); + await this.click(bookingProductsVendor.addBooking.selectABookableProduct(productName)); - await this.click(selector.vendor.vBooking.addBooking.createANewCorrespondingOrderForThisNewBooking); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.addBooking, selector.vendor.vBooking.addBooking.next); + await this.click(bookingProductsVendor.addBooking.createANewCorrespondingOrderForThisNewBooking); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.addBooking, bookingProductsVendor.addBooking.next); await this.clickAndWaitForResponse(data.subUrls.ajax, selector.customer.cBookings.selectCalendarDay(bookings.startDate.getMonth(), bookings.startDate.getDate())); await this.clickAndWaitForResponse(data.subUrls.ajax, selector.customer.cBookings.selectCalendarDay(bookings.endDate.getMonth(), bookings.endDate.getDate())); - await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.addBooking, selector.vendor.vBooking.addBooking.addBooking); - await this.toContainText(selector.vendor.vBooking.addBooking.successMessage, 'The booking has been added successfully.'); + await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.addBooking, bookingProductsVendor.addBooking.addBooking); + await this.toContainText(bookingProductsVendor.addBooking.successMessage, 'The booking has been added successfully.'); } // customer diff --git a/tests/pw/pages/vendorDashboardPage.ts b/tests/pw/pages/vendorDashboardPage.ts index 0e89873b69..6a875d6277 100644 --- a/tests/pw/pages/vendorDashboardPage.ts +++ b/tests/pw/pages/vendorDashboardPage.ts @@ -5,6 +5,9 @@ import { data } from '@utils/testData'; const { DOKAN_PRO } = process.env; +// selectors +const vendorDashboard = selector.vendor.vDashboard; + export class VendorDashboardPage extends VendorPage { constructor(page: Page) { super(page); @@ -17,26 +20,26 @@ export class VendorDashboardPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.dashboard); // at a glance elements are visible - await this.multipleElementVisible(selector.vendor.vDashboard.atAGlance); + await this.multipleElementVisible(vendorDashboard.atAGlance); // graph elements are visible - await this.multipleElementVisible(selector.vendor.vDashboard.graph); + await this.multipleElementVisible(vendorDashboard.graph); // orders elements are visible - await this.multipleElementVisible(selector.vendor.vDashboard.orders); + await this.multipleElementVisible(vendorDashboard.orders); // products elements are visible - await this.multipleElementVisible(selector.vendor.vDashboard.products); + await this.multipleElementVisible(vendorDashboard.products); if (DOKAN_PRO) { // profile progress elements are visible - await this.multipleElementVisible(selector.vendor.vDashboard.profileProgress); + await this.multipleElementVisible(vendorDashboard.profileProgress); // reviews elements are visible - await this.multipleElementVisible(selector.vendor.vDashboard.reviews); + await this.multipleElementVisible(vendorDashboard.reviews); // announcement elements are visible - await this.multipleElementVisible(selector.vendor.vDashboard.announcement); + await this.multipleElementVisible(vendorDashboard.announcement); } } } diff --git a/tests/pw/pages/vendorDeliveryTimePage.ts b/tests/pw/pages/vendorDeliveryTimePage.ts index 1af8533837..773d006df8 100644 --- a/tests/pw/pages/vendorDeliveryTimePage.ts +++ b/tests/pw/pages/vendorDeliveryTimePage.ts @@ -5,6 +5,11 @@ import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; import { vendor, deliveryTime } from '@utils/interfaces'; +// selectors +const deliveryTimeCustomer = selector.customer.cDeliveryTime; +const deliveryTimeVendor = selector.vendor.vDeliveryTime; +const deliveryTimeSettingsVendor = selector.vendor.vDeliveryTimeSettings; + export class VendorDeliveryTimePage extends CustomerPage { constructor(page: Page) { super(page); @@ -17,16 +22,16 @@ export class VendorDeliveryTimePage extends CustomerPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.deliveryTime); // delivery time and store pickup text is visible - await this.toBeVisible(selector.vendor.vDeliveryTime.deliveryTimeAndStorePickup); + await this.toBeVisible(deliveryTimeVendor.deliveryTimeAndStorePickup); // delivery time calendar is visible - await this.toBeVisible(selector.vendor.vDeliveryTime.deliveryTimeCalender); + await this.toBeVisible(deliveryTimeVendor.deliveryTimeCalender); // delivery time filter elements are visible - await this.multipleElementVisible(selector.vendor.vDeliveryTime.filter); + await this.multipleElementVisible(deliveryTimeVendor.filter); // delivery time navigation elements are visible - await this.multipleElementVisible(selector.vendor.vDeliveryTime.navigation); + await this.multipleElementVisible(deliveryTimeVendor.navigation); } // vendor delivery time settings render properly @@ -34,53 +39,53 @@ export class VendorDeliveryTimePage extends CustomerPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsDeliveryTime); // settings text is visible - await this.toBeVisible(selector.vendor.vDeliveryTimeSettings.settingsText); + await this.toBeVisible(deliveryTimeSettingsVendor.settingsText); // visit store link is visible - await this.toBeVisible(selector.vendor.vDeliveryTimeSettings.visitStore); + await this.toBeVisible(deliveryTimeSettingsVendor.visitStore); // delivery support elements are visible - await this.toBeVisible(selector.vendor.vDeliveryTimeSettings.homeDelivery); - await this.toBeVisible(selector.vendor.vDeliveryTimeSettings.storePickup); - await this.toBeVisible(selector.vendor.vDeliveryTimeSettings.deliveryBlockedBuffer); - await this.toBeVisible(selector.vendor.vDeliveryTimeSettings.timeSlot); - await this.toBeVisible(selector.vendor.vDeliveryTimeSettings.orderPerSlot); - await this.notToHaveCount(selector.vendor.vDeliveryTimeSettings.deliveryDaySwitches, 0); + await this.toBeVisible(deliveryTimeSettingsVendor.homeDelivery); + await this.toBeVisible(deliveryTimeSettingsVendor.storePickup); + await this.toBeVisible(deliveryTimeSettingsVendor.deliveryBlockedBuffer); + await this.toBeVisible(deliveryTimeSettingsVendor.timeSlot); + await this.toBeVisible(deliveryTimeSettingsVendor.orderPerSlot); + await this.notToHaveCount(deliveryTimeSettingsVendor.deliveryDaySwitches, 0); // update settings is visible - await this.toBeVisible(selector.vendor.vDeliveryTimeSettings.updateSettings); + await this.toBeVisible(deliveryTimeSettingsVendor.updateSettings); } // vendor set delivery settings async setDeliveryTimeSettings(deliveryTime: vendor['deliveryTime']): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsDeliveryTime); // delivery support - await this.check(selector.vendor.vDeliveryTimeSettings.homeDelivery); - await this.check(selector.vendor.vDeliveryTimeSettings.storePickup); - await this.clearAndType(selector.vendor.vDeliveryTimeSettings.deliveryBlockedBuffer, deliveryTime.deliveryBlockedBuffer); - await this.clearAndType(selector.vendor.vDeliveryTimeSettings.timeSlot, deliveryTime.timeSlot); - await this.clearAndType(selector.vendor.vDeliveryTimeSettings.orderPerSlot, deliveryTime.orderPerSlot); + await this.check(deliveryTimeSettingsVendor.homeDelivery); + await this.check(deliveryTimeSettingsVendor.storePickup); + await this.clearAndType(deliveryTimeSettingsVendor.deliveryBlockedBuffer, deliveryTime.deliveryBlockedBuffer); + await this.clearAndType(deliveryTimeSettingsVendor.timeSlot, deliveryTime.timeSlot); + await this.clearAndType(deliveryTimeSettingsVendor.orderPerSlot, deliveryTime.orderPerSlot); for (const day of deliveryTime.days) { - await this.enableSwitcherDeliveryTime(selector.vendor.vDeliveryTimeSettings.deliveryDaySwitch(day)); + await this.enableSwitcherDeliveryTime(deliveryTimeSettingsVendor.deliveryDaySwitch(day)); if (deliveryTime.choice === 'full-day') { - await this.click(selector.vendor.vDeliveryTimeSettings.openingTime(day)); + await this.click(deliveryTimeSettingsVendor.openingTime(day)); await this.page.getByRole('listitem').filter({ hasText: 'Full day' }).click(); } else { - await this.setAttributeValue(selector.vendor.vDeliveryTimeSettings.openingTime(day), 'value', deliveryTime.openingTime); - await this.setAttributeValue(selector.vendor.vDeliveryTimeSettings.openingTimeHiddenInput(day), 'value', deliveryTime.openingTime); - await this.setAttributeValue(selector.vendor.vDeliveryTimeSettings.closingTime(day), 'value', deliveryTime.closingTime); - await this.setAttributeValue(selector.vendor.vDeliveryTimeSettings.closingTimeHiddenInput(day), 'value', deliveryTime.closingTime); + await this.setAttributeValue(deliveryTimeSettingsVendor.openingTime(day), 'value', deliveryTime.openingTime); + await this.setAttributeValue(deliveryTimeSettingsVendor.openingTimeHiddenInput(day), 'value', deliveryTime.openingTime); + await this.setAttributeValue(deliveryTimeSettingsVendor.closingTime(day), 'value', deliveryTime.closingTime); + await this.setAttributeValue(deliveryTimeSettingsVendor.closingTimeHiddenInput(day), 'value', deliveryTime.closingTime); } } - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.settingsDeliveryTime, selector.vendor.vDeliveryTimeSettings.updateSettings, 302); - await this.toContainText(selector.vendor.vDeliveryTimeSettings.settingsSuccessMessage, deliveryTime.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.settingsDeliveryTime, deliveryTimeSettingsVendor.updateSettings, 302); + await this.toContainText(deliveryTimeSettingsVendor.settingsSuccessMessage, deliveryTime.saveSuccessMessage); } // filter delivery time async filterDeliveryTime(value: string) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.deliveryTime); - await this.selectByValue(selector.vendor.vDeliveryTime.filter.deliveryTimeFilter, value); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.deliveryTime, selector.vendor.vDeliveryTime.filter.filter); + await this.selectByValue(deliveryTimeVendor.filter.deliveryTimeFilter, value); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.deliveryTime, deliveryTimeVendor.filter.filter); // todo: add more assertion // todo: need order via delivery time; via api for assertion } @@ -89,8 +94,8 @@ export class VendorDeliveryTimePage extends CustomerPage { async updateCalendarView(value: string) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.deliveryTime); - await this.click(selector.vendor.vDeliveryTime.navigation[value as keyof typeof selector.vendor.vDeliveryTime.navigation]); - const currentView = await this.getAttributeValue(selector.vendor.vDeliveryTime.navigation[value as keyof typeof selector.vendor.vDeliveryTime.navigation], 'aria-pressed'); + await this.click(deliveryTimeVendor.navigation[value as keyof typeof deliveryTimeVendor.navigation]); + const currentView = await this.getAttributeValue(deliveryTimeVendor.navigation[value as keyof typeof deliveryTimeVendor.navigation], 'aria-pressed'); expect(currentView).toContain('true'); } @@ -102,18 +107,18 @@ export class VendorDeliveryTimePage extends CustomerPage { switch (deliveryType) { case 'delivery-time': - await this.click(selector.customer.cDeliveryTime.delivery); - await this.click(selector.customer.cDeliveryTime.deliveryTimeInput); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.customer.cDeliveryTime.deliveryDate(deliveryTime.date)); - await this.selectByNumber(selector.customer.cDeliveryTime.timePicker, 1); + await this.click(deliveryTimeCustomer.delivery); + await this.click(deliveryTimeCustomer.deliveryTimeInput); + await this.clickAndWaitForResponse(data.subUrls.ajax, deliveryTimeCustomer.deliveryDate(deliveryTime.date)); + await this.selectByNumber(deliveryTimeCustomer.timePicker, 1); break; case 'store-pickup': - await this.click(selector.customer.cDeliveryTime.storePickup); - await this.click(selector.customer.cDeliveryTime.deliveryTimeInput); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.customer.cDeliveryTime.deliveryDate(deliveryTime.date)); - await this.selectByNumber(selector.customer.cDeliveryTime.timePicker, 1); - await this.selectByNumber(selector.customer.cDeliveryTime.locationPicker, 1); + await this.click(deliveryTimeCustomer.storePickup); + await this.click(deliveryTimeCustomer.deliveryTimeInput); + await this.clickAndWaitForResponse(data.subUrls.ajax, deliveryTimeCustomer.deliveryDate(deliveryTime.date)); + await this.selectByNumber(deliveryTimeCustomer.timePicker, 1); + await this.selectByNumber(deliveryTimeCustomer.locationPicker, 1); break; default: @@ -123,11 +128,11 @@ export class VendorDeliveryTimePage extends CustomerPage { await this.paymentOrder(paymentMethod); if (deliveryType == 'delivery-time') { - await this.toBeVisible(selector.customer.cDeliveryTime.orderDetails.deliveryTimeDetails); - await this.toContainText(selector.customer.cDeliveryTime.orderDetails.deliveryTimeTitle, 'Delivery Date'); + await this.toBeVisible(deliveryTimeCustomer.orderDetails.deliveryTimeDetails); + await this.toContainText(deliveryTimeCustomer.orderDetails.deliveryTimeTitle, 'Delivery Date'); } else { - await this.toBeVisible(selector.customer.cDeliveryTime.orderDetails.storePickupDetails); - await this.toContainText(selector.customer.cDeliveryTime.orderDetails.storePickupTitle, 'Store location pickup'); + await this.toBeVisible(deliveryTimeCustomer.orderDetails.storePickupDetails); + await this.toContainText(deliveryTimeCustomer.orderDetails.storePickupTitle, 'Store location pickup'); } } } diff --git a/tests/pw/pages/vendorPage.ts b/tests/pw/pages/vendorPage.ts index bd3e1735d9..1c53b525d5 100644 --- a/tests/pw/pages/vendorPage.ts +++ b/tests/pw/pages/vendorPage.ts @@ -9,6 +9,12 @@ import { vendor, vendorSetupWizard } from '@utils/interfaces'; const { DOKAN_PRO } = process.env; +// selectors +const registrationVendor = selector.vendor.vRegistration; +const setupWizardVendor = selector.vendor.vSetup; +const productsVendor = selector.vendor.product; +const ordersVendor = selector.vendor.orders; + export class VendorPage extends BasePage { constructor(page: Page) { super(page); @@ -34,16 +40,25 @@ export class VendorPage extends BasePage { // go to order details async goToOrderDetails(orderNumber: string): Promise { await this.searchOrder(orderNumber); - await this.clickAndWaitForLoadState(selector.vendor.orders.view(orderNumber)); - await this.toContainText(selector.vendor.orders.orderDetails.orderNumber, orderNumber); + await this.clickAndWaitForLoadState(ordersVendor.view(orderNumber)); + await this.toContainText(ordersVendor.orderDetails.orderNumber, orderNumber); } // go to product edit async goToProductEdit(productName: string): Promise { await this.searchProduct(productName); - await this.hover(selector.vendor.product.productCell(productName)); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, selector.vendor.product.editProduct(productName)); - await this.toHaveValue(selector.vendor.product.edit.title, productName); + await this.hover(productsVendor.productCell(productName)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.products, productsVendor.editProduct(productName)); + await this.toHaveValue(productsVendor.edit.title, productName); + } + + // open vendor registration form + async openVendorRegistrationForm() { + await this.goto(data.subUrls.frontend.myAccount); + const regIsVisible = await this.isVisible(selector.customer.cRegistration.regEmail); + !regIsVisible && (await this.loginPage.logout()); + await this.focusAndClick(registrationVendor.regVendor); + await this.waitForVisibleLocator(registrationVendor.firstName); } // vendor registration @@ -53,38 +68,38 @@ export class VendorPage extends BasePage { await this.goToMyAccount(); const regIsVisible = await this.isVisible(selector.customer.cRegistration.regEmail); !regIsVisible && (await this.loginPage.logout()); - await this.clearAndType(selector.vendor.vRegistration.regEmail, username + data.vendor.vendorInfo.emailDomain); - await this.clearAndType(selector.vendor.vRegistration.regPassword, vendorInfo.password); - await this.focusAndClick(selector.vendor.vRegistration.regVendor); - await this.waitForVisibleLocator(selector.vendor.vRegistration.firstName); - await this.clearAndType(selector.vendor.vRegistration.firstName, username); - await this.clearAndType(selector.vendor.vRegistration.lastName, vendorInfo.lastName()); - await this.clearAndType(selector.vendor.vRegistration.shopName, vendorInfo.shopName()); - await this.click(selector.vendor.vRegistration.shopUrl); + await this.clearAndType(registrationVendor.regEmail, username + data.vendor.vendorInfo.emailDomain); + await this.clearAndType(registrationVendor.regPassword, vendorInfo.password); + await this.focusAndClick(registrationVendor.regVendor); + await this.waitForVisibleLocator(registrationVendor.firstName); + await this.clearAndType(registrationVendor.firstName, username); + await this.clearAndType(registrationVendor.lastName, vendorInfo.lastName()); + await this.clearAndType(registrationVendor.shopName, vendorInfo.shopName()); + await this.click(registrationVendor.shopUrl); // fill address if enabled on registration - const addressInputIsVisible = await this.isVisible(selector.vendor.vRegistration.street1); - if (addressInputIsVisible) { - await this.clearAndType(selector.vendor.vRegistration.street1, vendorInfo.street1); - await this.clearAndType(selector.vendor.vRegistration.street2, vendorInfo.street2); - await this.clearAndType(selector.vendor.vRegistration.city, vendorInfo.city); - await this.clearAndType(selector.vendor.vRegistration.zipCode, vendorInfo.zipCode); - await this.selectByValue(selector.vendor.vRegistration.country, vendorInfo.countrySelectValue); - await this.selectByValue(selector.vendor.vRegistration.state, vendorInfo.stateSelectValue); + if (vendorInfo.addressFieldsEnabled) { + await this.clearAndType(registrationVendor.street1, vendorInfo.street1); + await this.clearAndType(registrationVendor.street2, vendorInfo.street2); + await this.clearAndType(registrationVendor.city, vendorInfo.city); + await this.clearAndType(registrationVendor.zipCode, vendorInfo.zipCode); + await this.selectByValue(registrationVendor.country, vendorInfo.countrySelectValue); + await this.selectByValue(registrationVendor.state, vendorInfo.stateSelectValue); } if (DOKAN_PRO) { - await this.clearAndType(selector.vendor.vRegistration.companyName, vendorInfo.companyName); - await this.clearAndType(selector.vendor.vRegistration.companyId, vendorInfo.companyId); - await this.clearAndType(selector.vendor.vRegistration.vatNumber, vendorInfo.vatNumber); - await this.clearAndType(selector.vendor.vRegistration.bankName, vendorInfo.bankName); - await this.clearAndType(selector.vendor.vRegistration.bankIban, vendorInfo.bankIban); + await this.clearAndType(registrationVendor.companyName, vendorInfo.companyName); + await this.clearAndType(registrationVendor.companyId, vendorInfo.companyId); + await this.clearAndType(registrationVendor.vatNumber, vendorInfo.vatNumber); + await this.clearAndType(registrationVendor.bankName, vendorInfo.bankName); + await this.clearAndType(registrationVendor.bankIban, vendorInfo.bankIban); } - await this.clearAndType(selector.vendor.vRegistration.phone, vendorInfo.phoneNumber); + await this.clearAndType(registrationVendor.phone, vendorInfo.phoneNumber); await this.checkIfVisible(selector.customer.cDashboard.termsAndConditions); - // await this.checkIfVisible(selector.customer.cDashboard.termsAndConditions); // todo: fix - const subscriptionPackIsVisible = await this.isVisible(selector.vendor.vRegistration.subscriptionPack); - subscriptionPackIsVisible && (await this.selectByLabel(selector.vendor.vRegistration.subscriptionPack, data.predefined.vendorSubscription.nonRecurring)); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.setupWizard, selector.vendor.vRegistration.register); + const subscriptionPackIsVisible = await this.isVisible(registrationVendor.subscriptionPack); + subscriptionPackIsVisible && (await this.selectByLabel(registrationVendor.subscriptionPack, data.predefined.vendorSubscription.nonRecurring)); + setupWizardData.setupWizardEnabled + ? await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.setupWizard, registrationVendor.register) + : await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.dashboard, registrationVendor.register); const registrationErrorIsVisible = await this.isVisible(selector.customer.cWooSelector.wooCommerceError); if (registrationErrorIsVisible) { const hasError = await this.hasText(selector.customer.cWooSelector.wooCommerceError, data.customer.registration.registrationErrorMessage); @@ -94,74 +109,75 @@ export class VendorPage extends BasePage { } } subscriptionPackIsVisible && (await this.customer.placeOrder('bank', false, true, false)); - await this.vendorSetupWizard(setupWizardData); + setupWizardData.setupWizardEnabled && (await this.vendorSetupWizard(setupWizardData)); } // vendor setup wizard async vendorSetupWizard(setupWizardData: vendorSetupWizard): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.setupWizard); + if (setupWizardData.choice) { - await this.click(selector.vendor.vSetup.letsGo); - await this.clearAndType(selector.vendor.vSetup.street1, setupWizardData.street1); - await this.clearAndType(selector.vendor.vSetup.street2, setupWizardData.street2); - await this.clearAndType(selector.vendor.vSetup.city, setupWizardData.city); - await this.clearAndType(selector.vendor.vSetup.zipCode, setupWizardData.zipCode); - await this.click(selector.vendor.vSetup.country); - await this.type(selector.vendor.vSetup.countryInput, setupWizardData.country); - await this.toContainText(selector.vendor.vSetup.highlightedResult, setupWizardData.country); + await this.click(setupWizardVendor.letsGo); + await this.clearAndType(setupWizardVendor.street1, setupWizardData.street1); + await this.clearAndType(setupWizardVendor.street2, setupWizardData.street2); + await this.clearAndType(setupWizardVendor.city, setupWizardData.city); + await this.clearAndType(setupWizardVendor.zipCode, setupWizardData.zipCode); + await this.click(setupWizardVendor.country); + await this.type(setupWizardVendor.countryInput, setupWizardData.country); + await this.toContainText(setupWizardVendor.highlightedResult, setupWizardData.country); await this.press(data.key.enter); - await this.click(selector.vendor.vSetup.state); - await this.type(selector.vendor.vSetup.stateInput, setupWizardData.state); - await this.toContainText(selector.vendor.vSetup.highlightedResult, setupWizardData.state); + await this.click(setupWizardVendor.state); + await this.type(setupWizardVendor.stateInput, setupWizardData.state); + await this.toContainText(setupWizardVendor.highlightedResult, setupWizardData.state); await this.press(data.key.enter); // store categories - const storeCategoriesEnabled = await this.isVisible(selector.vendor.vSetup.storeCategories); + const storeCategoriesEnabled = await this.isVisible(setupWizardVendor.storeCategories); if (storeCategoriesEnabled) { - const allStoreCategories = await this.getMultipleElementTexts(selector.vendor.vSetup.selectedStoreCategories); + const allStoreCategories = await this.getMultipleElementTexts(setupWizardVendor.selectedStoreCategories); const categoryIsSelected = allStoreCategories.includes('×' + setupWizardData.storeCategory); if (!categoryIsSelected) { - await this.click(selector.vendor.vSetup.storeCategories); - await this.type(selector.vendor.vSetup.storeCategoriesInput, setupWizardData.storeCategory); - await this.toContainText(selector.vendor.vSetup.highlightedResult, setupWizardData.storeCategory); - await this.click(selector.vendor.vSetup.highlightedResult); + await this.click(setupWizardVendor.storeCategories); + await this.type(setupWizardVendor.storeCategoriesInput, setupWizardData.storeCategory); + await this.toContainText(setupWizardVendor.highlightedResult, setupWizardData.storeCategory); + await this.click(setupWizardVendor.highlightedResult); } } // map - const geoLocationEnabled = await this.isVisible(selector.vendor.vSetup.map); + const geoLocationEnabled = await this.isVisible(setupWizardVendor.map); if (geoLocationEnabled) { - await this.typeAndWaitForResponse(data.subUrls.gmap, selector.vendor.vSetup.map, setupWizardData.mapLocation); + await this.typeAndWaitForResponse(data.subUrls.gmap, setupWizardVendor.map, setupWizardData.mapLocation); // await this.press(data.key.arrowDown); // await this.press(data.key.enter); - await this.click(selector.vendor.vSetup.mapResultFirst); + await this.click(setupWizardVendor.mapResultFirst); } - await this.check(selector.vendor.vSetup.email); - await this.click(selector.vendor.vSetup.continueStoreSetup); + await this.check(setupWizardVendor.email); + await this.click(setupWizardVendor.continueStoreSetup); // payment // paypal - await this.clearAndType(selector.vendor.vSetup.paypal, setupWizardData.paypal()); + await this.clearAndType(setupWizardVendor.paypal, setupWizardData.paypal()); // bank transfer - await this.clearAndType(selector.vendor.vSetup.bankAccountName, setupWizardData.bankAccountName); - await this.selectByValue(selector.vendor.vSetup.bankAccountType, setupWizardData.bankAccountType); - await this.clearAndType(selector.vendor.vSetup.bankAccountNumber, setupWizardData.bankAccountNumber); - await this.clearAndType(selector.vendor.vSetup.bankRoutingNumber, setupWizardData.bankRoutingNumber); - await this.clearAndType(selector.vendor.vSetup.bankName, setupWizardData.bankName); - await this.clearAndType(selector.vendor.vSetup.bankAddress, setupWizardData.bankAddress); - await this.clearAndType(selector.vendor.vSetup.bankIban, setupWizardData.bankIban); - await this.clearAndType(selector.vendor.vSetup.bankSwiftCode, setupWizardData.bankSwiftCode); - await this.check(selector.vendor.vSetup.declaration); + await this.clearAndType(setupWizardVendor.bankAccountName, setupWizardData.bankAccountName); + await this.selectByValue(setupWizardVendor.bankAccountType, setupWizardData.bankAccountType); + await this.clearAndType(setupWizardVendor.bankAccountNumber, setupWizardData.bankAccountNumber); + await this.clearAndType(setupWizardVendor.bankRoutingNumber, setupWizardData.bankRoutingNumber); + await this.clearAndType(setupWizardVendor.bankName, setupWizardData.bankName); + await this.clearAndType(setupWizardVendor.bankAddress, setupWizardData.bankAddress); + await this.clearAndType(setupWizardVendor.bankIban, setupWizardData.bankIban); + await this.clearAndType(setupWizardVendor.bankSwiftCode, setupWizardData.bankSwiftCode); + await this.check(setupWizardVendor.declaration); // custom method - await this.typeIfVisible(selector.vendor.vSetup.customPayment, setupWizardData.customPayment); + await this.typeIfVisible(setupWizardVendor.customPayment, setupWizardData.customPayment); // skrill - await this.typeIfVisible(selector.vendor.vSetup.skrill, setupWizardData.skrill); - await this.click(selector.vendor.vSetup.continuePaymentSetup); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.dashboard, selector.vendor.vSetup.goToStoreDashboard); + await this.typeIfVisible(setupWizardVendor.skrill, setupWizardData.skrill); + await this.click(setupWizardVendor.continuePaymentSetup); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.dashboard, setupWizardVendor.goToStoreDashboard); } else { - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.dashboard, selector.vendor.vSetup.notRightNow); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.dashboard, setupWizardVendor.notRightNow); } await this.toBeVisible(selector.vendor.vDashboard.menus.dashboard); } @@ -224,42 +240,42 @@ export class VendorPage extends BasePage { refunded: 0, }; - orderDetails.vendorEarning = helpers.price((await this.getElementText(selector.vendor.orders.vendorEarningTable(orderNumber))) as string); - await this.clickAndWaitForLoadState(selector.vendor.orders.view(orderNumber)); + orderDetails.vendorEarning = helpers.price((await this.getElementText(ordersVendor.vendorEarningTable(orderNumber))) as string); + await this.clickAndWaitForLoadState(ordersVendor.view(orderNumber)); - orderDetails.orderNumber = ((await this.getElementText(selector.vendor.orders.orderDetails.orderNumber)) as string).split('#')[1] as string; + orderDetails.orderNumber = ((await this.getElementText(ordersVendor.orderDetails.orderNumber)) as string).split('#')[1] as string; - const refundedOrderTotalIsVisible = await this.isVisible(selector.vendor.orders.orderDetails.orderTotalAfterRefund); + const refundedOrderTotalIsVisible = await this.isVisible(ordersVendor.orderDetails.orderTotalAfterRefund); if (refundedOrderTotalIsVisible) { - orderDetails.orderTotalBeforeRefund = helpers.price((await this.getElementText(selector.vendor.orders.orderDetails.orderTotalBeforeRefund)) as string); - orderDetails.orderTotal = helpers.price((await this.getElementText(selector.vendor.orders.orderDetails.orderTotalAfterRefund)) as string); + orderDetails.orderTotalBeforeRefund = helpers.price((await this.getElementText(ordersVendor.orderDetails.orderTotalBeforeRefund)) as string); + orderDetails.orderTotal = helpers.price((await this.getElementText(ordersVendor.orderDetails.orderTotalAfterRefund)) as string); } else { - orderDetails.orderTotal = helpers.price((await this.getElementText(selector.vendor.orders.orderDetails.orderTotal)) as string); + orderDetails.orderTotal = helpers.price((await this.getElementText(ordersVendor.orderDetails.orderTotal)) as string); } - orderDetails.orderStatus = ((await this.getElementText(selector.vendor.orders.status.currentOrderStatus)) as string).replace('-', ' '); + orderDetails.orderStatus = ((await this.getElementText(ordersVendor.status.currentOrderStatus)) as string).replace('-', ' '); - const orderDate = ((await this.getElementText(selector.vendor.orders.orderDetails.orderDate)) as string)?.split(':')[1]?.trim() as string; + const orderDate = ((await this.getElementText(ordersVendor.orderDetails.orderDate)) as string)?.split(':')[1]?.trim() as string; orderDetails.orderDate = orderDate?.substring(0, orderDate.indexOf(',', orderDate.indexOf(',') + 1)); - const discountIsVisible = await this.isVisible(selector.vendor.orders.orderDetails.discount); + const discountIsVisible = await this.isVisible(ordersVendor.orderDetails.discount); if (discountIsVisible) { - orderDetails.discount = helpers.price((await this.getElementText(selector.vendor.orders.orderDetails.discount)) as string); + orderDetails.discount = helpers.price((await this.getElementText(ordersVendor.orderDetails.discount)) as string); } - const shippingMethodIsVisible = await this.isVisible(selector.vendor.orders.orderDetails.shippingMethod); + const shippingMethodIsVisible = await this.isVisible(ordersVendor.orderDetails.shippingMethod); if (shippingMethodIsVisible) { - orderDetails.shippingCost = helpers.price((await this.getElementText(selector.vendor.orders.orderDetails.shippingCost)) as string); + orderDetails.shippingCost = helpers.price((await this.getElementText(ordersVendor.orderDetails.shippingCost)) as string); } - const taxIsVisible = await this.isVisible(selector.vendor.orders.orderDetails.tax); + const taxIsVisible = await this.isVisible(ordersVendor.orderDetails.tax); if (taxIsVisible) { - orderDetails.tax = helpers.price((await this.getElementText(selector.vendor.orders.orderDetails.tax)) as string); + orderDetails.tax = helpers.price((await this.getElementText(ordersVendor.orderDetails.tax)) as string); } - const refundIsVisible = await this.isVisible(selector.vendor.orders.orderDetails.refunded); + const refundIsVisible = await this.isVisible(ordersVendor.orderDetails.refunded); if (refundIsVisible) { - orderDetails.refunded = helpers.price((await this.getElementText(selector.vendor.orders.orderDetails.refunded)) as string); + orderDetails.refunded = helpers.price((await this.getElementText(ordersVendor.orderDetails.refunded)) as string); } console.log(orderDetails); @@ -281,45 +297,46 @@ export class VendorPage extends BasePage { async searchProduct(productName: string): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.products); - await this.clearAndType(selector.vendor.product.search.searchInput, productName); - await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.products, selector.vendor.product.search.searchBtn); - await this.toBeVisible(selector.vendor.product.productLink(productName)); + await this.clearAndType(productsVendor.search.searchInput, productName); + await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.products, productsVendor.search.searchBtn); + await this.toBeVisible(productsVendor.productLink(productName)); } // search order async searchOrder(orderNumber: string): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.orders); - await this.clearAndType(selector.vendor.orders.search.searchInput, orderNumber); - await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.orders, selector.vendor.orders.search.searchBtn); - await this.toBeVisible(selector.vendor.orders.orderLink(orderNumber)); - await this.toHaveCount(selector.vendor.orders.numberOfRowsFound, 1); + await this.clearAndType(ordersVendor.search.searchInput, orderNumber); + await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.orders, ordersVendor.search.searchBtn); + await this.toBeVisible(ordersVendor.orderLink(orderNumber)); + await this.toHaveCount(ordersVendor.numberOfRowsFound, 1); } async buyProductAdvertising(productName: string) { await this.searchProduct(productName); - const advertisementStatus = await this.hasColor(selector.vendor.product.advertisementStatus(productName), 'rgb(255, 99, 71)'); + const advertisementStatus = await this.hasColor(productsVendor.advertisementStatus(productName), 'rgb(255, 99, 71)'); if (advertisementStatus) { console.log('Product advertisement is currently ongoing.'); test.skip(); // throw new Error('Product advertisement is currently ongoing.'); } - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.product.buyAdvertisement(productName)); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.product.confirmAction); - await this.click(selector.vendor.product.successMessage); + await this.clickAndWaitForResponse(data.subUrls.ajax, productsVendor.buyAdvertisement(productName)); + await this.clickAndWaitForResponse(data.subUrls.ajax, productsVendor.confirmAction); + await this.click(productsVendor.successMessage); const orderId = await this.customer.paymentOrder(); return orderId; } // vendor set banner and profile picture settings - // async bannerAndProfilePictureSettings(banner: string, profilePicture: string): Promise { // todo: fix banner and profile update - // // upload banner and profile picture - // await this.removePreviouslyUploadedImage(selector.vendor.vStoreSettings.bannerImage, selector.vendor.vStoreSettings.removeBannerImage); - // await this.click(selector.vendor.vStoreSettings.banner); - // await this.wpUploadFile(banner); - - // await this.removePreviouslyUploadedImage(selector.vendor.vStoreSettings.profilePictureImage, selector.vendor.vStoreSettings.removeProfilePictureImage); - // await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vStoreSettings.profilePicture); - // await this.wpUploadFile(profilePicture); - // } + async bannerAndProfilePictureSettings(banner: string, profilePicture: string): Promise { + // todo: fix banner and profile update + // upload banner and profile picture + await this.removePreviouslyUploadedImage(selector.vendor.vStoreSettings.bannerImage, selector.vendor.vStoreSettings.removeBannerImage); + await this.click(selector.vendor.vStoreSettings.banner); + await this.wpUploadFile(banner); + + await this.removePreviouslyUploadedImage(selector.vendor.vStoreSettings.profilePictureImage, selector.vendor.vStoreSettings.removeProfilePictureImage); + await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vStoreSettings.profilePicture); + await this.wpUploadFile(profilePicture); + } } diff --git a/tests/pw/pages/vendorProductSubscriptionPage.ts b/tests/pw/pages/vendorProductSubscriptionPage.ts index baf8736aef..68546c71e4 100644 --- a/tests/pw/pages/vendorProductSubscriptionPage.ts +++ b/tests/pw/pages/vendorProductSubscriptionPage.ts @@ -5,6 +5,10 @@ import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; import { customer } from '@utils/interfaces'; +// selectors +const subscriptionsVendor = selector.vendor.vUserSubscriptions; +const subscriptionsCustomer = selector.customer.cSubscription; + export class VendorProductSubscriptionPage extends VendorPage { constructor(page: Page) { super(page); @@ -19,10 +23,10 @@ export class VendorProductSubscriptionPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.userSubscriptions); // filter - const { filterByCustomerInput, result, ...filters } = selector.vendor.vUserSubscriptions.filters; + const { filterByCustomerInput, result, ...filters } = subscriptionsVendor.filters; await this.multipleElementVisible(filters); - const noSubscriptionsFound = await this.isVisible(selector.vendor.vUserSubscriptions.noSubscriptionsFound); + const noSubscriptionsFound = await this.isVisible(subscriptionsVendor.noSubscriptionsFound); if (noSubscriptionsFound) { return; } @@ -31,7 +35,6 @@ export class VendorProductSubscriptionPage extends VendorPage { // vendor view product subscription async viewProductSubscription(value: string) { // todo: go to subscription details via link , get subscription id via api - // todo: } // filter product subscriptions @@ -40,22 +43,22 @@ export class VendorProductSubscriptionPage extends VendorPage { switch (filterBy) { case 'by-customer': - await this.click(selector.vendor.vUserSubscriptions.filters.filterByCustomer); - await this.typeAndWaitForResponse(data.subUrls.ajax, selector.vendor.vUserSubscriptions.filters.filterByCustomerInput, inputValue); - await this.toContainText(selector.vendor.vUserSubscriptions.filters.result, inputValue); + await this.click(subscriptionsVendor.filters.filterByCustomer); + await this.typeAndWaitForResponse(data.subUrls.ajax, subscriptionsVendor.filters.filterByCustomerInput, inputValue); + await this.toContainText(subscriptionsVendor.filters.result, inputValue); await this.press(data.key.enter); break; case 'by-date': - await this.setAttributeValue(selector.vendor.vUserSubscriptions.filters.filterByDate, 'value', inputValue); + await this.setAttributeValue(subscriptionsVendor.filters.filterByDate, 'value', inputValue); break; default: break; } - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.userSubscriptions, selector.vendor.vUserSubscriptions.filters.filter); - await this.notToHaveCount(selector.vendor.vUserSubscriptions.numberOfRowsFound, 0); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.userSubscriptions, subscriptionsVendor.filters.filter); + await this.notToHaveCount(subscriptionsVendor.numberOfRowsFound, 0); } // customer @@ -65,10 +68,10 @@ export class VendorProductSubscriptionPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.productSubscriptionDetails(subscriptionId)); // subscription heading is visible - await this.toBeVisible(selector.customer.cSubscription.subscriptionDetails.subscriptionHeading); + await this.toBeVisible(subscriptionsCustomer.subscriptionDetails.subscriptionHeading); // subscription action elements are visible - const { reActivate, ...actions } = selector.customer.cSubscription.subscriptionDetails.actions; + const { reActivate, ...actions } = subscriptionsCustomer.subscriptionDetails.actions; await this.multipleElementVisible(actions); // todo: add more fields } @@ -77,17 +80,17 @@ export class VendorProductSubscriptionPage extends VendorPage { async cancelProductSubscription(subscriptionId: string) { await this.goIfNotThere(data.subUrls.frontend.productSubscriptionDetails(subscriptionId)); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.productSubscriptionDetails(subscriptionId), selector.customer.cSubscription.subscriptionDetails.actions.cancel, 302); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.productSubscriptionDetails(subscriptionId), subscriptionsCustomer.subscriptionDetails.actions.cancel, 302); await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, 'Your subscription has been cancelled.'); } // reactivate product subscription async reactivateProductSubscription(subscriptionId: string) { await this.goIfNotThere(data.subUrls.frontend.productSubscriptionDetails(subscriptionId)); - const subscriptionIsActive = await this.isVisible(selector.customer.cSubscription.subscriptionDetails.actions.cancel); + const subscriptionIsActive = await this.isVisible(subscriptionsCustomer.subscriptionDetails.actions.cancel); subscriptionIsActive && (await this.cancelProductSubscription(subscriptionId)); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.productSubscriptionDetails(subscriptionId), selector.customer.cSubscription.subscriptionDetails.actions.reActivate, 302); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.productSubscriptionDetails(subscriptionId), subscriptionsCustomer.subscriptionDetails.actions.reActivate, 302); await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, 'Your subscription has been reactivated.'); } @@ -95,7 +98,7 @@ export class VendorProductSubscriptionPage extends VendorPage { async changeAddressOfProductSubscription(subscriptionId: string, shippingInfo: customer['customerInfo']['shipping']) { await this.goIfNotThere(data.subUrls.frontend.productSubscriptionDetails(subscriptionId)); - await this.clickAndWaitForLoadState(selector.customer.cSubscription.subscriptionDetails.actions.changeAddress); + await this.clickAndWaitForLoadState(subscriptionsCustomer.subscriptionDetails.actions.changeAddress); await this.customerPage.updateShippingFields(shippingInfo); await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.shippingAddress, selector.customer.cAddress.shipping.shippingSaveAddress, 302); await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, data.customer.address.addressChangeSuccessMessage); @@ -104,16 +107,16 @@ export class VendorProductSubscriptionPage extends VendorPage { // change payment of product subscription async changePaymentOfProductSubscription(subscriptionId: string) { await this.goIfNotThere(data.subUrls.frontend.productSubscriptionDetails(subscriptionId)); - await this.clickAndWaitForLoadState(selector.customer.cSubscription.subscriptionDetails.actions.changePayment); + await this.clickAndWaitForLoadState(subscriptionsCustomer.subscriptionDetails.actions.changePayment); // todo: change to new card - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.productSubscriptionDetails(subscriptionId), selector.customer.cSubscription.subscriptionDetails.changePaymentMethod); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.productSubscriptionDetails(subscriptionId), subscriptionsCustomer.subscriptionDetails.changePaymentMethod); await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, 'Payment method updated.'); } // renew product subscription async renewProductSubscription(subscriptionId: string) { await this.goIfNotThere(data.subUrls.frontend.productSubscriptionDetails(subscriptionId)); - await this.clickAndWaitForLoadState(selector.customer.cSubscription.subscriptionDetails.actions.renewNow); + await this.clickAndWaitForLoadState(subscriptionsCustomer.subscriptionDetails.actions.renewNow); await this.customerPage.paymentOrder('stripe'); } diff --git a/tests/pw/pages/vendorReportsPage.ts b/tests/pw/pages/vendorReportsPage.ts index 761c714109..a897efa09d 100644 --- a/tests/pw/pages/vendorReportsPage.ts +++ b/tests/pw/pages/vendorReportsPage.ts @@ -3,6 +3,9 @@ import { VendorPage } from '@pages/vendorPage'; import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; +// selectors +const vendorReports = selector.vendor.vReports; + export class VendorReportsPage extends VendorPage { constructor(page: Page) { super(page); @@ -15,52 +18,52 @@ export class VendorReportsPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.reports); // reports text is visible - await this.toBeVisible(selector.vendor.vReports.reportsText); + await this.toBeVisible(vendorReports.reportsText); // reports menu elements are visible - await this.multipleElementVisible(selector.vendor.vReports.menus); + await this.multipleElementVisible(vendorReports.menus); // chart elements are visible - await this.multipleElementVisible(selector.vendor.vReports.chart); + await this.multipleElementVisible(vendorReports.chart); - await this.clickAndWaitForLoadState(selector.vendor.vReports.menus.salesByDay); + await this.clickAndWaitForLoadState(vendorReports.menus.salesByDay); // chart elements are visible - await this.multipleElementVisible(selector.vendor.vReports.chart); + await this.multipleElementVisible(vendorReports.chart); - await this.clickAndWaitForLoadState(selector.vendor.vReports.menus.topSelling); + await this.clickAndWaitForLoadState(vendorReports.menus.topSelling); // date picker elements are visible const { dateRangePickerinput, show } = selector.vendor.vAnalytics.datePicker; await this.multipleElementVisible({ dateRangePickerinput, show }); // top selling table elements are visible - await this.multipleElementVisible(selector.vendor.vReports.topSelling.table); + await this.multipleElementVisible(vendorReports.topSelling.table); - await this.clickAndWaitForLoadState(selector.vendor.vReports.menus.topEarning); + await this.clickAndWaitForLoadState(vendorReports.menus.topEarning); // date picker elements are visible await this.multipleElementVisible({ dateRangePickerinput, show }); // top earning table elements are visible - await this.multipleElementVisible(selector.vendor.vReports.topEarning.table); + await this.multipleElementVisible(vendorReports.topEarning.table); - await this.clickAndWaitForLoadState(selector.vendor.vReports.menus.statement); + await this.clickAndWaitForLoadState(vendorReports.menus.statement); // date picker elements are visible await this.multipleElementVisible({ dateRangePickerinput, show }); // statement table elements are visible - await this.multipleElementVisible(selector.vendor.vReports.statement.table); + await this.multipleElementVisible(vendorReports.statement.table); // export statements button is visible - await this.toBeVisible(selector.vendor.vReports.statement.exportStatements); + await this.toBeVisible(vendorReports.statement.exportStatements); } // vendor export statement async exportStatement(): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.statement); - const isDisabled = await this.hasAttribute(selector.vendor.vReports.statement.exportStatements, 'disabled'); - !isDisabled && (await this.clickAndWaitForDownload(selector.vendor.vReports.statement.exportStatements)); + const isDisabled = await this.hasAttribute(vendorReports.statement.exportStatements, 'disabled'); + !isDisabled && (await this.clickAndWaitForDownload(vendorReports.statement.exportStatements)); } } diff --git a/tests/pw/pages/vendorReturnRequestPage.ts b/tests/pw/pages/vendorReturnRequestPage.ts index 7934595c05..c09dd36d5d 100644 --- a/tests/pw/pages/vendorReturnRequestPage.ts +++ b/tests/pw/pages/vendorReturnRequestPage.ts @@ -5,6 +5,9 @@ import { data } from '@utils/testData'; import { order } from '@utils/interfaces'; import { helpers } from '@utils/helpers'; +// selectors +const vendorReturnRequest = selector.vendor.vReturnRequest; + export class VendorReturnRequestPage extends VendorPage { constructor(page: Page) { super(page); @@ -17,83 +20,83 @@ export class VendorReturnRequestPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.returnRequest); // return request menu elements are visible - await this.toBeVisible(selector.vendor.vReturnRequest.menus.all); + await this.toBeVisible(vendorReturnRequest.menus.all); // return request table elements are visible - await this.multipleElementVisible(selector.vendor.vReturnRequest.table); + await this.multipleElementVisible(vendorReturnRequest.table); - const noRequestsFound = await this.isVisible(selector.vendor.vReturnRequest.noRowsFound); + const noRequestsFound = await this.isVisible(vendorReturnRequest.noRowsFound); if (noRequestsFound) { return; } - await this.notToHaveCount(selector.vendor.vReturnRequest.numberOfRowsFound, 0); + await this.notToHaveCount(vendorReturnRequest.numberOfRowsFound, 0); } // vendor view rma details async vendorViewRmaDetails(orderNumber: string): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.returnRequest); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.returnRequest, selector.vendor.vReturnRequest.view(orderNumber)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.returnRequest, vendorReturnRequest.view(orderNumber)); // back to list is visible - await this.toBeVisible(selector.vendor.vReturnRequest.returnRequestDetails.backToList); + await this.toBeVisible(vendorReturnRequest.returnRequestDetails.backToList); // basic details elements are visible - await this.multipleElementVisible(selector.vendor.vReturnRequest.returnRequestDetails.basicDetails); + await this.multipleElementVisible(vendorReturnRequest.returnRequestDetails.basicDetails); // additional details elements are visible - await this.multipleElementVisible(selector.vendor.vReturnRequest.returnRequestDetails.additionalDetails); + await this.multipleElementVisible(vendorReturnRequest.returnRequestDetails.additionalDetails); // status elements are visible - const { sendRefund, ...status } = selector.vendor.vReturnRequest.returnRequestDetails.status; + const { sendRefund, ...status } = vendorReturnRequest.returnRequestDetails.status; await this.multipleElementVisible(status); // conversations elements are visible - await this.multipleElementVisible(selector.vendor.vReturnRequest.returnRequestDetails.conversations); + await this.multipleElementVisible(vendorReturnRequest.returnRequestDetails.conversations); } // vendor send rma message async vendorSendRmaMessage(orderNumber: string, message: string): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.returnRequest); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.returnRequest, selector.vendor.vReturnRequest.view(orderNumber)); - await this.clearAndType(selector.vendor.vReturnRequest.returnRequestDetails.conversations.message, message); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.returnRequest, selector.vendor.vReturnRequest.returnRequestDetails.conversations.sendMessage, 302); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.returnRequest, vendorReturnRequest.view(orderNumber)); + await this.clearAndType(vendorReturnRequest.returnRequestDetails.conversations.message, message); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.returnRequest, vendorReturnRequest.returnRequestDetails.conversations.sendMessage, 302); await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, data.customer.rma.sendMessage); } // vendor update rma status async vendorUpdateRmaStatus(orderNumber: string, status: string) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.returnRequest); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.returnRequest, selector.vendor.vReturnRequest.view(orderNumber)); - await this.selectByValue(selector.vendor.vReturnRequest.returnRequestDetails.status.changeStatus, status); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vReturnRequest.returnRequestDetails.status.update); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.returnRequest, vendorReturnRequest.view(orderNumber)); + await this.selectByValue(vendorReturnRequest.returnRequestDetails.status.changeStatus, status); + await this.clickAndWaitForResponse(data.subUrls.ajax, vendorReturnRequest.returnRequestDetails.status.update); } // vendor send rma refund async vendorRmaRefund(orderNumber: string, productName: string, status: string) { // await this.goIfNotThere(data.subUrls.frontend.vDashboard.returnRequest); // todo: await this.goto(data.subUrls.frontend.vDashboard.returnRequest); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.returnRequest, selector.vendor.vReturnRequest.view(orderNumber)); - const sendRefundIsVisible = await this.isVisible(selector.vendor.vReturnRequest.returnRequestDetails.status.sendRefund); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.returnRequest, vendorReturnRequest.view(orderNumber)); + const sendRefundIsVisible = await this.isVisible(vendorReturnRequest.returnRequestDetails.status.sendRefund); !sendRefundIsVisible && (await this.vendorUpdateRmaStatus(orderNumber, status)); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vReturnRequest.returnRequestDetails.status.sendRefund); - const taxIsVisible = await this.isVisible(selector.vendor.vReturnRequest.returnRequestDetails.modal.taxRefundColumn); + await this.clickAndWaitForResponse(data.subUrls.ajax, vendorReturnRequest.returnRequestDetails.status.sendRefund); + const taxIsVisible = await this.isVisible(vendorReturnRequest.returnRequestDetails.modal.taxRefundColumn); if (taxIsVisible) { - const tax = (await this.getElementText(selector.vendor.vReturnRequest.returnRequestDetails.modal.taxAmount(productName))) as string; - await this.type(selector.vendor.vReturnRequest.returnRequestDetails.modal.taxRefund(productName), helpers.removeCurrencySign(tax)); + const tax = (await this.getElementText(vendorReturnRequest.returnRequestDetails.modal.taxAmount(productName))) as string; + await this.type(vendorReturnRequest.returnRequestDetails.modal.taxRefund(productName), helpers.removeCurrencySign(tax)); } - const subtotal = (await this.getElementText(selector.vendor.vReturnRequest.returnRequestDetails.modal.subTotal(productName))) as string; - await this.type(selector.vendor.vReturnRequest.returnRequestDetails.modal.subTotalRefund(productName), helpers.removeCurrencySign(subtotal)); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.vendor.vReturnRequest.returnRequestDetails.modal.sendRequest); - await this.toContainText(selector.vendor.vReturnRequest.returnRequestDetails.modal.sendRequestSuccessMessage, 'Already send refund request. Wait for admin approval'); + const subtotal = (await this.getElementText(vendorReturnRequest.returnRequestDetails.modal.subTotal(productName))) as string; + await this.type(vendorReturnRequest.returnRequestDetails.modal.subTotalRefund(productName), helpers.removeCurrencySign(subtotal)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, vendorReturnRequest.returnRequestDetails.modal.sendRequest); + await this.toContainText(vendorReturnRequest.returnRequestDetails.modal.sendRequestSuccessMessage, 'Already send refund request. Wait for admin approval'); } // vendor delete rma request async vendorDeleteRmaRequest(orderNumber: string) { // await this.goIfNotThere(data.subUrls.frontend.vDashboard.returnRequest); // todo: await this.goto(data.subUrls.frontend.vDashboard.returnRequest); - await this.hover(selector.vendor.vReturnRequest.returnRequestCell(orderNumber)); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.returnRequest, selector.vendor.vReturnRequest.delete(orderNumber)); + await this.hover(vendorReturnRequest.returnRequestCell(orderNumber)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.returnRequest, vendorReturnRequest.delete(orderNumber)); await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, 'Return Request has been deleted successfully'); } diff --git a/tests/pw/pages/vendorSettingsPage.ts b/tests/pw/pages/vendorSettingsPage.ts index acc77410af..144eea4e8a 100644 --- a/tests/pw/pages/vendorSettingsPage.ts +++ b/tests/pw/pages/vendorSettingsPage.ts @@ -7,6 +7,9 @@ import { vendor } from '@utils/interfaces'; const { DOKAN_PRO } = process.env; +// selectors +const vendorSettings = selector.vendor.vStoreSettings; + export class VendorSettingsPage extends VendorPage { constructor(page: Page) { super(page); @@ -19,40 +22,40 @@ export class VendorSettingsPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsStore); // settings text is visible - await this.toBeVisible(selector.vendor.vStoreSettings.settingsText); + await this.toBeVisible(vendorSettings.settingsText); // todo: update for lite // visit store link is visible - await this.toBeVisible(selector.vendor.vStoreSettings.banner); - await this.toBeVisible(selector.vendor.vStoreSettings.profilePicture); - await this.toBeVisible(selector.vendor.vStoreSettings.storeName); - await this.toBeVisible(selector.vendor.vStoreSettings.phoneNo); - DOKAN_PRO && (await this.toBeVisible(selector.vendor.vStoreSettings.multipleLocation)); + await this.toBeVisible(vendorSettings.banner); + await this.toBeVisible(vendorSettings.profilePicture); + await this.toBeVisible(vendorSettings.storeName); + await this.toBeVisible(vendorSettings.phoneNo); + DOKAN_PRO && (await this.toBeVisible(vendorSettings.multipleLocation)); // store address location elements are visible - const { saveLocation, cancelSaveLocation, deleteSaveLocation, ...address } = selector.vendor.vStoreSettings.address; + const { saveLocation, cancelSaveLocation, deleteSaveLocation, ...address } = vendorSettings.address; await this.multipleElementVisible(address); DOKAN_PRO && (await this.toBeVisible(saveLocation)); // company info elements are visible - DOKAN_PRO && (await this.multipleElementVisible(selector.vendor.vStoreSettings.companyInfo)); + DOKAN_PRO && (await this.multipleElementVisible(vendorSettings.companyInfo)); - await this.toBeVisible(selector.vendor.vStoreSettings.email); + await this.toBeVisible(vendorSettings.email); // map is visible - // await this.toBeVisible(selector.vendor.vStoreSettings.map); //TODO: g_map value not found + // await this.toBeVisible(vendorSettings.map); //TODO: g_map value not found // todo: catalog, discount, vacation, open close, store category // biography is visible - DOKAN_PRO && (await this.toBeVisible(selector.vendor.vStoreSettings.biographyIframe)); + DOKAN_PRO && (await this.toBeVisible(vendorSettings.biographyIframe)); // todo: min-max, store-support // update settings are visible - await this.toBeVisible(selector.vendor.vStoreSettings.updateSettingsTop); - await this.toBeVisible(selector.vendor.vStoreSettings.updateSettings); + await this.toBeVisible(vendorSettings.updateSettingsTop); + await this.toBeVisible(vendorSettings.updateSettings); } // vendor shipstation render properly @@ -152,8 +155,8 @@ export class VendorSettingsPage extends VendorPage { // update store map via settings save async updateStoreMapViaSettingsSave() { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsStore); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.vendor.vStoreSettings.updateSettings); - await this.toContainText(selector.vendor.vStoreSettings.updateSettingsSuccessMessage, 'Your information has been saved successfully'); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, vendorSettings.updateSettings); + await this.toContainText(vendorSettings.updateSettingsSuccessMessage, 'Your information has been saved successfully'); } // vendor set store settings @@ -218,43 +221,43 @@ export class VendorSettingsPage extends VendorPage { } // update settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.vendor.vStoreSettings.updateSettings); - await this.toContainText(selector.vendor.vStoreSettings.updateSettingsSuccessMessage, data.vendor.vendorInfo.storeSettingsSaveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, vendorSettings.updateSettings); + await this.toContainText(vendorSettings.updateSettingsSuccessMessage, data.vendor.vendorInfo.storeSettingsSaveSuccessMessage); } // vendor set basic info settings async basicInfoSettings(vendorInfo: vendor['vendorInfo']): Promise { // store basic info - await this.clearAndType(selector.vendor.vStoreSettings.storeName, vendorInfo.storeName); - await this.clearAndType(selector.vendor.vStoreSettings.phoneNo, vendorInfo.phoneNumber); + await this.clearAndType(vendorSettings.storeName, vendorInfo.storeName); + await this.clearAndType(vendorSettings.phoneNo, vendorInfo.phoneNumber); // email - await this.check(selector.vendor.vStoreSettings.email); + await this.check(vendorSettings.email); } // vendor set store address async setStoreAddress(vendorInfo: vendor['vendorInfo']): Promise { - await this.clearAndType(selector.vendor.vStoreSettings.address.street, vendorInfo.street1); - await this.clearAndType(selector.vendor.vStoreSettings.address.street2, vendorInfo.street2); - await this.clearAndType(selector.vendor.vStoreSettings.address.city, vendorInfo.city); - await this.clearAndType(selector.vendor.vStoreSettings.address.postOrZipCode, vendorInfo.zipCode); - await this.selectByValue(selector.vendor.vStoreSettings.address.country, vendorInfo.countrySelectValue); - await this.selectByValue(selector.vendor.vStoreSettings.address.state, vendorInfo.stateSelectValue); + await this.clearAndType(vendorSettings.address.street, vendorInfo.street1); + await this.clearAndType(vendorSettings.address.street2, vendorInfo.street2); + await this.clearAndType(vendorSettings.address.city, vendorInfo.city); + await this.clearAndType(vendorSettings.address.postOrZipCode, vendorInfo.zipCode); + await this.selectByValue(vendorSettings.address.country, vendorInfo.countrySelectValue); + await this.selectByValue(vendorSettings.address.state, vendorInfo.stateSelectValue); } // vendor set company info async setCompanyInfo(vendorInfo: vendor['vendorInfo']): Promise { - await this.clearAndType(selector.vendor.vStoreSettings.companyInfo.companyName, vendorInfo.companyName); - await this.clearAndType(selector.vendor.vStoreSettings.companyInfo.companyId, vendorInfo.companyId); - await this.clearAndType(selector.vendor.vStoreSettings.companyInfo.vatOrTaxNumber, vendorInfo.vatNumber); - await this.clearAndType(selector.vendor.vStoreSettings.companyInfo.nameOfBank, vendorInfo.bankName); - await this.clearAndType(selector.vendor.vStoreSettings.companyInfo.bankIban, vendorInfo.bankIban); + await this.clearAndType(vendorSettings.companyInfo.companyName, vendorInfo.companyName); + await this.clearAndType(vendorSettings.companyInfo.companyId, vendorInfo.companyId); + await this.clearAndType(vendorSettings.companyInfo.vatOrTaxNumber, vendorInfo.vatNumber); + await this.clearAndType(vendorSettings.companyInfo.nameOfBank, vendorInfo.bankName); + await this.clearAndType(vendorSettings.companyInfo.bankIban, vendorInfo.bankIban); } // vendor set map settings async mapSettings(mapLocation: string): Promise { - const geoLocationEnabled = await this.isVisible(selector.vendor.vStoreSettings.map); + const geoLocationEnabled = await this.isVisible(vendorSettings.map); if (geoLocationEnabled) { - await this.typeAndWaitForResponse(data.subUrls.gmap, selector.vendor.vStoreSettings.map, mapLocation); + await this.typeAndWaitForResponse(data.subUrls.gmap, vendorSettings.map, mapLocation); await this.press(data.key.arrowDown); await this.press(data.key.enter); } @@ -262,59 +265,59 @@ export class VendorSettingsPage extends VendorPage { // vendor set terms and conditions settings async termsAndConditionsSettings(termsAndConditions: string): Promise { - const tocEnabled = await this.isVisible(selector.vendor.vStoreSettings.termsAndConditions); + const tocEnabled = await this.isVisible(vendorSettings.termsAndConditions); if (tocEnabled) { - await this.check(selector.vendor.vStoreSettings.termsAndConditions); - await this.typeFrameSelector(selector.vendor.vStoreSettings.termsAndConditionsIframe, selector.vendor.vStoreSettings.termsAndConditionsHtmlBody, termsAndConditions); + await this.check(vendorSettings.termsAndConditions); + await this.typeFrameSelector(vendorSettings.termsAndConditionsIframe, vendorSettings.termsAndConditionsHtmlBody, termsAndConditions); } } // vendor set opening closing time settings async openingClosingTimeSettings(openingClosingTime: vendor['vendorInfo']['openingClosingTime']): Promise { - const openCloseTimeEnabled = await this.isVisible(selector.vendor.vStoreSettings.storeOpeningClosingTime); + const openCloseTimeEnabled = await this.isVisible(vendorSettings.storeOpeningClosingTime); if (openCloseTimeEnabled) { - await this.check(selector.vendor.vStoreSettings.storeOpeningClosingTime); + await this.check(vendorSettings.storeOpeningClosingTime); for (const day of openingClosingTime.days) { if (DOKAN_PRO) { - await this.enableSwitcherDeliveryTime(selector.vendor.vStoreSettings.openingClosingTimeSwitch(day)); - await this.setAttributeValue(selector.vendor.vStoreSettings.openingTime(day), 'value', openingClosingTime.openingTime); - await this.setAttributeValue(selector.vendor.vStoreSettings.openingTimeHiddenInput(day), 'value', openingClosingTime.openingTime); - await this.setAttributeValue(selector.vendor.vStoreSettings.closingTime(day), 'value', openingClosingTime.closingTime); - await this.setAttributeValue(selector.vendor.vStoreSettings.closingTimeHiddenInput(day), 'value', openingClosingTime.closingTime); + await this.enableSwitcherDeliveryTime(vendorSettings.openingClosingTimeSwitch(day)); + await this.setAttributeValue(vendorSettings.openingTime(day), 'value', openingClosingTime.openingTime); + await this.setAttributeValue(vendorSettings.openingTimeHiddenInput(day), 'value', openingClosingTime.openingTime); + await this.setAttributeValue(vendorSettings.closingTime(day), 'value', openingClosingTime.closingTime); + await this.setAttributeValue(vendorSettings.closingTimeHiddenInput(day), 'value', openingClosingTime.closingTime); } else { // lite - await this.selectByValue(selector.vendor.vStoreSettings.lite.openingClosingTimeEnable(day), openingClosingTime.statusLite); - await this.clearAndType(selector.vendor.vStoreSettings.lite.openingTimeInput(day), openingClosingTime.openingTime); - await this.clearAndType(selector.vendor.vStoreSettings.lite.closingTimeInput(day), openingClosingTime.closingTime); + await this.selectByValue(vendorSettings.lite.openingClosingTimeEnable(day), openingClosingTime.statusLite); + await this.clearAndType(vendorSettings.lite.openingTimeInput(day), openingClosingTime.openingTime); + await this.clearAndType(vendorSettings.lite.closingTimeInput(day), openingClosingTime.closingTime); } } - await this.clearAndType(selector.vendor.vStoreSettings.storeOpenNotice, openingClosingTime.storeOpenNotice); - await this.clearAndType(selector.vendor.vStoreSettings.storeCloseNotice, openingClosingTime.storeCloseNotice); + await this.clearAndType(vendorSettings.storeOpenNotice, openingClosingTime.storeOpenNotice); + await this.clearAndType(vendorSettings.storeCloseNotice, openingClosingTime.storeCloseNotice); } } // vendor set vacation settings async vacationSettings(vacation: vendor['vendorInfo']['vacation']): Promise { - const vacationModeEnabled = await this.isVisible(selector.vendor.vStoreSettings.goToVacation); + const vacationModeEnabled = await this.isVisible(vendorSettings.goToVacation); if (vacationModeEnabled) { - await this.check(selector.vendor.vStoreSettings.goToVacation); - await this.selectByValue(selector.vendor.vStoreSettings.closingStyle, vacation.closingStyle); + await this.check(vendorSettings.goToVacation); + await this.selectByValue(vendorSettings.closingStyle, vacation.closingStyle); switch (vacation.closingStyle) { // instantly close case 'instantly': - await this.clearAndType(selector.vendor.vStoreSettings.setVacationMessageInstantly, vacation.instantly.vacationMessage); + await this.clearAndType(vendorSettings.setVacationMessageInstantly, vacation.instantly.vacationMessage); break; // datewise close case 'datewise': { const vacationDayFrom = vacation.datewise.vacationDayFrom(); const vacationDayTo = vacation.datewise.vacationDayTo(vacationDayFrom); - await this.setAttributeValue(selector.vendor.vStoreSettings.vacationDateRange, 'value', helpers.dateFormatFYJ(vacationDayFrom) + ' - ' + helpers.dateFormatFYJ(vacationDayTo)); - await this.setAttributeValue(selector.vendor.vStoreSettings.vacationDateRangeFrom, 'value', vacationDayFrom); - await this.setAttributeValue(selector.vendor.vStoreSettings.vacationDateRangeTo, 'value', vacationDayTo); - await this.clearAndType(selector.vendor.vStoreSettings.setVacationMessageDatewise, vacation.datewise.vacationMessage); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vStoreSettings.saveVacationEdit); + await this.setAttributeValue(vendorSettings.vacationDateRange, 'value', helpers.dateFormatFYJ(vacationDayFrom) + ' - ' + helpers.dateFormatFYJ(vacationDayTo)); + await this.setAttributeValue(vendorSettings.vacationDateRangeFrom, 'value', vacationDayFrom); + await this.setAttributeValue(vendorSettings.vacationDateRangeTo, 'value', vacationDayTo); + await this.clearAndType(vendorSettings.setVacationMessageDatewise, vacation.datewise.vacationMessage); + await this.clickAndWaitForResponse(data.subUrls.ajax, vendorSettings.saveVacationEdit); break; } @@ -327,81 +330,81 @@ export class VendorSettingsPage extends VendorPage { // vendor delete pervious datewise vacation settings if any async deletePreviousDatewiseVacation() { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsStore); - const noVacationIsSetIsVisible = await this.isVisible(selector.vendor.vStoreSettings.noVacationIsSet); + const noVacationIsSetIsVisible = await this.isVisible(vendorSettings.noVacationIsSet); if (!noVacationIsSetIsVisible) { - await this.hover(selector.vendor.vStoreSettings.vacationRow); - await this.click(selector.vendor.vStoreSettings.deleteSavedVacationSchedule); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vStoreSettings.confirmDeleteSavedVacationSchedule); + await this.hover(vendorSettings.vacationRow); + await this.click(vendorSettings.deleteSavedVacationSchedule); + await this.clickAndWaitForResponse(data.subUrls.ajax, vendorSettings.confirmDeleteSavedVacationSchedule); } // update settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.vendor.vStoreSettings.updateSettings); - await this.toContainText(selector.vendor.vStoreSettings.updateSettingsSuccessMessage, data.vendor.vendorInfo.storeSettingsSaveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, vendorSettings.updateSettings); + await this.toContainText(vendorSettings.updateSettingsSuccessMessage, data.vendor.vendorInfo.storeSettingsSaveSuccessMessage); } // vendor set catalog mode settings async catalogModeSettings(): Promise { - const catalogModeEnabled = await this.isVisible(selector.vendor.vStoreSettings.removeAddToCartButton); + const catalogModeEnabled = await this.isVisible(vendorSettings.removeAddToCartButton); if (catalogModeEnabled) { - await this.check(selector.vendor.vStoreSettings.removeAddToCartButton); - await this.check(selector.vendor.vStoreSettings.hideProductPrice); - await this.checkIfVisible(selector.vendor.vStoreSettings.enableRequestQuoteSupport); + await this.check(vendorSettings.removeAddToCartButton); + await this.check(vendorSettings.hideProductPrice); + await this.checkIfVisible(vendorSettings.enableRequestQuoteSupport); } } // reset catalog async resetCatalog(): Promise { - await this.uncheck(selector.vendor.vStoreSettings.removeAddToCartButton); + await this.uncheck(vendorSettings.removeAddToCartButton); // update settings - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.vendor.vStoreSettings.updateSettings); - await this.toContainText(selector.vendor.vStoreSettings.updateSettingsSuccessMessage, data.vendor.vendorInfo.storeSettingsSaveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, vendorSettings.updateSettings); + await this.toContainText(vendorSettings.updateSettingsSuccessMessage, data.vendor.vendorInfo.storeSettingsSaveSuccessMessage); } // vendor set discount settings async discountSettings(amountDiscount: vendor['vendorInfo']['amountDiscount']): Promise { - const discountEnabled = await this.isVisible(selector.vendor.vStoreSettings.enableStoreWideDiscount); + const discountEnabled = await this.isVisible(vendorSettings.enableStoreWideDiscount); if (discountEnabled) { - await this.check(selector.vendor.vStoreSettings.enableStoreWideDiscount); - await this.clearAndType(selector.vendor.vStoreSettings.minimumOrderAmount, amountDiscount.minimumOrderAmount); - await this.clearAndType(selector.vendor.vStoreSettings.percentage, amountDiscount.discountPercentage); + await this.check(vendorSettings.enableStoreWideDiscount); + await this.clearAndType(vendorSettings.minimumOrderAmount, amountDiscount.minimumOrderAmount); + await this.clearAndType(vendorSettings.percentage, amountDiscount.discountPercentage); } } // vendor set biography settings async biographySettings(biography: string): Promise { - await this.typeFrameSelector(selector.vendor.vStoreSettings.biographyIframe, selector.vendor.vStoreSettings.biographyHtmlBody, biography); + await this.typeFrameSelector(vendorSettings.biographyIframe, vendorSettings.biographyHtmlBody, biography); } // vendor set store support settings async storeSupportSettings(supportButtonText: string): Promise { - const storeSupportEnabled = await this.isVisible(selector.vendor.vStoreSettings.removeAddToCartButton); + const storeSupportEnabled = await this.isVisible(vendorSettings.removeAddToCartButton); if (storeSupportEnabled) { - await this.check(selector.vendor.vStoreSettings.showSupportButtonInStore); - await this.check(selector.vendor.vStoreSettings.showSupportButtonInSingleProduct); - await this.clearAndType(selector.vendor.vStoreSettings.supportButtonText, supportButtonText); + await this.check(vendorSettings.showSupportButtonInStore); + await this.check(vendorSettings.showSupportButtonInSingleProduct); + await this.clearAndType(vendorSettings.supportButtonText, supportButtonText); } } // vendor set minmax settings async minMaxSettings(minMax: vendor['vendorInfo']['minMax']): Promise { - const minMaxEnabled = await this.isVisible(selector.vendor.vStoreSettings.enableMinMaxQuantities); + const minMaxEnabled = await this.isVisible(vendorSettings.enableMinMaxQuantities); if (minMaxEnabled) { // min max quantities - await this.check(selector.vendor.vStoreSettings.enableMinMaxQuantities); - await this.clearAndType(selector.vendor.vStoreSettings.minimumProductQuantityToPlaceAnOrder, minMax.minimumProductQuantity); - await this.clearAndType(selector.vendor.vStoreSettings.maximumProductQuantityToPlaceAnOrder, minMax.maximumProductQuantity); + await this.check(vendorSettings.enableMinMaxQuantities); + await this.clearAndType(vendorSettings.minimumProductQuantityToPlaceAnOrder, minMax.minimumProductQuantity); + await this.clearAndType(vendorSettings.maximumProductQuantityToPlaceAnOrder, minMax.maximumProductQuantity); // min max amount - await this.check(selector.vendor.vStoreSettings.enableMinMaxAmount); - await this.clearAndType(selector.vendor.vStoreSettings.minimumAmountToPlaceAnOrder, minMax.minimumAmount); - await this.clearAndType(selector.vendor.vStoreSettings.maximumAmountToPlaceAnOrder, minMax.maximumAmount); - await this.click(selector.vendor.vStoreSettings.clear); - await this.click(selector.vendor.vStoreSettings.selectAll); - const multipleCategory = await this.isVisible(selector.vendor.vStoreSettings.selectCategorySearch); + await this.check(vendorSettings.enableMinMaxAmount); + await this.clearAndType(vendorSettings.minimumAmountToPlaceAnOrder, minMax.minimumAmount); + await this.clearAndType(vendorSettings.maximumAmountToPlaceAnOrder, minMax.maximumAmount); + await this.click(vendorSettings.clear); + await this.click(vendorSettings.selectAll); + const multipleCategory = await this.isVisible(vendorSettings.selectCategorySearch); if (multipleCategory) { - await this.select2ByTextMultiSelector(selector.vendor.vStoreSettings.selectCategorySearch, selector.vendor.vStoreSettings.selectCategorySearchedResult, minMax.category); + await this.select2ByTextMultiSelector(vendorSettings.selectCategorySearch, vendorSettings.selectCategorySearchedResult, minMax.category); } else { - await this.selectByLabel(selector.vendor.vStoreSettings.selectCategory, minMax.category); + await this.selectByLabel(vendorSettings.selectCategory, minMax.category); } } } diff --git a/tests/pw/pages/vendorShippingPage.ts b/tests/pw/pages/vendorShippingPage.ts index 1d74080fed..4044c7054f 100644 --- a/tests/pw/pages/vendorShippingPage.ts +++ b/tests/pw/pages/vendorShippingPage.ts @@ -4,6 +4,9 @@ import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; import { vendor, shipping } from '@utils/interfaces'; +// selectors +const vendorShipping = selector.vendor.vShippingSettings; + export class VendorShippingPage extends VendorPage { constructor(page: Page) { super(page); @@ -16,32 +19,32 @@ export class VendorShippingPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsShipping); // shipstation text is visible - await this.toBeVisible(selector.vendor.vShippingSettings.shippingSettingsText); + await this.toBeVisible(vendorShipping.shippingSettingsText); // visit store link is visible - await this.toBeVisible(selector.vendor.vShippingSettings.visitStore); + await this.toBeVisible(vendorShipping.visitStore); // add shipping policies is visible - await this.toBeVisible(selector.vendor.vShippingSettings.shippingPolicies.clickHereToAddShippingPolicies); + await this.toBeVisible(vendorShipping.shippingPolicies.clickHereToAddShippingPolicies); // previous shipping settings link is visible - await this.toBeVisible(selector.vendor.vShippingSettings.shippingPolicies.clickHereToAddShippingPolicies); + await this.toBeVisible(vendorShipping.shippingPolicies.clickHereToAddShippingPolicies); // shipping zone table elements are visible - await this.multipleElementVisible(selector.vendor.vShippingSettings.table); + await this.multipleElementVisible(vendorShipping.table); - await this.clickAndWaitForLoadState(selector.vendor.vShippingSettings.shippingPolicies.clickHereToAddShippingPolicies); + await this.clickAndWaitForLoadState(vendorShipping.shippingPolicies.clickHereToAddShippingPolicies); // shipping policy elements are visible - const { clickHereToAddShippingPolicies, ...companyVerifications } = selector.vendor.vShippingSettings.shippingPolicies; + const { clickHereToAddShippingPolicies, ...companyVerifications } = vendorShipping.shippingPolicies; await this.multipleElementVisible(companyVerifications); - await this.clickAndWaitForLoadState(selector.vendor.vShippingSettings.shippingPolicies.backToZoneList); + await this.clickAndWaitForLoadState(vendorShipping.shippingPolicies.backToZoneList); - await this.clickAndWaitForLoadState(selector.vendor.vShippingSettings.previousShippingSettings.previousShippingSettings); + await this.clickAndWaitForLoadState(vendorShipping.previousShippingSettings.previousShippingSettings); // previous shipping settings elements are visible - const { previousShippingSettings, ...previousShipping } = selector.vendor.vShippingSettings.previousShippingSettings; + const { previousShippingSettings, ...previousShipping } = vendorShipping.previousShippingSettings; await this.multipleElementVisible(previousShipping); // await this.goBack(); @@ -50,12 +53,12 @@ export class VendorShippingPage extends VendorPage { // set shipping policies async setShippingPolicies(shippingPolicy: vendor['shipping']['shippingPolicy']): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsShipping); - await this.click(selector.vendor.vShippingSettings.shippingPolicies.clickHereToAddShippingPolicies); - await this.selectByValue(selector.vendor.vShippingSettings.shippingPolicies.processingTime, shippingPolicy.processingTime); - await this.clearAndType(selector.vendor.vShippingSettings.shippingPolicies.shippingPolicy, shippingPolicy.shippingPolicy); - await this.clearAndType(selector.vendor.vShippingSettings.shippingPolicies.refundPolicy, shippingPolicy.refundPolicy); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vShippingSettings.shippingPolicies.saveSettings); - await this.toContainText(selector.vendor.vShippingSettings.updateSettingsSuccessMessage, shippingPolicy.saveSuccessMessage); + await this.click(vendorShipping.shippingPolicies.clickHereToAddShippingPolicies); + await this.selectByValue(vendorShipping.shippingPolicies.processingTime, shippingPolicy.processingTime); + await this.clearAndType(vendorShipping.shippingPolicies.shippingPolicy, shippingPolicy.shippingPolicy); + await this.clearAndType(vendorShipping.shippingPolicies.refundPolicy, shippingPolicy.refundPolicy); + await this.clickAndWaitForResponse(data.subUrls.ajax, vendorShipping.shippingPolicies.saveSettings); + await this.toContainText(vendorShipping.updateSettingsSuccessMessage, shippingPolicy.saveSuccessMessage); } // vendor set all shipping settings @@ -71,15 +74,15 @@ export class VendorShippingPage extends VendorPage { async addShippingMethod(shipping: any, forceAdd = false, skip?: boolean): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsShipping); // edit shipping zone - await this.hover(selector.vendor.vShippingSettings.shippingZoneCell(shipping.shippingZone)); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.vendor.vShippingSettings.editShippingZone(shipping.shippingZone)); + await this.hover(vendorShipping.shippingZoneCell(shipping.shippingZone)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, vendorShipping.editShippingZone(shipping.shippingZone)); // add shipping method if not available - let methodExists = await this.isVisible(selector.vendor.vShippingSettings.shippingMethodCell(shipping.shippingMethod)); + let methodExists = await this.isVisible(vendorShipping.shippingMethodCell(shipping.shippingMethod)); if (!methodExists || forceAdd) { - await this.click(selector.vendor.vShippingSettings.addShippingMethod); - await this.selectByValue(selector.vendor.vShippingSettings.shippingMethod, shipping.selectShippingMethod); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.vendor.vShippingSettings.shippingMethodPopupAddShippingMethod); + await this.click(vendorShipping.addShippingMethod); + await this.selectByValue(vendorShipping.shippingMethod, shipping.selectShippingMethod); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, vendorShipping.shippingMethodPopupAddShippingMethod); await expect(this.page.getByText(shipping.shippingMethodSaveSuccessMessage)).toBeVisible(); await expect(this.page.getByText(shipping.zoneSaveSuccessMessage)).toBeVisible(); methodExists = true; @@ -91,76 +94,76 @@ export class VendorShippingPage extends VendorPage { } // edit shipping method - await this.hover(selector.vendor.vShippingSettings.shippingMethodCell(shipping.shippingMethod)); - await this.click(selector.vendor.vShippingSettings.editShippingMethod(shipping.shippingMethod)); + await this.hover(vendorShipping.shippingMethodCell(shipping.shippingMethod)); + await this.click(vendorShipping.editShippingMethod(shipping.shippingMethod)); switch (shipping.selectShippingMethod) { // flat rate case 'flat_rate': - await this.clearAndType(selector.vendor.vShippingSettings.flatRateMethodTitle, shipping.shippingMethodTitle); - await this.clearAndType(selector.vendor.vShippingSettings.flatRateCost, shipping.shippingCost); - await this.selectByValue(selector.vendor.vShippingSettings.flatRateTaxStatus, shipping.taxStatus); - await this.clearAndType(selector.vendor.vShippingSettings.flatRateDescription, shipping.description); - await this.selectByValue(selector.vendor.vShippingSettings.flatRateCalculationType, shipping.calculationType); + await this.clearAndType(vendorShipping.flatRateMethodTitle, shipping.shippingMethodTitle); + await this.clearAndType(vendorShipping.flatRateCost, shipping.shippingCost); + await this.selectByValue(vendorShipping.flatRateTaxStatus, shipping.taxStatus); + await this.clearAndType(vendorShipping.flatRateDescription, shipping.description); + await this.selectByValue(vendorShipping.flatRateCalculationType, shipping.calculationType); break; // free shipping case 'free_shipping': - await this.clearAndType(selector.vendor.vShippingSettings.freeShippingTitle, shipping.shippingMethodTitle); - await this.clearAndType(selector.vendor.vShippingSettings.freeShippingMinimumOrderAmount, shipping.freeShippingMinimumOrderAmount); + await this.clearAndType(vendorShipping.freeShippingTitle, shipping.shippingMethodTitle); + await this.clearAndType(vendorShipping.freeShippingMinimumOrderAmount, shipping.freeShippingMinimumOrderAmount); break; // local pickup case 'local_pickup': - await this.clearAndType(selector.vendor.vShippingSettings.localPickupTitle, shipping.shippingMethodTitle); - await this.clearAndType(selector.vendor.vShippingSettings.localPickupCost, shipping.shippingCost); - await this.selectByValue(selector.vendor.vShippingSettings.localPickupTaxStatus, shipping.taxStatus); - await this.clearAndType(selector.vendor.vShippingSettings.flatRateDescription, shipping.description); + await this.clearAndType(vendorShipping.localPickupTitle, shipping.shippingMethodTitle); + await this.clearAndType(vendorShipping.localPickupCost, shipping.shippingCost); + await this.selectByValue(vendorShipping.localPickupTaxStatus, shipping.taxStatus); + await this.clearAndType(vendorShipping.flatRateDescription, shipping.description); break; // dokan table rate shipping case 'dokan_table_rate_shipping': - await this.clearAndType(selector.vendor.vShippingSettings.tableRateShippingMethodTitle, shipping.shippingMethodTitle); - await this.selectByValue(selector.vendor.vShippingSettings.tableRateShippingTaxStatus, shipping.taxStatus); - await this.selectByValue(selector.vendor.vShippingSettings.tableRateShippingTaxIncludedInShippingCosts, shipping.taxIncludedInShippingCosts); - await this.clearAndType(selector.vendor.vShippingSettings.tableRateShippingHandlingFee, shipping.handlingFee); - await this.clearAndType(selector.vendor.vShippingSettings.tableRateShippingMaximumShippingCost, shipping.maximumShippingCost); + await this.clearAndType(vendorShipping.tableRateShippingMethodTitle, shipping.shippingMethodTitle); + await this.selectByValue(vendorShipping.tableRateShippingTaxStatus, shipping.taxStatus); + await this.selectByValue(vendorShipping.tableRateShippingTaxIncludedInShippingCosts, shipping.taxIncludedInShippingCosts); + await this.clearAndType(vendorShipping.tableRateShippingHandlingFee, shipping.handlingFee); + await this.clearAndType(vendorShipping.tableRateShippingMaximumShippingCost, shipping.maximumShippingCost); // rates - // await this.selectByValue(selector.vendor.vShippingSettings.tableRateShippingCalculationType, shipping.calculationType) - await this.clearAndType(selector.vendor.vShippingSettings.tableRateShippingHandlingFeePerOrder, shipping.handlingFeePerOrder); - await this.clearAndType(selector.vendor.vShippingSettings.tableRateShippingMinimumCostPerOrder, shipping.minimumCostPerOrder); - await this.clearAndType(selector.vendor.vShippingSettings.tableRateShippingMaximumCostPerOrder, shipping.maximumCostPerOrder); - await this.click(selector.vendor.vShippingSettings.tableRateShippingUpdateSettings); - await this.toContainText(selector.vendor.vShippingSettings.tableRateShippingUpdateSettingsSuccessMessage, shipping.tableRateSaveSuccessMessage); + // await this.selectByValue(vendorShipping.tableRateShippingCalculationType, shipping.calculationType) + await this.clearAndType(vendorShipping.tableRateShippingHandlingFeePerOrder, shipping.handlingFeePerOrder); + await this.clearAndType(vendorShipping.tableRateShippingMinimumCostPerOrder, shipping.minimumCostPerOrder); + await this.clearAndType(vendorShipping.tableRateShippingMaximumCostPerOrder, shipping.maximumCostPerOrder); + await this.click(vendorShipping.tableRateShippingUpdateSettings); + await this.toContainText(vendorShipping.tableRateShippingUpdateSettingsSuccessMessage, shipping.tableRateSaveSuccessMessage); return; // dokan distance rate shipping case 'dokan_distance_rate_shipping': - await this.clearAndType(selector.vendor.vShippingSettings.distanceRateShippingMethodTitle, shipping.shippingMethodTitle); - await this.selectByValue(selector.vendor.vShippingSettings.distanceRateShippingTaxStatus, shipping.taxStatus); - await this.selectByValue(selector.vendor.vShippingSettings.distanceRateShippingTransportationMode, shipping.transportationMode); - await this.selectByValue(selector.vendor.vShippingSettings.distanceRateShippingAvoid, shipping.avoid); - await this.selectByValue(selector.vendor.vShippingSettings.distanceRateShippingDistanceUnit, shipping.distanceUnit); - await this.check(selector.vendor.vShippingSettings.distanceRateShippingShowDistance); - await this.check(selector.vendor.vShippingSettings.distanceRateShippingShowDuration); + await this.clearAndType(vendorShipping.distanceRateShippingMethodTitle, shipping.shippingMethodTitle); + await this.selectByValue(vendorShipping.distanceRateShippingTaxStatus, shipping.taxStatus); + await this.selectByValue(vendorShipping.distanceRateShippingTransportationMode, shipping.transportationMode); + await this.selectByValue(vendorShipping.distanceRateShippingAvoid, shipping.avoid); + await this.selectByValue(vendorShipping.distanceRateShippingDistanceUnit, shipping.distanceUnit); + await this.check(vendorShipping.distanceRateShippingShowDistance); + await this.check(vendorShipping.distanceRateShippingShowDuration); // shipping address - await this.clearAndType(selector.vendor.vShippingSettings.distanceRateShippingAddress1, shipping.street1); - await this.clearAndType(selector.vendor.vShippingSettings.distanceRateShippingAddress2, shipping.street2); - await this.clearAndType(selector.vendor.vShippingSettings.distanceRateShippingCity, shipping.city); - await this.clearAndType(selector.vendor.vShippingSettings.distanceRateShippingZipOrPostalCode, shipping.zipCode); - await this.clearAndType(selector.vendor.vShippingSettings.distanceRateShippingStateOrProvince, shipping.state); - await this.selectByValue(selector.vendor.vShippingSettings.distanceRateShippingCountry, shipping.country); - await this.click(selector.vendor.vShippingSettings.distanceRateShippingUpdateSettings); - await this.toContainText(selector.vendor.vShippingSettings.distanceRateShippingUpdateSettingsSuccessMessage, shipping.distanceRateSaveSuccessMessage); + await this.clearAndType(vendorShipping.distanceRateShippingAddress1, shipping.street1); + await this.clearAndType(vendorShipping.distanceRateShippingAddress2, shipping.street2); + await this.clearAndType(vendorShipping.distanceRateShippingCity, shipping.city); + await this.clearAndType(vendorShipping.distanceRateShippingZipOrPostalCode, shipping.zipCode); + await this.clearAndType(vendorShipping.distanceRateShippingStateOrProvince, shipping.state); + await this.selectByValue(vendorShipping.distanceRateShippingCountry, shipping.country); + await this.click(vendorShipping.distanceRateShippingUpdateSettings); + await this.toContainText(vendorShipping.distanceRateShippingUpdateSettingsSuccessMessage, shipping.distanceRateSaveSuccessMessage); return; default: break; } - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.vendor.vShippingSettings.shippingSettingsSaveSettings); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.vendor.vShippingSettings.saveChanges); - await this.toContainText(selector.vendor.vShippingSettings.updateSettingsSuccessMessage, shipping.saveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, vendorShipping.shippingSettingsSaveSettings); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, vendorShipping.saveChanges); + await this.toContainText(vendorShipping.updateSettingsSuccessMessage, shipping.saveSuccessMessage); } // vendor add shipping method @@ -168,20 +171,20 @@ export class VendorShippingPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsShipping); // edit shipping zone - await this.hover(selector.vendor.vShippingSettings.shippingZoneCell(shipping.shippingZone)); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.vendor.vShippingSettings.editShippingZone(shipping.shippingZone)); + await this.hover(vendorShipping.shippingZoneCell(shipping.shippingZone)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, vendorShipping.editShippingZone(shipping.shippingZone)); - const noOfMethods = await this.countLocator(selector.vendor.vShippingSettings.shippingMethodCell(shipping.shippingMethod)); + const noOfMethods = await this.countLocator(vendorShipping.shippingMethodCell(shipping.shippingMethod)); if (noOfMethods > 1) { - this.lastLocator(selector.vendor.vShippingSettings.shippingMethodCell(shipping.shippingMethod)).hover(); - const deleteMethod = this.lastLocator(selector.vendor.vShippingSettings.deleteShippingMethod(shipping.shippingMethod)); + this.lastLocator(vendorShipping.shippingMethodCell(shipping.shippingMethod)).hover(); + const deleteMethod = this.lastLocator(vendorShipping.deleteShippingMethod(shipping.shippingMethod)); await this.clickLocatorAndWaitForResponse(data.subUrls.ajax, deleteMethod); - await this.toHaveCount(selector.vendor.vShippingSettings.shippingMethodCell(shipping.shippingMethod), noOfMethods - 1); + await this.toHaveCount(vendorShipping.shippingMethodCell(shipping.shippingMethod), noOfMethods - 1); } else { - await this.hover(selector.vendor.vShippingSettings.shippingMethodCell(shipping.shippingMethod)); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vShippingSettings.deleteShippingMethod(shipping.shippingMethod)); - await this.notToBeVisible(selector.vendor.vShippingSettings.shippingZoneCell(shipping.shippingZone)); + await this.hover(vendorShipping.shippingMethodCell(shipping.shippingMethod)); + await this.clickAndWaitForResponse(data.subUrls.ajax, vendorShipping.deleteShippingMethod(shipping.shippingMethod)); + await this.notToBeVisible(vendorShipping.shippingZoneCell(shipping.shippingZone)); } } } diff --git a/tests/pw/pages/vendorStaffPage.ts b/tests/pw/pages/vendorStaffPage.ts index 621fcc6cd4..93b627e2f2 100644 --- a/tests/pw/pages/vendorStaffPage.ts +++ b/tests/pw/pages/vendorStaffPage.ts @@ -4,6 +4,9 @@ import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; import { staff } from '@utils/interfaces'; +// selectors +const vendorStaff = selector.vendor.vStaff; + export class VendorStaffPage extends VendorPage { constructor(page: Page) { super(page); @@ -16,102 +19,102 @@ export class VendorStaffPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.staff); // staff text is visible - await this.toBeVisible(selector.vendor.vStaff.staffText); + await this.toBeVisible(vendorStaff.staffText); // add new staff is visible - await this.toBeVisible(selector.vendor.vStaff.addStaff.addNewStaff); + await this.toBeVisible(vendorStaff.addStaff.addNewStaff); - const noStaff = await this.isVisible(selector.vendor.vStaff.noRowsFound); + const noStaff = await this.isVisible(vendorStaff.noRowsFound); if (noStaff) { - await this.toContainText(selector.vendor.vStaff.noRowsFound, 'No staff found'); + await this.toContainText(vendorStaff.noRowsFound, 'No staff found'); console.log('No staff found on staff page'); } else { // vendor staff table elements are visible - await this.multipleElementVisible(selector.vendor.vStaff.table); + await this.multipleElementVisible(vendorStaff.table); } } // update staff fields async updateStaffFields(staff: staff) { - await this.clearAndType(selector.vendor.vStaff.addStaff.firstName, staff.firstName); - await this.clearAndType(selector.vendor.vStaff.addStaff.lastName, staff.lastName); - await this.clearAndType(selector.vendor.vStaff.addStaff.email, staff.email); - await this.clearAndType(selector.vendor.vStaff.addStaff.phone, staff.phone); - const isPasswordVisible = await this.isVisible(selector.vendor.vStaff.editStaff.password); - isPasswordVisible && (await this.clearAndType(selector.vendor.vStaff.editStaff.password, staff.password)); + await this.clearAndType(vendorStaff.addStaff.firstName, staff.firstName); + await this.clearAndType(vendorStaff.addStaff.lastName, staff.lastName); + await this.clearAndType(vendorStaff.addStaff.email, staff.email); + await this.clearAndType(vendorStaff.addStaff.phone, staff.phone); + const isPasswordVisible = await this.isVisible(vendorStaff.editStaff.password); + isPasswordVisible && (await this.clearAndType(vendorStaff.editStaff.password, staff.password)); } // add new staff async addStaff(staff: staff) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.staff); - await this.clickAndWaitForLoadState(selector.vendor.vStaff.addStaff.addNewStaff); + await this.clickAndWaitForLoadState(vendorStaff.addStaff.addNewStaff); await this.updateStaffFields(staff); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.staff, selector.vendor.vStaff.addStaff.createStaff); - const userAlreadyExists = await this.isVisible(selector.vendor.vStaff.addStaff.userAlreadyExists); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.staff, vendorStaff.addStaff.createStaff); + const userAlreadyExists = await this.isVisible(vendorStaff.addStaff.userAlreadyExists); if (userAlreadyExists) { console.log('Staff already exists!!'); return; } - await this.toBeVisible(selector.vendor.vStaff.staffCell(staff.firstName + ' ' + staff.lastName)); + await this.toBeVisible(vendorStaff.staffCell(staff.firstName + ' ' + staff.lastName)); } // edit staff async editStaff(staff: staff) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.staff); - await this.hover(selector.vendor.vStaff.staffCell(staff.firstName + ' ' + staff.lastName)); - await this.clickAndWaitForLoadState(selector.vendor.vStaff.editStaff.editStaff(staff.firstName + ' ' + staff.lastName)); + await this.hover(vendorStaff.staffCell(staff.firstName + ' ' + staff.lastName)); + await this.clickAndWaitForLoadState(vendorStaff.editStaff.editStaff(staff.firstName + ' ' + staff.lastName)); await this.updateStaffFields(staff); - await this.pressOnLocatorAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.staff, selector.vendor.vStaff.editStaff.updateStaff, data.key.enter); - await this.toBeVisible(selector.vendor.vStaff.staffCell(staff.firstName + ' ' + staff.lastName)); + await this.pressOnLocatorAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.staff, vendorStaff.editStaff.updateStaff, data.key.enter); + await this.toBeVisible(vendorStaff.staffCell(staff.firstName + ' ' + staff.lastName)); } // add new staff async deleteStaff(staffName: string) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.staff); - await this.hover(selector.vendor.vStaff.staffCell(staffName)); - await this.click(selector.vendor.vStaff.deleteStaff.deleteStaff(staffName)); - await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.staff, selector.vendor.vStaff.deleteStaff.okDelete, 302); - await this.toContainText(selector.vendor.vStaff.deleteStaff.deleteSuccessMessage, 'Staff deleted successfully'); + await this.hover(vendorStaff.staffCell(staffName)); + await this.click(vendorStaff.deleteStaff.deleteStaff(staffName)); + await this.clickAndWaitForResponse(data.subUrls.frontend.vDashboard.staff, vendorStaff.deleteStaff.okDelete, 302); + await this.toContainText(vendorStaff.deleteStaff.deleteSuccessMessage, 'Staff deleted successfully'); } // manage staff permission async manageStaffPermission(staffName: string) { await this.goIfNotThere(data.subUrls.frontend.vDashboard.staff); - await this.hover(selector.vendor.vStaff.staffCell(staffName)); - await this.clickAndWaitForLoadState(selector.vendor.vStaff.managePermission.managePermission(staffName)); + await this.hover(vendorStaff.staffCell(staffName)); + await this.clickAndWaitForLoadState(vendorStaff.managePermission.managePermission(staffName)); // manage overview permission - await this.multipleElementCheck(selector.vendor.vStaff.managePermission.overview); + await this.multipleElementCheck(vendorStaff.managePermission.overview); // manage order permission - await this.multipleElementCheck(selector.vendor.vStaff.managePermission.order); + await this.multipleElementCheck(vendorStaff.managePermission.order); // manage review permission - await this.multipleElementCheck(selector.vendor.vStaff.managePermission.review); + await this.multipleElementCheck(vendorStaff.managePermission.review); // manage product permission - await this.multipleElementCheck(selector.vendor.vStaff.managePermission.product); + await this.multipleElementCheck(vendorStaff.managePermission.product); // manage booking permission - // await this.multipleElementCheck(selector.vendor.vStaff.managePermission.booking); // todo: add booking module + plugin check + // await this.multipleElementCheck(vendorStaff.managePermission.booking); // todo: add booking module + plugin check // manage store support permission - await this.multipleElementCheck(selector.vendor.vStaff.managePermission.storeSupport); + await this.multipleElementCheck(vendorStaff.managePermission.storeSupport); // manage report permission - await this.multipleElementCheck(selector.vendor.vStaff.managePermission.report); + await this.multipleElementCheck(vendorStaff.managePermission.report); // manage coupon permission - await this.multipleElementCheck(selector.vendor.vStaff.managePermission.coupon); + await this.multipleElementCheck(vendorStaff.managePermission.coupon); // manage withdraw permission - await this.multipleElementCheck(selector.vendor.vStaff.managePermission.withdraw); + await this.multipleElementCheck(vendorStaff.managePermission.withdraw); // manage menu permission - await this.multipleElementCheck(selector.vendor.vStaff.managePermission.menu); + await this.multipleElementCheck(vendorStaff.managePermission.menu); // manage auction permission - // await this.multipleElementCheck(selector.vendor.vStaff.managePermission.auction); // todo: add auction module + plugin check + // await this.multipleElementCheck(vendorStaff.managePermission.auction); // todo: add auction module + plugin check } } diff --git a/tests/pw/pages/vendorToolsPage.ts b/tests/pw/pages/vendorToolsPage.ts index 7c9cef1e0b..d469ec5091 100644 --- a/tests/pw/pages/vendorToolsPage.ts +++ b/tests/pw/pages/vendorToolsPage.ts @@ -3,6 +3,9 @@ import { VendorPage } from '@pages/vendorPage'; import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; +// selectors +const vendorTools = selector.vendor.vTools; + export class VendorToolsPage extends VendorPage { constructor(page: Page) { super(page); @@ -15,42 +18,42 @@ export class VendorToolsPage extends VendorPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.tools); // tools text is visible - await this.toBeVisible(selector.vendor.vTools.toolsText); + await this.toBeVisible(vendorTools.toolsText); // tools menus are visible - await this.multipleElementVisible(selector.vendor.vTools.menus); + await this.multipleElementVisible(vendorTools.menus); // import // import xml elements are visible - const { completionMessage, ...xml } = selector.vendor.vTools.import.xml; + const { completionMessage, ...xml } = vendorTools.import.xml; await this.multipleElementVisible(xml); // csv // import csv text is visible - await this.toBeVisible(selector.vendor.vTools.import.csv.importCsvText); + await this.toBeVisible(vendorTools.import.csv.importCsvText); // import csv button is visible - await this.toBeVisible(selector.vendor.vTools.import.csv.csv); + await this.toBeVisible(vendorTools.import.csv.csv); // export - await this.click(selector.vendor.vTools.menus.export); + await this.click(vendorTools.menus.export); // export xml elements are visible - await this.multipleElementVisible(selector.vendor.vTools.export.xml); + await this.multipleElementVisible(vendorTools.export.xml); // export csv text is visible - await this.toBeVisible(selector.vendor.vTools.export.csv.exportCsvText); + await this.toBeVisible(vendorTools.export.csv.exportCsvText); // export csv button is visible - await this.toBeVisible(selector.vendor.vTools.export.csv.exportCsv); + await this.toBeVisible(vendorTools.export.csv.exportCsv); - await this.click(selector.vendor.vTools.export.csv.exportCsv); + await this.click(vendorTools.export.csv.exportCsv); // export csv elements are visible - const { exportCsvText, exportCsv, ...csv } = selector.vendor.vTools.export.csv; + const { exportCsvText, exportCsv, ...csv } = vendorTools.export.csv; await this.multipleElementVisible(csv); } @@ -59,18 +62,18 @@ export class VendorToolsPage extends VendorPage { switch (importType) { case 'xml': - await this.uploadFile(selector.vendor.vTools.import.xml.chooseXmlFile, filePath); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.tools, selector.vendor.vTools.import.xml.xml); - await this.toBeVisible(selector.vendor.vTools.import.xml.completionMessage); + await this.uploadFile(vendorTools.import.xml.chooseXmlFile, filePath); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.tools, vendorTools.import.xml.xml); + await this.toBeVisible(vendorTools.import.xml.completionMessage); break; case 'csv': // todo: add wait for uploading file, add api level assertion - await this.clickAndWaitForLoadState(selector.vendor.vTools.import.csv.csv); - await this.uploadFile(selector.vendor.vTools.import.csv.chooseCsv, filePath); - await this.click(selector.vendor.vTools.import.csv.updateExistingProducts); - await this.clickAndWaitForLoadState(selector.vendor.vTools.import.csv.continue); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.csvImport, selector.vendor.vTools.import.csv.runTheImporter); - await this.toContainText(selector.vendor.vTools.import.csv.completionMessage, 'Import complete!'); + await this.clickAndWaitForLoadState(vendorTools.import.csv.csv); + await this.uploadFile(vendorTools.import.csv.chooseCsv, filePath); + await this.click(vendorTools.import.csv.updateExistingProducts); + await this.clickAndWaitForLoadState(vendorTools.import.csv.continue); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.csvImport, vendorTools.import.csv.runTheImporter); + await this.toContainText(vendorTools.import.csv.completionMessage, 'Import complete!'); break; default: @@ -83,14 +86,14 @@ export class VendorToolsPage extends VendorPage { switch (exportType) { case 'xml': - await this.click(selector.vendor.vTools.export.xml.all); - await this.clickAndWaitForDownload(selector.vendor.vTools.export.xml.exportXml); + await this.click(vendorTools.export.xml.all); + await this.clickAndWaitForDownload(vendorTools.export.xml.exportXml); break; case 'csv': - await this.clickAndWaitForLoadState(selector.vendor.vTools.export.csv.exportCsv); - await this.click(selector.vendor.vTools.export.csv.customMeta); - await this.clickAndWaitForDownload(selector.vendor.vTools.export.csv.generateCsv); + await this.clickAndWaitForLoadState(vendorTools.export.csv.exportCsv); + await this.click(vendorTools.export.csv.customMeta); + await this.clickAndWaitForDownload(vendorTools.export.csv.generateCsv); break; default: diff --git a/tests/pw/pages/vendorVerificationsPage.ts b/tests/pw/pages/vendorVerificationsPage.ts index dc24a22162..5a451f22bc 100644 --- a/tests/pw/pages/vendorVerificationsPage.ts +++ b/tests/pw/pages/vendorVerificationsPage.ts @@ -4,6 +4,10 @@ import { selector } from '@pages/selectors'; import { data } from '@utils/testData'; import { vendor } from '@utils/interfaces'; +// selectors +const verificationsAdmin = selector.admin.dokan.verifications; +const verificationsVendor = selector.vendor.vVerificationSettings; + export class vendorVerificationsPage extends AdminPage { constructor(page: Page) { super(page); @@ -16,51 +20,51 @@ export class vendorVerificationsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.verifications); // tools text is visible - await this.toBeVisible(selector.admin.dokan.verifications.verificationRequestsText); + await this.toBeVisible(verificationsAdmin.verificationRequestsText); // navTab elements are visible - await this.multipleElementVisible(selector.admin.dokan.verifications.navTabs); + await this.multipleElementVisible(verificationsAdmin.navTabs); // verification table elements are visible - await this.multipleElementVisible(selector.admin.dokan.verifications.table); + await this.multipleElementVisible(verificationsAdmin.table); } // approve verification requests async approveVerificationRequest(storeName: string, verificationType: string, action: string) { await this.goIfNotThere(data.subUrls.backend.dokan.verifications); - const verificationRequestIsExists = await this.isVisible(selector.admin.dokan.verifications.vendorRow(storeName)); + const verificationRequestIsExists = await this.isVisible(verificationsAdmin.vendorRow(storeName)); if (!verificationRequestIsExists) { console.log('No pending verification request found!!'); return; } - await this.hover(selector.admin.dokan.verifications.vendorRow(storeName)); + await this.hover(verificationsAdmin.vendorRow(storeName)); switch (verificationType) { case 'id': if (action === 'approve') { - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.verifications.idRequest.approveRequest(storeName)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, verificationsAdmin.idRequest.approveRequest(storeName)); } else { - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.verifications.idRequest.rejectRequest(storeName)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, verificationsAdmin.idRequest.rejectRequest(storeName)); } break; case 'address': if (action === 'approve') { - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.verifications.addressRequest.approveRequest(storeName)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, verificationsAdmin.addressRequest.approveRequest(storeName)); } else { - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.verifications.addressRequest.rejectRequest(storeName)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, verificationsAdmin.addressRequest.rejectRequest(storeName)); } break; case 'company': if (action === 'approve') { - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.verifications.companyRequest.approveRequest(storeName)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, verificationsAdmin.companyRequest.approveRequest(storeName)); } else { - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.verifications.companyRequest.rejectRequest(storeName)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, verificationsAdmin.companyRequest.rejectRequest(storeName)); } break; @@ -74,27 +78,27 @@ export class vendorVerificationsPage extends AdminPage { async disapproveVerificationRequest(storeName: string, verificationType: string) { await this.goIfNotThere(data.subUrls.backend.dokan.verifications); - await this.clickAndWaitForLoadState(selector.admin.dokan.verifications.navTabs.approved); + await this.clickAndWaitForLoadState(verificationsAdmin.navTabs.approved); - const verificationRequestIsExists = await this.isVisible(selector.admin.dokan.verifications.vendorRow(storeName)); + const verificationRequestIsExists = await this.isVisible(verificationsAdmin.vendorRow(storeName)); if (!verificationRequestIsExists) { console.log('No approved verification request found!!'); return; } - await this.hover(selector.admin.dokan.verifications.vendorRow(storeName)); + await this.hover(verificationsAdmin.vendorRow(storeName)); switch (verificationType) { case 'id': - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.verifications.idRequest.disapproveRequest(storeName)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, verificationsAdmin.idRequest.disapproveRequest(storeName)); break; case 'address': - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.verifications.addressRequest.disapproveRequest(storeName)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, verificationsAdmin.addressRequest.disapproveRequest(storeName)); break; case 'company': - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.admin.dokan.verifications.companyRequest.disapproveRequest(storeName)); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, verificationsAdmin.companyRequest.disapproveRequest(storeName)); break; default: @@ -109,113 +113,113 @@ export class vendorVerificationsPage extends AdminPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsVerification); // verification text is visible - await this.toBeVisible(selector.vendor.vVerificationSettings.verificationText); + await this.toBeVisible(verificationsVendor.verificationText); // visit store link is visible - await this.toBeVisible(selector.vendor.vVerificationSettings.visitStore); + await this.toBeVisible(verificationsVendor.visitStore); // verification div and heading text // id - await this.toBeVisible(selector.vendor.vVerificationSettings.id.idVerificationDiv); - await this.toBeVisible(selector.vendor.vVerificationSettings.id.idVerificationText); + await this.toBeVisible(verificationsVendor.id.idVerificationDiv); + await this.toBeVisible(verificationsVendor.id.idVerificationText); // address - await this.toBeVisible(selector.vendor.vVerificationSettings.address.addressVerificationDiv); - await this.toBeVisible(selector.vendor.vVerificationSettings.address.addressVerificationText); + await this.toBeVisible(verificationsVendor.address.addressVerificationDiv); + await this.toBeVisible(verificationsVendor.address.addressVerificationText); // company - await this.toBeVisible(selector.vendor.vVerificationSettings.company.companyVerificationDiv); - await this.toBeVisible(selector.vendor.vVerificationSettings.company.companyVerificationText); + await this.toBeVisible(verificationsVendor.company.companyVerificationDiv); + await this.toBeVisible(verificationsVendor.company.companyVerificationText); // verification request is pending // id - const idRequestIsPending = await this.isVisible(selector.vendor.vVerificationSettings.id.idPendingFeedback); + const idRequestIsPending = await this.isVisible(verificationsVendor.id.idPendingFeedback); if (idRequestIsPending) { - await this.toContainText(selector.vendor.vVerificationSettings.id.idPendingFeedback, 'Your ID verification request is pending'); - await this.toBeVisible(selector.vendor.vVerificationSettings.id.cancelIdVerificationRequest); + await this.toContainText(verificationsVendor.id.idPendingFeedback, 'Your ID verification request is pending'); + await this.toBeVisible(verificationsVendor.id.cancelIdVerificationRequest); } // address - const addressRequestIsPending = await this.isVisible(selector.vendor.vVerificationSettings.address.addressPendingFeedback); + const addressRequestIsPending = await this.isVisible(verificationsVendor.address.addressPendingFeedback); if (addressRequestIsPending) { - await this.toContainText(selector.vendor.vVerificationSettings.address.addressPendingFeedback, 'Your Address verification request is pending'); - await this.toBeVisible(selector.vendor.vVerificationSettings.address.cancelAddressVerificationRequest); + await this.toContainText(verificationsVendor.address.addressPendingFeedback, 'Your Address verification request is pending'); + await this.toBeVisible(verificationsVendor.address.cancelAddressVerificationRequest); } // company - const companyRequestIsPending = await this.isVisible(selector.vendor.vVerificationSettings.company.companyPendingFeedback); + const companyRequestIsPending = await this.isVisible(verificationsVendor.company.companyPendingFeedback); if (companyRequestIsPending) { - await this.toContainText(selector.vendor.vVerificationSettings.company.companyPendingFeedback, 'Your company verification request is pending'); - await this.toBeVisible(selector.vendor.vVerificationSettings.company.cancelCompanyVerificationRequest); + await this.toContainText(verificationsVendor.company.companyPendingFeedback, 'Your company verification request is pending'); + await this.toBeVisible(verificationsVendor.company.cancelCompanyVerificationRequest); } // verification request is approved // id - const idRequestIsApproved = await this.isVisible(selector.vendor.vVerificationSettings.id.idApproveFeedback); + const idRequestIsApproved = await this.isVisible(verificationsVendor.id.idApproveFeedback); if (idRequestIsApproved) { - await this.toContainText(selector.vendor.vVerificationSettings.id.idApproveFeedback, 'Your ID verification request is approved'); + await this.toContainText(verificationsVendor.id.idApproveFeedback, 'Your ID verification request is approved'); } // address - const addressRequestIsApproved = await this.isVisible(selector.vendor.vVerificationSettings.address.addressApproveFeedback); + const addressRequestIsApproved = await this.isVisible(verificationsVendor.address.addressApproveFeedback); if (addressRequestIsApproved) { - await this.toContainText(selector.vendor.vVerificationSettings.address.addressApproveFeedback, 'Your Address verification request is approved'); - await this.toBeVisible(selector.vendor.vVerificationSettings.address.startAddressVerification); + await this.toContainText(verificationsVendor.address.addressApproveFeedback, 'Your Address verification request is approved'); + await this.toBeVisible(verificationsVendor.address.startAddressVerification); } // company - const companyRequestIsApproved = await this.isVisible(selector.vendor.vVerificationSettings.company.companyApproveFeedback); + const companyRequestIsApproved = await this.isVisible(verificationsVendor.company.companyApproveFeedback); if (companyRequestIsApproved) { - await this.toContainText(selector.vendor.vVerificationSettings.company.companyApproveFeedback, 'Your company verification request is approved'); - await this.toBeVisible(selector.vendor.vVerificationSettings.company.startCompanyVerification); + await this.toContainText(verificationsVendor.company.companyApproveFeedback, 'Your company verification request is approved'); + await this.toBeVisible(verificationsVendor.company.startCompanyVerification); } // no verification request is submitted // id if (!idRequestIsPending && !idRequestIsApproved) { - await this.toBeVisible(selector.vendor.vVerificationSettings.id.startIdVerification); + await this.toBeVisible(verificationsVendor.id.startIdVerification); - await this.click(selector.vendor.vVerificationSettings.id.startIdVerification); + await this.click(verificationsVendor.id.startIdVerification); - await this.toBeVisible(selector.vendor.vVerificationSettings.id.passport); - await this.toBeVisible(selector.vendor.vVerificationSettings.id.nationalIdCard); - await this.toBeVisible(selector.vendor.vVerificationSettings.id.drivingLicense); - const previousUploadedPhotoIsVisible = await this.isVisible(selector.vendor.vVerificationSettings.id.previousUploadedPhoto); - previousUploadedPhotoIsVisible && (await this.toBeVisible(selector.vendor.vVerificationSettings.id.uploadPhoto)); - await this.toBeVisible(selector.vendor.vVerificationSettings.id.submitId); - await this.toBeVisible(selector.vendor.vVerificationSettings.id.cancelSubmitId); + await this.toBeVisible(verificationsVendor.id.passport); + await this.toBeVisible(verificationsVendor.id.nationalIdCard); + await this.toBeVisible(verificationsVendor.id.drivingLicense); + const previousUploadedPhotoIsVisible = await this.isVisible(verificationsVendor.id.previousUploadedPhoto); + previousUploadedPhotoIsVisible && (await this.toBeVisible(verificationsVendor.id.uploadPhoto)); + await this.toBeVisible(verificationsVendor.id.submitId); + await this.toBeVisible(verificationsVendor.id.cancelSubmitId); } // address if (!addressRequestIsPending && !addressRequestIsApproved) { - await this.toBeVisible(selector.vendor.vVerificationSettings.address.startAddressVerification); - - await this.click(selector.vendor.vVerificationSettings.address.startAddressVerification); - - await this.toBeVisible(selector.vendor.vVerificationSettings.address.street); - await this.toBeVisible(selector.vendor.vVerificationSettings.address.street2); - await this.toBeVisible(selector.vendor.vVerificationSettings.address.city); - await this.toBeVisible(selector.vendor.vVerificationSettings.address.postOrZipCode); - await this.toBeVisible(selector.vendor.vVerificationSettings.address.country); - const previousUploadedResidenceProofIsVisible = await this.isVisible(selector.vendor.vVerificationSettings.address.previousUploadedResidenceProof); - !previousUploadedResidenceProofIsVisible && (await this.toBeVisible(selector.vendor.vVerificationSettings.address.uploadResidenceProof)); - await this.toBeVisible(selector.vendor.vVerificationSettings.address.submitAddress); - await this.toBeVisible(selector.vendor.vVerificationSettings.address.cancelSubmitAddress); + await this.toBeVisible(verificationsVendor.address.startAddressVerification); + + await this.click(verificationsVendor.address.startAddressVerification); + + await this.toBeVisible(verificationsVendor.address.street); + await this.toBeVisible(verificationsVendor.address.street2); + await this.toBeVisible(verificationsVendor.address.city); + await this.toBeVisible(verificationsVendor.address.postOrZipCode); + await this.toBeVisible(verificationsVendor.address.country); + const previousUploadedResidenceProofIsVisible = await this.isVisible(verificationsVendor.address.previousUploadedResidenceProof); + !previousUploadedResidenceProofIsVisible && (await this.toBeVisible(verificationsVendor.address.uploadResidenceProof)); + await this.toBeVisible(verificationsVendor.address.submitAddress); + await this.toBeVisible(verificationsVendor.address.cancelSubmitAddress); } // company if (!companyRequestIsPending && !companyRequestIsApproved) { - await this.toBeVisible(selector.vendor.vVerificationSettings.company.startCompanyVerification); + await this.toBeVisible(verificationsVendor.company.startCompanyVerification); - await this.click(selector.vendor.vVerificationSettings.company.startCompanyVerification); + await this.click(verificationsVendor.company.startCompanyVerification); - await this.toBeVisible(selector.vendor.vVerificationSettings.company.uploadFiles); - await this.toBeVisible(selector.vendor.vVerificationSettings.company.submitCompanyInfo); - await this.toBeVisible(selector.vendor.vVerificationSettings.company.cancelSubmitCompanyInfo); + await this.toBeVisible(verificationsVendor.company.uploadFiles); + await this.toBeVisible(verificationsVendor.company.submitCompanyInfo); + await this.toBeVisible(verificationsVendor.company.cancelSubmitCompanyInfo); } } @@ -223,37 +227,38 @@ export class vendorVerificationsPage extends AdminPage { async sendIdVerificationRequest(verification: vendor['verification']): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsVerification); - const idRequestIsApproved = await this.isVisible(selector.vendor.vVerificationSettings.id.idApproveFeedback); + const idRequestIsApproved = await this.isVisible(verificationsVendor.id.idApproveFeedback); if (idRequestIsApproved) { return; } // cancel previous verification request if any - const cancelRequestIsVisible = await this.isVisible(selector.vendor.vVerificationSettings.id.cancelIdVerificationRequest); + const cancelRequestIsVisible = await this.isVisible(verificationsVendor.id.cancelIdVerificationRequest); if (cancelRequestIsVisible) { - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vVerificationSettings.id.cancelIdVerificationRequest); - await this.toContainText(selector.vendor.vVerificationSettings.id.idUpdateSuccessMessage, verification.idRequestSubmitCancel); + await this.clickAndWaitForResponse(data.subUrls.ajax, verificationsVendor.id.cancelIdVerificationRequest); + await this.toContainText(verificationsVendor.id.idUpdateSuccessMessage, verification.idRequestSubmitCancel); } // id verification - await this.click(selector.vendor.vVerificationSettings.id.startIdVerification); - await this.wait(0.5); // todo: resolve this + await this.click(verificationsVendor.id.startIdVerification); + // await this.wait(0.5); // todo: resolve this + await this.waitForVisibleLocator(verificationsVendor.id.submitId); // remove previously uploaded image - const uploadPhotoBtnIsVisible = await this.isVisible(selector.vendor.vVerificationSettings.id.uploadPhoto); + const uploadPhotoBtnIsVisible = await this.isVisible(verificationsVendor.id.uploadPhoto); if (!uploadPhotoBtnIsVisible) { - // await this.hover(selector.vendor.vVerificationSettings.id.previousUploadedPhoto); // todo: not working: playwright issue - // await this.click(selector.vendor.vVerificationSettings.id.removePreviousUploadedPhoto); + // await this.hover(verificationsVendor.id.previousUploadedPhoto); // todo: not working: playwright issue + // await this.click(verificationsVendor.id.removePreviousUploadedPhoto); await this.setAttributeValue('.gravatar-wrap', 'class', 'gravatar-wrap dokan-hide'); await this.setAttributeValue('.gravatar-button-area.dokan-hide', 'class', 'gravatar-button-area'); } - await this.click(selector.vendor.vVerificationSettings.id.uploadPhoto); + await this.click(verificationsVendor.id.uploadPhoto); await this.uploadMedia(verification.file); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vVerificationSettings.id.submitId); - await this.toContainText(selector.vendor.vVerificationSettings.id.idUpdateSuccessMessage, verification.idRequestSubmitSuccessMessage); + await this.clickAndWaitForResponse(data.subUrls.ajax, verificationsVendor.id.submitId); + await this.toContainText(verificationsVendor.id.idUpdateSuccessMessage, verification.idRequestSubmitSuccessMessage); } // vendor send address verification request @@ -261,33 +266,33 @@ export class vendorVerificationsPage extends AdminPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsVerification); // cancel previous verification request if any - const cancelRequestIsVisible = await this.isVisible(selector.vendor.vVerificationSettings.address.cancelAddressVerificationRequest); + const cancelRequestIsVisible = await this.isVisible(verificationsVendor.address.cancelAddressVerificationRequest); if (cancelRequestIsVisible) { - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vVerificationSettings.address.cancelAddressVerificationRequest); - await this.toContainText(selector.vendor.vVerificationSettings.address.addressUpdateSuccessMessage, verification.addressRequestSubmitCancel); + await this.clickAndWaitForResponse(data.subUrls.ajax, verificationsVendor.address.cancelAddressVerificationRequest); + await this.toContainText(verificationsVendor.address.addressUpdateSuccessMessage, verification.addressRequestSubmitCancel); } // address verification - await this.click(selector.vendor.vVerificationSettings.address.startAddressVerification); - await this.clearAndType(selector.vendor.vVerificationSettings.address.street, verification.street1); - await this.clearAndType(selector.vendor.vVerificationSettings.address.street2, verification.street2); - await this.clearAndType(selector.vendor.vVerificationSettings.address.city, verification.city); - await this.clearAndType(selector.vendor.vVerificationSettings.address.postOrZipCode, verification.zipCode); - await this.selectByValue(selector.vendor.vVerificationSettings.address.country, verification.country); - await this.selectByValue(selector.vendor.vVerificationSettings.address.state, verification.state); + await this.click(verificationsVendor.address.startAddressVerification); + await this.clearAndType(verificationsVendor.address.street, verification.street1); + await this.clearAndType(verificationsVendor.address.street2, verification.street2); + await this.clearAndType(verificationsVendor.address.city, verification.city); + await this.clearAndType(verificationsVendor.address.postOrZipCode, verification.zipCode); + await this.selectByValue(verificationsVendor.address.country, verification.country); + await this.selectByValue(verificationsVendor.address.state, verification.state); // remove previously uploaded image - const uploadProofBtnIsVisible = await this.isVisible(selector.vendor.vVerificationSettings.address.uploadResidenceProof); + const uploadProofBtnIsVisible = await this.isVisible(verificationsVendor.address.uploadResidenceProof); if (!uploadProofBtnIsVisible) { await this.removeAttribute('div.proof-button-area', 'style'); await this.setAttributeValue('div.vendor_img_container', 'style', 'display: none;'); } - await this.click(selector.vendor.vVerificationSettings.address.uploadResidenceProof); + await this.click(verificationsVendor.address.uploadResidenceProof); await this.uploadMedia(verification.file); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vVerificationSettings.address.submitAddress); - await this.toContainText(selector.vendor.vVerificationSettings.address.addressUpdateSuccessMessage, verification.addressRequestSubmitSuccessMessage); + await this.clickAndWaitForResponse(data.subUrls.ajax, verificationsVendor.address.submitAddress); + await this.toContainText(verificationsVendor.address.addressUpdateSuccessMessage, verification.addressRequestSubmitSuccessMessage); } // vendor send company verification request @@ -295,40 +300,27 @@ export class vendorVerificationsPage extends AdminPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.settingsVerification); // cancel previous verification request if any - const cancelRequestIsVisible = await this.isVisible(selector.vendor.vVerificationSettings.company.cancelCompanyVerificationRequest); + const cancelRequestIsVisible = await this.isVisible(verificationsVendor.company.cancelCompanyVerificationRequest); if (cancelRequestIsVisible) { - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vVerificationSettings.company.cancelCompanyVerificationRequest); - await this.toContainText(selector.vendor.vVerificationSettings.company.companyInfoUpdateSuccessMessage, verification.companyRequestSubmitCancel); + await this.clickAndWaitForResponse(data.subUrls.ajax, verificationsVendor.company.cancelCompanyVerificationRequest); + await this.toContainText(verificationsVendor.company.companyInfoUpdateSuccessMessage, verification.companyRequestSubmitCancel); } // company verification - await this.click(selector.vendor.vVerificationSettings.company.startCompanyVerification); - await this.wait(1); + await this.click(verificationsVendor.company.startCompanyVerification); + // await this.wait(1); // todo: need to resolve this + await this.waitForVisibleLocator(verificationsVendor.company.submitCompanyInfo); // remove previously uploaded company file - const UploadedCompanyFileIsVisible = await this.isVisible(selector.vendor.vVerificationSettings.company.uploadedFileFirst); + const UploadedCompanyFileIsVisible = await this.isVisible(verificationsVendor.company.uploadedFileFirst); if (UploadedCompanyFileIsVisible) { - await this.click(selector.vendor.vVerificationSettings.company.uploadedFileFirst); + await this.click(verificationsVendor.company.uploadedFileFirst); } - await this.click(selector.vendor.vVerificationSettings.company.uploadFiles); + await this.click(verificationsVendor.company.uploadFiles); await this.uploadMedia(verification.file); - await this.clickAndWaitForResponse(data.subUrls.ajax, selector.vendor.vVerificationSettings.company.submitCompanyInfo); - await this.toContainText(selector.vendor.vVerificationSettings.company.companyInfoUpdateSuccessMessage, verification.companyRequestSubmitSuccessMessage); - } - - // upload media // todo: move to base-page and merge with wpUploadFile - async uploadMedia(file: string) { - await this.wait(0.5); - const uploadedMediaIsVisible = await this.isVisible(selector.wpMedia.uploadedMediaFirst); - if (uploadedMediaIsVisible) { - await this.click(selector.wpMedia.uploadedMediaFirst); - } else { - await this.uploadFile(selector.wpMedia.selectFilesInput, file); - const isSelectDisabled = await this.isDisabled(selector.wpMedia.select); - isSelectDisabled && (await this.click(selector.wpMedia.selectUploadedMedia)); - await this.click(selector.wpMedia.select); - } + await this.clickAndWaitForResponse(data.subUrls.ajax, verificationsVendor.company.submitCompanyInfo); + await this.toContainText(verificationsVendor.company.companyInfoUpdateSuccessMessage, verification.companyRequestSubmitSuccessMessage); } } diff --git a/tests/pw/pages/wholesaleCustomersPage.ts b/tests/pw/pages/wholesaleCustomersPage.ts index dc3ae46439..63f18b9421 100644 --- a/tests/pw/pages/wholesaleCustomersPage.ts +++ b/tests/pw/pages/wholesaleCustomersPage.ts @@ -7,6 +7,10 @@ import { data } from '@utils/testData'; import { helpers } from '@utils/helpers'; import { customer } from '@utils/interfaces'; +// selectors +const wholesaleCustomersAdmin = selector.admin.dokan.wholesaleCustomer; +const userInfo = selector.admin.users.userInfo; + export class WholesaleCustomersPage extends AdminPage { constructor(page: Page) { super(page); @@ -22,83 +26,83 @@ export class WholesaleCustomersPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.wholeSaleCustomer); // wholesale customer text is visible - await this.toBeVisible(selector.admin.dokan.wholesaleCustomer.wholesaleCustomerText); + await this.toBeVisible(wholesaleCustomersAdmin.wholesaleCustomerText); // nav tabs are visible - await this.multipleElementVisible(selector.admin.dokan.wholesaleCustomer.navTabs); + await this.multipleElementVisible(wholesaleCustomersAdmin.navTabs); // bulk action elements are visible - await this.multipleElementVisible(selector.admin.dokan.wholesaleCustomer.bulkActions); + await this.multipleElementVisible(wholesaleCustomersAdmin.bulkActions); // search wholesale customer input is visible - await this.toBeVisible(selector.admin.dokan.wholesaleCustomer.search); + await this.toBeVisible(wholesaleCustomersAdmin.search); // wholesale customer table elements are visible - await this.multipleElementVisible(selector.admin.dokan.wholesaleCustomer.table); + await this.multipleElementVisible(wholesaleCustomersAdmin.table); } // search wholesale customer async searchWholesaleCustomer(wholesaleCustomer: string) { await this.goIfNotThere(data.subUrls.backend.dokan.wholeSaleCustomer); - await this.clearInputField(selector.admin.dokan.wholesaleCustomer.search); + await this.clearInputField(wholesaleCustomersAdmin.search); - await this.typeAndWaitForResponse(data.subUrls.api.dokan.wholesaleCustomers, selector.admin.dokan.wholesaleCustomer.search, wholesaleCustomer); - await this.toBeVisible(selector.admin.dokan.wholesaleCustomer.wholesaleCustomerCell(wholesaleCustomer)); + await this.typeAndWaitForResponse(data.subUrls.api.dokan.wholesaleCustomers, wholesaleCustomersAdmin.search, wholesaleCustomer); + await this.toBeVisible(wholesaleCustomersAdmin.wholesaleCustomerCell(wholesaleCustomer)); } // edit wholesale customer async editWholesaleCustomer(wholesaleCustomer: customer) { await this.searchWholesaleCustomer(wholesaleCustomer.username); - await this.hover(selector.admin.dokan.wholesaleCustomer.wholesaleCustomerCell(wholesaleCustomer.username)); - await this.clickAndWaitForLoadState(selector.admin.dokan.wholesaleCustomer.wholesaleCustomerEdit(wholesaleCustomer.username)); + await this.hover(wholesaleCustomersAdmin.wholesaleCustomerCell(wholesaleCustomer.username)); + await this.clickAndWaitForLoadState(wholesaleCustomersAdmin.wholesaleCustomerEdit(wholesaleCustomer.username)); // basic info - await this.selectByValue(selector.admin.users.userInfo.role, wholesaleCustomer.customerInfo.role); - await this.clearAndType(selector.admin.users.userInfo.firstName, wholesaleCustomer.username); - await this.clearAndType(selector.admin.users.userInfo.lastName, wholesaleCustomer.lastname); - await this.clearAndType(selector.admin.users.userInfo.nickname, wholesaleCustomer.username); + await this.selectByValue(userInfo.role, wholesaleCustomer.customerInfo.role); + await this.clearAndType(userInfo.firstName, wholesaleCustomer.username); + await this.clearAndType(userInfo.lastName, wholesaleCustomer.lastname); + await this.clearAndType(userInfo.nickname, wholesaleCustomer.username); // contact info - await this.clearAndType(selector.admin.users.userInfo.email, wholesaleCustomer.username + data.customer.customerInfo.emailDomain); + await this.clearAndType(userInfo.email, wholesaleCustomer.username + data.customer.customerInfo.emailDomain); // About the user - await this.clearAndType(selector.admin.users.userInfo.biographicalInfo, wholesaleCustomer.customerInfo.biography); + await this.clearAndType(userInfo.biographicalInfo, wholesaleCustomer.customerInfo.biography); // customer address // billing - await this.clearAndType(selector.admin.users.userInfo.billingAddress.firstName, wholesaleCustomer.username); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.lastName, wholesaleCustomer.lastname); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.company, wholesaleCustomer.customerInfo.companyName); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.address1, wholesaleCustomer.customerInfo.street1); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.address2, wholesaleCustomer.customerInfo.street2); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.city, wholesaleCustomer.customerInfo.city); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.postcode, wholesaleCustomer.customerInfo.zipCode); - await this.click(selector.admin.users.userInfo.billingAddress.country); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.countryInput, wholesaleCustomer.customerInfo.country); + await this.clearAndType(userInfo.billingAddress.firstName, wholesaleCustomer.username); + await this.clearAndType(userInfo.billingAddress.lastName, wholesaleCustomer.lastname); + await this.clearAndType(userInfo.billingAddress.company, wholesaleCustomer.customerInfo.companyName); + await this.clearAndType(userInfo.billingAddress.address1, wholesaleCustomer.customerInfo.street1); + await this.clearAndType(userInfo.billingAddress.address2, wholesaleCustomer.customerInfo.street2); + await this.clearAndType(userInfo.billingAddress.city, wholesaleCustomer.customerInfo.city); + await this.clearAndType(userInfo.billingAddress.postcode, wholesaleCustomer.customerInfo.zipCode); + await this.click(userInfo.billingAddress.country); + await this.clearAndType(userInfo.billingAddress.countryInput, wholesaleCustomer.customerInfo.country); await this.press(data.key.enter); - await this.click(selector.admin.users.userInfo.billingAddress.state); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.stateInput, wholesaleCustomer.customerInfo.state); + await this.click(userInfo.billingAddress.state); + await this.clearAndType(userInfo.billingAddress.stateInput, wholesaleCustomer.customerInfo.state); await this.press(data.key.enter); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.phone, wholesaleCustomer.customerInfo.phone); - await this.clearAndType(selector.admin.users.userInfo.billingAddress.email, wholesaleCustomer.username + data.customer.customerInfo.emailDomain); + await this.clearAndType(userInfo.billingAddress.phone, wholesaleCustomer.customerInfo.phone); + await this.clearAndType(userInfo.billingAddress.email, wholesaleCustomer.username + data.customer.customerInfo.emailDomain); // shipping - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.firstName, wholesaleCustomer.username); - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.lastName, wholesaleCustomer.lastname); - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.company, wholesaleCustomer.customerInfo.companyName); - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.address1, wholesaleCustomer.customerInfo.street1); - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.address2, wholesaleCustomer.customerInfo.street2); - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.city, wholesaleCustomer.customerInfo.city); - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.postcode, wholesaleCustomer.customerInfo.zipCode); - await this.click(selector.admin.users.userInfo.shippingAddress.country); - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.countryInput, wholesaleCustomer.customerInfo.country); + await this.clearAndType(userInfo.shippingAddress.firstName, wholesaleCustomer.username); + await this.clearAndType(userInfo.shippingAddress.lastName, wholesaleCustomer.lastname); + await this.clearAndType(userInfo.shippingAddress.company, wholesaleCustomer.customerInfo.companyName); + await this.clearAndType(userInfo.shippingAddress.address1, wholesaleCustomer.customerInfo.street1); + await this.clearAndType(userInfo.shippingAddress.address2, wholesaleCustomer.customerInfo.street2); + await this.clearAndType(userInfo.shippingAddress.city, wholesaleCustomer.customerInfo.city); + await this.clearAndType(userInfo.shippingAddress.postcode, wholesaleCustomer.customerInfo.zipCode); + await this.click(userInfo.shippingAddress.country); + await this.clearAndType(userInfo.shippingAddress.countryInput, wholesaleCustomer.customerInfo.country); await this.press(data.key.enter); - await this.click(selector.admin.users.userInfo.shippingAddress.state); - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.stateInput, wholesaleCustomer.customerInfo.state); + await this.click(userInfo.shippingAddress.state); + await this.clearAndType(userInfo.shippingAddress.stateInput, wholesaleCustomer.customerInfo.state); await this.press(data.key.enter); - await this.clearAndType(selector.admin.users.userInfo.shippingAddress.phone, wholesaleCustomer.customerInfo.phone); + await this.clearAndType(userInfo.shippingAddress.phone, wholesaleCustomer.customerInfo.phone); // update user await this.clickAndWaitForResponse(data.subUrls.backend.user, selector.admin.users.updateUser, 302); @@ -108,9 +112,9 @@ export class WholesaleCustomersPage extends AdminPage { // view wholesale customer orders async viewWholesaleCustomerOrders(wholesaleCustomer: string) { await this.searchWholesaleCustomer(wholesaleCustomer); - await this.hover(selector.admin.dokan.wholesaleCustomer.wholesaleCustomerCell(wholesaleCustomer)); - await this.clickAndWaitForLoadState(selector.admin.dokan.wholesaleCustomer.wholesaleCustomerOrders(wholesaleCustomer)); - const count = (await this.getElementText(selector.admin.dokan.wholesaleCustomer.numberOfRowsFound))?.split(' ')[0]; + await this.hover(wholesaleCustomersAdmin.wholesaleCustomerCell(wholesaleCustomer)); + await this.clickAndWaitForLoadState(wholesaleCustomersAdmin.wholesaleCustomerOrders(wholesaleCustomer)); + const count = (await this.getElementText(wholesaleCustomersAdmin.numberOfRowsFound))?.split(' ')[0]; expect(Number(count)).toBeGreaterThan(0); } @@ -120,16 +124,16 @@ export class WholesaleCustomersPage extends AdminPage { switch (action) { case 'enable': - await this.enableSwitcherAndWaitForResponse(data.subUrls.api.dokan.wholesaleCustomers, selector.admin.dokan.wholesaleCustomer.statusSlider(wholesaleCustomer)); + await this.enableSwitcherAndWaitForResponse(data.subUrls.api.dokan.wholesaleCustomers, wholesaleCustomersAdmin.statusSlider(wholesaleCustomer)); break; case 'disable': - await this.disableSwitcherAndWaitForResponse(data.subUrls.api.dokan.wholesaleCustomers, selector.admin.dokan.wholesaleCustomer.statusSlider(wholesaleCustomer)); + await this.disableSwitcherAndWaitForResponse(data.subUrls.api.dokan.wholesaleCustomers, wholesaleCustomersAdmin.statusSlider(wholesaleCustomer)); break; case 'delete': - await this.hover(selector.admin.dokan.wholesaleCustomer.wholesaleCustomerCell(wholesaleCustomer)); - await this.clickAndAcceptAndWaitForResponse(data.subUrls.api.dokan.wholesaleCustomers, selector.admin.dokan.wholesaleCustomer.wholesaleCustomerRemove(wholesaleCustomer)); + await this.hover(wholesaleCustomersAdmin.wholesaleCustomerCell(wholesaleCustomer)); + await this.clickAndAcceptAndWaitForResponse(data.subUrls.api.dokan.wholesaleCustomers, wholesaleCustomersAdmin.wholesaleCustomerRemove(wholesaleCustomer)); break; default: @@ -142,11 +146,11 @@ export class WholesaleCustomersPage extends AdminPage { wholesaleCustomer ? await this.searchWholesaleCustomer(wholesaleCustomer) : await this.goIfNotThere(data.subUrls.backend.dokan.wholeSaleCustomer); // ensure row exists - await this.notToBeVisible(selector.admin.dokan.wholesaleCustomer.noRowsFound); + await this.notToBeVisible(wholesaleCustomersAdmin.noRowsFound); - await this.click(selector.admin.dokan.wholesaleCustomer.bulkActions.selectAll); - await this.selectByValue(selector.admin.dokan.wholesaleCustomer.bulkActions.selectAction, action); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.wholesaleCustomers, selector.admin.dokan.wholesaleCustomer.bulkActions.applyAction); + await this.click(wholesaleCustomersAdmin.bulkActions.selectAll); + await this.selectByValue(wholesaleCustomersAdmin.bulkActions.selectAction, action); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.wholesaleCustomers, wholesaleCustomersAdmin.bulkActions.applyAction); } // customer request to become wholesale customer diff --git a/tests/pw/pages/withdrawsPage.ts b/tests/pw/pages/withdrawsPage.ts index d972f99b7e..6924889a4d 100644 --- a/tests/pw/pages/withdrawsPage.ts +++ b/tests/pw/pages/withdrawsPage.ts @@ -7,6 +7,10 @@ import { vendor } from '@utils/interfaces'; const { DOKAN_PRO } = process.env; +// selectors +const withdrawsAdmin = selector.admin.dokan.withdraw; +const withdrawsVendor = selector.vendor.vWithdraw; + export class WithdrawsPage extends AdminPage { constructor(page: Page) { super(page); @@ -19,61 +23,61 @@ export class WithdrawsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.withdraw); // withdraw text is visible - await this.toBeVisible(selector.admin.dokan.withdraw.withdrawText); + await this.toBeVisible(withdrawsAdmin.withdrawText); // nav tabs elements are visible - await this.multipleElementVisible(selector.admin.dokan.withdraw.navTabs); + await this.multipleElementVisible(withdrawsAdmin.navTabs); // bulk action elements are visible - await this.multipleElementVisible(selector.admin.dokan.withdraw.bulkActions); + await this.multipleElementVisible(withdrawsAdmin.bulkActions); // filter elements are visible - const { filterInput, clearFilter, result, ...filters } = selector.admin.dokan.withdraw.filters; + const { filterInput, clearFilter, result, ...filters } = withdrawsAdmin.filters; await this.multipleElementVisible(filters); // withdraw table elements are visible - await this.multipleElementVisible(selector.admin.dokan.withdraw.table); + await this.multipleElementVisible(withdrawsAdmin.table); } // filter withdraws async filterWithdraws(input: string, action: string): Promise { await this.goto(data.subUrls.backend.dokan.withdraw); // await this.goIfNotThere(data.subUrls.backend.dokan.withdraw); - await this.click(selector.admin.dokan.withdraw.filters.clearFilter); + await this.click(withdrawsAdmin.filters.clearFilter); switch (action) { case 'by-vendor': - await this.click(selector.admin.dokan.withdraw.filters.filterByVendor); + await this.click(withdrawsAdmin.filters.filterByVendor); break; case 'by-payment-method': - await this.click(selector.admin.dokan.withdraw.filters.filterByPaymentMethods); + await this.click(withdrawsAdmin.filters.filterByPaymentMethods); break; default: break; } - await this.fill(selector.admin.dokan.withdraw.filters.filterInput, input); - await this.toContainText(selector.admin.dokan.withdraw.filters.result, input); + await this.fill(withdrawsAdmin.filters.filterInput, input); + await this.toContainText(withdrawsAdmin.filters.result, input); // todo: need to wait for focus event await this.pressAndWaitForResponse(data.subUrls.api.dokan.withdraws, data.key.enter); - const count = (await this.getElementText(selector.admin.dokan.withdraw.numberOfRowsFound))?.split(' ')[0]; + const count = (await this.getElementText(withdrawsAdmin.numberOfRowsFound))?.split(' ')[0]; expect(Number(count)).toBeGreaterThan(0); } // export withdraws async exportWithdraws() { await this.goIfNotThere(data.subUrls.backend.dokan.withdraw); - await this.clickAndWaitForDownload(selector.admin.dokan.withdraw.exportWithdraws); + await this.clickAndWaitForDownload(withdrawsAdmin.exportWithdraws); } // add note to withdraw request async addNoteWithdrawRequest(vendorName: string, note: string): Promise { await this.filterWithdraws(vendorName, 'by-vendor'); - await this.click(selector.admin.dokan.withdraw.withdrawAddNote(vendorName)); - await this.clearAndType(selector.admin.dokan.withdraw.addNote, note); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.withdraws, selector.admin.dokan.withdraw.updateNote); + await this.click(withdrawsAdmin.withdrawAddNote(vendorName)); + await this.clearAndType(withdrawsAdmin.addNote, note); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.withdraws, withdrawsAdmin.updateNote); } // add note to withdraw request @@ -82,17 +86,17 @@ export class WithdrawsPage extends AdminPage { switch (action) { case 'approve': - await this.clickAndWaitForResponse(data.subUrls.api.dokan.withdraws, selector.admin.dokan.withdraw.withdrawApprove(vendorName)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.withdraws, withdrawsAdmin.withdrawApprove(vendorName)); break; case 'cancel': - await this.hover(selector.admin.dokan.withdraw.withdrawCell(vendorName)); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.withdraws, selector.admin.dokan.withdraw.withdrawCancel(vendorName)); + await this.hover(withdrawsAdmin.withdrawCell(vendorName)); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.withdraws, withdrawsAdmin.withdrawCancel(vendorName)); break; case 'delete': - await this.hover(selector.admin.dokan.withdraw.withdrawCell(vendorName)); - await this.clickAndAcceptAndWaitForResponse(data.subUrls.api.dokan.withdraws, selector.admin.dokan.withdraw.withdrawDelete(vendorName)); + await this.hover(withdrawsAdmin.withdrawCell(vendorName)); + await this.clickAndAcceptAndWaitForResponse(data.subUrls.api.dokan.withdraws, withdrawsAdmin.withdrawDelete(vendorName)); break; default: @@ -105,11 +109,11 @@ export class WithdrawsPage extends AdminPage { await this.goIfNotThere(data.subUrls.backend.dokan.withdraw); // ensure row exists - await this.notToBeVisible(selector.admin.dokan.withdraw.noRowsFound); + await this.notToBeVisible(withdrawsAdmin.noRowsFound); - await this.click(selector.admin.dokan.withdraw.bulkActions.selectAll); - await this.selectByValue(selector.admin.dokan.withdraw.bulkActions.selectAction, action); - await this.clickAndWaitForResponse(data.subUrls.api.dokan.withdraws, selector.admin.dokan.withdraw.bulkActions.applyAction); + await this.click(withdrawsAdmin.bulkActions.selectAll); + await this.selectByValue(withdrawsAdmin.bulkActions.selectAction, action); + await this.clickAndWaitForResponse(data.subUrls.api.dokan.withdraws, withdrawsAdmin.bulkActions.applyAction); } // withdraw @@ -119,37 +123,37 @@ export class WithdrawsPage extends AdminPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.withdraw); // withdraw text is visible - await this.toBeVisible(selector.vendor.vWithdraw.withdrawText); + await this.toBeVisible(withdrawsVendor.withdrawText); // balance elements are visible - const { balanceLite, balancePro, ...balance } = selector.vendor.vWithdraw.balance; + const { balanceLite, balancePro, ...balance } = withdrawsVendor.balance; await this.multipleElementVisible(balance); DOKAN_PRO ? await this.toBeVisible(balancePro) : await this.toBeVisible(balanceLite); // request withdraw is visible - await this.toBeVisible(selector.vendor.vWithdraw.manualWithdrawRequest.requestWithdraw); + await this.toBeVisible(withdrawsVendor.manualWithdrawRequest.requestWithdraw); // payment details manual elements are visible - await this.multipleElementVisible(selector.vendor.vWithdraw.paymentDetails.manual); + await this.multipleElementVisible(withdrawsVendor.paymentDetails.manual); // view payments is visible - await this.toBeVisible(selector.vendor.vWithdraw.viewPayments.viewPayments); + await this.toBeVisible(withdrawsVendor.viewPayments.viewPayments); if (DOKAN_PRO) { // payment details schedule elements are visible - await this.multipleElementVisible(selector.vendor.vWithdraw.paymentDetails.schedule); + await this.multipleElementVisible(withdrawsVendor.paymentDetails.schedule); // enable & edit schedule is visible - await this.toBeVisible(selector.vendor.vWithdraw.autoWithdrawDisbursement.enableSchedule); - await this.toBeVisible(selector.vendor.vWithdraw.autoWithdrawDisbursement.editSchedule); + await this.toBeVisible(withdrawsVendor.autoWithdrawDisbursement.enableSchedule); + await this.toBeVisible(withdrawsVendor.autoWithdrawDisbursement.editSchedule); } // todo: pending request can be added // withdraw payment methods div elements are visible - await this.toBeVisible(selector.vendor.vWithdraw.withdrawPaymentMethods.paymentMethodsDiv); + await this.toBeVisible(withdrawsVendor.withdrawPaymentMethods.paymentMethodsDiv); - await this.notToHaveCount(selector.vendor.vWithdraw.withdrawPaymentMethods.paymentMethods, 0); + await this.notToHaveCount(withdrawsVendor.withdrawPaymentMethods.paymentMethods, 0); // todo: add request & disbursement modal } @@ -159,16 +163,16 @@ export class WithdrawsPage extends AdminPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.withdrawRequests); // withdraw requests menus are visible - await this.multipleElementVisible(selector.vendor.vWithdraw.viewPayments.menus); + await this.multipleElementVisible(withdrawsVendor.viewPayments.menus); // request withdraw button is visible - await this.toBeVisible(selector.vendor.vWithdraw.viewPayments.requestWithdraw); + await this.toBeVisible(withdrawsVendor.viewPayments.requestWithdraw); // withdraw dashboard button is visible - await this.toBeVisible(selector.vendor.vWithdraw.viewPayments.withdrawDashboard); + await this.toBeVisible(withdrawsVendor.viewPayments.withdrawDashboard); // withdraw requests table elements are visible - await this.multipleElementVisible(selector.vendor.vWithdraw.viewPayments.table); + await this.multipleElementVisible(withdrawsVendor.viewPayments.table); } // vendor request withdraw @@ -176,11 +180,11 @@ export class WithdrawsPage extends AdminPage { await this.goIfNotThere(data.subUrls.frontend.vDashboard.withdraw); if (helpers.price(withdraw.currentBalance) > helpers.price(withdraw.minimumWithdrawAmount)) { - await this.click(selector.vendor.vWithdraw.manualWithdrawRequest.requestWithdraw); - await this.clearAndType(selector.vendor.vWithdraw.manualWithdrawRequest.withdrawAmount, String(withdraw.minimumWithdrawAmount)); - await this.selectByValue(selector.vendor.vWithdraw.manualWithdrawRequest.withdrawMethod, withdraw.withdrawMethod.default); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.vendor.vWithdraw.manualWithdrawRequest.submitRequest); - // await expect(this.page.getByText(selector.vendor.vWithdraw.manualWithdrawRequest.withdrawRequestSaveSuccessMessage)).toBeVisible(); // todo: + await this.click(withdrawsVendor.manualWithdrawRequest.requestWithdraw); + await this.clearAndType(withdrawsVendor.manualWithdrawRequest.withdrawAmount, String(withdraw.minimumWithdrawAmount)); + await this.selectByValue(withdrawsVendor.manualWithdrawRequest.withdrawMethod, withdraw.withdrawMethod.default); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, withdrawsVendor.manualWithdrawRequest.submitRequest); + // await expect(this.page.getByText(withdrawsVendor.manualWithdrawRequest.withdrawRequestSaveSuccessMessage)).toBeVisible(); // todo: } else { console.log('Vendor balance is less than minimum withdraw amount'); test.skip(); @@ -191,38 +195,38 @@ export class WithdrawsPage extends AdminPage { // vendor can't request withdraw when pending request exists async cantRequestWithdraw(): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.withdraw); - await this.click(selector.vendor.vWithdraw.manualWithdrawRequest.requestWithdraw); - await this.toContainText(selector.vendor.vWithdraw.manualWithdrawRequest.pendingRequestAlert, selector.vendor.vWithdraw.manualWithdrawRequest.pendingRequestAlertMessage); - await this.click(selector.vendor.vWithdraw.manualWithdrawRequest.closeModal); + await this.click(withdrawsVendor.manualWithdrawRequest.requestWithdraw); + await this.toContainText(withdrawsVendor.manualWithdrawRequest.pendingRequestAlert, withdrawsVendor.manualWithdrawRequest.pendingRequestAlertMessage); + await this.click(withdrawsVendor.manualWithdrawRequest.closeModal); } // vendor cancel withdraw request async cancelWithdrawRequest(): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.withdraw); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.withdrawRequests, selector.vendor.vWithdraw.manualWithdrawRequest.cancelRequest, 302); - await this.toContainText(selector.vendor.vWithdraw.manualWithdrawRequest.cancelWithdrawRequestSuccess, selector.vendor.vWithdraw.manualWithdrawRequest.cancelWithdrawRequestSaveSuccessMessage); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.vDashboard.withdrawRequests, withdrawsVendor.manualWithdrawRequest.cancelRequest, 302); + await this.toContainText(withdrawsVendor.manualWithdrawRequest.cancelWithdrawRequestSuccess, withdrawsVendor.manualWithdrawRequest.cancelWithdrawRequestSaveSuccessMessage); } // vendor add auto withdraw disbursement schedule async addAutoWithdrawDisbursementSchedule(withdraw: vendor['withdraw']): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.withdraw); - await this.enableSwitcherDisbursement(selector.vendor.vWithdraw.autoWithdrawDisbursement.enableSchedule); - await this.click(selector.vendor.vWithdraw.autoWithdrawDisbursement.editSchedule); - await this.selectByValue(selector.vendor.vWithdraw.autoWithdrawDisbursement.preferredPaymentMethod, withdraw.preferredPaymentMethod); - await this.click(selector.vendor.vWithdraw.autoWithdrawDisbursement.preferredSchedule(withdraw.preferredSchedule)); - await this.selectByValue(selector.vendor.vWithdraw.autoWithdrawDisbursement.onlyWhenBalanceIs, withdraw.minimumWithdrawAmount); - await this.selectByValue(selector.vendor.vWithdraw.autoWithdrawDisbursement.maintainAReserveBalance, withdraw.reservedBalance); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, selector.vendor.vWithdraw.autoWithdrawDisbursement.changeSchedule); - await this.notToContainText(selector.vendor.vWithdraw.autoWithdrawDisbursement.scheduleMessage, data.vendor.withdraw.scheduleMessageInitial); + await this.enableSwitcherDisbursement(withdrawsVendor.autoWithdrawDisbursement.enableSchedule); + await this.click(withdrawsVendor.autoWithdrawDisbursement.editSchedule); + await this.selectByValue(withdrawsVendor.autoWithdrawDisbursement.preferredPaymentMethod, withdraw.preferredPaymentMethod); + await this.click(withdrawsVendor.autoWithdrawDisbursement.preferredSchedule(withdraw.preferredSchedule)); + await this.selectByValue(withdrawsVendor.autoWithdrawDisbursement.onlyWhenBalanceIs, withdraw.minimumWithdrawAmount); + await this.selectByValue(withdrawsVendor.autoWithdrawDisbursement.maintainAReserveBalance, withdraw.reservedBalance); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, withdrawsVendor.autoWithdrawDisbursement.changeSchedule); + await this.notToContainText(withdrawsVendor.autoWithdrawDisbursement.scheduleMessage, data.vendor.withdraw.scheduleMessageInitial); } // vendor add default withdraw payment methods async addDefaultWithdrawPaymentMethods(preferredSchedule: string): Promise { await this.goIfNotThere(data.subUrls.frontend.vDashboard.withdraw); - const methodIsDefault = await this.isVisible(selector.vendor.vWithdraw.withdrawPaymentMethods.defaultMethod(preferredSchedule)); + const methodIsDefault = await this.isVisible(withdrawsVendor.withdrawPaymentMethods.defaultMethod(preferredSchedule)); if (!methodIsDefault) { - await this.clickAndWaitForLoadState(selector.vendor.vWithdraw.withdrawPaymentMethods.makeMethodDefault(preferredSchedule)); - await this.toBeVisible(selector.vendor.vWithdraw.withdrawPaymentMethods.defaultMethod(preferredSchedule)); + await this.clickAndWaitForLoadState(withdrawsVendor.withdrawPaymentMethods.makeMethodDefault(preferredSchedule)); + await this.toBeVisible(withdrawsVendor.withdrawPaymentMethods.defaultMethod(preferredSchedule)); } } } diff --git a/tests/pw/playwright.config.ts b/tests/pw/playwright.config.ts new file mode 100644 index 0000000000..574d9cfd0f --- /dev/null +++ b/tests/pw/playwright.config.ts @@ -0,0 +1,116 @@ +import { defineConfig, devices, expect } from '@playwright/test'; +import { customExpect } from '@utils/pwMatchers'; +import 'dotenv/config'; +const { CI, BASE_URL, SLOWMO, ADMIN, ADMIN_PASSWORD } = process.env; + +export default defineConfig({ + testDir: './tests/', + testMatch: /.*\.spec\.ts/, + /* Folder for test artifacts such as screenshots, videos, traces, etc. */ + outputDir: 'playwright/test-artifacts/', + /* Path to the global setup file. This file will be required and run before all the tests. */ + // globalSetup: './global-setup', + /* Path to the global teardown file. This file will be required and run after all the tests. */ + // globalTeardown : './global-teardown', + /* Maximum time in milliseconds the whole test suite can run */ + globalTimeout: CI ? 40 * (60 * 1000) : 40 * (60 * 1000), + /* The maximum number of test failures for the whole test suite run. After reaching this number, testing will stop and exit with an error. */ + maxFailures: CI ? 40 : 40, + /* Maximum time one test can run for. */ + timeout: CI ? 45 * 1000 : 45 * 1000, + /* Configuration for the expect assertion library */ + expect: { + /* Maximum time expect() should wait for the condition to be met. For example in `await expect(locator).toHaveText();`*/ + timeout: 15 * 1000, + toHaveScreenshot: { + maxDiffPixelRatio: 0.2, + maxDiffPixels: 500, + threshold: 0.5, + }, + }, + /* Whether to preserve test output in the testConfig.outputDir. Defaults to 'always'. */ + preserveOutput: 'always', + /* Run tests in files in parallel */ + // fullyParallel: true, + /* Fail the build on CI if you accidentally left test-only in the source code. */ + // forbidOnly: !!CI, + /* The number of times to repeat each test, useful for debugging flaky tests. */ + repeatEach: CI ? 1 : 0, + /* The maximum number of retry attempts given to failed tests. */ + retries: CI ? 1 : 0, + workers: CI ? 4 : 1 /* Opt out of parallel tests on CI. */, + reportSlowTests: { max: 3, threshold: 25 } /* Whether to report slow test files. Pass null to disable this feature. */, + /* Configure reporters */ + reporter: CI + ? [ + ['github'], + ['html', { open: 'never', outputFolder: 'playwright-report/html-report' }], + // ['junit', { outputFile: 'playwright-report/junit-report/results.xml' }], + ['list', { printSteps: true }], + ['./utils/summaryReporter.ts', { outputFile: 'playwright-report/summary-report/results.json' }], + ] + : [ + ['html', { open: 'never', outputFolder: 'playwright-report/html-report' }], + // ['junit', { outputFile: 'playwright-report/junit-report/results.xml' }], + ['list', { printSteps: true }], + ['./utils/summaryReporter.ts', { outputFile: 'playwright-report/summary-report/results.json' }], + ], + use: { + ...devices['Desktop Chrome'], + /* Whether to automatically download all the attachments. */ + acceptDownloads: true, + /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ + actionTimeout: 25 * 1000, + /* Maximum time each navigation such as 'goto()' can take. */ + navigationTimeout: 30 * 1000, + /* Base URL */ + baseURL: BASE_URL ? BASE_URL : 'http://localhost:9999', + /* Name of the browser that runs tests. */ + // browserName: 'chromium', + /* Toggles bypassing page's Content-Security-Policy. */ + bypassCSP: true, + /* Browser distribution channel. */ + // channel: 'chrome', + /* Emulates 'prefers-colors-scheme' media feature, supported values are 'light', 'dark', 'no-preference' */ + // colorScheme: 'dark' , + /* Whether to run tests on headless or non-headless mode */ + headless: CI ? !!CI : false, + /* Whether to ignore HTTPS errors during navigation. */ + ignoreHTTPSErrors: true, + /* Record trace only when retrying a test for the first time. */ + // trace: 'on-first-retry', + trace: { + mode: 'on-first-retry', + snapshots: true, + screenshots: true, + sources: true, + attachments: true, + }, + /* Capture screenshot after each test failure. */ + screenshot: { + mode: 'only-on-failure', + fullPage: true, + }, + /* Record video only when retrying a test for the first time. */ + video: 'on-first-retry', + /* Size of viewport */ + viewport: { width: 1420, height: 900 }, // default 1280x720 + /* whether to slow down test execution by provided seconds */ + launchOptions: { slowMo: SLOWMO ? Number(SLOWMO) * 1000 : 0 }, + + /* api request headers */ + extraHTTPHeaders: { + Accept: '*/*', + Authorization: 'Basic ' + Buffer.from(ADMIN + ':' + ADMIN_PASSWORD).toString('base64'), + }, + }, + + /* Configure projects for major browsers */ + projects: [ + { + use: { ...devices['Desktop Chrome'] }, + }, + ], +}); + +expect.extend(customExpect); diff --git a/tests/pw/tests/api/_coverage.teardown.ts b/tests/pw/tests/api/_coverage.teardown.ts index 478db8a5d7..853cb5622c 100644 --- a/tests/pw/tests/api/_coverage.teardown.ts +++ b/tests/pw/tests/api/_coverage.teardown.ts @@ -1,56 +1,75 @@ -import { test } from '@playwright/test'; +import { test, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { helpers } from '@utils/helpers'; import { execSync } from 'child_process'; +import fs from 'fs'; +import path from 'path'; test.describe('get api test coverage', () => { + const outputFile = 'playwright-report/api/coverage-report/coverage.json'; let apiUtils: ApiUtils; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); + }); + + test.afterAll(async () => { + await apiUtils.dispose(); }); test('get coverage', async () => { - const [, responseBody1] = await apiUtils.get(endPoints.getAllDokanEndpointsAdmin); - const [, responseBody2] = await apiUtils.get(endPoints.getAllDokanEndpointsV1); - const [, responseBody3] = await apiUtils.get(endPoints.getAllDokanEndpointsV2); - const allRoutes = [...Object.keys(responseBody1.routes), ...Object.keys(responseBody2.routes), ...Object.keys(responseBody3.routes)]; - // const allRoutes = [ ...Object.keys(responseBody3.routes)]; - const allRouteObjValues = [...Object.values(responseBody1.routes), ...Object.values(responseBody2.routes), ...Object.values(responseBody3.routes)]; - // const allRouteObjValues = [ ...Object.values(responseBody3.routes)]; + const endpoints = [endPoints.getAllDokanEndpointsAdmin, endPoints.getAllDokanEndpointsV1, endPoints.getAllDokanEndpointsV2]; + const allRoutes: string[] = []; + const allRouteObjValues = []; + for (const endpoint of endpoints) { + const [, responseBody] = await apiUtils.get(endpoint); + allRoutes.push(...Object.keys(responseBody.routes)); + allRouteObjValues.push(...Object.values(responseBody.routes)); + } const allRouteMethods: string[][] = allRouteObjValues.map(route => route.methods); - // console.log(allRoutes); - // console.log(allRouteMethods); let coverageArray = allRouteMethods.flatMap((methods, i) => methods.map(method => `${method} ${allRoutes[i]}`)); coverageArray = [...new Set(coverageArray)]; coverageArray = coverageArray.filter(e => !e.includes('PATCH')); // console.log(coverageArray); - console.log(coverageArray.length); - getCoverage(coverageArray); + // console.log(coverageArray.length); + + getCoverage(coverageArray, outputFile); }); }); -function getCoverage(coverageArray: any[]) { +function getCoverage(coverageArray: any[], outputFile?: string) { + const coverageReport: any = { + total_endpoints: 0, + covered_endpoints: 0, + coverage: '', + uncovered_Endpoints: [], + }; + const totalEndPoints = coverageArray.length; let coveredEndPoints = 0; - const nonCoveredEndpoints: string[] = []; + const uncoveredEndpoints: string[] = []; //Iterates through the coverageArray to grep each file in the test directory looking for matches for (const route of coverageArray) { const pattern = `COVERAGE_TAG: ${helpers.escapeRegex(route)}$`; const output = execSync(`grep -irl -E '${pattern}' tests/api | cat `, { encoding: 'utf-8' }); - // console.log('route: ', pattern); - // console.log('grep_Output: ', output); - if (output.toString() != '') { - coveredEndPoints += 1; - } else { - console.log(`Endpoint with no coverage: ${route}`); - nonCoveredEndpoints.push(route); - } + output.toString() != '' ? (coveredEndPoints += 1) : uncoveredEndpoints.push(route); } + const percentCovered = ((coveredEndPoints / totalEndPoints) * 100).toFixed(2) + '%'; - const percentCovered = ((coveredEndPoints / totalEndPoints) * 100).toFixed(2); - console.log('Total Endpoints: ' + totalEndPoints); - console.log('Covered Endpoints: ' + coveredEndPoints); - console.log('Coverage: ' + percentCovered + '%'); + if (outputFile) { + coverageReport.total_endpoints = totalEndPoints; + coverageReport.covered_endpoints = coveredEndPoints; + coverageReport.coverage = percentCovered; + coverageReport.uncovered_Endpoints = uncoveredEndpoints; + if (!fs.existsSync(path.dirname(outputFile))) { + fs.mkdirSync(path.dirname(outputFile), { recursive: true }); + } + fs.writeFileSync(outputFile, JSON.stringify(coverageReport)); + } else { + console.log('Uncovered Endpoints: ', uncoveredEndpoints); + console.log('Total Endpoints: ' + totalEndPoints); + console.log('Covered Endpoints: ' + coveredEndPoints); + console.log('Coverage: ' + percentCovered + '%'); + } } diff --git a/tests/pw/tests/api/_env.setup.ts b/tests/pw/tests/api/_env.setup.ts index 898b2d8e41..f56666682a 100644 --- a/tests/pw/tests/api/_env.setup.ts +++ b/tests/pw/tests/api/_env.setup.ts @@ -1,4 +1,4 @@ -import { test as setup, expect } from '@playwright/test'; +import { test as setup, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -7,26 +7,29 @@ import { dbUtils } from '@utils/dbUtils'; import { dbData } from '@utils/dbData'; import { data } from '@utils/testData'; -// const { BASE_URL } = process.env; +const { BASE_URL } = process.env; setup.describe('setup test environment', () => { let apiUtils: ApiUtils; - setup.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + setup.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); }); - // setup.skip('get server url @lite', async ({ request }) => { - // const apiUtils = new ApiUtils(request); - // const headers = await apiUtils.getSiteHeaders(BASE_URL); - // if (headers.link) { - // const serverUrl = headers.link.includes('rest_route') ? BASE_URL + '/?rest_route=' : BASE_URL + '/wp-json'; - // console.log('ServerUrl:', serverUrl); - // process.env.SERVER_URL = serverUrl; - // } else { - // console.log("Headers link doesn't exists"); - // } - // }); + setup.afterAll(async () => { + await apiUtils.dispose(); + }); + + setup.skip('get server url @lite', async () => { + const headers = await apiUtils.getSiteHeaders(BASE_URL); + if (headers.link) { + const serverUrl = headers.link.includes('rest_route') ? BASE_URL + '/?rest_route=' : BASE_URL + '/wp-json'; + console.log('ServerUrl:', serverUrl); + process.env.SERVER_URL = serverUrl; + } else { + console.log("Headers link doesn't exists"); + } + }); setup('setup store settings @lite', async () => { const [response] = await apiUtils.put(endPoints.updateSettings, { data: payloads.setupStore }); diff --git a/tests/pw/tests/api/_env2.setup.spec.ts b/tests/pw/tests/api/_env2.setup.spec.ts deleted file mode 100644 index eacaeb4119..0000000000 --- a/tests/pw/tests/api/_env2.setup.spec.ts +++ /dev/null @@ -1,53 +0,0 @@ -// import { test as setup, expect, Page } from '@playwright/test'; -// import { LoginPage } from '@pages/loginPage'; -// import { ProductAdvertisingPage } from '@pages/productAdvertisingPage'; -// import { ReverseWithdrawsPage } from '@pages/reverseWithdrawsPage'; -// import { ApiUtils } from '@utils/apiUtils'; -// import { payloads } from '@utils/payloads'; -// import { data } from '@utils/testData'; - -// setup.describe('authenticate users & set permalink', () => { -// setup('authenticate admin @lite', async ({ page }) => { -// const loginPage = new LoginPage(page); -// await loginPage.adminLogin(data.admin, data.auth.adminAuthFile); -// }); -// }); - -// setup.describe('setup dokan settings e2e', () => { -// let productAdvertisingPage: ProductAdvertisingPage; -// let reverseWithdrawsPage: ReverseWithdrawsPage; -// let aPage: Page, vPage: Page; -// let apiUtils: ApiUtils; - -// setup.beforeAll(async ({ browser, request }) => { -// const adminContext = await browser.newContext(data.auth.adminAuth); -// aPage = await adminContext.newPage(); -// productAdvertisingPage = new ProductAdvertisingPage(aPage); -// reverseWithdrawsPage = new ReverseWithdrawsPage(aPage); - -// apiUtils = new ApiUtils(request); -// }); - -// setup.afterAll(async () => { -// await aPage.close(); -// await vPage.close(); -// }); - -// setup('recreate reverse withdrawal payment product via settings save @lite', async () => { -// await reverseWithdrawsPage.reCreateReverseWithdrawalPaymentViaSettingsSave(); -// }); - -// setup('reverse Withdraw payment product exists @lite', async () => { -// const product = await apiUtils.checkProductExistence('Reverse Withdrawal Payment', payloads.adminAuth); -// expect(product).toBeTruthy(); -// }); - -// setup('recreate product advertisement payment product via settings save @pro', async () => { -// await productAdvertisingPage.recreateProductAdvertisementPaymentViaSettingsSave(); -// }); - -// setup('product advertisement payment product exists @pro', async () => { -// const product = await apiUtils.checkProductExistence('Product Advertisement Payment', payloads.adminAuth); -// expect(product).toBeTruthy(); -// }); -// }); diff --git a/tests/pw/tests/api/_env2.setup.ts b/tests/pw/tests/api/_env2.setup.ts new file mode 100644 index 0000000000..5c0ca09682 --- /dev/null +++ b/tests/pw/tests/api/_env2.setup.ts @@ -0,0 +1,54 @@ +import { test as setup, expect, request, Page } from '@playwright/test'; +import { LoginPage } from '@pages/loginPage'; +import { ProductAdvertisingPage } from '@pages/productAdvertisingPage'; +import { ReverseWithdrawsPage } from '@pages/reverseWithdrawsPage'; +import { ApiUtils } from '@utils/apiUtils'; +import { payloads } from '@utils/payloads'; +import { data } from '@utils/testData'; + +setup.describe.skip('authenticate users & set permalink', () => { + setup('authenticate admin @lite', async ({ page }) => { + const loginPage = new LoginPage(page); + await loginPage.adminLogin(data.admin, data.auth.adminAuthFile); + }); +}); + +setup.describe.skip('setup dokan settings e2e', () => { + let productAdvertisingPage: ProductAdvertisingPage; + let reverseWithdrawsPage: ReverseWithdrawsPage; + let aPage: Page, vPage: Page; + let apiUtils: ApiUtils; + + setup.beforeAll(async ({ browser }) => { + const adminContext = await browser.newContext(data.auth.adminAuth); + aPage = await adminContext.newPage(); + productAdvertisingPage = new ProductAdvertisingPage(aPage); + reverseWithdrawsPage = new ReverseWithdrawsPage(aPage); + + apiUtils = new ApiUtils(await request.newContext()); + }); + + setup.afterAll(async () => { + await aPage.close(); + await vPage.close(); + await apiUtils.dispose(); + }); + + setup('recreate reverse withdrawal payment product via settings save @lite', async () => { + await reverseWithdrawsPage.reCreateReverseWithdrawalPaymentViaSettingsSave(); + }); + + setup('reverse Withdraw payment product exists @lite', async () => { + const product = await apiUtils.checkProductExistence('Reverse Withdrawal Payment', payloads.adminAuth); + expect(product).toBeTruthy(); + }); + + setup('recreate product advertisement payment product via settings save @pro', async () => { + await productAdvertisingPage.recreateProductAdvertisementPaymentViaSettingsSave(); + }); + + setup('product advertisement payment product exists @pro', async () => { + const product = await apiUtils.checkProductExistence('Product Advertisement Payment', payloads.adminAuth); + expect(product).toBeTruthy(); + }); +}); diff --git a/tests/pw/tests/api/_resetSite.teardown.ts b/tests/pw/tests/api/_resetSite.teardown.ts index 29778c4a98..fa90061bf4 100644 --- a/tests/pw/tests/api/_resetSite.teardown.ts +++ b/tests/pw/tests/api/_resetSite.teardown.ts @@ -1,4 +1,4 @@ -import { test as test, expect } from '@playwright/test'; +import { test, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { payloads } from '@utils/payloads'; // import { endPoints } from '@utils/apiEndPoints'; @@ -9,39 +9,49 @@ import { payloads } from '@utils/payloads'; test.describe('test environment', () => { let apiUtils: ApiUtils; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); }); - test('delete all media items @lite', async () => { + test.afterAll(async () => { + await apiUtils.dispose(); + }); + + test('delete all media items', async () => { await apiUtils.deleteAllMediaItems(payloads.adminAuth); }); - test('delete all products @lite', async () => { - await apiUtils.deleteAllProducts('', payloads.adminAuth); + test('delete all products', async () => { + await apiUtils.deleteAllProducts(payloads.adminAuth); + await apiUtils.deleteAllProducts(payloads.vendorAuth); + await apiUtils.deleteAllProducts(payloads.vendor2Auth); }); - test('delete all stores @lite', async () => { + test('delete all stores', async () => { await apiUtils.deleteAllStores(payloads.adminAuth); //todo: don't work }); - test('delete all customers @lite', async () => { + test('delete all customers', async () => { await apiUtils.deleteAllCustomers(payloads.adminAuth); }); - test('delete all seller badges @lite', async () => { + test('delete all seller badges', async () => { await apiUtils.deleteAllSellerBadges(); }); - test('delete all RFQ Rules @lite', async () => { + test('delete all RFQ Rules', async () => { await apiUtils.deleteAllQuoteRules(payloads.adminAuth); }); - test('delete all Request Quotes @lite', async () => { + test('delete all request quotes', async () => { await apiUtils.deleteAllQuoteRequests(payloads.adminAuth); }); - //todo: delete all announcements - //todo: delete all support tickets - //todo: delete all abuse reports tickets + test('delete all announcements', async () => { + await apiUtils.deleteAllAnnouncements(payloads.adminAuth); + }); + + test('delete all abuse report tickets', async () => { + await apiUtils.deleteAllAbuseReports(payloads.adminAuth); + }); }); diff --git a/tests/pw/tests/api/abuseReports.spec.ts b/tests/pw/tests/api/abuseReports.spec.ts index 95d3319c8f..5e3024009c 100644 --- a/tests/pw/tests/api/abuseReports.spec.ts +++ b/tests/pw/tests/api/abuseReports.spec.ts @@ -3,7 +3,7 @@ //COVERAGE_TAG: DELETE /dokan/v1/abuse-reports/(?P[\d]+) //COVERAGE_TAG: DELETE /dokan/v1/abuse-reports/batch -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -16,13 +16,17 @@ const { VENDOR_ID, CUSTOMER_ID } = process.env; test.describe('abuse report api test', () => { let apiUtils: ApiUtils; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); const [, productId] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth); await dbUtils.createAbuseReport(dbData.dokan.createAbuseReport, productId, VENDOR_ID, CUSTOMER_ID); await dbUtils.createAbuseReport(dbData.dokan.createAbuseReport, productId, VENDOR_ID, CUSTOMER_ID); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get all abuse report reasons @pro', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getAllAbuseReportReasons); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/admins.spec.ts b/tests/pw/tests/api/admins.spec.ts index 918d924d02..58d4fa472b 100644 --- a/tests/pw/tests/api/admins.spec.ts +++ b/tests/pw/tests/api/admins.spec.ts @@ -9,7 +9,7 @@ //COVERAGE_TAG: GET /dokan/v1/admin/logs //COVERAGE_TAG: GET /dokan/v1/admin/logs/export -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { schemas } from '@utils/schemas'; @@ -17,8 +17,12 @@ import { schemas } from '@utils/schemas'; test.describe('admin api test', () => { let apiUtils: ApiUtils; - test.beforeAll(({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); + }); + + test.afterAll(async () => { + await apiUtils.dispose(); }); test('get admin report overview @lite', async () => { diff --git a/tests/pw/tests/api/announcements.spec.ts b/tests/pw/tests/api/announcements.spec.ts index d5ed5f5a72..b418147d8b 100644 --- a/tests/pw/tests/api/announcements.spec.ts +++ b/tests/pw/tests/api/announcements.spec.ts @@ -6,7 +6,7 @@ //COVERAGE_TAG: PUT /dokan/v1/announcement/(?P[\d]+)/restore //COVERAGE_TAG: PUT /dokan/v1/announcement/batch -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -17,12 +17,16 @@ test.describe('announcements api test', () => { let announcementId: string; let announcementNoticeId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, announcementId] = await apiUtils.createAnnouncement(payloads.createAnnouncement()); announcementNoticeId = await apiUtils.getAnnouncementNoticeId(payloads.vendorAuth); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get all announcements @pro', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getAllAnnouncements); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/attributeTerms.spec.ts b/tests/pw/tests/api/attributeTerms.spec.ts index ae5296e01b..4ee63937cb 100644 --- a/tests/pw/tests/api/attributeTerms.spec.ts +++ b/tests/pw/tests/api/attributeTerms.spec.ts @@ -5,7 +5,7 @@ //COVERAGE_TAG: DELETE /dokan/v1/products/attributes/(?P[\d]+)/terms/(?P[\d]+) //COVERAGE_TAG: PUT /dokan/v1/products/attributes/(?P[\d]+)/terms/batch -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -16,11 +16,15 @@ test.describe('attribute term api test', () => { let attributeId: string; let attributeTermId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, attributeId, attributeTermId] = await apiUtils.createAttributeTerm(payloads.createAttribute(), payloads.createAttributeTerm()); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get all attribute terms @lite', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getAllAttributeTerms(attributeId)); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/attributes.spec.ts b/tests/pw/tests/api/attributes.spec.ts index 791f671fe4..3e5d87c9e9 100644 --- a/tests/pw/tests/api/attributes.spec.ts +++ b/tests/pw/tests/api/attributes.spec.ts @@ -7,7 +7,7 @@ //COVERAGE_TAG: PUT /dokan/v1/products/attributes/set-default/(?P[\d]+) //COVERAGE_TAG: POST /dokan/v1/products/attributes/edit-product/(?P[\d]+) -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -21,13 +21,17 @@ test.describe('attribute api test', () => { let attributeTerm: any; let attributeTermId: string; //todo: why attributetermId is needed here - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, productId] = await apiUtils.createProduct(payloads.createProduct()); [attributeTerm, attributeId, attributeTermId] = await apiUtils.createAttributeTerm(payloads.createAttribute(), payloads.createAttributeTerm()); attribute = await apiUtils.getSingleAttribute(attributeId); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get all attributes @lite', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getAllAttributes); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/calculation.spec.ts b/tests/pw/tests/api/calculation.spec.ts index 00940cfc3e..87e82cd935 100644 --- a/tests/pw/tests/api/calculation.spec.ts +++ b/tests/pw/tests/api/calculation.spec.ts @@ -1,11 +1,14 @@ -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { helpers } from '@utils/helpers'; import { payloads } from '@utils/payloads'; import { dbUtils } from '@utils/dbUtils'; +import { dbData } from '@utils/dbData'; import { commission, feeRecipient } from '@utils/interfaces'; -// test.use({ extraHTTPHeaders: { Authorization: payloads.adminAuth.Authorization } }); +const { DOKAN_PRO } = process.env; + +test.use({ extraHTTPHeaders: { Authorization: payloads.adminAuth.Authorization } }); test.describe.skip('calculation test', () => { let apiUtils: ApiUtils; @@ -13,13 +16,17 @@ test.describe.skip('calculation test', () => { let commission: commission; let feeRecipient: feeRecipient; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); taxRate = await apiUtils.setUpTaxRate(payloads.enableTaxRate, payloads.createTaxRate); // todo: get tax rate instead of setup if possible [commission, feeRecipient] = await dbUtils.getSellingInfo(); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('calculation test @pro', async () => { // todo: modify for lite as well const [, res, oid] = await apiUtils.createOrder(payloads.createProduct(), payloads.createOrder); @@ -80,8 +87,8 @@ test.describe.skip('Marketplace Coupon calculation test', () => { let feeRecipient: feeRecipient; let sequentialCoupon: { value: string } | boolean; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); taxRate = await apiUtils.setUpTaxRate(payloads.enableTaxRate, payloads.createTaxRate); // taxRate = await apiUtils.updateSingleWcSettingOptions('general', 'woocommerce_calc_discounts_sequentially', { value: 'no' }); sequentialCoupon = await apiUtils.getSingleWcSettingOptions('general', 'woocommerce_calc_discounts_sequentially'); @@ -153,3 +160,112 @@ test.describe.skip('Marketplace Coupon calculation test', () => { expect(Number(vendorEarning)).toEqual(calculatedVendorEarning); }); }); + +test.describe.skip('commission test', () => { + let apiUtils: ApiUtils; + const taxRate: number = 10; + let commission: commission; + let feeRecipient: feeRecipient; + + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); + // taxRate = await apiUtils.setUpTaxRate(payloads.enableTaxRate, { ...payloads.createTaxRate, rate: '10' }); + }); + + test.afterAll(async () => { + // await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, dbData.dokan.sellingSettings); + await apiUtils.dispose(); + }); + + test('percentage commission (global) test @lite', async () => { + // await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, commission_type: 'percentage' }); + // const [commission, feeRecipient] = await dbUtils.getSellingInfo(); + const [, res, oid] = await apiUtils.createOrder(payloads.createProduct(), payloads.createOrder); + console.log(res); + }); + + test('flat commission test (global) @lite', async () => { + await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, commission_type: 'flat' }); + }); + + test('combined commission (global) test @lite', async () => { + await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, commission_type: 'combine' }); + }); + + // //todo: add vendorwise, categorywise, productwise commission + + test('shipping fee recipient test @pro', async () => { + await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, shipping_fee_recipient: 'seller' }); + await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, shipping_fee_recipient: 'admin' }); + }); + + test('product tax fee recipient test @pro', async () => { + await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, tax_fee_recipient: 'seller' }); + await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, tax_fee_recipient: 'admin' }); + }); + + test('shipping tax fee recipient test @pro', async () => { + await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, shipping_tax_fee_recipient: 'seller' }); + await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, shipping_tax_fee_recipient: 'admin' }); + }); + + test('calculation test @lite', async () => { + // provided data + const [commission, feeRecipient] = await dbUtils.getSellingInfo(); + const providedShippingFee = Number(payloads.createOrder.shipping_lines[0]?.total); + + const [, res, oid] = await apiUtils.createOrder(payloads.createProduct(), payloads.createOrder); + + // received data + const shippingFee = res.shipping_total; + const shippingTax = res.shipping_tax; + const cartTax = res.cart_tax; + const totalTax = res.total_tax; + const orderTotal = res.total; + const gatewayFee = 0; + const lineItems = res.line_items; + + const calculatedSubTotal = helpers.lineItemsToSubtotal(lineItems); + const calculatedProductTax = helpers.productTax(taxRate, calculatedSubTotal); + const calculatedShippingTax = helpers.shippingTax(taxRate, providedShippingFee); + const calculatedTotalTax = calculatedProductTax + calculatedShippingTax; + const calculatedOrderTotal = helpers.orderTotal(calculatedSubTotal, calculatedProductTax, calculatedShippingTax, providedShippingFee); + const calculatedAdminCommission = helpers.adminCommission(calculatedSubTotal, commission, calculatedProductTax, calculatedShippingTax, providedShippingFee, gatewayFee, feeRecipient); + const calculatedVendorEarning = helpers.vendorEarning(calculatedSubTotal, calculatedAdminCommission, calculatedProductTax, calculatedShippingTax, providedShippingFee, gatewayFee, feeRecipient); + + if (DOKAN_PRO) { + const singleOrderLog = await apiUtils.getSingleOrderLog(String(oid)); + const order_total = singleOrderLog.order_total; + const vendor_earning = singleOrderLog.vendor_earning; + const admin_commission = singleOrderLog.commission; + const gateway_fee = singleOrderLog.dokan_gateway_fee; + const shipping_fee = singleOrderLog.shipping_total; + const shipping_tax = singleOrderLog.shipping_total_tax; + const tax_total = singleOrderLog.tax_total; + // todo: add discount scenario + + const table = [ + [`OID: ${oid}`, 'OrderTotal', 'VendorEarning', 'AdmminCommission', 'GatewayFee', 'ShippingFee', 'ShippingTax', 'ProductTax'], + ['Expected', calculatedOrderTotal, calculatedVendorEarning, calculatedAdminCommission, gatewayFee, providedShippingFee, calculatedShippingTax, calculatedProductTax], + ['Received', order_total, vendor_earning, admin_commission, gateway_fee, shipping_fee, shipping_tax, tax_total], + ]; + console.table(table); + } else { + // todo: modify for lite as well + const table = [ + [`OID: ${oid}`, 'OrderTotal', 'VendorEarning', 'AdmminCommission', 'GatewayFee', 'ShippingFee', 'ShippingTax', 'ProductTax'], + ['Expected', calculatedOrderTotal, calculatedVendorEarning, calculatedAdminCommission, gatewayFee, providedShippingFee, calculatedShippingTax, calculatedProductTax], + ['Received', orderTotal, '-', '-', gatewayFee, shippingFee, shippingTax, cartTax], + ]; + console.table(table); + } + + expect(Number(orderTotal)).toEqual(calculatedOrderTotal); + expect(Number(vendor_earning)).toEqual(calculatedVendorEarning); + expect(Number(admin_commission)).toEqual(calculatedAdminCommission); + expect(Number(shippingFee)).toEqual(providedShippingFee); + expect(Number(shippingTax)).toEqual(calculatedShippingTax); + expect(Number(cartTax)).toEqual(calculatedProductTax); + expect(Number(totalTax)).toEqual(calculatedTotalTax); + }); +}); diff --git a/tests/pw/tests/api/coupons.spec.ts b/tests/pw/tests/api/coupons.spec.ts index ef042f91c9..1f4ee4fca7 100644 --- a/tests/pw/tests/api/coupons.spec.ts +++ b/tests/pw/tests/api/coupons.spec.ts @@ -4,7 +4,7 @@ //COVERAGE_TAG: PUT /dokan/v1/coupons/(?P[\d]+) //COVERAGE_TAG: DELETE /dokan/v1/coupons/(?P[\d]+) -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -15,12 +15,16 @@ test.describe('coupon api test', () => { let couponId: string; let productId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, productId] = await apiUtils.createProduct(payloads.createProduct()); [, couponId] = await apiUtils.createCoupon([productId], payloads.createCoupon()); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get all coupons @pro', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getAllCoupons); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/customers.spec.ts b/tests/pw/tests/api/customers.spec.ts index 991d63de9f..93d775d41a 100644 --- a/tests/pw/tests/api/customers.spec.ts +++ b/tests/pw/tests/api/customers.spec.ts @@ -5,7 +5,7 @@ //COVERAGE_TAG: DELETE /dokan/v1/request-for-quote/customers/(?P[\d]+) //COVERAGE_TAG: PUT /dokan/v1/request-for-quote/customers/batch -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -15,11 +15,15 @@ test.describe('customers api test', () => { let apiUtils: ApiUtils; let customerId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, customerId] = await apiUtils.createCustomer(payloads.createCustomer()); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get all customers @pro', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getAllCustomers); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/dokanEndpoints.spec.ts b/tests/pw/tests/api/dokanEndpoints.spec.ts index d6ea9ecf0b..391e50e998 100644 --- a/tests/pw/tests/api/dokanEndpoints.spec.ts +++ b/tests/pw/tests/api/dokanEndpoints.spec.ts @@ -2,15 +2,19 @@ //COVERAGE_TAG: GET /dokan/v1/admin //COVERAGE_TAG: GET /dokan/v2 -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; test.describe('dokan api endpoints test', () => { let apiUtils: ApiUtils; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); + }); + + test.afterAll(async () => { + await apiUtils.dispose(); }); test('get all dokan v1 endpoints @lite', async () => { diff --git a/tests/pw/tests/api/dummyData.spec.ts b/tests/pw/tests/api/dummyData.spec.ts index 14ac36bd7e..bbbb72cda0 100644 --- a/tests/pw/tests/api/dummyData.spec.ts +++ b/tests/pw/tests/api/dummyData.spec.ts @@ -2,7 +2,7 @@ //COVERAGE_TAG: POST /dokan/v1/dummy-data/import //COVERAGE_TAG: DELETE /dokan/v1/dummy-data/clear -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -11,8 +11,12 @@ import { schemas } from '@utils/schemas'; test.describe('dummy Data api test', () => { let apiUtils: ApiUtils; - test.beforeAll(({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); + }); + + test.afterAll(async () => { + await apiUtils.dispose(); }); test('get dummy data status @lite', async () => { diff --git a/tests/pw/tests/api/followStores.spec.ts b/tests/pw/tests/api/followStores.spec.ts index a157a48349..4c942578e5 100644 --- a/tests/pw/tests/api/followStores.spec.ts +++ b/tests/pw/tests/api/followStores.spec.ts @@ -2,7 +2,7 @@ //COVERAGE_TAG: POST /dokan/v1/follow-store //COVERAGE_TAG: GET /dokan/v1/follow-store/followers -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { schemas } from '@utils/schemas'; @@ -12,13 +12,17 @@ test.describe('follow store api test', () => { let apiUtils: ApiUtils; let sellerId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); // [, sellerId,] = await apiUtils.createStore(payloads.createStore()); [, sellerId] = await apiUtils.getCurrentUser(); // await apiUtils.followUnfollowStore(sellerId); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get store follow status @pro', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getStoreFollowStatus, { params: { vendor_id: sellerId } }); const headers = response.headers(); diff --git a/tests/pw/tests/api/modules.spec.ts b/tests/pw/tests/api/modules.spec.ts index 135fd70e78..4a10e2e00f 100644 --- a/tests/pw/tests/api/modules.spec.ts +++ b/tests/pw/tests/api/modules.spec.ts @@ -2,7 +2,7 @@ //COVERAGE_TAG: PUT /dokan/v1/admin/modules/deactivate //COVERAGE_TAG: PUT /dokan/v1/admin/modules/activate -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { helpers } from '@utils/helpers'; @@ -12,11 +12,16 @@ test.describe('modules api test', () => { let apiUtils: ApiUtils; let randomModule: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); randomModule = helpers.randomItem(await apiUtils.getAllModuleIds()); }); + test.afterAll(async () => { + await apiUtils.activateModules([randomModule]); + await apiUtils.dispose(); + }); + test('get all modules @pro', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getAllModules); expect(response.ok()).toBeTruthy(); @@ -29,9 +34,6 @@ test.describe('modules api test', () => { expect(response.ok()).toBeTruthy(); expect(responseBody).toBeTruthy(); expect(responseBody).toMatchSchema(schemas.modulesSchema); - - // reactivate module - // await apiUtils.activateModules(randomModule) }); test('activate a module @pro', async () => { diff --git a/tests/pw/tests/api/orderDownloads.spec.ts b/tests/pw/tests/api/orderDownloads.spec.ts index 70f7596045..1c306407a5 100644 --- a/tests/pw/tests/api/orderDownloads.spec.ts +++ b/tests/pw/tests/api/orderDownloads.spec.ts @@ -2,7 +2,7 @@ //COVERAGE_TAG: POST /dokan/v2/orders/(?P[\d]+)/downloads //COVERAGE_TAG: DELETE /dokan/v2/orders/(?P[\d]+)/downloads -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -13,8 +13,8 @@ test.describe('order downloads api test', () => { let orderId: string; let downloadId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); const [responseBody] = await apiUtils.uploadMedia('../../tests/pw/utils/sampleData/avatar.png', payloads.mimeTypes.png, payloads.adminAuth); // todo: update image path const downloads = [ { @@ -28,6 +28,10 @@ test.describe('order downloads api test', () => { [, downloadId] = await apiUtils.createOrderDownload(orderId, [downloadableProductId]); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get all order downloads @v2 @lite', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getAllOrderDownloads(orderId)); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/orderNotes.spec.ts b/tests/pw/tests/api/orderNotes.spec.ts index d5a8a5a42f..1fce628fc4 100644 --- a/tests/pw/tests/api/orderNotes.spec.ts +++ b/tests/pw/tests/api/orderNotes.spec.ts @@ -7,7 +7,7 @@ //COVERAGE_TAG: POST /dokan/v2/orders/(?P[\d]+)/notes //COVERAGE_TAG: DELETE /dokan/v2/orders/(?P[\d]+)/notes/(?P[\d]+) -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -17,11 +17,15 @@ test.describe('order note api test', () => { let orderId: string; let orderNoteId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, orderId, orderNoteId] = await apiUtils.createOrderNote(payloads.createProduct(), payloads.createOrder, payloads.createOrderNote); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get all order notes @lite', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getAllOrderNotes(orderId)); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/orders.spec.ts b/tests/pw/tests/api/orders.spec.ts index 939d39fb4e..7f28216f0a 100644 --- a/tests/pw/tests/api/orders.spec.ts +++ b/tests/pw/tests/api/orders.spec.ts @@ -8,7 +8,7 @@ //COVERAGE_TAG: PUT /dokan/v2/orders/(?P[\d]+) //COVERAGE_TAG: POST /dokan/v2/orders/bulk-actions -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -20,11 +20,15 @@ for (const version of versions) { test.describe(`order api test ${version}`, () => { let orderId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, , orderId] = await apiUtils.createOrder(payloads.createProduct(), payloads.createOrder); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get all orders @lite', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getAllOrders.replace('v1', version)); expect(response.ok()).toBeTruthy(); @@ -57,8 +61,8 @@ for (const version of versions) { }); } -test('update batch orders @v2 @lite', async ({ request }) => { - apiUtils = new ApiUtils(request); +test('update batch orders @v2 @lite', async () => { + apiUtils = new ApiUtils(await request.newContext()); const allOrderIds = (await apiUtils.getAllOrders())?.map((a: { id: unknown }) => a.id); const [response, responseBody] = await apiUtils.post(endPoints.updateBatchOrders, { data: { order_ids: allOrderIds, status: 'wc-completed' } }); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/productAdvertisements.spec.ts b/tests/pw/tests/api/productAdvertisements.spec.ts index 424f1e7748..d13fbd9bef 100644 --- a/tests/pw/tests/api/productAdvertisements.spec.ts +++ b/tests/pw/tests/api/productAdvertisements.spec.ts @@ -5,7 +5,7 @@ //COVERAGE_TAG: DELETE /dokan/v1/product_adv/(?P[\d]+) //COVERAGE_TAG: PUT /dokan/v1/product_adv/batch -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -14,11 +14,15 @@ test.describe('product advertisement api test', () => { let apiUtils: ApiUtils; let productAdvertisementId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, productAdvertisementId] = await apiUtils.createProductAdvertisement(payloads.createProduct()); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get all advertised product stores @pro', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getAllProductAdvertisementStores); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/productBlock.spec.ts b/tests/pw/tests/api/productBlock.spec.ts index 45c3628f8e..3669cdf791 100644 --- a/tests/pw/tests/api/productBlock.spec.ts +++ b/tests/pw/tests/api/productBlock.spec.ts @@ -1,7 +1,7 @@ //COVERAGE_TAG: GET /dokan/v1/blocks/products/(?P[\d]+) //COVERAGE_TAG: GET /dokan/v1/blocks/product-variation/(?P[\d]+) -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -11,8 +11,12 @@ test.describe('product block api test', () => { let productId: string; let variationId: string; - test.beforeAll(({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); + }); + + test.afterAll(async () => { + await apiUtils.dispose(); }); test('get product block details @lite', async () => { diff --git a/tests/pw/tests/api/productDuplicate.spec.ts b/tests/pw/tests/api/productDuplicate.spec.ts index 4dc9959f81..574863264a 100644 --- a/tests/pw/tests/api/productDuplicate.spec.ts +++ b/tests/pw/tests/api/productDuplicate.spec.ts @@ -1,6 +1,6 @@ //COVERAGE_TAG: POST /dokan/v2/products/(?P[\d]+)/duplicate -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -9,11 +9,15 @@ test.describe('product duplicate api test', () => { let apiUtils: ApiUtils; let productId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, productId] = await apiUtils.createProduct(payloads.createProduct()); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('create duplicate product @v2 @pro', async () => { const [response, responseBody] = await apiUtils.post(endPoints.createDuplicateProduct(productId)); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/productFilter.spec.ts b/tests/pw/tests/api/productFilter.spec.ts index b6de2634b9..dd1fb6f9cd 100644 --- a/tests/pw/tests/api/productFilter.spec.ts +++ b/tests/pw/tests/api/productFilter.spec.ts @@ -1,6 +1,6 @@ //COVERAGE_TAG: GET /dokan/v2/products/filter-by-data -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -8,11 +8,15 @@ import { payloads } from '@utils/payloads'; test.describe('product filter api test', () => { let apiUtils: ApiUtils; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); await apiUtils.createProduct(payloads.createProduct()); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get products filter by data @v2 @lite', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getProductsFilterByData); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/productQA.spec.ts b/tests/pw/tests/api/productQA.spec.ts new file mode 100644 index 0000000000..8d7502ec96 --- /dev/null +++ b/tests/pw/tests/api/productQA.spec.ts @@ -0,0 +1,117 @@ +//COVERAGE_TAG: GET /dokan/v1/product-questions +//COVERAGE_TAG: GET /dokan/v1/product-questions/(?P[\d]+) +//COVERAGE_TAG: POST /dokan/v1/product-questions +//COVERAGE_TAG: PUT /dokan/v1/product-questions/(?P[\d]+) +//COVERAGE_TAG: DELETE /dokan/v1/product-questions/(?P[\d]+) +//COVERAGE_TAG: PUT /dokan/v1/product-questions/bulk_action +//COVERAGE_TAG: GET /dokan/v1/product-answers +//COVERAGE_TAG: GET /dokan/v1/product-answers/(?P[\d]+) +//COVERAGE_TAG: POST /dokan/v1/product-answers +//COVERAGE_TAG: PUT /dokan/v1/product-answers/(?P[\d]+) +//COVERAGE_TAG: DELETE /dokan/v1/product-answers/(?P[\d]+) + +import { test, expect, request } from '@playwright/test'; +import { ApiUtils } from '@utils/apiUtils'; +import { endPoints } from '@utils/apiEndPoints'; +import { payloads } from '@utils/payloads'; +import { schemas } from '@utils/schemas'; + +const { PRODUCT_ID } = process.env; + +test.describe('product questions and answeres api test', () => { + test.skip(true, 'feature is not merged yet'); + + let apiUtils: ApiUtils; + let questionId: string; + let answerId: string; + + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); + [, questionId] = await apiUtils.createProductQuestion({ ...payloads.createProductQuestion(), product_id: PRODUCT_ID }, payloads.customerAuth); + [, answerId] = await apiUtils.createProductQuestionAnswer({ ...payloads.createProductQuestionAnswer(), question_id: questionId }, payloads.vendorAuth); + }); + + test.afterAll(async () => { + await apiUtils.dispose(); + }); + + // questions + + test('get all product questions @pro', async () => { + const [response, responseBody] = await apiUtils.get(endPoints.getAllProductQuestions, { headers: payloads.vendorAuth }); + expect(response.ok()).toBeTruthy(); + expect(responseBody).toBeTruthy(); + expect(responseBody).toMatchSchema(schemas.productQaSchema.productQuestionsSchema); + }); + + test('get single product question @pro', async () => { + const [response, responseBody] = await apiUtils.get(endPoints.getSingleProductQuestion(questionId), { headers: payloads.vendorAuth }); + expect(response.ok()).toBeTruthy(); + expect(responseBody).toBeTruthy(); + expect(responseBody).toMatchSchema(schemas.productQaSchema.productQuestionSchema); + }); + + test('create a product question @pro', async () => { + const [response, responseBody] = await apiUtils.post(endPoints.createProductQuestion, { data: { ...payloads.createProductQuestion(), product_id: PRODUCT_ID }, headers: payloads.customerAuth }); + expect(response.ok()).toBeTruthy(); + expect(responseBody).toBeTruthy(); + expect(responseBody).toMatchSchema(schemas.productQaSchema.productQuestionSchema); + }); + + test('update a product question @pro', async () => { + const [response, responseBody] = await apiUtils.put(endPoints.updateProductQuestion(questionId), { data: payloads.updateProductQuestion() }); + expect(response.ok()).toBeTruthy(); + expect(responseBody).toBeTruthy(); + expect(responseBody).toMatchSchema(schemas.productQaSchema.productQuestionSchema); + }); + + test('delete a product question @pro', async () => { + const [, questionId] = await apiUtils.createProductQuestion({ ...payloads.createProductQuestion(), product_id: PRODUCT_ID }, payloads.customerAuth); + const [response] = await apiUtils.delete(endPoints.deleteProductQuestion(questionId)); + expect(response.ok()).toBeTruthy(); + }); + + test('update batch product questions @pro', async () => { + const allProductQuestionIds = (await apiUtils.getAllProductQuestions()).map((a: { id: unknown }) => a.id); + + const [response, responseBody] = await apiUtils.put(endPoints.updateBatchProductQuestions, { data: { action: 'read', ids: allProductQuestionIds } }); + expect(response.ok()).toBeTruthy(); + expect(responseBody).toBeTruthy(); + expect(responseBody).toMatchSchema(schemas.productQaSchema.batchUpdateproductQuestionsSchema); + }); + + // answers + + test('get all product question answers @pro', async () => { + const [response, responseBody] = await apiUtils.get(endPoints.getAllProductQuestionAnswers, { headers: payloads.vendorAuth }); + expect(response.ok()).toBeTruthy(); + expect(responseBody).toBeTruthy(); + expect(responseBody).toMatchSchema(schemas.productQaSchema.productQuestionAnswersSchema); + }); + + test('get single product question answer @pro', async () => { + const [response, responseBody] = await apiUtils.get(endPoints.getSingleProductQuestionAnswer(answerId), { headers: payloads.vendorAuth }); + expect(response.ok()).toBeTruthy(); + expect(responseBody).toBeTruthy(); + expect(responseBody).toMatchSchema(schemas.productQaSchema.productQuestionAnswerSchema); + }); + + test('create a product question answer @pro', async () => { + const [response, responseBody] = await apiUtils.post(endPoints.createProductQuestionAnswer, { data: { ...payloads.createProductQuestionAnswer(), question_id: questionId }, headers: payloads.vendorAuth }); + expect(response.ok()).toBeTruthy(); + expect(responseBody).toBeTruthy(); + expect(responseBody).toMatchSchema(schemas.productQaSchema.productQuestionAnswerSchema); + }); + + test('update a product question answer @pro', async () => { + const [response, responseBody] = await apiUtils.put(endPoints.updateProductQuestionAnswer(answerId), { data: payloads.updateProductQuestionAnswer() }); + expect(response.ok()).toBeTruthy(); + expect(responseBody).toBeTruthy(); + expect(responseBody).toMatchSchema(schemas.productQaSchema.productQuestionAnswerSchema); + }); + + test('delete a product question answer @pro', async () => { + const [response] = await apiUtils.delete(endPoints.deleteProductQuestionAnswer(answerId)); + expect(response.ok()).toBeTruthy(); + }); +}); diff --git a/tests/pw/tests/api/productReviews.spec.ts b/tests/pw/tests/api/productReviews.spec.ts index 4ad9cf46b5..8e071921e8 100644 --- a/tests/pw/tests/api/productReviews.spec.ts +++ b/tests/pw/tests/api/productReviews.spec.ts @@ -2,7 +2,7 @@ //COVERAGE_TAG: GET /dokan/v1/reviews/summary //COVERAGE_TAG: PUT /dokan/v1/reviews/(?P[\d]+) -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -11,11 +11,15 @@ test.describe('product review api test', () => { let apiUtils: ApiUtils; let reviewId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, reviewId] = await apiUtils.createProductReview(payloads.createProduct(), payloads.createProductReview()); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get all product reviews @pro', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getAllProductReviews); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/productVariations.spec.ts b/tests/pw/tests/api/productVariations.spec.ts index 5d927e9222..0d4cbfe48f 100644 --- a/tests/pw/tests/api/productVariations.spec.ts +++ b/tests/pw/tests/api/productVariations.spec.ts @@ -5,7 +5,7 @@ //COVERAGE_TAG: DELETE /dokan/v1/products/(?P[\d]+)/variations/(?P[\d]+) //COVERAGE_TAG: PUT /dokan/v1/products/(?P[\d]+)/variations/batch -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -17,11 +17,15 @@ test.describe('product variation api test', () => { let productId: string; let variationId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [productId, variationId] = await apiUtils.createVariableProductWithVariation(payloads.createAttribute(), payloads.createAttributeTerm(), payloads.createVariableProduct()); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get all product variations @pro', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getAllProductVariations(productId)); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/products.spec.ts b/tests/pw/tests/api/products.spec.ts index 4c92280455..9f1c2fa694 100644 --- a/tests/pw/tests/api/products.spec.ts +++ b/tests/pw/tests/api/products.spec.ts @@ -23,7 +23,7 @@ //COVERAGE_TAG: PUT /dokan/v2/products/(?P[\d]+) //COVERAGE_TAG: DELETE /dokan/v2/products/(?P[\d]+) -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -35,11 +35,15 @@ for (const version of versions) { let apiUtils: ApiUtils; let productId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, productId] = await apiUtils.createProduct(payloads.createProduct()); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get products summary @lite', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getProductsSummary.replace('v1', version)); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/quoteRequests.spec.ts b/tests/pw/tests/api/quoteRequests.spec.ts index c68ff6c700..efb8b8ca90 100644 --- a/tests/pw/tests/api/quoteRequests.spec.ts +++ b/tests/pw/tests/api/quoteRequests.spec.ts @@ -7,7 +7,7 @@ //COVERAGE_TAG: POST /dokan/v1/request-for-quote/convert-to-order //COVERAGE_TAG: PUT /dokan/v1/request-for-quote/batch -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -17,13 +17,17 @@ test.describe('request quote api test', () => { let requestQuoteId: string; const productId: string[] = []; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); const [, pId] = await apiUtils.createProduct(payloads.createProduct()); productId.push(pId); [, requestQuoteId] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId }); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get all request quotes @pro', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getAllQuoteRequests); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/quoteRules.spec.ts b/tests/pw/tests/api/quoteRules.spec.ts index 021d71e773..39c3971702 100644 --- a/tests/pw/tests/api/quoteRules.spec.ts +++ b/tests/pw/tests/api/quoteRules.spec.ts @@ -6,7 +6,7 @@ //COVERAGE_TAG: PUT /dokan/v1/request-for-quote/quote-rule/(?P[\d]+)/restore //COVERAGE_TAG: PUT /dokan/v1/request-for-quote/quote-rule/batch -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -15,11 +15,15 @@ test.describe('quote rules api test', () => { let apiUtils: ApiUtils; let quoteRuleId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, quoteRuleId] = await apiUtils.createQuoteRule(payloads.createQuoteRule()); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get all quote rules @pro', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getAllQuoteRules); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/rankMath.spec.ts b/tests/pw/tests/api/rankMath.spec.ts index e137fe8e35..4ba952f5a3 100644 --- a/tests/pw/tests/api/rankMath.spec.ts +++ b/tests/pw/tests/api/rankMath.spec.ts @@ -1,6 +1,6 @@ //COVERAGE_TAG: POST /dokan/v2/(?P[\d]+)/store-current-editable-post -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -9,12 +9,16 @@ test.describe.skip('rank math api test', () => { let apiUtils: ApiUtils; let productId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, productId] = await apiUtils.createProduct(payloads.createProduct()); }); - test.skip('rank math @pro', async () => { + test.afterAll(async () => { + await apiUtils.dispose(); + }); + + test('rank math @pro', async () => { const [response, responseBody] = await apiUtils.post(endPoints.rankMath(productId), { data: {} }); expect(response.ok()).toBeTruthy(); expect(responseBody).toBeTruthy(); diff --git a/tests/pw/tests/api/refunds.spec.ts b/tests/pw/tests/api/refunds.spec.ts index def02a6dc9..ac51bd0647 100644 --- a/tests/pw/tests/api/refunds.spec.ts +++ b/tests/pw/tests/api/refunds.spec.ts @@ -4,7 +4,7 @@ //COVERAGE_TAG: PUT /dokan/v1/refunds/(?P[\d]+)/approve //COVERAGE_TAG: PUT /dokan/v1/refunds/batch -import { test, expect, APIResponse } from '@playwright/test'; +import { test, expect, request, APIResponse } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { dbUtils } from '@utils/dbUtils'; import { endPoints } from '@utils/apiEndPoints'; @@ -16,10 +16,14 @@ test.describe('refunds api test', () => { let refundId: string; let orderResponseBody: APIResponse; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, orderResponseBody] = await apiUtils.createOrderWithStatus(payloads.createProduct(), payloads.createOrder, 'wc-processing', payloads.vendorAuth); - [, refundId] = await dbUtils.createRefund(orderResponseBody); + [, refundId] = await dbUtils.createRefundRequest(orderResponseBody); // todo: replace by woocommerce api + }); + + test.afterAll(async () => { + await apiUtils.dispose(); }); test('get all refunds @pro', async () => { @@ -47,14 +51,14 @@ test.describe('refunds api test', () => { }); test('approve a refund @pro', async () => { - const [, refundId] = await dbUtils.createRefund(orderResponseBody); + const [, refundId] = await dbUtils.createRefundRequest(orderResponseBody); const [response, responseBody] = await apiUtils.put(endPoints.approveRefund(refundId)); expect(response.ok()).toBeTruthy(); expect(responseBody).toBeTruthy(); }); test('update batch refunds @pro', async () => { - await dbUtils.createRefund(orderResponseBody); + await dbUtils.createRefundRequest(orderResponseBody); const allPendingRefundsIds = (await apiUtils.getAllRefunds('pending', payloads.vendorAuth)).map((a: { id: unknown }) => a.id); const [response, responseBody] = await apiUtils.put(endPoints.updateBatchRefunds, { data: { cancelled: allPendingRefundsIds } }); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/reports.spec.ts b/tests/pw/tests/api/reports.spec.ts index e579472bd1..f1aca2342a 100644 --- a/tests/pw/tests/api/reports.spec.ts +++ b/tests/pw/tests/api/reports.spec.ts @@ -3,7 +3,7 @@ //COVERAGE_TAG: GET /dokan/v1/reports/top_earners //COVERAGE_TAG: GET /dokan/v1/reports/top_selling -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -11,11 +11,15 @@ import { payloads } from '@utils/payloads'; test.describe('report api test', () => { let apiUtils: ApiUtils; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); await apiUtils.createOrder(payloads.createProduct(), payloads.createOrder); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get sales overview report @pro', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getSalesOverviewReport); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/reverseWithdrawal.spec.ts b/tests/pw/tests/api/reverseWithdrawal.spec.ts index 984a1eb36c..75c867ab90 100644 --- a/tests/pw/tests/api/reverseWithdrawal.spec.ts +++ b/tests/pw/tests/api/reverseWithdrawal.spec.ts @@ -5,7 +5,7 @@ //COVERAGE_TAG: GET /dokan/v1/reverse-withdrawal/vendor-due-status //COVERAGE_TAG: POST /dokan/v1/reverse-withdrawal/add-to-cart -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -16,8 +16,8 @@ import { dbData } from '@utils/dbData'; test.describe('reverse withdrawal api test', () => { let apiUtils: ApiUtils; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); await dbUtils.setDokanSettings(dbData.dokan.optionName.reverseWithdraw, dbData.dokan.reverseWithdrawSettings); const [, , orderId] = await apiUtils.createOrderWithStatus(payloads.createProduct(), payloads.createOrderCod, data.order.orderStatus.processing, payloads.vendorAuth); @@ -26,6 +26,7 @@ test.describe('reverse withdrawal api test', () => { test.afterAll(async () => { await dbUtils.setDokanSettings(dbData.dokan.optionName.reverseWithdraw, { ...dbData.dokan.reverseWithdrawSettings, enabled: 'off' }); + await apiUtils.dispose(); }); test('get reverse withdrawal transaction types @lite', async () => { diff --git a/tests/pw/tests/api/roles.spec.ts b/tests/pw/tests/api/roles.spec.ts index 8547061dbe..05aa8a6d51 100644 --- a/tests/pw/tests/api/roles.spec.ts +++ b/tests/pw/tests/api/roles.spec.ts @@ -1,14 +1,18 @@ //COVERAGE_TAG: GET /dokan/v1/request-for-quote/roles -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; test.describe('roles api test', () => { let apiUtils: ApiUtils; - test.beforeAll(({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); + }); + + test.afterAll(async () => { + await apiUtils.dispose(); }); test('get all user roles @pro', async () => { diff --git a/tests/pw/tests/api/sellerBadge.spec.ts b/tests/pw/tests/api/sellerBadge.spec.ts index bc4885ba00..03cd961962 100644 --- a/tests/pw/tests/api/sellerBadge.spec.ts +++ b/tests/pw/tests/api/sellerBadge.spec.ts @@ -10,7 +10,7 @@ //COVERAGE_TAG: DELETE /dokan/v1/seller-badge/(?P[\d]+) //COVERAGE_TAG: PUT /dokan/v1/seller-badge/bulk-actions -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -21,14 +21,18 @@ test.describe('seller badge api test', () => { let badgeId: string; let currentUserId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); // delete previous badges await apiUtils.deleteAllSellerBadges(); [, currentUserId] = await apiUtils.getCurrentUser(); [, badgeId] = await apiUtils.createSellerBadge(payloads.createSellerBadgeExclusiveToPlatform); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get verified-seller verification types @pro', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getVerifiedSellerVerificationTypes); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/settings.spec.ts b/tests/pw/tests/api/settings.spec.ts index 84ebeaf304..a9a9dfa887 100644 --- a/tests/pw/tests/api/settings.spec.ts +++ b/tests/pw/tests/api/settings.spec.ts @@ -1,17 +1,21 @@ //COVERAGE_TAG: GET /dokan/v1/settings //COVERAGE_TAG: PUT /dokan/v1/settings -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; -import { schemas } from '@utils/schemas'; +// import { schemas } from '@utils/schemas'; test.describe('settings api test', () => { let apiUtils: ApiUtils; - test.beforeAll(({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); + }); + + test.afterAll(async () => { + await apiUtils.dispose(); }); test('get settings @lite', async () => { diff --git a/tests/pw/tests/api/setttingsGroup.spec.ts b/tests/pw/tests/api/setttingsGroup.spec.ts index 2f4010fa14..f86fffbfe2 100644 --- a/tests/pw/tests/api/setttingsGroup.spec.ts +++ b/tests/pw/tests/api/setttingsGroup.spec.ts @@ -6,7 +6,7 @@ //COVERAGE_TAG: GET /dokan/v2/settings/(?P[\w-]+)/(?P[\w-]+)/(?P[\w-]+) //COVERAGE_TAG: POST /dokan/v2/settings/(?P[\w-]+)/(?P[\w-]+)/(?P[\w-]+) -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -14,8 +14,12 @@ import { payloads } from '@utils/payloads'; test.describe('new settings api test', () => { let apiUtils: ApiUtils; - test.beforeAll(({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); + }); + + test.afterAll(async () => { + await apiUtils.dispose(); }); test('get store settings @v2 @lite', async () => { diff --git a/tests/pw/tests/api/spmv.spec.ts b/tests/pw/tests/api/spmv.spec.ts index 97ec5b6923..b8ba78f9eb 100644 --- a/tests/pw/tests/api/spmv.spec.ts +++ b/tests/pw/tests/api/spmv.spec.ts @@ -2,7 +2,7 @@ //COVERAGE_TAG: GET /dokan/v1/spmv-product/search //COVERAGE_TAG: POST /dokan/v1/spmv-product/add-to-store -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -11,11 +11,15 @@ test.describe('spmv API test', () => { let apiUtils: ApiUtils; let productId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, productId] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendor2Auth); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get spmv settings @pro', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getSpmvSettings); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/storeCategories.spec.ts b/tests/pw/tests/api/storeCategories.spec.ts index 158315529b..4b6a147ed9 100644 --- a/tests/pw/tests/api/storeCategories.spec.ts +++ b/tests/pw/tests/api/storeCategories.spec.ts @@ -6,7 +6,7 @@ //COVERAGE_TAG: PUT /dokan/v1/store-categories/(?P[\d]+) //COVERAGE_TAG: DELETE /dokan/v1/store-categories/(?P[\d]+) -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -16,11 +16,15 @@ test.describe('store categories api test', () => { let apiUtils: ApiUtils; let categoryId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, categoryId] = await apiUtils.createStoreCategory(payloads.createStoreCategory()); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get default store category @pro', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getDefaultStoreCategory); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/storeReviews.spec.ts b/tests/pw/tests/api/storeReviews.spec.ts index 80e54ca8cb..09b6054810 100644 --- a/tests/pw/tests/api/storeReviews.spec.ts +++ b/tests/pw/tests/api/storeReviews.spec.ts @@ -7,7 +7,7 @@ //COVERAGE_TAG: PUT /dokan/v1/store-reviews/(?P[\d]+)/restore //COVERAGE_TAG: PUT /dokan/v1/store-reviews/batch -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -17,13 +17,17 @@ test.describe('store reviews api test', () => { let sellerId: string; let reviewId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); // let [, sId,] = await apiUtils.createStore(payloads.createStore()) [, sellerId] = await apiUtils.getCurrentUser(); [, reviewId] = await apiUtils.createStoreReview(sellerId, payloads.createStoreReview, payloads.customerAuth); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get store reviews @pro', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getStoreReviews(sellerId)); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/stores.spec.ts b/tests/pw/tests/api/stores.spec.ts index 9045622e54..ccc18236c0 100644 --- a/tests/pw/tests/api/stores.spec.ts +++ b/tests/pw/tests/api/stores.spec.ts @@ -13,7 +13,7 @@ //COVERAGE_TAG: POST /dokan/v1/stores/(?P[\d]+)/email //COVERAGE_TAG: PUT /dokan/v1/stores/batch -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -22,12 +22,16 @@ test.describe('stores api test', () => { let apiUtils: ApiUtils; let sellerId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, sellerId] = await apiUtils.createStore(payloads.createStore()); // let [, id] = await apiUtils.getCurrentUser() }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get all stores @lite', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getAllStores); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/supportTickets.spec.ts b/tests/pw/tests/api/supportTickets.spec.ts index 2f7347ecaa..821f802a41 100644 --- a/tests/pw/tests/api/supportTickets.spec.ts +++ b/tests/pw/tests/api/supportTickets.spec.ts @@ -7,7 +7,7 @@ //COVERAGE_TAG: DELETE /dokan/v1/admin/support-ticket/(?P[\d]+)/comment //COVERAGE_TAG: PUT /dokan/v1/admin/support-ticket/batch -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -18,11 +18,15 @@ test.describe('support ticket api test', () => { let apiUtils: ApiUtils; let supportTicketId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, supportTicketId] = await apiUtils.createSupportTicket({ ...payloads.createSupportTicket, author: CUSTOMER_ID, store_id: VENDOR_ID }); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get all support ticket customers @pro', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getAllSupportTicketCustomers); expect(response.ok()).toBeTruthy(); @@ -76,8 +80,8 @@ test.describe('support ticket api test', () => { expect(responseBody).toBeTruthy(); // reopen all support tickets - for (const supportTicketId of allSupportTicketIds) { - await apiUtils.updateSupportTicketStatus(supportTicketId, 'open'); - } + // for (const supportTicketId of allSupportTicketIds) { + // await apiUtils.updateSupportTicketStatus(supportTicketId, 'open'); + // } }); }); diff --git a/tests/pw/tests/api/vendorDashborad.spec.ts b/tests/pw/tests/api/vendorDashborad.spec.ts index 0f02f20a1b..696fe8d9bd 100644 --- a/tests/pw/tests/api/vendorDashborad.spec.ts +++ b/tests/pw/tests/api/vendorDashborad.spec.ts @@ -6,15 +6,19 @@ //COVERAGE_TAG: GET /dokan/v1/vendor-dashboard/preferences //COVERAGE_TAG: GET /dokan/v1/vendor-dashboard/profile-progressbar -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; test.describe('vendor dashboard api test', () => { let apiUtils: ApiUtils; - test.beforeAll(({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); + }); + + test.afterAll(async () => { + await apiUtils.dispose(); }); test('get vendor dashboard statistics @lite', async () => { diff --git a/tests/pw/tests/api/vendorStaff.spec.ts b/tests/pw/tests/api/vendorStaff.spec.ts index 4cee96271e..b549205daa 100644 --- a/tests/pw/tests/api/vendorStaff.spec.ts +++ b/tests/pw/tests/api/vendorStaff.spec.ts @@ -7,7 +7,7 @@ //COVERAGE_TAG: PUT /dokan/v1/vendor-staff/(?P[\d]+)/capabilities //COVERAGE_TAG: DELETE /dokan/v1/vendor-staff/(?P[\d]+) -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -16,11 +16,15 @@ test.describe('vendor staff api test', () => { let apiUtils: ApiUtils; let staffId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, staffId] = await apiUtils.createVendorStaff(payloads.createStaff(), payloads.vendorAuth); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test.use({ extraHTTPHeaders: { Authorization: payloads.vendorAuth.Authorization } }); test('get all vendor staffs @pro', async () => { diff --git a/tests/pw/tests/api/wholesaleCustomers.spec.ts b/tests/pw/tests/api/wholesaleCustomers.spec.ts index b14c571d26..89955d512a 100644 --- a/tests/pw/tests/api/wholesaleCustomers.spec.ts +++ b/tests/pw/tests/api/wholesaleCustomers.spec.ts @@ -3,7 +3,7 @@ //COVERAGE_TAG: POST /dokan/v1/wholesale/customer/(?P[\d]+) //COVERAGE_TAG: PUT /dokan/v1/wholesale/customers/batch -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -12,11 +12,15 @@ test.describe('wholesale customers api test', () => { let apiUtils: ApiUtils; let wholesaleCustomerId: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, wholesaleCustomerId] = await apiUtils.createWholesaleCustomer(payloads.createCustomer(), payloads.adminAuth); }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get all wholesale customers @pro', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getAllWholesaleCustomers); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/api/withdrawSettings.spec.ts b/tests/pw/tests/api/withdrawSettings.spec.ts index f28d7ccfd7..38191c56c7 100644 --- a/tests/pw/tests/api/withdrawSettings.spec.ts +++ b/tests/pw/tests/api/withdrawSettings.spec.ts @@ -4,7 +4,7 @@ //COVERAGE_TAG: POST /dokan/v2/withdraw/disbursement //COVERAGE_TAG: POST /dokan/v2/withdraw/disbursement/disable -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -12,8 +12,12 @@ import { payloads } from '@utils/payloads'; test.describe('withdraw api test', () => { let apiUtils: ApiUtils; - test.beforeAll(({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); + }); + + test.afterAll(async () => { + await apiUtils.dispose(); }); test('get withdraw settings @v2 @lite', async () => { diff --git a/tests/pw/tests/api/withdraws.spec.ts b/tests/pw/tests/api/withdraws.spec.ts index 53e1b1b152..e2de96f9b2 100644 --- a/tests/pw/tests/api/withdraws.spec.ts +++ b/tests/pw/tests/api/withdraws.spec.ts @@ -6,7 +6,7 @@ //COVERAGE_TAG: PUT /dokan/v1/withdraw/batch //COVERAGE_TAG: POST /dokan/v1/withdraw -import { test, expect } from '@playwright/test'; +import { test, expect, request } from '@playwright/test'; import { ApiUtils } from '@utils/apiUtils'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; @@ -17,14 +17,18 @@ test.describe('withdraw api test', () => { let withdrawId: string; let minimumWithdrawLimit: string; - test.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + test.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); [, minimumWithdrawLimit] = await apiUtils.getMinimumWithdrawLimit(); await apiUtils.createOrderWithStatus(payloads.createProduct(), payloads.createOrder, 'wc-completed'); const [responseBody, id] = await apiUtils.createWithdraw({ ...payloads.createWithdraw, amount: minimumWithdrawLimit }); withdrawId = responseBody.message === 'You already have a pending withdraw request' ? await apiUtils.getWithdrawId() : id; }); + test.afterAll(async () => { + await apiUtils.dispose(); + }); + test('get withdraw payment methods @lite', async () => { const [response, responseBody] = await apiUtils.get(endPoints.getWithdrawPaymentMethods); expect(response.ok()).toBeTruthy(); diff --git a/tests/pw/tests/e2e/_auth.setup.ts b/tests/pw/tests/e2e/_auth.setup.ts index 0e69507a01..6828478e8b 100644 --- a/tests/pw/tests/e2e/_auth.setup.ts +++ b/tests/pw/tests/e2e/_auth.setup.ts @@ -1,59 +1,64 @@ -import { test as setup, expect } from '@playwright/test'; +import { test as setup, expect, request } from '@playwright/test'; import { LoginPage } from '@pages/loginPage'; -// import { WpPage } from '@pages/wpPage'; +import { WpPage } from '@pages/wpPage'; import { ApiUtils } from '@utils/apiUtils'; import { payloads } from '@utils/payloads'; import { data } from '@utils/testData'; import { helpers } from '@utils/helpers'; -const { DOKAN_PRO } = process.env; +const { DOKAN_PRO, BASE_URL } = process.env; setup.describe('authenticate users & set permalink', () => { - // setup.skip('get server url @lite', async ({ request }) => { - // const apiUtils = new ApiUtils(request); - // const headers = await apiUtils.getSiteHeaders(BASE_URL); - // if (headers.link) { - // const serverUrl = headers.link.includes('rest_route') ? BASE_URL + '/?rest_route=' : BASE_URL + '/wp-json'; - // console.log('ServerUrl:', serverUrl); - // process.env.SERVER_URL = serverUrl; - // } else { - // console.log("Headers link doesn't exists"); - // } - // }); + let apiUtils: ApiUtils; + + setup.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); + }); + + setup.afterAll(async () => { + await apiUtils.dispose(); + }); + + setup.skip('get server url @lite', async () => { + const apiUtils = new ApiUtils(await request.newContext()); + const headers = await apiUtils.getSiteHeaders(BASE_URL); + if (headers.link) { + const serverUrl = headers.link.includes('rest_route') ? BASE_URL + '/?rest_route=' : BASE_URL + '/wp-json'; + console.log('ServerUrl:', serverUrl); + process.env.SERVER_URL = serverUrl; + } else { + console.log("Headers link doesn't exists"); + } + }); setup('authenticate admin @lite', async ({ page }) => { const loginPage = new LoginPage(page); await loginPage.adminLogin(data.admin, data.auth.adminAuthFile); }); - // setup('admin set WpSettings @lite', async ({ page }) => { - // const loginPage = new LoginPage(page); - // const wpPage = new WpPage(page); - // await loginPage.adminLogin(data.admin); - // await wpPage.setPermalinkSettings(data.wpSettings.permalink); - // }); + setup.skip('admin set WpSettings @lite', async ({ page }) => { + const loginPage = new LoginPage(page); + const wpPage = new WpPage(page); + await loginPage.adminLogin(data.admin); + await wpPage.setPermalinkSettings(data.wpSettings.permalink); + }); - setup('add customer1 @lite', async ({ request }) => { - const apiUtils = new ApiUtils(request); + setup('add customer1 @lite', async () => { const [, customerId] = await apiUtils.createCustomer(payloads.createCustomer1, payloads.adminAuth); console.log('CUSTOMER_ID:', customerId); process.env.CUSTOMER_ID = customerId; helpers.appendEnv(`CUSTOMER_ID=${customerId}`); // for local testing }); - setup('add vendor1 @lite', async ({ request }) => { - const apiUtils = new ApiUtils(request); - const [, sellerId] = await apiUtils.createStore(payloads.createStore1, payloads.adminAuth); - await apiUtils.updateCustomer(sellerId, payloads.updateAddress, payloads.adminAuth); + setup('add vendor1 @lite', async () => { + const [, sellerId] = await apiUtils.createStore(payloads.createStore1, payloads.adminAuth, true); console.log('VENDOR_ID:', sellerId); process.env.VENDOR_ID = sellerId; helpers.appendEnv(`VENDOR_ID=${sellerId}`); // for local testing }); - setup('add vendor2 @lite', async ({ request }) => { - const apiUtils = new ApiUtils(request); - const [, sellerId] = await apiUtils.createStore(payloads.createStore2, payloads.adminAuth); - await apiUtils.updateCustomer(sellerId, payloads.updateAddress, payloads.adminAuth); + setup('add vendor2 @lite', async () => { + const [, sellerId] = await apiUtils.createStore(payloads.createStore2, payloads.adminAuth, true); console.log('VENDOR2_ID:', sellerId); process.env.VENDOR2_ID = sellerId; helpers.appendEnv(`VENDOR2_ID=${sellerId}`); // for local testing @@ -69,8 +74,12 @@ setup.describe('authenticate users & set permalink', () => { await loginPage.login(data.vendor, data.auth.vendorAuthFile); }); - setup('dokan pro enabled or not @lite', async ({ request }) => { - const apiUtils = new ApiUtils(request); + setup('authenticate vendor2 @lite', async ({ page }) => { + const loginPage = new LoginPage(page); + await loginPage.login(data.vendor.vendor2, data.auth.vendor2AuthFile); + }); + + setup('dokan pro enabled or not @lite', async () => { let res = await apiUtils.checkPluginsExistence(data.plugin.dokanPro, payloads.adminAuth); if (res) { res = await apiUtils.pluginsActiveOrNot(data.plugin.dokanPro, payloads.adminAuth); @@ -78,8 +87,7 @@ setup.describe('authenticate users & set permalink', () => { DOKAN_PRO ? expect(res).toBeTruthy() : expect(res).toBeFalsy(); }); - setup('get test environment info @lite', async ({ request }) => { - const apiUtils = new ApiUtils(request); + setup('get test environment info @lite', async () => { const [, systemInfo] = await apiUtils.getSystemStatus(payloads.adminAuth); helpers.writeFile(data.systemInfo, JSON.stringify(systemInfo)); }); diff --git a/tests/pw/tests/e2e/_env.setup.ts b/tests/pw/tests/e2e/_env.setup.ts index 702ac9df51..b427663b18 100644 --- a/tests/pw/tests/e2e/_env.setup.ts +++ b/tests/pw/tests/e2e/_env.setup.ts @@ -1,4 +1,4 @@ -import { test as setup, expect, Page } from '@playwright/test'; +import { test as setup, expect, request, Page } from '@playwright/test'; import { ProductAdvertisingPage } from '@pages/productAdvertisingPage'; import { ReverseWithdrawsPage } from '@pages/reverseWithdrawsPage'; import { VendorSettingsPage } from '@pages/vendorSettingsPage'; @@ -16,8 +16,12 @@ setup.describe('setup site & woocommerce & user settings', () => { let apiUtils: ApiUtils; - setup.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + setup.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); + }); + + setup.afterAll(async () => { + await apiUtils.dispose(); }); setup('check active plugins @lite', async () => { @@ -45,7 +49,7 @@ setup.describe('setup site & woocommerce & user settings', () => { // delete previous shipping zones const allShippingZoneIds = (await apiUtils.getAllShippingZones()).map((a: { id: string }) => a.id); // allShippingZoneIds = helpers.removeItem(allShippingZoneIds, 0) // avoid remove default zone id - if (allShippingZoneIds.length) { + if (allShippingZoneIds?.length) { for (const shippingZoneId of allShippingZoneIds) { await apiUtils.deleteShippingZone(shippingZoneId); } @@ -102,7 +106,7 @@ setup.describe('setup site & woocommerce & user settings', () => { setup('disable simple-auction ajax bid check @pro', async () => { setup.skip(!process.env.CI || !DOKAN_PRO, 'skip on local'); - const [, , status] = await apiUtils.getSinglePlugin('wa/woocommerce-simple-auctions', payloads.adminAuth); + const [, , status] = await apiUtils.getSinglePlugin('woocommerce-simple-auctions/woocommerce-simple-auctions', payloads.adminAuth); status === 'active' && (await dbUtils.updateWpOptionTable('simple_auctions_live_check', 'no')); }); }); @@ -112,8 +116,12 @@ setup.describe('setup user settings', () => { let apiUtils: ApiUtils; - setup.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + setup.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); + }); + + setup.afterAll(async () => { + await apiUtils.dispose(); }); // Vendor Details @@ -122,8 +130,7 @@ setup.describe('setup user settings', () => { await apiUtils.deleteAllProducts(data.predefined.simpleProduct.product1.name, payloads.vendorAuth); // create store product - const product = { ...payloads.createProduct(), name: data.predefined.simpleProduct.product1.name }; - const [, productId] = await apiUtils.createProduct(product, payloads.vendorAuth); + const [, productId] = await apiUtils.createProduct({ ...payloads.createProduct(), name: data.predefined.simpleProduct.product1.name }, payloads.vendorAuth); console.log('PRODUCT_ID', productId); process.env.PRODUCT_ID = productId; helpers.appendEnv(`PRODUCT_ID=${productId}`); // for local testing @@ -134,8 +141,7 @@ setup.describe('setup user settings', () => { await apiUtils.deleteAllProducts(data.predefined.vendor2.simpleProduct.product1.name, payloads.vendor2Auth); // create store product - const product = { ...payloads.createProduct(), name: data.predefined.vendor2.simpleProduct.product1.name }; - const [, productId] = await apiUtils.createProduct(product, payloads.vendor2Auth); + const [, productId] = await apiUtils.createProduct({ ...payloads.createProduct(), name: data.predefined.vendor2.simpleProduct.product1.name }, payloads.vendor2Auth); console.log('V2_PRODUCT_ID:', productId); process.env.V2_PRODUCT_ID = productId; helpers.appendEnv(`V2_PRODUCT_ID=${productId}`); // for local testing @@ -155,17 +161,17 @@ setup.describe('setup user settings', () => { await apiUtils.createProduct({ ...product, status: 'pending', in_stock: true }, payloads.vendorAuth); await apiUtils.createProduct({ ...product, status: 'publish', in_stock: true }, payloads.vendorAuth); }); - - setup.skip('add test vendor orders @lite', async () => { - await apiUtils.createOrder(payloads.createProduct(), { ...payloads.createOrder, customer_id: CUSTOMER_ID }, payloads.vendorAuth); - }); }); setup.describe('setup dokan settings', () => { let apiUtils: ApiUtils; - setup.beforeAll(async ({ request }) => { - apiUtils = new ApiUtils(request); + setup.beforeAll(async () => { + apiUtils = new ApiUtils(await request.newContext()); + }); + + setup.afterAll(async () => { + await apiUtils.dispose(); }); setup('set dokan general settings @lite', async () => { @@ -274,7 +280,7 @@ setup.describe('setup dokan settings e2e', () => { let aPage: Page, vPage: Page; let apiUtils: ApiUtils; - setup.beforeAll(async ({ browser, request }) => { + setup.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); productAdvertisingPage = new ProductAdvertisingPage(aPage); @@ -284,12 +290,13 @@ setup.describe('setup dokan settings e2e', () => { vPage = await vendorContext.newPage(); vendorPage = new VendorSettingsPage(vPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); }); setup.afterAll(async () => { await aPage.close(); await vPage.close(); + await apiUtils.dispose(); }); setup('recreate reverse withdrawal payment product via settings save @lite', async () => { diff --git a/tests/pw/tests/e2e/_localSite.install.ts b/tests/pw/tests/e2e/_localSite.install.ts index 96fc0c0f17..4ee62b21c9 100644 --- a/tests/pw/tests/e2e/_localSite.install.ts +++ b/tests/pw/tests/e2e/_localSite.install.ts @@ -1,4 +1,4 @@ -import { test } from '@playwright/test'; +import { test, request } from '@playwright/test'; import { data } from '@utils/testData'; import { LoginPage } from '@pages/loginPage'; import { LocalSetupPage } from '@pages/localSetupPage'; @@ -11,7 +11,7 @@ import { dbData } from '@utils/dbData'; test.describe('setup local site', () => { test.skip(!!process.env.CI, 'skip site setup on CI'); - // test('download wordpress to desired folder', async ({ page }) => { + test('download wordpress to desired folder', async ({ page }) => {}); // todo: /* @@ -24,8 +24,7 @@ test.describe('setup local site', () => { // }); - // test('delete database or all tables ', async ({ page }) => { - // }); + test('delete database or all tables', async ({ page }) => {}); test('admin setup WP', async ({ page }) => { const loginPage = new LoginPage(page); @@ -40,12 +39,12 @@ test.describe('setup local site', () => { // await dbUtils.updateWpOptionTable(dbData.dokan.optionName.dokanActiveModules, dbData.dokan.modules, 'serialize'); }); - // test('install and activate theme', async ({ request }) => {} + test('install and activate theme', async ({ request }) => {}); // todo: skip global setup for local_setup - test('activate dokan & woocommerce plugins', async ({ request }) => { - const apiUtils = new ApiUtils(request); + test('activate dokan & woocommerce plugins', async () => { + const apiUtils = new ApiUtils(await request.newContext()); const plugins = [ 'woocommerce/woocommerce', 'dokan/dokan', diff --git a/tests/pw/tests/e2e/abuseReports.spec.ts b/tests/pw/tests/e2e/abuseReports.spec.ts index c2361509c6..da1adc1bbf 100644 --- a/tests/pw/tests/e2e/abuseReports.spec.ts +++ b/tests/pw/tests/e2e/abuseReports.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { AbuseReportsPage } from '@pages/abuseReportsPage'; import { ApiUtils } from '@utils/apiUtils'; import { dbUtils } from '@utils/dbUtils'; @@ -11,11 +11,10 @@ const { VENDOR_ID, CUSTOMER_ID } = process.env; test.describe('Abuse report test', () => { let admin: AbuseReportsPage; let customer: AbuseReportsPage; - let guest: AbuseReportsPage; - let aPage: Page, cPage: Page, uPage: Page; + let aPage: Page, cPage: Page; let apiUtils: ApiUtils; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new AbuseReportsPage(aPage); @@ -24,11 +23,7 @@ test.describe('Abuse report test', () => { cPage = await customerContext.newPage(); customer = new AbuseReportsPage(cPage); - const guestContext = await browser.newContext(data.auth.noAuth); - uPage = await guestContext.newPage(); - guest = new AbuseReportsPage(uPage); - - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); const productId = await apiUtils.getProductId(data.predefined.simpleProduct.product1.name, payloads.vendorAuth); await dbUtils.createAbuseReport(dbData.dokan.createAbuseReport, productId, VENDOR_ID, CUSTOMER_ID); }); @@ -36,45 +31,50 @@ test.describe('Abuse report test', () => { test.afterAll(async () => { await aPage.close(); await cPage.close(); - await uPage.close(); + // await gPage.close(); + await apiUtils.dispose(); }); - test('dokan abuse report menu page is rendering properly @pro @explo', async () => { + test('dokan abuse report menu page is rendering properly @pro @exp @a', async () => { await admin.adminAbuseReportRenderProperly(); }); - test('admin can view abuse report details @pro @explo', async () => { + test('admin can view abuse report details @pro @exp @a', async () => { await admin.abuseReportDetails(); }); - test('admin can filter abuse reports by abuse reason @pro', async () => { + test('admin can filter abuse reports by abuse reason @pro @a', async () => { await admin.filterAbuseReports('This content is spam', 'by-reason'); }); - test('admin can filter abuse reports by product @pro', async () => { + test('admin can filter abuse reports by product @pro @a', async () => { await admin.filterAbuseReports(data.predefined.simpleProduct.product1.name, 'by-product'); }); - test('admin can filter abuse reports by vendor @pro', async () => { + test('admin can filter abuse reports by vendor @pro @a', async () => { await admin.filterAbuseReports(data.predefined.vendorStores.vendor1, 'by-vendor'); }); - test('admin can perform abuse report bulk action @pro', async () => { + test.skip('admin can perform abuse report bulk action @pro @a', async () => { + // todo: might cause other tests to fail in parallel await admin.abuseReportBulkAction('delete'); }); // customer - test('customer can report product @pro', async () => { + test('customer can report product @pro @c', async () => { await customer.reportProduct(data.predefined.simpleProduct.product1.name, data.product.report); }); - test('guest customer can report product @pro', async () => { + test('guest customer can report product @pro @g', async ({ page }) => { + const guest = new AbuseReportsPage(page); await guest.reportProduct(data.predefined.simpleProduct.product1.name, data.product.report); }); - test('only logged-in customer can report product @pro', async () => { + test('guest customer need to log-in to report product @pro @g', async ({ page }) => { + const guest = new AbuseReportsPage(page); await dbUtils.setDokanSettings(dbData.dokan.optionName.productReportAbuse, { ...dbData.dokan.productReportAbuseSettings, reported_by_logged_in_users_only: 'on' }); await guest.reportProduct(data.predefined.simpleProduct.product1.name, data.product.report); + await dbUtils.setDokanSettings(dbData.dokan.optionName.productReportAbuse, dbData.dokan.productReportAbuseSettings); }); }); diff --git a/tests/pw/tests/e2e/admin.spec.ts b/tests/pw/tests/e2e/admin.spec.ts index 612341b448..f9e83ab706 100644 --- a/tests/pw/tests/e2e/admin.spec.ts +++ b/tests/pw/tests/e2e/admin.spec.ts @@ -1,95 +1,67 @@ import { test, Page } from '@playwright/test'; import { LoginPage } from '@pages/loginPage'; -import { AdminPage } from '@pages/adminPage'; -// import { ApiUtils } from '@utils/apiUtils'; +import { TaxPage } from '@pages/taxPage'; +import { ShippingPage } from '@pages/shippingPage'; import { data } from '@utils/testData'; -// import { payloads } from '@utils/payloads'; - -test.describe('Admin user functionality test', () => { - test.use({ storageState: { cookies: [], origins: [] } }); - - let loginPage: LoginPage; - let page: Page; - - test.beforeAll(async ({ browser }) => { - const context = await browser.newContext(); - page = await context.newPage(); - loginPage = new LoginPage(page); - }); - - test.afterAll(async () => { - await page.close(); - }); - - test('admin can login @lite', async () => { - await loginPage.adminLogin(data.admin); - }); - - test('admin can logout @lite', async () => { - await loginPage.adminLogin(data.admin); - await loginPage.logoutBackend(); - }); -}); test.describe('Admin functionality test', () => { - let adminPage: AdminPage; + let taxPage: TaxPage; + let shippingPage: ShippingPage; let aPage: Page; test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); - adminPage = new AdminPage(aPage); + taxPage = new TaxPage(aPage); + shippingPage = new ShippingPage(aPage); }); test.afterAll(async () => { await aPage.close(); }); - // test('admin can add categories @lite', async ( ) => { - // await adminPage.addCategory(data.product.category.randomCategory()); - // }); + test('admin can login @lite @a', async ({ page }) => { + const loginPage = new LoginPage(page); + await loginPage.adminLogin(data.admin); + }); - // test('admin can add attributes @lite', async ( ) => { - // await adminPage.addAttributes(data.product.attribute.randomAttribute()); - // }); + test('admin can logout @lite @a', async ({ page }) => { + const loginPage = new LoginPage(page); + await loginPage.adminLogin(data.admin); + await loginPage.logoutBackend(); + }); // settings // tax settings - // test('admin can set standard tax rate', async ( ) => { - // await adminPage.addStandardTaxRate(data.tax) - // }) - // shipping settings - // test('admin can set flat rate shipping', async ( ) => { - // await adminPage.addShippingMethod(data.shipping.shippingMethods.flatRate); - // }); + test('admin can set standard tax rate @lite @a', async () => { + await taxPage.addStandardTaxRate(data.tax); + }); - // test('admin can set free shipping', async ( ) => { - // await adminPage.addShippingMethod(data.shipping.shippingMethods.freeShipping) - // }) + // shipping settings - // test('admin can set local pickup shipping', async ( ) => { - // await adminPage.addShippingMethod(data.shipping.shippingMethods.localPickup) - // }) + test.skip('admin can set flat rate shipping @lite @a', async () => { + await shippingPage.addShippingMethod(data.shipping.shippingMethods.flatRate); + }); - // test('admin can set table rate shipping', async ( ) => { - // await adminPage.addShippingMethod(data.shipping.shippingMethods.tableRateShipping) - // }) + test.skip('admin can set free shipping @lite @a', async () => { + await shippingPage.addShippingMethod(data.shipping.shippingMethods.freeShipping); + }); - // test('admin can set distance rate shipping', async ( ) => { - // await adminPage.addShippingMethod(data.shipping.shippingMethods.distanceRateShipping) - // }) + test.skip('admin can set local pickup shipping @lite @a', async () => { + await shippingPage.addShippingMethod(data.shipping.shippingMethods.localPickup); + }); - // test('admin can set vendor shipping', async ( ) => { - // await adminPage.addShippingMethod(data.shipping.shippingMethods.vendorShipping) - // }) + test.skip('admin can set table rate shipping @pro @a', async () => { + await shippingPage.addShippingMethod(data.shipping.shippingMethods.tableRateShipping); + }); - test('dokan notice @lite', async () => { - await adminPage.dokanNotice(); + test.skip('admin can set distance rate shipping @pro @a', async () => { + await shippingPage.addShippingMethod(data.shipping.shippingMethods.distanceRateShipping); }); - test('dokan promotion @lite', async () => { - await adminPage.dokanPromotion(); + test.skip('admin can set vendor shipping @pro @a', async () => { + await shippingPage.addShippingMethod(data.shipping.shippingMethods.vendorShipping); }); }); diff --git a/tests/pw/tests/e2e/adminDashboard.spec.ts b/tests/pw/tests/e2e/adminDashboard.spec.ts index 019a0a14cc..24bfbecf12 100644 --- a/tests/pw/tests/e2e/adminDashboard.spec.ts +++ b/tests/pw/tests/e2e/adminDashboard.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { AdminDashboardPage } from '@pages/adminDashboardPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; @@ -9,27 +9,28 @@ test.describe('Admin dashboard test', () => { let aPage: Page; let apiUtils: ApiUtils; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new AdminDashboardPage(aPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); }); test.afterAll(async () => { await aPage.close(); + await apiUtils.dispose(); }); - test('dokan admin dashboard is rendering properly @lite @explo', async () => { + test('dokan admin dashboard is rendering properly @lite @exp @a', async () => { await admin.adminDashboardRenderProperly(); }); - test('admin dashboard at a glance values are accurate @lite', async () => { + test('admin dashboard at a glance values are accurate @lite @a', async () => { const summary = await apiUtils.getAdminReportSummary(payloads.adminAuth); await admin.dokanAtAGlanceValueAccuracy(summary); }); - test('admin can add dokan news subscriber @lite', async () => { + test('admin can add dokan news subscriber @lite @a', async () => { await admin.addDokanNewsSubscriber(data.user.userDetails); }); }); diff --git a/tests/pw/tests/e2e/announcements.spec.ts b/tests/pw/tests/e2e/announcements.spec.ts index fd0bbf5213..01d8d46a70 100644 --- a/tests/pw/tests/e2e/announcements.spec.ts +++ b/tests/pw/tests/e2e/announcements.spec.ts @@ -1,96 +1,102 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { AnnouncementsPage } from '@pages/announcementsPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; import { payloads } from '@utils/payloads'; -test.describe('Announcements test', () => { +test.describe('Announcements test (admin)', () => { let admin: AnnouncementsPage; let aPage: Page; let apiUtils: ApiUtils; let announcementTitle: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new AnnouncementsPage(aPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); [, , announcementTitle] = await apiUtils.createAnnouncement({ ...payloads.createAnnouncement(), status: 'draft' }, payloads.adminAuth); }); test.afterAll(async () => { await aPage.close(); + await apiUtils.dispose(); }); - test('dokan announcements menu page is rendering properly @pro @explo', async () => { + //admin + + test('dokan announcements menu page is rendering properly @pro @exp @a', async () => { await admin.adminAnnouncementsRenderProperly(); }); - test('admin can send announcement @pro', async () => { + test('admin can send announcement @pro @a', async () => { await admin.addAnnouncement({ ...data.announcement, title: data.announcement.randomTitle() }); }); - test('admin can schedule announcement @pro', async () => { + test('admin can schedule announcement @pro @a', async () => { await admin.addAnnouncement({ ...data.announcement, title: data.announcement.randomTitle(), publishType: 'schedule' }); }); - test('admin can edit announcement @pro', async () => { + test('admin can edit announcement @pro @a', async () => { await admin.editAnnouncement({ ...data.announcement, title: announcementTitle }); }); - test('admin can trash announcement @pro', async () => { + test('admin can trash announcement @pro @a', async () => { + const [, , announcementTitle] = await apiUtils.createAnnouncement(payloads.createAnnouncement(), payloads.adminAuth); await admin.updateAnnouncement(announcementTitle, 'trash'); }); - test('admin can restore announcement @pro', async () => { + test('admin can restore announcement @pro @a', async () => { const [, announcementId, announcementTitle] = await apiUtils.createAnnouncement(payloads.createAnnouncement(), payloads.adminAuth); await apiUtils.deleteAnnouncement(announcementId, payloads.adminAuth); await admin.updateAnnouncement(announcementTitle, 'restore'); }); - test('admin can permanently delete announcement @pro', async () => { + test('admin can permanently delete announcement @pro @a', async () => { const [, announcementId, announcementTitle] = await apiUtils.createAnnouncement(payloads.createAnnouncement(), payloads.adminAuth); await apiUtils.deleteAnnouncement(announcementId, payloads.adminAuth); await admin.updateAnnouncement(announcementTitle, 'permanently-delete'); }); - test('admin can perform announcements bulk action @pro', async () => { + test.skip('admin can perform announcements bulk action @pro @a', async () => { + // todo: might cause other tests to fail in parallel // await apiUtils.createAnnouncement(payloads.createAnnouncement(), payloads.adminAuth); await admin.announcementBulkAction('trash'); }); }); -test.describe('Announcements test vendor', () => { +test.describe('Announcements test (vendor)', () => { let vendor: AnnouncementsPage; let vPage: Page; let apiUtils: ApiUtils; const announcement = payloads.createAnnouncement(); - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const vendorContext = await browser.newContext(data.auth.vendorAuth); vPage = await vendorContext.newPage(); vendor = new AnnouncementsPage(vPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); await apiUtils.createAnnouncement(announcement, payloads.adminAuth); }); test.afterAll(async () => { await vPage.close(); + await apiUtils.dispose(); }); // vendor - test('vendor announcement menu page is rendering properly @pro @explo', async () => { + test('vendor announcement menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorAnnouncementsRenderProperly(); }); - test('vendor can view announcement details @pro', async () => { + test('vendor can view announcement details @pro @v', async () => { await vendor.vendorViewAnnouncement(announcement); }); - test('vendor can delete announcement @pro', async () => { + test('vendor can delete announcement @pro @v', async () => { await vendor.vendorDeleteAnnouncement(announcement.title); }); }); diff --git a/tests/pw/tests/e2e/calculation.spec.ts b/tests/pw/tests/e2e/calculation.spec.ts deleted file mode 100644 index 526bb6925c..0000000000 --- a/tests/pw/tests/e2e/calculation.spec.ts +++ /dev/null @@ -1,115 +0,0 @@ -// import { test, expect, Page } from '@playwright/test'; -// import { data } from '@utils/testData'; -// import { helpers } from '@utils/helpers'; -// import { LoginPage } from '@pages/loginPage'; -// import { AdminPage } from '@pages/adminPage'; -// import { CustomerPage } from '@pages/customerPage'; -// import { VendorPage } from '@pages/vendorPage'; - -// test.describe.skip( 'Calculation functionality test', () => { -// test('refund through rma test', async ({ page }) => { -// const loginPage = new LoginPage(page); -// const adminPage = new AdminPage(page); -// const vendorPage = new VendorPage(page); -// const customerPage = new CustomerPage(page); -// // let productName = data.product.name.simple -// const productName = 'product1'; -// //create product -// // await loginPage.login(data.vendor) -// // await vendorPage.addSimpleProduct(data.product.name.simple, data.product.price, data.product.category -// // buy product -// // await loginPage.switchUser(data.customer) -// await loginPage.login(data.customer); -// const cOrderDetails = await customerPage.buyProduct(productName, false, true); -// //update order status -// await loginPage.switchUser(data.vendor); -// await vendorPage.changeOrderStatus(cOrderDetails.orderNumber, data.orderStatus[1]); -// //send refund request -// await loginPage.switchUser(data.customer); -// await customerPage.sendWarrantyRequest(cOrderDetails.orderNumber, productName, data.order.refundRequestType, data.order.refundRequestReasons, data.order.refundRequestDetails); -// //vendor approve rma request -// await loginPage.switchUser(data.vendor); -// await vendorPage.approveReturnRequest(cOrderDetails.orderNumber, productName); -// // await vendorPage.deleteReturnRequest(orderId -// //admin approve refund request -// await loginPage.switchUser(data.admin); -// await adminPage.approveRefundRequest(cOrderDetails.orderNumber, true); -// }); - -// test('vendor refund test', async ({ page }) => { -// const loginPage = new LoginPage(page); -// const adminPage = new AdminPage(page); -// const vendorPage = new VendorPage(page); -// const customerPage = new CustomerPage(page); -// // let productName = data.product.name.simple -// const productName = 'product1'; -// //create product -// // await loginPage.login(data.vendor) -// // await vendorPage.addSimpleProduct(productName, data.product.price, data.product.category -// // buy product -// // await loginPage.switchUser(data.customer) -// await loginPage.login(data.customer); -// const cOrderDetails = await customerPage.buyProduct(productName, false, true); -// //refund order -// await loginPage.switchUser(data.vendor); -// await vendorPage.changeOrderStatus(cOrderDetails.orderNumber, data.orderStatus[1]); -// await vendorPage.refundOrder(cOrderDetails.orderNumber, productName, true); -// // approve refund request -// await loginPage.switchUser(data.admin); -// await adminPage.approveRefundRequest(cOrderDetails.orderNumber, true); -// }); - -// test( 'calculation test', async ( { browser } ) => { -// const adminContext = await browser.newContext( { storageState: 'adminStorageState.json' } ); -// const adminPage = await adminContext.newPage(); -// const vendorContext = await browser.newContext( { storageState: 'vendorStorageState.json' } ); -// const vendorPage = await vendorContext.newPage(); -// const customerContext = await browser.newContext( { storageState: 'customerStorageState.json' } ); -// const customerPage = await customerContext.newPage(); - -// const productName = data.predefined.simpleProduct.product1.name; - -// const cOrderDetails0 = await customerPage.buyProduct( productName, false, true, 'bank' ); -// const cOrderDetails = await customerPage.getOrderDetails( cOrderDetails0.orderNumber ); - -// //vendor order details -// const aOrderDetails = await adminPage.getOrderDetails( cOrderDetails.orderNumber ); - -// //admin order details -// const vOrderDetails = await vendorPage.getOrderDetails( cOrderDetails.orderNumber ); - -// console.log( 'cOrderDetails: ', cOrderDetails, 'aOrderDetails: ', aOrderDetails, 'vOrderDetails: ', vOrderDetails ); - -// const subtotal = cOrderDetails.subtotal; -// const taxRate = Number( process.env.TAX_RATE ); -// const commissionRate = Number( process.env.COMMISSION_RATE ); -// const shipping = 0; -// const gatewayFee = 0; -// const calculatedTax = helpers.tax( taxRate, subtotal, shipping ); -// const calculatedOrderTotal = helpers.orderTotal( subtotal, calculatedTax, shipping ); -// const calculatedAdminCommission = helpers.adminCommission( subtotal, commissionRate, calculatedTax, shipping, gatewayFee ); -// const calculatedVendorEarning = helpers.vendorEarning( subtotal, calculatedAdminCommission, calculatedTax, shipping, gatewayFee ); -// console.log( calculatedTax, calculatedOrderTotal, calculatedAdminCommission, calculatedVendorEarning ); - -// console.log( `orderNumber : c:${ cOrderDetails.orderNumber }, a:${ aOrderDetails.orderNumber }, v:${ vOrderDetails.orderNumber }` ); -// console.log( `orderStatus : c:${ cOrderDetails.orderStatus }, a:${ aOrderDetails.orderStatus }, v:${ vOrderDetails.orderStatus }` ); -// console.log( `orderStatus : c:${ cOrderDetails.orderDate }, a:${ aOrderDetails.orderDate }, v:${ vOrderDetails.orderDate }` ); -// console.log( `subtotal : c:${ cOrderDetails.subtotal }` ); -// console.log( `shipping : c:${ cOrderDetails.shippingMethod }, v:${ vOrderDetails.shippingMethod }` ); -// console.log( `shipping : c:${ cOrderDetails.shippingCost }, a:${ aOrderDetails.shippingCost }, v:${ vOrderDetails.shippingCost }` ); -// console.log( `tax : cal:${ calculatedTax }, c:${ cOrderDetails.tax }, a:${ aOrderDetails.tax }, v:${ vOrderDetails.tax }` ); -// console.log( `orderTotal : cal:${ calculatedOrderTotal }, a:${ aOrderDetails.orderTotal },` ); -// console.log( `commission : cal:${ calculatedAdminCommission }, a:${ aOrderDetails.commission }` ); -// console.log( `vendorEarning : cal:${ calculatedVendorEarning }, a:${ aOrderDetails.vendorEarning }, v:${ vOrderDetails.vendorEarning }` ); - -// expect( cOrderDetails.orderNumber == aOrderDetails.orderNumber == vOrderDetails.orderNumber ).toBeTruthy(); -// expect( cOrderDetails.orderStatus == aOrderDetails.orderStatus == vOrderDetails.orderStatus ).toBeTruthy(); -// expect( cOrderDetails.orderDate == aOrderDetails.orderDate == vOrderDetails.orderDate ).toBeTruthy(); -// expect( calculatedTax == cOrderDetails.tax == aOrderDetails.tax == vOrderDetails.tax ).toBeTruthy(); -// expect( cOrderDetails.shippingMethod == vOrderDetails.shippingMethod ).toBeTruthy(); -// expect( cOrderDetails.shippingCost == aOrderDetails.shippingCost == vOrderDetails.shippingCost ).toBeTruthy(); -// expect( calculatedOrderTotal == cOrderDetails.orderTotal == aOrderDetails.orderTotal == vOrderDetails.orderTotal ).toBeTruthy(); -// expect( calculatedAdminCommission == aOrderDetails.commission ).toBeTruthy(); -// expect( calculatedVendorEarning == aOrderDetails.vendorEarning == vOrderDetails.vendorEarning ).toBeTruthy(); -// } ); -// } ); diff --git a/tests/pw/tests/e2e/coupons.spec.ts b/tests/pw/tests/e2e/coupons.spec.ts index e54c1ccdcc..fbf656c38e 100644 --- a/tests/pw/tests/e2e/coupons.spec.ts +++ b/tests/pw/tests/e2e/coupons.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { CouponsPage } from '@pages/couponsPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; @@ -15,7 +15,7 @@ test.describe('Coupons test', () => { let marketplaceCouponCode: string; let couponCode: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new CouponsPage(aPage); @@ -28,7 +28,7 @@ test.describe('Coupons test', () => { cPage = await customerContext.newPage(); customer = new CouponsPage(cPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); [, , marketplaceCouponCode] = await apiUtils.createMarketPlaceCoupon(payloads.createMarketPlaceCoupon(), payloads.adminAuth); [, , couponCode] = await apiUtils.createCoupon([PRODUCT_ID], payloads.createCoupon(), payloads.vendorAuth); }); @@ -37,42 +37,47 @@ test.describe('Coupons test', () => { await aPage.close(); await vPage.close(); await cPage.close(); + await apiUtils.dispose(); }); - test('admin can add marketplace coupon @pro', async () => { + test.skip('admin can add marketplace coupon @pro @a', async () => { await admin.addMarketplaceCoupon({ ...data.coupon, title: data.coupon.couponTitle() }); }); - test('vendor coupon menu page is rendering properly @pro @explo', async () => { + //vendor + + test('vendor coupon menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorCouponsRenderProperly(); }); - test('vendor can view marketPlace coupon @pro @explo', async () => { + test('vendor can view marketPlace coupon @pro @exp @v', async () => { await vendor.viewMarketPlaceCoupon(marketplaceCouponCode); }); - test('vendor can add coupon @pro', async () => { + test('vendor can add coupon @pro @v', async () => { await vendor.addCoupon({ ...data.coupon, title: data.coupon.couponTitle() }); }); - test('vendor can edit coupon @pro', async () => { + test('vendor can edit coupon @pro @v', async () => { await vendor.editCoupon({ ...data.coupon, title: couponCode }); }); - test('vendor can delete coupon @pro', async () => { + test('vendor can delete coupon @pro @v', async () => { const [, , couponCode] = await apiUtils.createCoupon([PRODUCT_ID], payloads.createCoupon(), payloads.vendorAuth); await vendor.deleteCoupon(couponCode); }); - test('customer can view coupon on single store @pro', async () => { + //customer + + test('customer can view coupon on single store @pro @c', async () => { await customer.viewStoreCoupon(data.predefined.vendorStores.vendor1, couponCode); }); - test('customer can apply coupon @pro', async () => { + test('customer can apply coupon @pro @c', async () => { await customer.applyCoupon(data.predefined.simpleProduct.product1.name, data.predefined.coupon.couponCode); }); - test('customer can buy product with coupon @pro', async () => { + test('customer can buy product with coupon @pro @c', async () => { await customer.buyProductWithCoupon(data.predefined.simpleProduct.product1.name, data.predefined.coupon.couponCode); }); }); diff --git a/tests/pw/tests/e2e/customer.spec.ts b/tests/pw/tests/e2e/customer.spec.ts index b35f563415..12492320a1 100644 --- a/tests/pw/tests/e2e/customer.spec.ts +++ b/tests/pw/tests/e2e/customer.spec.ts @@ -1,94 +1,73 @@ import { test, Page, BrowserContext } from '@playwright/test'; import { LoginPage } from '@pages/loginPage'; import { CustomerPage } from '@pages/customerPage'; -// import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; -// import { payloads } from '@utils/payloads'; -test.describe('Customer user functionality test', () => { - test.use({ storageState: { cookies: [], origins: [] } }); - - let loginPage: LoginPage; +test.describe('Customer functionality test', () => { let customer: CustomerPage; - let page: Page; + let cPage: Page; + let customerContext: BrowserContext; test.beforeAll(async ({ browser }) => { - const context = await browser.newContext(); - page = await context.newPage(); - loginPage = new LoginPage(page); - customer = new CustomerPage(page); + customerContext = await browser.newContext(data.auth.customerAuth); + cPage = await customerContext.newPage(); + customer = new CustomerPage(cPage); }); test.afterAll(async () => { - await page.close(); + await cPage.close(); }); - test('customer can register @lite', async () => { + test('customer can register @lite @c', async ({ page }) => { + const customer = new CustomerPage(page); await customer.customerRegister(data.customer.customerInfo); }); - test('customer can login @lite', async () => { + test('customer can login @lite @c', async ({ page }) => { + const loginPage = new LoginPage(page); await loginPage.login(data.customer); }); - test('customer can logout @lite', async () => { + test('customer can logout @lite @c', async ({ page }) => { + const loginPage = new LoginPage(page); await loginPage.login(data.customer); await loginPage.logout(); }); - test('customer can become a vendor @lite', async () => { + test('customer can become a vendor @lite @c', async ({ page }) => { + const customer = new CustomerPage(page); await customer.customerRegister(data.customer.customerInfo); await customer.customerBecomeVendor(data.customer.customerInfo); }); -}); - -test.describe('Customer functionality test', () => { - let customer: CustomerPage; - let cPage: Page; - let customerContext: BrowserContext; - // let apiUtils: ApiUtils; - - test.beforeAll(async ({ browser }) => { - customerContext = await browser.newContext(data.auth.customerAuth); - cPage = await customerContext.newPage(); - customer = new CustomerPage(cPage); - // apiUtils = new ApiUtils(request); - }); - - test.afterAll(async () => { - await cPage.close(); - }); - test('customer can add billing details @lite', async () => { + test('customer can add billing details @lite @c', async () => { await customer.addBillingAddress(data.customer.customerInfo.billing); }); - test('customer can add shipping details @lite', async () => { + test('customer can add shipping details @lite @c', async () => { await customer.addShippingAddress(data.customer.customerInfo.shipping); }); - test('customer can add customer details @lite', async () => { + test('customer can add customer details @lite @c', async () => { await customer.addCustomerDetails(data.customer); }); - test('customer can add product to cart @lite', async () => { + test('customer can add product to cart @lite @c', async () => { const productName = data.predefined.simpleProduct.product1.name; await customer.addProductToCart(productName, 'single-product'); await customer.productIsOnCart(productName); }); - test('customer can buy product @lite', async () => { + test('customer can buy product @lite @c', async () => { await customer.addProductToCart(data.predefined.simpleProduct.product1.name, 'single-product'); await customer.placeOrder(); }); - test('customer can buy multi vendor products @lite', async () => { + test('customer can buy multi-vendor products @lite @c', async () => { await customer.addProductToCart(data.predefined.simpleProduct.product1.name, 'single-product'); await customer.addProductToCart(data.predefined.vendor2.simpleProduct.product1.name, 'single-product', false); await customer.placeOrder(); }); - // test.skip('customer can download downloadables @lite', async ( ) => { - // pre: complete download product - // }); + // todo: customer can download downloadable product }); diff --git a/tests/pw/tests/e2e/emailVerification.spec.ts b/tests/pw/tests/e2e/emailVerification.spec.ts index 69193e7815..9aeb7685ff 100644 --- a/tests/pw/tests/e2e/emailVerification.spec.ts +++ b/tests/pw/tests/e2e/emailVerification.spec.ts @@ -4,29 +4,29 @@ import { data } from '@utils/testData'; import { dbUtils } from '@utils/dbUtils'; import { dbData } from '@utils/dbData'; -test.describe('Email verifications test', () => { +test.describe.skip('Email verifications test', () => { let guest: EmailVerificationsPage; - let uPage: Page; + let gPage: Page; const user = { username: data.user.username() + data.user.userDetails.emailDomain, password: data.user.password }; test.beforeAll(async ({ browser }) => { const guestContext = await browser.newContext(data.auth.noAuth); - uPage = await guestContext.newPage(); - guest = new EmailVerificationsPage(uPage); + gPage = await guestContext.newPage(); + guest = new EmailVerificationsPage(gPage); await dbUtils.setDokanSettings(dbData.dokan.optionName.emailVerification, { ...dbData.dokan.emailVerificationSettings, enabled: 'on' }); }); test.afterAll(async () => { await dbUtils.setDokanSettings(dbData.dokan.optionName.emailVerification, dbData.dokan.emailVerificationSettings); - await uPage.close(); + await gPage.close(); }); - test('user can see registration notice (2-step authentication) while registering as customer @pro', async () => { + test('user can see registration notice (2-step auth) while registering as customer @pro @g', async () => { await guest.register(user); }); - test('user can see registration notice (2-step authentication) while loggingIn @pro', async () => { + test('user can see registration notice (2-step auth) while loggingIn @pro @g', async () => { await guest.login(user); }); }); diff --git a/tests/pw/tests/e2e/followStore.spec.ts b/tests/pw/tests/e2e/followStore.spec.ts index 14a24cc5dd..14ab6a48bf 100644 --- a/tests/pw/tests/e2e/followStore.spec.ts +++ b/tests/pw/tests/e2e/followStore.spec.ts @@ -1,14 +1,16 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { FollowStorePage } from '@pages/followStorePage'; -// import { ApiUtils } from '@utils/apiUtils'; +import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; -// import { payloads } from '@utils/payloads'; +import { payloads } from '@utils/payloads'; + +const { VENDOR_ID } = process.env; test.describe('Follow stores functionality test', () => { let vendor: FollowStorePage; let customer: FollowStorePage; let vPage: Page, cPage: Page; - // let apiUtils: ApiUtils; + let apiUtils: ApiUtils; test.beforeAll(async ({ browser }) => { const vendorContext = await browser.newContext(data.auth.vendorAuth); @@ -19,34 +21,39 @@ test.describe('Follow stores functionality test', () => { cPage = await customerContext.newPage(); customer = new FollowStorePage(cPage); - // apiUtils = new ApiUtils(request); - // todo: need followers + apiUtils = new ApiUtils(await request.newContext()); + await apiUtils.followUnfollowStore(VENDOR_ID, payloads.customerAuth); }); test.afterAll(async () => { await vPage.close(); await cPage.close(); + await apiUtils.dispose(); }); // follow store - test('customer followed vendors menu page is rendering properly @pro @explo', async () => { + // customer + + test('customer followed vendors menu page is rendering properly @pro @exp @c', async () => { await customer.customerFollowedVendorsRenderProperly(); }); - test('customer can follow store on store listing @pro', async () => { + test('customer can follow store on store listing @pro @c', async () => { await customer.followStore(data.predefined.vendorStores.vendor1, data.predefined.vendorStores.followFromStoreListing); }); - test('customer can follow store on single store @pro', async () => { + test('customer can follow store on single store @pro @c', async () => { await customer.followStore(data.predefined.vendorStores.vendor1, data.predefined.vendorStores.followFromSingleStore); }); - test('vendor followers menu page is rendering properly @pro @explo', async () => { + //vendor + + test('vendor followers menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorFollowersRenderProperly(); }); - test('vendor can view followers @pro', async () => { + test('vendor can view followers @pro @v', async () => { await vendor.vendorViewFollowers(); }); }); diff --git a/tests/pw/tests/e2e/help.spec.ts b/tests/pw/tests/e2e/help.spec.ts index 87245030af..35508c5004 100644 --- a/tests/pw/tests/e2e/help.spec.ts +++ b/tests/pw/tests/e2e/help.spec.ts @@ -16,11 +16,11 @@ test.describe('Dokan help test', () => { await aPage.close(); }); - test('dokan help menu page is rendering properly @lite @explo', async () => { + test('dokan help menu page is rendering properly @lite @exp @a', async () => { await admin.adminHelpRenderProperly(); }); - test('dokan get help dropdown is rendering properly @lite @explo', async () => { + test('dokan get help dropdown is rendering properly @lite @exp @a', async () => { await admin.adminGetHelpDropdownRenderProperly(); }); }); diff --git a/tests/pw/tests/e2e/license.spec.ts b/tests/pw/tests/e2e/license.spec.ts index b4a155e94d..8b0a3695f5 100644 --- a/tests/pw/tests/e2e/license.spec.ts +++ b/tests/pw/tests/e2e/license.spec.ts @@ -13,22 +13,23 @@ test.describe('License test', () => { }); test.afterAll(async () => { + await admin.activateLicense(data.dokanLicense.correctKey); await aPage.close(); }); - test('dokan license menu page is rendering properly @pro @explo', async () => { + test('dokan license menu page is rendering properly @pro @exp @a', async () => { await admin.adminLicenseRenderProperly(); }); - test("admin can't activate license with incorrect key @pro @neg", async () => { + test("admin can't activate license with incorrect key @pro @a @neg", async () => { await admin.activateLicense(data.dokanLicense.incorrectKey, 'incorrect'); }); - test('admin can activate license @pro', async () => { + test('admin can activate license @pro @a', async () => { await admin.activateLicense(data.dokanLicense.correctKey); }); - test('admin can deactivate license @pro', async () => { + test('admin can deactivate license @pro @a', async () => { await admin.activateLicense(data.dokanLicense.correctKey); await admin.deactivateLicense(); }); diff --git a/tests/pw/tests/e2e/modules.spec.ts b/tests/pw/tests/e2e/modules.spec.ts index 3408b233b8..61e78f1308 100644 --- a/tests/pw/tests/e2e/modules.spec.ts +++ b/tests/pw/tests/e2e/modules.spec.ts @@ -1,46 +1,53 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { ModulesPage } from '@pages/modulesPage'; +import { ApiUtils } from '@utils/apiUtils'; +import { payloads } from '@utils/payloads'; import { data } from '@utils/testData'; test.describe('Modules test', () => { let admin: ModulesPage; let aPage: Page; + let apiUtils: ApiUtils; test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new ModulesPage(aPage); + + apiUtils = new ApiUtils(await request.newContext()); }); test.afterAll(async () => { await aPage.close(); + await apiUtils.dispose(); }); - test('dokan modules menu page is rendering properly @pro @explo', async () => { + test('dokan modules menu page is rendering properly @pro @exp @a', async () => { await admin.adminModulesRenderProperly(); }); - test('admin can search module @pro', async () => { + test('admin can search module @pro @a', async () => { await admin.searchModule(data.modules.modulesName.AuctionIntegration); }); - test('admin can filter modules by category @pro', async () => { + test('admin can filter modules by category @pro @a', async () => { await admin.filterModules(data.modules.moduleCategory.productManagement); }); - test('admin can deactivate module @pro', async () => { + test('admin can deactivate module @pro @a', async () => { await admin.activateDeactivateModule(data.modules.modulesName.AuctionIntegration); }); - test('admin can activate module @pro', async () => { + test('admin can activate module @pro @a', async () => { + await apiUtils.deactivateModules([payloads.moduleIds.auction], payloads.adminAuth); await admin.activateDeactivateModule(data.modules.modulesName.AuctionIntegration); }); - test('admin can perform module bulk action @pro', async () => { + test('admin can perform module bulk action @pro @a', async () => { await admin.moduleBulkAction('activate'); }); - test('admin can change module view layout @pro', async () => { + test('admin can change module view layout @pro @a', async () => { await admin.moduleViewLayout(data.modules.layout.list); }); }); diff --git a/tests/pw/tests/e2e/myOrders.spec.ts b/tests/pw/tests/e2e/myOrders.spec.ts index bc54afed3c..0ac4b510bf 100644 --- a/tests/pw/tests/e2e/myOrders.spec.ts +++ b/tests/pw/tests/e2e/myOrders.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { MyOrdersPage } from '@pages/myOrdersPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; @@ -11,43 +11,44 @@ test.describe('My orders functionality test', () => { let cPage: Page; let apiUtils: ApiUtils; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const customerContext = await browser.newContext(data.auth.customerAuth); cPage = await customerContext.newPage(); customer = new MyOrdersPage(cPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); }); test.afterAll(async () => { await cPage.close(); + await apiUtils.dispose(); }); - test('customer my orders page is rendering properly @lite', async () => { + test('customer my orders page is rendering properly @lite @c', async () => { await customer.myOrdersRenderProperly(); }); - test('customer can view order details @lite', async () => { + test('customer can view order details @lite @c', async () => { const [, , orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, { ...payloads.createOrder, customer_id: CUSTOMER_ID }, data.order.orderStatus.completed, payloads.vendorAuth); await customer.viewOrderDetails(orderId); }); - test('customer can view order note @lite', async () => { + test('customer can view order note @lite @c', async () => { const orderNote = data.orderNote.note(); const [, orderId] = await apiUtils.createOrderNote(PRODUCT_ID, { ...payloads.createOrder, customer_id: CUSTOMER_ID }, { ...payloads.createOrderNoteForCustomer, note: orderNote }, payloads.vendorAuth); await customer.viewOrderNote(orderId, orderNote); }); - test('customer can pay pending payment order @lite', async () => { + test('customer can pay pending payment order @lite @c', async () => { const [, , orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, { ...payloads.createOrder, customer_id: CUSTOMER_ID }, data.order.orderStatus.pending, payloads.vendorAuth); await customer.payPendingOrder(orderId, 'bank'); }); - test('customer can cancel order @lite', async () => { + test('customer can cancel order @lite @c', async () => { const [, , orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, { ...payloads.createOrder, customer_id: CUSTOMER_ID }, data.order.orderStatus.pending, payloads.vendorAuth); await customer.cancelPendingOrder(orderId); }); - test.skip('customer can order again @lite', async () => { + test.skip('customer can order again @lite @c', async () => { const [, , orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, { ...payloads.createOrder, customer_id: CUSTOMER_ID }, data.order.orderStatus.completed, payloads.vendorAuth); await customer.orderAgain(orderId); }); diff --git a/tests/pw/tests/e2e/noticeAndPromotion.spec.ts b/tests/pw/tests/e2e/noticeAndPromotion.spec.ts new file mode 100644 index 0000000000..e2b4fa4ae5 --- /dev/null +++ b/tests/pw/tests/e2e/noticeAndPromotion.spec.ts @@ -0,0 +1,30 @@ +import { test, Page } from '@playwright/test'; +import { NoticeAndPromotionPage } from '@pages/noticeAndPromotionPage'; +import { data } from '@utils/testData'; + +test.describe('Dokan pro feature promo test', () => { + let admin: NoticeAndPromotionPage; + let aPage: Page; + + test.beforeAll(async ({ browser }) => { + const adminContext = await browser.newContext(data.auth.adminAuth); + aPage = await adminContext.newPage(); + admin = new NoticeAndPromotionPage(aPage); + }); + + test.afterAll(async () => { + await aPage.close(); + }); + + test('dokan notice is rendering properly @lite @exp @a', async () => { + await admin.dokanNoticeRenderProperly(); + }); + + test('dokan promotion is rendering properly @lite @exp @a', async () => { + await admin.dokanPromotionRenderProperly(); + }); + + test('dokan pro features promotions are rendering properly @liteOnly @exp @a', async () => { + await admin.dokanProPromotionRenderProperly(); + }); +}); diff --git a/tests/pw/tests/e2e/orders.spec.ts b/tests/pw/tests/e2e/orders.spec.ts index ba6d0d4552..0b54d49082 100644 --- a/tests/pw/tests/e2e/orders.spec.ts +++ b/tests/pw/tests/e2e/orders.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { OrdersPage } from '@pages/ordersPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; @@ -14,83 +14,85 @@ test.describe('Order functionality test', () => { let apiUtils: ApiUtils; let orderId: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const vendorContext = await browser.newContext(data.auth.vendorAuth); vPage = await vendorContext.newPage(); vendor = new OrdersPage(vPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); [, , orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, { ...payloads.createOrder, customer_id: CUSTOMER_ID }, data.order.orderStatus.onhold, payloads.vendorAuth); }); test.afterAll(async () => { await vPage.close(); + await apiUtils.dispose(); }); // orders - test('vendor order menu page is rendering properly @lite @explo', async () => { + test('vendor order menu page is rendering properly @lite @exp @v', async () => { await vendor.vendorOrdersRenderProperly(); }); - test('vendor can export all orders @lite', async () => { + test('vendor can export all orders @lite @v', async () => { await vendor.exportOrders('all'); }); - test('vendor can export filtered orders @lite', async () => { + test('vendor can export filtered orders @lite @v', async () => { await vendor.filterOrders('by-customer', data.customer.username); await vendor.exportOrders('filtered'); }); - test('vendor can search order @lite', async () => { + test('vendor can search order @lite @v', async () => { await vendor.searchOrder(orderId); }); - test('vendor can filter orders by customer @lite', async () => { + test('vendor can filter orders by customer @lite @v', async () => { await vendor.filterOrders('by-customer', data.customer.username); }); - test('vendor can filter orders by date range @lite', async () => { + test('vendor can filter orders by date range @lite @v', async () => { await vendor.filterOrders('by-date', data.date.dateRange); }); - test('vendor can view order details @lite', async () => { + test('vendor can view order details @lite @v', async () => { await vendor.viewOrderDetails(orderId); }); - test('vendor can update order status on table @lite', async () => { + test('vendor can update order status on order table @lite @v', async () => { await vendor.updateOrderStatusOnTable(orderId, data.order.orderStatus.processing); }); - test('vendor can update order status on order details @lite', async () => { + test('vendor can update order status on order details @lite @v', async () => { + [, , orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, { ...payloads.createOrder, customer_id: CUSTOMER_ID }, data.order.orderStatus.onhold, payloads.vendorAuth); await vendor.updateOrderStatus(orderId, data.order.orderStatus.completed); }); - test('vendor can add order note @lite', async () => { + test('vendor can add order note @lite @v', async () => { await vendor.addOrderNote(orderId, data.orderNote.customer); }); - test('vendor can add private order note @lite', async () => { + test('vendor can add private order note @lite @v', async () => { await vendor.addOrderNote(orderId, data.orderNote.private); }); - test('vendor can add tracking details to order @lite', async () => { + test('vendor can add tracking details to order @lite @v', async () => { DOKAN_PRO && (await dbUtils.setDokanSettings(dbData.dokan.optionName.shippingStatus, { ...dbData.dokan.shippingStatusSettings, enabled: 'off' })); await vendor.addTrackingDetails(orderId, data.orderTrackingDetails); DOKAN_PRO && (await dbUtils.setDokanSettings(dbData.dokan.optionName.shippingStatus, { ...dbData.dokan.shippingStatusSettings, enabled: 'on' })); }); - test('vendor can add shipment to order @pro', async () => { + test('vendor can add shipment to order @pro @v', async () => { await vendor.addShipment(orderId, data.orderShipmentDetails); }); - // test.skip('vendor can add downloadable product permission to order @lite', async ( ) => { - // const [,, downloadableProductName] = await apiUtils.createProduct(payloads.createDownloadableProduct(), payloads.vendorAuth); - // await vendor.addDownloadableProduct(orderId, downloadableProductName); - // await vendor.removeDownloadableProduct(orderId, downloadableProductName); - // }); + test.skip('vendor can add downloadable product permission to order @lite @v', async () => { + const [, , downloadableProductName] = await apiUtils.createProduct(payloads.createDownloadableProduct(), payloads.vendorAuth); + await vendor.addDownloadableProduct(orderId, downloadableProductName); + await vendor.removeDownloadableProduct(orderId, downloadableProductName); + }); - test('vendor can perform order bulk action @lite', async () => { + test('vendor can perform order bulk action @lite @v', async () => { await vendor.orderBulkAction('completed', orderId); }); }); diff --git a/tests/pw/tests/e2e/payments.spec.ts b/tests/pw/tests/e2e/payments.spec.ts index bc92c9a5e0..e2db7592dc 100644 --- a/tests/pw/tests/e2e/payments.spec.ts +++ b/tests/pw/tests/e2e/payments.spec.ts @@ -1,89 +1,98 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { PaymentsPage } from '@pages/paymentsPage'; -// import { ApiUtils } from '@utils/apiUtils'; +import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; +import { payloads } from '@utils/payloads'; test.describe('Payments test', () => { - // let admin: PaymentsPage; + let admin: PaymentsPage; let vendor: PaymentsPage; - // let aPage: Page, vPage: Page; - let vPage: Page; - // let apiUtils: ApiUtils; + let aPage: Page, vPage: Page; + let apiUtils: ApiUtils; test.beforeAll(async ({ browser }) => { - // const adminContext = await browser.newContext(data.auth.adminAuth); - // aPage = await adminContext.newPage(); - // admin = new PaymentsPage(aPage); + const adminContext = await browser.newContext(data.auth.adminAuth); + aPage = await adminContext.newPage(); + admin = new PaymentsPage(aPage); const vendorContext = await browser.newContext(data.auth.vendorAuth); vPage = await vendorContext.newPage(); vendor = new PaymentsPage(vPage); - // apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); }); test.afterAll(async () => { - // await aPage.close(); + await aPage.close(); await vPage.close(); + await apiUtils.dispose(); }); - // test('admin can add basic payment methods', async ( ) => { - // await adminPage.setupBasicPaymentMethods(data.payment) - // }) + //admin - // test('admin can add strip payment method', async ( ) => { - // await adminPage.setupStripeConnect(data.payment) - // }) + test.skip('admin can add basic payment methods @lite @a', async () => { + await admin.setupBasicPaymentMethods(data.payment); + }); + + test.skip('admin can add strip payment method @pro @a', async () => { + await admin.setupStripeConnect(data.payment); + }); + + test.skip('admin can add paypal marketplace payment method @pro @a', async () => { + await admin.setupPaypalMarketPlace(data.payment); + }); - // test('admin can add paypal marketplace payment method', async ( ) => { - // await adminPage.setupPaypalMarketPlace(data.payment) - // }) + test.skip('admin can add mangopay payment method @pro @a', async () => { + await admin.setupMangoPay(data.payment); + }); - // test('admin can add mangopay payment method', async ( ) => { - // await adminPage.setupMangoPay(data.payment) - // }) + test.skip('admin can add razorpay payment method @pro @a', async () => { + await admin.setupRazorpay(data.payment); + }); - // test('admin can add razorpay payment method', async ( ) => { - // await adminPage.setupRazorpay(data.payment) - // }) + test.skip('admin can add strip express payment method @pro @a', async () => { + await admin.setupStripeExpress(data.payment); + }); - // test('admin can add strip express payment method', async ( ) => { - // await adminPage.setupStripeExpress(data.payment) - // }) + //vendor - test('vendor payment menu is rendering properly @lite @explo', async () => { + test('vendor payment menu is rendering properly @lite @exp @v', async () => { await vendor.vendorPaymentSettingsRenderProperly(); }); - test('vendor can add paypal payment method @lite', async () => { + test('vendor can add paypal payment method @lite @v', async () => { await vendor.setBasicPayment({ ...data.vendor.payment, methodName: 'paypal' }); }); - test('vendor can add bank payment method @lite', async () => { + test('vendor can add bank payment method @lite @v', async () => { await vendor.setBankTransfer(data.vendor.payment); }); - test('vendor can add skrill payment method @pro', async () => { + test('vendor can add skrill payment method @pro @v', async () => { await vendor.setBasicPayment({ ...data.vendor.payment, methodName: 'skrill' }); }); - test('vendor can add custom payment method @pro', async () => { + test('vendor can add custom payment method @pro @v', async () => { await vendor.setBasicPayment({ ...data.vendor.payment, methodName: 'custom' }); }); - test('vendor can disconnect paypal payment method @lite', async () => { + test('vendor can disconnect paypal payment method @lite @v', async () => { await vendor.disconnectBasicPayment({ ...data.vendor.payment, methodName: 'paypal' }); + //reset + await apiUtils.setStoreSettings(payloads.defaultStoreSettings, payloads.vendorAuth); }); - test('vendor can disconnect bank payment method @lite', async () => { + test('vendor can disconnect bank payment method @lite @v', async () => { await vendor.disconnectBasicPayment({ ...data.vendor.payment, methodName: 'bank' }); + // reset + await apiUtils.setStoreSettings(payloads.defaultStoreSettings, payloads.vendorAuth); }); - test('vendor can disconnect skrill payment method @pro', async () => { + test('vendor can disconnect skrill payment method @pro @v', async () => { await vendor.disconnectBasicPayment({ ...data.vendor.payment, methodName: 'skrill' }); }); - test('vendor can disconnect custom payment method @pro', async () => { + test('vendor can disconnect custom payment method @pro @v', async () => { await vendor.disconnectBasicPayment({ ...data.vendor.payment, methodName: 'custom' }); }); }); diff --git a/tests/pw/tests/e2e/plugin.spec.ts b/tests/pw/tests/e2e/plugin.spec.ts index 863b45a815..c6ac4f8b11 100644 --- a/tests/pw/tests/e2e/plugin.spec.ts +++ b/tests/pw/tests/e2e/plugin.spec.ts @@ -1,63 +1,64 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { PluginPage } from '@pages/pluginPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; import { payloads } from '@utils/payloads'; test.describe.skip('Plugin functionality test', () => { - let pluginPage: PluginPage; + let admin: PluginPage; let aPage: Page; let apiUtils: ApiUtils; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); - pluginPage = new PluginPage(aPage); + admin = new PluginPage(aPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); }); test.afterAll(async () => { await aPage.close(); + await apiUtils.dispose(); }); //todo: install plugin - test('Activate dokan lite plugin @lite', async () => { + test('activate dokan lite plugin @lite @a', async () => { await apiUtils.updatePlugin('dokan/dokan', { status: 'inactive' }, payloads.adminAuth); - await pluginPage.activatePlugin(data.plugin.pluginName.dokanlite); + await admin.activatePlugin(data.plugin.pluginName.dokanLite); }); - test('Deactivate dokan lite plugin @lite', async () => { + test('deactivate dokan lite plugin @lite @a', async () => { await apiUtils.updatePlugin('dokan/dokan', { status: 'active' }, payloads.adminAuth); - await pluginPage.deactivateDokanPlugin(data.plugin.pluginName.dokanlite, false); + await admin.deactivateDokanPlugin(data.plugin.pluginName.dokanLite, false); }); - test('Deactivate dokan lite plugin with deactivate reason @lite', async () => { + test('deactivate dokan lite plugin with deactivate reason @lite @a', async () => { await apiUtils.updatePlugin('dokan/dokan', { status: 'active' }, payloads.adminAuth); - await pluginPage.deactivateDokanPlugin(data.plugin.pluginName.dokanlite, true); + await admin.deactivateDokanPlugin(data.plugin.pluginName.dokanLite, true); }); - test('Activate dokan pro plugin @pro', async () => { + test('activate dokan pro plugin @pro @a', async () => { await apiUtils.updatePlugin('dokan-pro/dokan-pro', { status: 'inactive' }, payloads.adminAuth); - await pluginPage.activatePlugin(data.plugin.pluginName.dokanPro); + await admin.activatePlugin(data.plugin.pluginName.dokanPro); }); - test('Deactivate dokan pro plugin @pro', async () => { + test('deactivate dokan pro plugin @pro @a', async () => { await apiUtils.updatePlugin('dokan-pro/dokan-pro', { status: 'active' }, payloads.adminAuth); - await pluginPage.deactivateDokanPlugin(data.plugin.pluginName.dokanPro, false); + await admin.deactivateDokanPlugin(data.plugin.pluginName.dokanPro, false); }); - test('Deactivate dokan pro plugin with deactivate reason @pro', async () => { + test('deactivate dokan pro plugin with deactivate reason @pro @a', async () => { await apiUtils.updatePlugin('dokan-pro/dokan-pro', { status: 'active' }, payloads.adminAuth); - await pluginPage.deactivateDokanPlugin(data.plugin.pluginName.dokanPro, true); + await admin.deactivateDokanPlugin(data.plugin.pluginName.dokanPro, true); }); - // test('Delete dokan lite plugin @lite', async ( ) => { - // await pluginPage.activatePlugin(data.plugin.dokanLite); - // }); + test('delete dokan lite plugin @lite @a', async () => { + await admin.activatePlugin(data.plugin.pluginName.dokanLite); + }); - // test('Delete dokan pro plugin @pro', async ( ) => { - // await pluginPage.activatePlugin(data.plugin.dokanLite); - // }); + test('delete dokan pro plugin @pro @a', async () => { + await admin.activatePlugin(data.plugin.pluginName.dokanLite); + }); }); diff --git a/tests/pw/tests/e2e/privacyPolicy.spec.ts b/tests/pw/tests/e2e/privacyPolicy.spec.ts index 17c565d152..c71a966e10 100644 --- a/tests/pw/tests/e2e/privacyPolicy.spec.ts +++ b/tests/pw/tests/e2e/privacyPolicy.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { PrivacyPolicy } from '@pages/privacyPolicyPage'; import { CustomerPage } from '@pages/customerPage'; import { ApiUtils } from '@utils/apiUtils'; @@ -13,13 +13,13 @@ test.describe.skip('Privacy Policy & Store Contact form test', () => { let apiUtils: ApiUtils; let privacyPolicySettings: object; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const customerContext = await browser.newContext(data.auth.customerAuth); cPage = await customerContext.newPage(); customerPage = new CustomerPage(cPage); customer = new PrivacyPolicy(cPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); privacyPolicySettings = await dbUtils.getDokanSettings(dbData.dokan.optionName.privacyPolicy); }); @@ -27,22 +27,23 @@ test.describe.skip('Privacy Policy & Store Contact form test', () => { await dbUtils.setDokanSettings(dbData.dokan.optionName.privacyPolicy, { ...privacyPolicySettings, enable_privacy: 'on' }); await dbUtils.setDokanSettings(dbData.dokan.optionName.appearance, dbData.dokan.appearanceSettings); await cPage.close(); + await apiUtils.dispose(); }); - test('customer can contact vendor @lite', async () => { + test('customer can contact vendor @lite @c', async () => { await customer.contactVendor(data.predefined.vendorStores.vendor1, data.storeContactData); }); - test('customer can navigate to dokan privacy policy @lite', async () => { + test('customer can navigate to dokan privacy policy @lite @c', async () => { await customer.goToPrivacyPolicy(data.predefined.vendorStores.vendor1); }); - test('privacy policy is disabled on store contact form @lite', async () => { + test('privacy policy is disabled on store contact form @lite @c', async () => { await dbUtils.setDokanSettings(dbData.dokan.optionName.privacyPolicy, { ...privacyPolicySettings, enable_privacy: 'off' }); await customer.disablePrivacyPolicy(data.predefined.vendorStores.vendor1); }); - test('store contact form is disabled on store sidebar @lite', async () => { + test('store contact form is disabled on store sidebar @lite @c', async () => { await dbUtils.setDokanSettings(dbData.dokan.optionName.appearance, { ...dbData.dokan.appearanceSettings, contact_seller: 'off' }); await customer.disableStoreContactForm(data.predefined.vendorStores.vendor1); }); diff --git a/tests/pw/tests/e2e/proPromo.spec.ts b/tests/pw/tests/e2e/proPromo.spec.ts deleted file mode 100644 index 7c079c692f..0000000000 --- a/tests/pw/tests/e2e/proPromo.spec.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { test, Page } from '@playwright/test'; -import { ProPromoPage } from '@pages/proPromoPage'; -import { ApiUtils } from '@utils/apiUtils'; -import { data } from '@utils/testData'; -// import { payloads } from '@utils/payloads'; - -test.describe('Dokan pro feature promo test', () => { - let admin: ProPromoPage; - let aPage: Page; - let apiUtils: ApiUtils; - - test.beforeAll(async ({ browser, request }) => { - const adminContext = await browser.newContext(data.auth.adminAuth); - aPage = await adminContext.newPage(); - admin = new ProPromoPage(aPage); - - apiUtils = new ApiUtils(request); - }); - - test.afterAll(async () => { - await aPage.close(); - }); - - test('dokan pro features promo @liteOnly', async () => { - // await apiUtils.updatePlugin('dokan-pro/dokan-pro', { status:'inactive' }, payloads.adminAuth); - await admin.dokanProPromo(); - // await apiUtils.updatePlugin('dokan-pro/dokan-pro', { status:'active' }, payloads.adminAuth); - }); -}); diff --git a/tests/pw/tests/e2e/productAddons.spec.ts b/tests/pw/tests/e2e/productAddons.spec.ts index aceb86b332..80b51ccf22 100644 --- a/tests/pw/tests/e2e/productAddons.spec.ts +++ b/tests/pw/tests/e2e/productAddons.spec.ts @@ -1,40 +1,56 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { ProductAddonsPage } from '@pages/productAddonsPage'; +import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; +import { payloads } from '@utils/payloads'; +import { dbUtils } from '@utils/dbUtils'; + +const { VENDOR_ID } = process.env; test.describe('Product addon functionality test', () => { let vendor: ProductAddonsPage; let vPage: Page; let addonName: string; let addonFieldTitle: string; + let categoryName: string; + let apiUtils: ApiUtils; + + async function createVendorProductAddon(): Promise<[string, string, string, string]> { + const [, categoryId, categoryName] = await apiUtils.createCategory(payloads.createCategoryRandom(), payloads.adminAuth); + const [, addonId, addonName, addonFieldTitle] = await apiUtils.createProductAddon({ ...payloads.createProductAddons(), restrict_to_categories: [categoryId] }, payloads.adminAuth); + await dbUtils.updateCell(addonId, VENDOR_ID); + return [addonId, addonName, addonFieldTitle, categoryName]; + } test.beforeAll(async ({ browser }) => { const vendorContext = await browser.newContext(data.auth.vendorAuth); vPage = await vendorContext.newPage(); vendor = new ProductAddonsPage(vPage); - addonName = data.vendor.addon.randomName(); - addonFieldTitle = data.vendor.addon.randomTitle(); - await vendor.addAddon({ ...data.vendor.addon, name: addonName, titleRequired: addonFieldTitle }); + apiUtils = new ApiUtils(await request.newContext()); + [, addonName, addonFieldTitle, categoryName] = await createVendorProductAddon(); }); test.afterAll(async () => { + await apiUtils.deleteAllProductAddons(payloads.adminAuth); await vPage.close(); + await apiUtils.dispose(); }); - test('vendor product addons menu page is rendering properly @pro @explo', async () => { + test('vendor product addons menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorProductAddonsSettingsRenderProperly(); }); - test('vendor can add addons @pro', async () => { - await vendor.addAddon({ ...data.vendor.addon, name: data.vendor.addon.randomName() }); + test('vendor can add addons @pro @v', async () => { + await vendor.addAddon({ ...data.vendor.addon(), category: categoryName }); }); - test('vendor can edit addon @pro', async () => { - await vendor.editAddon({ ...data.vendor.addon, name: addonName, titleRequired: addonFieldTitle }); + test('vendor can edit addon @pro @v', async () => { + await vendor.editAddon({ ...data.vendor.addon(), name: addonName, title: addonFieldTitle }); }); - test('vendor can delete addon @pro', async () => { - await vendor.deleteAddon({ ...data.vendor.addon, name: addonName }); + test('vendor can delete addon @pro @v', async () => { + const [, addonName] = await createVendorProductAddon(); + await vendor.deleteAddon({ ...data.vendor.addon(), name: addonName }); }); }); diff --git a/tests/pw/tests/e2e/productAdvertising.spec.ts b/tests/pw/tests/e2e/productAdvertising.spec.ts index ffb7f81bf4..71b05540c7 100644 --- a/tests/pw/tests/e2e/productAdvertising.spec.ts +++ b/tests/pw/tests/e2e/productAdvertising.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { ProductAdvertisingPage } from '@pages/productAdvertisingPage'; import { VendorPage } from '@pages/vendorPage'; import { ApiUtils } from '@utils/apiUtils'; @@ -11,8 +11,9 @@ test.describe('Product Advertising test', () => { let aPage: Page, vPage: Page; let apiUtils: ApiUtils; let productName: string; + let advertisedProduct: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new ProductAdvertisingPage(aPage); @@ -21,61 +22,71 @@ test.describe('Product Advertising test', () => { vPage = await vendorContext.newPage(); vendor = new VendorPage(vPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); [, , productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth); - await apiUtils.createProductAdvertisement(payloads.createProduct(), payloads.vendorAuth); + [, , advertisedProduct] = await apiUtils.createProductAdvertisement(payloads.createProduct(), payloads.vendorAuth); }); test.afterAll(async () => { await aPage.close(); await vPage.close(); + await apiUtils.dispose(); }); - test('dokan product advertising menu page is rendering properly @pro @explo', async () => { + //admin + + test('dokan product advertising menu page is rendering properly @pro @exp', async () => { await admin.adminProductAdvertisingRenderProperly(); }); - test('admin can add product advertisement @pro', async () => { + test('admin can add product advertisement @pro @a', async () => { await admin.addNewProductAdvertisement({ ...data.productAdvertisement, advertisedProduct: productName }); }); - test('admin can search advertised product @pro', async () => { - await admin.searchAdvertisedProduct(productName); + test('admin can search advertised product @pro @a', async () => { + await admin.searchAdvertisedProduct(advertisedProduct); }); - test('admin can filter advertised product by stores @pro', async () => { + test('admin can filter advertised product by stores @pro @a', async () => { await admin.filterAdvertisedProduct(data.productAdvertisement.filter.byStore, 'by-store'); }); - test('admin can filter advertised product by creation process @pro', async () => { + test('admin can filter advertised product by creation process @pro @a', async () => { await admin.filterAdvertisedProduct(data.productAdvertisement.filter.createVia.admin, 'by-creation'); }); - test('admin can expire advertised product @pro', async () => { + test('admin can expire advertised product @pro @a', async () => { await admin.updateAdvertisedProduct(productName, 'expire'); }); - test('admin can delete advertised product @pro', async () => { - await admin.updateAdvertisedProduct(productName, 'delete'); + test('admin can delete advertised product @pro @a', async () => { + const [, , advertisedProduct] = await apiUtils.createProductAdvertisement(payloads.createProduct(), payloads.vendorAuth); + await admin.updateAdvertisedProduct(advertisedProduct, 'delete'); }); - test('admin can perform product advertising bulk action @pro', async () => { - // await apiUtils.createProductAdvertisement(payloads.createProduct(), payloads.vendorAuth); + test.skip('admin can perform product advertising bulk action @pro @a', async () => { + // todo: might cause other tests to fail in parallel await admin.productAdvertisingBulkAction('delete'); }); - test('vendor can buy product advertising @pro', async () => { - const orderId = await vendor.buyProductAdvertising(data.productAdvertisement.advertisedProduct); + // vendor + + test.skip('vendor can buy product advertising @pro @v', async () => { + //todo: p1_v1 status gets pending review; need to resolve + const [, , productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth); + const orderId = await vendor.buyProductAdvertising(productName); await apiUtils.updateOrderStatus(orderId, 'wc-completed', payloads.adminAuth); }); - // test('vendor can buy booking product advertising @pro', async ( ) => { // todo: - // const orderId = await vendor.buyProductAdvertising(data.productAdvertisement.advertisedProduct); - // await apiUtils.updateOrderStatus(orderId, 'wc-completed', payloads.adminAuth); - // }); + test.skip('vendor can buy booking product advertising @pro @v', async () => { + // todo: create booking product via api + const orderId = await vendor.buyProductAdvertising(data.productAdvertisement.advertisedProduct); + await apiUtils.updateOrderStatus(orderId, 'wc-completed', payloads.adminAuth); + }); - // test('vendor can buy auction product advertising @pro', async ( ) => { // todo: - // const orderId = await vendor.buyProductAdvertising(data.productAdvertisement.advertisedProduct); - // await apiUtils.updateOrderStatus(orderId, 'wc-completed', payloads.adminAuth); - // }); + test.skip('vendor can buy auction product advertising @pro @v', async () => { + // todo: create auction product via api + const orderId = await vendor.buyProductAdvertising(data.productAdvertisement.advertisedProduct); + await apiUtils.updateOrderStatus(orderId, 'wc-completed', payloads.adminAuth); + }); }); diff --git a/tests/pw/tests/e2e/productEnquiry.spec.ts b/tests/pw/tests/e2e/productEnquiry.spec.ts index f494585c12..73cfaaddbc 100644 --- a/tests/pw/tests/e2e/productEnquiry.spec.ts +++ b/tests/pw/tests/e2e/productEnquiry.spec.ts @@ -1,48 +1,40 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { ProductEnquiryPage } from '@pages/productEnquiryPage'; import { ApiUtils } from '@utils/apiUtils'; import { dbUtils } from '@utils/dbUtils'; import { data } from '@utils/testData'; import { dbData } from '@utils/dbData'; -import { payloads } from '@utils/payloads'; +// import { payloads } from '@utils/payloads'; -const { VENDOR_ID, CUSTOMER_ID } = process.env; +const { VENDOR_ID, CUSTOMER_ID, PRODUCT_ID } = process.env; test.describe('Product Enquiry test', () => { - // let admin: ProductEnquiryPage; let customer: ProductEnquiryPage; let guest: ProductEnquiryPage; - let cPage: Page, uPage: Page; + let cPage: Page; let apiUtils: ApiUtils; - test.beforeAll(async ({ browser, request }) => { - // const adminContext = await browser.newContext(data.auth.adminAuth); - // aPage = await adminContext.newPage(); - // admin = new ProductEnquiryPage(aPage); - + test.beforeAll(async ({ browser }) => { const customerContext = await browser.newContext(data.auth.customerAuth); cPage = await customerContext.newPage(); customer = new ProductEnquiryPage(cPage); - const guestContext = await browser.newContext(data.auth.noAuth); - uPage = await guestContext.newPage(); - guest = new ProductEnquiryPage(uPage); - - apiUtils = new ApiUtils(request); - const productId = await apiUtils.getProductId(data.predefined.simpleProduct.product1.name, payloads.vendorAuth); - await dbUtils.createAbuseReport(dbData.dokan.createAbuseReport, productId, VENDOR_ID, CUSTOMER_ID); + apiUtils = new ApiUtils(await request.newContext()); + // const productId = await apiUtils.getProductId(data.predefined.simpleProduct.product1.name, payloads.vendorAuth); //todo: might not needed + await dbUtils.createAbuseReport(dbData.dokan.createAbuseReport, PRODUCT_ID, VENDOR_ID, CUSTOMER_ID); }); test.afterAll(async () => { await cPage.close(); - await uPage.close(); + await apiUtils.dispose(); }); - test('customer can enquire product @pro', async () => { + test('customer can enquire product @pro @c', async () => { await customer.enquireProduct(data.predefined.simpleProduct.product1.name, data.product.enquiry); }); - test('guest customer can enquire product @pro', async () => { + test('guest customer can enquire product @pro @g', async ({ page }) => { + guest = new ProductEnquiryPage(page); await guest.enquireProduct(data.predefined.simpleProduct.product1.name, data.product.enquiry); }); }); diff --git a/tests/pw/tests/e2e/productQA.spec.ts b/tests/pw/tests/e2e/productQA.spec.ts new file mode 100644 index 0000000000..fb715b7bb6 --- /dev/null +++ b/tests/pw/tests/e2e/productQA.spec.ts @@ -0,0 +1,159 @@ +import { test, request, Page } from '@playwright/test'; +import { ProductQAPage } from '@pages/productQAPage'; +import { ApiUtils } from '@utils/apiUtils'; +import { data } from '@utils/testData'; +import { payloads } from '@utils/payloads'; + +const { PRODUCT_ID } = process.env; + +test.describe('Product QA functionality test', () => { + test.skip(true, 'feature is not merged yet'); + let admin: ProductQAPage; + let vendor: ProductQAPage; + let customer: ProductQAPage; + let guest: ProductQAPage; + let aPage: Page, vPage: Page, cPage: Page; + let apiUtils: ApiUtils; + let questionId: string; + let answerId: string; + + test.beforeAll(async ({ browser }) => { + const adminContext = await browser.newContext(data.auth.adminAuth); + aPage = await adminContext.newPage(); + admin = new ProductQAPage(aPage); + + const vendorContext = await browser.newContext(data.auth.vendorAuth); + vPage = await vendorContext.newPage(); + vendor = new ProductQAPage(vPage); + + const customerContext = await browser.newContext(data.auth.customerAuth); + cPage = await customerContext.newPage(); + customer = new ProductQAPage(cPage); + + apiUtils = new ApiUtils(await request.newContext()); + [, questionId] = await apiUtils.createProductQuestion({ ...payloads.createProductQuestion(), product_id: PRODUCT_ID }, payloads.customerAuth); + [, answerId] = await apiUtils.createProductQuestionAnswer({ ...payloads.createProductQuestionAnswer(), question_id: questionId }, payloads.vendorAuth); + }); + + test.afterAll(async () => { + await aPage.close(); + await vPage.close(); + await cPage.close(); + await apiUtils.dispose(); + }); + + // admin + + test('admin product QA menu page is rendering properly @pro @exp @a', async () => { + await admin.adminProductQARenderProperly(); + }); + + test('admin can view product question details @pro @exp @a', async () => { + const [, questionId] = await apiUtils.createProductQuestion({ ...payloads.createProductQuestion(), product_id: PRODUCT_ID }, payloads.customerAuth); + await admin.viewQuestionDetails(questionId); + }); + + // todo: admin receive notification for new question + + test.skip('unread count decrease after admin viewing a question @pro', async () => { + await admin.decreaseUnreadQuestionCount(); + }); + + test('admin can filter questions by vendor @pro @a', async () => { + await admin.filterQuestions(data.questionAnswers.filter.byVendor, 'by-vendor'); + }); + + test('admin can filter questions by product @pro @a', async () => { + await admin.filterQuestions(data.questionAnswers.filter.byProduct, 'by-product'); + }); + + test('admin can edit question @pro @a', async () => { + await admin.editQuestion(questionId, data.questionAnswers); + }); + + test('admin can answer to question @pro @a', async () => { + const [, questionId] = await apiUtils.createProductQuestion({ ...payloads.createProductQuestion(), product_id: PRODUCT_ID }, payloads.customerAuth); + await admin.answerQuestion(questionId, data.questionAnswers); + }); + + test('admin can edit answer @pro @a', async () => { + await admin.editAnswer(questionId, data.questionAnswers); + }); + + test('admin can delete answer @pro @a', async () => { + await admin.deleteAnswer(questionId); + }); + + test('admin can edit (hide) question visibility @pro @a', async () => { + await admin.editQuestionVisibility(questionId, 'hide'); + }); + + test('admin can edit (show) question visibility @pro @a', async () => { + await apiUtils.updateProductQuestion(questionId, payloads.updateProductQuestion(), payloads.adminAuth); + await admin.editQuestionVisibility(questionId, 'show'); + }); + + test('admin can delete a question @pro @a', async () => { + const [, questionId] = await apiUtils.createProductQuestion({ ...payloads.createProductQuestion(), product_id: PRODUCT_ID }, payloads.customerAuth); + await admin.deleteQuestion(questionId); + }); + + test('admin can perform store support bulk action @pro @a', async () => { + await admin.productQuestionsBulkAction('read'); + }); + + // vendor + + test('vendor product QA menu page is rendering properly @pro @exp @v', async () => { + await vendor.vendorProductQARenderProperly(); + }); + + test('vendor can view product question details @pro @exp @v', async () => { + const [, questionId] = await apiUtils.createProductQuestion({ ...payloads.createProductQuestion(), product_id: PRODUCT_ID }, payloads.customerAuth); + await vendor.vendorViewQuestionDetails(questionId); + }); + + // todo: vendor receive notification for new question + + test.skip('unread count decrease after vendor viewing a question @pro @a', async () => { + await admin.decreaseUnreadQuestionCount(); + }); + + test('vendor can filter questions @pro @v', async () => { + await vendor.vendorFilterQuestions(data.predefined.simpleProduct.product1.name); + }); + + test('vendor can answer to question @pro @v', async () => { + const [, questionId] = await apiUtils.createProductQuestion({ ...payloads.createProductQuestion(), product_id: PRODUCT_ID }, payloads.customerAuth); + await vendor.vendorAnswerQuestion(questionId, data.questionAnswers); + }); + + test('vendor can edit answer @pro @v', async () => { + await vendor.vendorEditAnswer(questionId, data.questionAnswers); + }); + + test('vendor can delete a answer @pro @v', async () => { + await vendor.vendorDeleteAnswer(questionId); + }); + + test('vendor can delete a question @pro @v', async () => { + await vendor.vendorDeleteQuestion(questionId); + }); + + // customer + + test('customer can search question @pro @c', async () => { + await customer.searchQuestion(data.predefined.simpleProduct.product1.name, data.questionAnswers); + }); + + test('customer can post question @pro @c', async () => { + await customer.postQuestion(data.predefined.simpleProduct.product1.name, data.questionAnswers); + }); + + // guest + + test('guest customer need to sign-in/signup post question @pro @g', async ({ page }) => { + guest = new ProductQAPage(page); + await guest.postQuestion(data.predefined.simpleProduct.product1.name, data.questionAnswers); + }); +}); diff --git a/tests/pw/tests/e2e/productReviews.spec.ts b/tests/pw/tests/e2e/productReviews.spec.ts index 8969c77b99..4da88e9dac 100644 --- a/tests/pw/tests/e2e/productReviews.spec.ts +++ b/tests/pw/tests/e2e/productReviews.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { ProductReviewsPage } from '@pages/productReviewsPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; @@ -12,57 +12,60 @@ test.describe('Product Reviews test', () => { let apiUtils: ApiUtils; let reviewMessage: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const vendorContext = await browser.newContext(data.auth.vendorAuth); vPage = await vendorContext.newPage(); vendor = new ProductReviewsPage(vPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); [, , reviewMessage] = await apiUtils.createProductReview(PRODUCT_ID, payloads.createProductReview(), payloads.vendorAuth); }); test.afterAll(async () => { await vPage.close(); + await apiUtils.dispose(); }); - test('vendor product reviews menu page is rendering properly @pro @explo', async () => { + test('vendor product reviews menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorProductReviewsRenderProperly(); }); - test('vendor can view product review @pro @explo', async () => { + test('vendor can view product review @pro @exp @v', async () => { await vendor.viewProductReview(reviewMessage); }); - test('vendor can unApprove product review @pro', async () => { + test('vendor can unApprove product review @pro @v', async () => { + const [, , reviewMessage] = await apiUtils.createProductReview(PRODUCT_ID, payloads.createProductReview(), payloads.vendorAuth); await vendor.updateProductReview('unApprove', reviewMessage); }); - test('vendor can spam product review @pro', async () => { + test('vendor can spam product review @pro @v', async () => { const [, , reviewMessage] = await apiUtils.createProductReview(PRODUCT_ID, payloads.createProductReview(), payloads.vendorAuth); await vendor.updateProductReview('spam', reviewMessage); }); - test('vendor can trash product review @pro', async () => { + test('vendor can trash product review @pro @v', async () => { const [, , reviewMessage] = await apiUtils.createProductReview(PRODUCT_ID, payloads.createProductReview(), payloads.vendorAuth); await vendor.updateProductReview('trash', reviewMessage); }); - test('vendor can approve product review @pro', async () => { + test('vendor can approve product review @pro @v', async () => { const [, , reviewMessage] = await apiUtils.createProductReview(PRODUCT_ID, { ...payloads.createProductReview(), status: 'hold' }, payloads.vendorAuth); await vendor.updateProductReview('approve', reviewMessage); }); - test('vendor can restore trashed product review @pro', async () => { + test('vendor can restore trashed product review @pro @v', async () => { const [, , reviewMessage] = await apiUtils.createProductReview(PRODUCT_ID, { ...payloads.createProductReview(), status: 'trash' }, payloads.vendorAuth); await vendor.updateProductReview('restore', reviewMessage); }); - test('vendor can permanently-delete product review @pro', async () => { + test('vendor can permanently-delete product review @pro @v', async () => { const [, , reviewMessage] = await apiUtils.createProductReview(PRODUCT_ID, { ...payloads.createProductReview(), status: 'trash' }, payloads.vendorAuth); await vendor.updateProductReview('permanently-delete', reviewMessage); }); - test('vendor can perform product reviews bulk action @pro', async () => { + test.skip('vendor can perform product reviews bulk action @pro @v', async () => { + // todo: might cause other tests to fail in parallel await vendor.productReviewsBulkActions('hold'); }); }); diff --git a/tests/pw/tests/e2e/products.spec.ts b/tests/pw/tests/e2e/products.spec.ts index 44c9746d06..75e82145d0 100644 --- a/tests/pw/tests/e2e/products.spec.ts +++ b/tests/pw/tests/e2e/products.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { ProductsPage } from '@pages/productsPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; @@ -11,7 +11,7 @@ test.describe('Product functionality test', () => { let apiUtils: ApiUtils; let productName: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new ProductsPage(aPage); @@ -20,44 +20,47 @@ test.describe('Product functionality test', () => { vPage = await vendorContext.newPage(); vendor = new ProductsPage(vPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); [, , productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth); }); test.afterAll(async () => { await aPage.close(); await vPage.close(); + await apiUtils.dispose(); }); - test('admin can add product category @lite', async () => { + //admin + + test('admin can add product category @lite @a', async () => { await admin.addCategory(data.product.category.randomCategory()); }); - test('admin can add product attribute @lite', async () => { + test('admin can add product attribute @lite @a', async () => { await admin.addAttribute(data.product.attribute.randomAttribute()); }); - test('admin can add simple product @lite', async () => { + test('admin can add simple product @lite @a', async () => { await admin.addSimpleProduct(data.product.simple); }); - // test('admin can add variable product @pro', async ( ) => { - // await admin.addVariableProduct(data.product.variable); - // }); + test.skip('admin can add variable product @pro @a', async () => { + await admin.addVariableProduct(data.product.variable); + }); - test('admin can add simple subscription @pro', async () => { + test('admin can add simple subscription product @pro @a', async () => { await admin.addSimpleSubscription(data.product.simpleSubscription); }); - // test('admin can add variable subscription @pro', async ( ) => { - // await admin.addVariableSubscription(data.product.variableSubscription); - // }); + test.skip('admin can add variable subscription product @pro @a', async () => { + await admin.addVariableSubscription(data.product.variableSubscription); + }); - test('admin can add external product @lite', async () => { + test('admin can add external product @lite @a', async () => { await admin.addExternalProduct(data.product.external); }); - test('admin can add vendor subscription @pro', async () => { + test.skip('admin can add vendor subscription @pro @a', async () => { await admin.addDokanSubscription(data.product.vendorSubscription); }); @@ -65,117 +68,121 @@ test.describe('Product functionality test', () => { // todo: move create product in separate files, or product functionality to another page - test('vendor can add simple product @lite', async () => { + test('vendor can add simple product @lite @v', async () => { await vendor.vendorAddSimpleProduct(data.product.simple, false); }); - test('vendor can add variable product @pro', async () => { + test('vendor can add variable product @pro @v', async () => { await vendor.vendorAddVariableProduct(data.product.variable, false); }); - test('vendor can add simple subscription product @pro', async () => { + test('vendor can add simple subscription product @pro @v', async () => { await vendor.vendorAddSimpleSubscription(data.product.simpleSubscription, false); }); - test('vendor can add variable subscription product @pro', async () => { + test('vendor can add variable subscription product @pro @v', async () => { await vendor.vendorAddVariableSubscription(data.product.variableSubscription, false); }); - test('vendor can add external product @pro', async () => { + test('vendor can add external product @pro @v', async () => { await vendor.vendorAddExternalProduct(data.product.external, false); }); - test('vendor can add downloadable product @lite', async () => { + test('vendor can add downloadable product @lite @v', async () => { await vendor.vendorAddDownloadableProduct(data.product.downloadable, false); }); - test('vendor can add virtual product @lite', async () => { + test('vendor can add virtual product @lite @v', async () => { await vendor.vendorAddVirtualProduct(data.product.virtual, false); }); - test('vendor can add product category @lite', async () => { + test('vendor can add product category @lite @v', async () => { await vendor.vendorAddProductCategory(data.predefined.simpleProduct.product1.name, data.product.category.unCategorized); }); - test('vendor product menu page is rendering properly @lite @explo', async () => { + // todo: move to other files: product categories + // todo: add multistep product categories test + // todo: add product categories settings test + + test('vendor product menu page is rendering properly @lite @exp @v', async () => { await vendor.vendorProductsRenderProperly(); }); - test('vendor can export products @pro', async () => { + test('vendor can export products @pro @v', async () => { await vendor.exportProducts(); }); - test('vendor can search product @lite', async () => { + test('vendor can search product @lite @v', async () => { await vendor.searchProduct(data.predefined.simpleProduct.product1.name); }); - test('vendor can filter products by date @lite', async () => { + test('vendor can filter products by date @lite @v', async () => { await vendor.filterProducts('by-date', '1'); }); - test('vendor can filter products by category @lite', async () => { + test('vendor can filter products by category @lite @v', async () => { await vendor.filterProducts('by-category', 'Uncategorized'); }); - test('vendor can filter products by type @pro', async () => { + test('vendor can filter products by type @pro @v', async () => { await vendor.filterProducts('by-type', 'simple'); }); - test('vendor can filter products by other @pro', async () => { + test('vendor can filter products by other @pro @v', async () => { await vendor.filterProducts('by-other', 'featured'); }); - test('vendor can view product @lite', async () => { - await vendor.viewProduct(data.predefined.simpleProduct.product1.name); + test('vendor can view product @lite @v', async () => { + await vendor.viewProduct(productName); }); - test("vendor can't buy own product @pro", async () => { + test("vendor can't buy own product @pro @v", async () => { await vendor.cantBuyOwnProduct(productName); }); - test('vendor can edit product @lite', async () => { + test('vendor can edit product @lite @v', async () => { await vendor.editProduct({ ...data.product.simple, editProduct: productName }); }); - test('vendor can quick edit product @pro', async () => { + test('vendor can quick edit product @pro @v', async () => { await vendor.quickEditProduct({ ...data.product.simple, editProduct: productName }); }); - test('vendor can add product description @lite', async () => { + test('vendor can add product description @lite @v', async () => { await vendor.addProductDescription(productName, data.product.productInfo.description); }); - // test('vendor can add product quantity discount @pro', async ( ) => { - // await vendor.addProductQuantityDiscount(data.predefined.simpleProduct.product1.name, data.product.productInfo.quantityDiscount); - // }); + test.skip('vendor can add product quantity discount @pro @v', async () => { + await vendor.addProductQuantityDiscount(productName, data.product.productInfo.quantityDiscount); + }); - test('vendor can add product rma options @pro', async () => { + test.skip('vendor can add product rma options @pro @v', async () => { await vendor.addProductRmaOptions(productName, data.vendor.rma); }); - test('vendor can add product wholesale options @pro', async () => { + test('vendor can add product wholesale options @pro @v', async () => { await vendor.addProductWholesaleOptions(productName, data.product.productInfo.wholesaleOption); }); - test.skip('vendor can add product min-max options @pro', async () => { + test.skip('vendor can add product min-max options @pro @v', async () => { await vendor.addProductMinMaxOptions(productName, data.product.productInfo.minMax); }); - test('vendor can add product other options @lite', async () => { + test('vendor can add product other options @lite @v', async () => { await vendor.addProductOtherOptions(productName, data.product.productInfo.otherOptions); }); - test.skip('vendor can add catalog mode @lite', async () => { + test.skip('vendor can add catalog mode @lite @v', async () => { await vendor.addCatalogMode(productName); }); // todo: add more product edit tests -> discount, wholesale, advertising - test('vendor can duplicate product @pro', async () => { + test('vendor can duplicate product @pro @v', async () => { await vendor.duplicateProduct(productName); }); - test('vendor can permanently delete product @lite', async () => { + test('vendor can permanently delete product @lite @v', async () => { const [, , productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth); await vendor.permanentlyDeleteProduct(productName); }); diff --git a/tests/pw/tests/e2e/refunds.spec.ts b/tests/pw/tests/e2e/refunds.spec.ts index bc9592e771..b5ce8a455a 100644 --- a/tests/pw/tests/e2e/refunds.spec.ts +++ b/tests/pw/tests/e2e/refunds.spec.ts @@ -1,4 +1,4 @@ -import { test, Page, APIResponse } from '@playwright/test'; +import { test, request, Page, APIResponse } from '@playwright/test'; import { RefundsPage } from '@pages/refundsPage'; import { ApiUtils } from '@utils/apiUtils'; import { dbUtils } from '@utils/dbUtils'; @@ -15,7 +15,7 @@ test.describe('Refunds test', () => { let orderResponseBody: APIResponse; let orderId: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new RefundsPage(aPage); @@ -24,46 +24,54 @@ test.describe('Refunds test', () => { vPage = await vendorContext.newPage(); vendor = new RefundsPage(vPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); [, orderResponseBody, orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, payloads.createOrder, data.order.orderStatus.processing, payloads.vendorAuth); - await dbUtils.createRefund(orderResponseBody); + await dbUtils.createRefundRequest(orderResponseBody); }); test.afterAll(async () => { await aPage.close(); + await apiUtils.dispose(); }); - test('admin refunds menu page is rendering properly @pro @explo', async () => { + //admin + + test('admin refunds menu page is rendering properly @pro @exp @a', async () => { await admin.adminRefundRequestsRenderProperly(); }); - test('admin can search refund requests @pro', async () => { + test('admin can search refund requests by order-id @pro @a', async () => { await admin.searchRefundRequests(orderId); - // await admin.searchRefundRequests(data.predefined.vendorStores.vendor1); }); - test('admin can approve refund request @pro', async () => { + test('admin can search refund requests by vendor @pro @a', async () => { + await admin.searchRefundRequests(data.predefined.vendorStores.vendor1); + }); + + test('admin can approve refund request @pro @a', async () => { await admin.updateRefundRequests(orderId, 'approve'); }); - test('admin can cancel refund requests @pro', async () => { + test('admin can cancel refund requests @pro @a', async () => { const [, orderResponseBody, orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, payloads.createOrder, data.order.orderStatus.processing, payloads.vendorAuth); - await dbUtils.createRefund(orderResponseBody); + await dbUtils.createRefundRequest(orderResponseBody); await admin.updateRefundRequests(orderId, 'cancel'); }); - test('admin can perform refund requests bulk actions @pro', async () => { + test.skip('admin can perform refund requests bulk actions @pro @a', async () => { const [, orderResponseBody, ,] = await apiUtils.createOrderWithStatus(PRODUCT_ID, payloads.createOrder, data.order.orderStatus.processing, payloads.vendorAuth); - await dbUtils.createRefund(orderResponseBody); + await dbUtils.createRefundRequest(orderResponseBody); await admin.refundRequestsBulkAction('completed'); }); - test('vendor can full refund @pro', async () => { + //vendor + + test('vendor can full refund @pro @v', async () => { const [, , orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, { ...payloads.createOrder, customer_id: CUSTOMER_ID }, data.order.orderStatus.completed, payloads.vendorAuth); await vendor.refundOrder(orderId, data.predefined.simpleProduct.product1.name); }); - test('vendor can partial refund @pro', async () => { + test('vendor can partial refund @pro @v', async () => { const [, , orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, { ...payloads.createOrder, customer_id: CUSTOMER_ID }, data.order.orderStatus.completed, payloads.vendorAuth); await vendor.refundOrder(orderId, data.predefined.simpleProduct.product1.name, true); }); diff --git a/tests/pw/tests/e2e/reports.spec.ts b/tests/pw/tests/e2e/reports.spec.ts index 0da8f57bda..510e08312f 100644 --- a/tests/pw/tests/e2e/reports.spec.ts +++ b/tests/pw/tests/e2e/reports.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { ReportsPage } from '@pages/reportsPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; @@ -12,44 +12,45 @@ test.describe('Reports test', () => { let apiUtils: ApiUtils; let orderId: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new ReportsPage(aPage); - apiUtils = new ApiUtils(request); + + apiUtils = new ApiUtils(await request.newContext()); [, , orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, payloads.createOrder, data.order.orderStatus.completed, payloads.vendorAuth); }); test.afterAll(async () => { await aPage.close(); + await apiUtils.dispose(); }); // reports - test('admin reports menu page is rendering properly @pro @explo', async () => { + test('admin reports menu page is rendering properly @pro @exp @a', async () => { await admin.adminReportsRenderProperly(); }); // all logs - test('admin All Logs menu page is rendering properly @pro @explo', async () => { + test('admin all Logs menu page is rendering properly @pro @exp @a', async () => { await admin.adminAllLogsRenderProperly(); }); - test('admin can search all logs @pro', async () => { + test('admin can search all logs @pro @a', async () => { await admin.searchAllLogs(orderId); }); - test('admin can export all logs @pro', async () => { - // await admin.exportAllLogs(orderId); + test('admin can export all logs @pro @a', async () => { await admin.exportAllLogs(); }); - test('admin can filter all logs by store name @pro', async () => { + test('admin can filter all logs by store name @pro @a', async () => { await admin.filterAllLogsByStore(data.predefined.vendorStores.vendor1); }); - test('admin can filter all logs by order status @pro', async () => { + test('admin can filter all logs by order status @pro @a', async () => { await admin.filterAllLogsByStatus('completed'); }); }); diff --git a/tests/pw/tests/e2e/requestForQuoteRules.spec.ts b/tests/pw/tests/e2e/requestForQuoteRules.spec.ts index 9f698211e8..70e9e9b38d 100644 --- a/tests/pw/tests/e2e/requestForQuoteRules.spec.ts +++ b/tests/pw/tests/e2e/requestForQuoteRules.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { RequestForQuotationsPage } from '@pages/requestForQuotationsPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; @@ -8,48 +8,57 @@ test.describe('Request for quotation Rules test', () => { let admin: RequestForQuotationsPage; let aPage: Page; let apiUtils: ApiUtils; - const quoteRuleTitle = data.requestForQuotation.quoteRule.title(); + let quoteRuleTitle: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new RequestForQuotationsPage(aPage); - apiUtils = new ApiUtils(request); - await apiUtils.createQuoteRule({ ...payloads.createQuoteRule(), rule_name: quoteRuleTitle }, payloads.adminAuth); + + apiUtils = new ApiUtils(await request.newContext()); + [, , quoteRuleTitle] = await apiUtils.createQuoteRule(payloads.createQuoteRule(), payloads.adminAuth); }); test.afterAll(async () => { + await apiUtils.deleteAllQuoteRules(payloads.adminAuth); + await apiUtils.deleteAllQuoteRulesTrashed(payloads.adminAuth); await aPage.close(); + await apiUtils.dispose(); }); // quote rules - test('admin quote rules menu page is rendering properly @pro @explo', async () => { + //admin + + test('admin quote rules menu page is rendering properly @pro @exp @a', async () => { await admin.adminQuoteRulesRenderProperly(); }); - test('admin can add quote rule @pro', async () => { - await admin.addQuoteRule({ ...data.requestForQuotation.quoteRule, title: data.requestForQuotation.quoteRule.title() }); + test('admin can add quote rule @pro @a', async () => { + await admin.addQuoteRule(data.requestForQuotation.quoteRule()); }); - test('admin can edit quote rule @pro', async () => { - await admin.editQuoteRule({ ...data.requestForQuotation.quoteRule, title: quoteRuleTitle }); + test('admin can edit quote rule @pro @a', async () => { + await admin.editQuoteRule({ ...data.requestForQuotation.quoteRule(), title: quoteRuleTitle }); }); - test('admin can trash quote rule @pro', async () => { + test('admin can trash quote rule @pro @a', async () => { + const [, , quoteRuleTitle] = await apiUtils.createQuoteRule(payloads.createQuoteRule(), payloads.adminAuth); await admin.updateQuoteRule(quoteRuleTitle, 'trash'); }); - test('admin can restore quote rule @pro', async () => { + test('admin can restore quote rule @pro @a', async () => { + const [, , quoteRuleTitle] = await apiUtils.createQuoteRule({ ...payloads.createQuoteRule(), status: 'trash' }, payloads.adminAuth); await admin.updateQuoteRule(quoteRuleTitle, 'restore'); }); - test('admin can permanently delete quote rule @pro', async () => { - await apiUtils.createQuoteRule({ ...payloads.createQuoteRule(), rule_name: data.requestForQuotation.trashedQuoteRule.title, status: data.requestForQuotation.trashedQuoteRule.status }, payloads.adminAuth); - await admin.updateQuoteRule(data.requestForQuotation.trashedQuoteRule.title, 'permanently-delete'); + test('admin can permanently delete quote rule @pro @a', async () => { + const [, , quoteRuleTitle] = await apiUtils.createQuoteRule({ ...payloads.createQuoteRule(), status: 'trash' }, payloads.adminAuth); + await admin.updateQuoteRule(quoteRuleTitle, 'permanently-delete'); }); - test('admin can perform quote rule bulk actions @pro', async () => { + test.skip('admin can perform quote rule bulk actions @pro @a', async () => { + // todo: might cause other tests to fail in parallel await admin.quoteRulesBulkAction('trash'); }); }); diff --git a/tests/pw/tests/e2e/requestForQuotes.spec.ts b/tests/pw/tests/e2e/requestForQuotes.spec.ts index d8d4ee73bf..14517a070b 100644 --- a/tests/pw/tests/e2e/requestForQuotes.spec.ts +++ b/tests/pw/tests/e2e/requestForQuotes.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { RequestForQuotationsPage } from '@pages/requestForQuotationsPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; @@ -13,60 +13,62 @@ test.describe('Request for quotation test admin', () => { const productId: string[] = []; let quoteTitle: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new RequestForQuotationsPage(aPage); - apiUtils = new ApiUtils(request); - const [, pId] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth); - productId.push(pId); + apiUtils = new ApiUtils(await request.newContext()); + [, productId[0]] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth); [, , quoteTitle] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId, user_id: CUSTOMER_ID }, payloads.adminAuth); }); test.afterAll(async () => { await aPage.close(); + await apiUtils.dispose(); }); // quotes - test('admin quotes menu page is rendering properly @pro @explo', async () => { + test('admin quotes menu page is rendering properly @pro @exp @a', async () => { await admin.adminQuotesRenderProperly(); }); - test('admin can add quote @pro', async () => { - await admin.addQuote({ ...data.requestForQuotation.quote, title: data.requestForQuotation.quote.title() }); + test('admin can add quote @pro @a', async () => { + await admin.addQuote(data.requestForQuotation.quote()); }); - test('admin can edit quote @pro', async () => { - await admin.editQuote({ ...data.requestForQuotation.quote, title: quoteTitle }); + test('admin can edit quote @pro @a', async () => { + await admin.editQuote({ ...data.requestForQuotation.quote(), title: quoteTitle }); }); - test('admin can trash quote @pro', async () => { + test('admin can trash quote @pro @a', async () => { + const [, , quoteTitle] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId, user_id: CUSTOMER_ID }, payloads.adminAuth); await admin.updateQuote(quoteTitle, 'trash'); }); - test('admin can restore quote @pro', async () => { + test('admin can restore quote @pro @a', async () => { const [, , quoteTitle] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId, status: 'trash', user_id: CUSTOMER_ID }, payloads.adminAuth); await admin.updateQuote(quoteTitle, 'restore'); }); - test('admin can permanently delete quote @pro', async () => { + test('admin can permanently delete quote @pro @a', async () => { const [, , quoteTitle] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId, status: 'trash', user_id: CUSTOMER_ID }, payloads.adminAuth); await admin.updateQuote(quoteTitle, 'permanently-delete'); }); - test('admin can approve quote @pro', async () => { + test('admin can approve quote @pro @a', async () => { const [, , quoteTitle] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId, user_id: CUSTOMER_ID }, payloads.adminAuth); await admin.approveQuote(quoteTitle); }); - test('admin can convert quote to order @pro', async () => { + test('admin can convert quote to order @pro @a', async () => { const [, , quoteTitle] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId, status: 'approve', user_id: CUSTOMER_ID }, payloads.adminAuth); await admin.convertQuoteToOrder(quoteTitle); }); - test('admin can perform quote bulk actions @pro', async () => { + test.skip('admin can perform quote bulk actions @pro @a', async () => { + // todo: might cause other tests to fail in parallel await admin.quotesBulkAction('trash'); }); }); @@ -78,42 +80,42 @@ test.describe('Request for quotation test vendor', () => { const productId: string[] = []; let quoteTitle: string; let productName: string; - let pId: string; let quoteId: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const vendorContext = await browser.newContext(data.auth.vendorAuth); vPage = await vendorContext.newPage(); vendor = new RequestForQuotationsPage(vPage); - apiUtils = new ApiUtils(request); - [, pId, productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth); - productId.push(pId); + apiUtils = new ApiUtils(await request.newContext()); + [, productId[0], productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth); [, quoteId, quoteTitle] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId, user_id: CUSTOMER_ID }, payloads.adminAuth); }); test.afterAll(async () => { await vPage.close(); + await apiUtils.dispose(); }); - test('vendor request quotes menu page is rendering properly @pro @explo', async () => { + test('vendor request quotes menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorRequestQuotesRenderProperly(); }); - test('vendor can view request quote details @pro @explo', async () => { + test('vendor can view request quote details @pro @exp @v', async () => { await vendor.vendorViewQuoteDetails(quoteTitle); }); - test('vendor can update quote request @pro', async () => { + test('vendor can update quote request @pro @v', async () => { await vendor.vendorUpdateQuoteRequest(quoteId, { ...data.requestForQuotation.vendorUpdateQuote, productName: productName }); }); - test('vendor can approve quote request @pro', async () => { + test('vendor can approve quote request @pro @v', async () => { + const [, quoteId] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId, user_id: CUSTOMER_ID }, payloads.adminAuth); await vendor.vendorApproveQuoteRequest(quoteId); }); - test('vendor can convert quote request to order @pro', async () => { - // const [, quoteId] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId, status: 'approve', user_id: CUSTOMER_ID }, payloads.adminAuth); + test('vendor can convert quote request to order @pro @v', async () => { + const [, quoteId] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId, status: 'approve', user_id: CUSTOMER_ID }, payloads.adminAuth); await vendor.vendorConvertQuoteToOrder(quoteId); }); }); @@ -121,63 +123,60 @@ test.describe('Request for quotation test vendor', () => { test.describe('Request for quotation test customer', () => { let customer: RequestForQuotationsPage; let guest: RequestForQuotationsPage; - let cPage: Page, uPage: Page; + let cPage: Page; let apiUtils: ApiUtils; const productId: string[] = []; let productName: string; - let pId: string; let quoteId: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const customerContext = await browser.newContext(data.auth.customerAuth); cPage = await customerContext.newPage(); customer = new RequestForQuotationsPage(cPage); - const guestContext = await browser.newContext(data.auth.noAuth); - uPage = await guestContext.newPage(); - guest = new RequestForQuotationsPage(uPage); - - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); - [, pId, productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth); - productId.push(pId); - const [responseBody] = await apiUtils.createQuoteRule({ ...payloads.createQuoteRule(), product_ids: productId, apply_on_all_product: '0' }, payloads.adminAuth); - // console.log(responseBody); - // console.log(productName); + [, productId[0], productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendorAuth); + await apiUtils.createQuoteRule({ ...payloads.createQuoteRule(), product_ids: productId, apply_on_all_product: '0' }, payloads.adminAuth); [, quoteId] = await apiUtils.createQuoteRequest({ ...payloads.createQuoteRequest(), product_ids: productId, user_id: CUSTOMER_ID }, payloads.adminAuth); }); test.afterAll(async () => { await cPage.close(); - await uPage.close(); + await apiUtils.dispose(); }); - test('customer request for quote menu page is rendering properly @pro @explo', async () => { + //customer + + test('customer request for quote menu page is rendering properly @pro @exp @c', async () => { await customer.requestForQuoteRenderProperly(); }); - test('customer requested quote page is rendering properly @pro @explo', async () => { + test('customer requested quote page is rendering properly @pro @exp @c', async () => { await customer.requestedQuotesRenderProperly(); }); - test('customer can view requested quote details @pro @explo', async () => { + test('customer can view requested quote details @pro @exp @c', async () => { await customer.customerViewRequestedQuoteDetails(quoteId); }); - test('customer can update quote request @pro', async () => { + test('customer can update quote request @pro @c', async () => { await customer.customerUpdateRequestedQuote(quoteId, { ...data.requestForQuotation.customerQuoteProduct, productName: productName }); }); - test('customer can pay order converted from quote request @pro', async () => { + test('customer can pay for order converted from quote request @pro @c', async () => { await apiUtils.convertQuoteToOrder(quoteId, payloads.adminAuth); await customer.payConvertedQuote(quoteId); }); - test.skip('customer can quote product @pro @explo', async () => { + test('customer can quote product @pro @c', async () => { await customer.customerQuoteProduct({ ...data.requestForQuotation.customerQuoteProduct, productName: productName }); }); - test.skip('guest customer can quote product @pro @explo', async () => { + //guest + + test('guest customer can quote product @pro @g', async ({ page }) => { + guest = new RequestForQuotationsPage(page); await guest.customerQuoteProduct({ ...data.requestForQuotation.customerQuoteProduct, productName: productName }, data.requestForQuotation.guest()); }); }); diff --git a/tests/pw/tests/e2e/reverseWithdraws.spec.ts b/tests/pw/tests/e2e/reverseWithdraws.spec.ts index 353e133fcb..6430a44a47 100644 --- a/tests/pw/tests/e2e/reverseWithdraws.spec.ts +++ b/tests/pw/tests/e2e/reverseWithdraws.spec.ts @@ -1,81 +1,75 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { ReverseWithdrawsPage } from '@pages/reverseWithdrawsPage'; -// import { OrdersPage } from '@pages/ordersPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; import { payloads } from '@utils/payloads'; import { dbUtils } from '@utils/dbUtils'; import { dbData } from '@utils/dbData'; -const { PRODUCT_ID } = process.env; - test.describe('Reverse withdraw test', () => { let admin: ReverseWithdrawsPage; let vendor: ReverseWithdrawsPage; let aPage: Page, vPage: Page; let apiUtils: ApiUtils; - // let orderId: string; + let productId: string; + let productName: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new ReverseWithdrawsPage(aPage); - const vendorContext = await browser.newContext(data.auth.vendorAuth); + const vendorContext = await browser.newContext(data.auth.vendor2Auth); vPage = await vendorContext.newPage(); vendor = new ReverseWithdrawsPage(vPage); - // const vendor1 = new OrdersPage(vPage); - - apiUtils = new ApiUtils(request); await dbUtils.setDokanSettings(dbData.dokan.optionName.reverseWithdraw, dbData.dokan.reverseWithdrawSettings); - // await admin.addReverseWithdrawal({ ...data.reverseWithdraw, amount: '1000', withdrawalBalanceType: 'debit' } ); - // await apiUtils.createOrderWithStatus(PRODUCT_ID, payloads.createOrderCod, data.order.orderStatus.completed, payloads.vendorAuth); - // [,, orderId,]= await apiUtils.createOrderWithStatus(PRODUCT_ID, payloads.createOrderCod, data.order.orderStatus.processing, payloads.vendorAuth); - // await vendor1.updateOrderStatusOnTable(orderId, 'complete'); + apiUtils = new ApiUtils(await request.newContext()); - const [, , orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, payloads.createOrderCod, data.order.orderStatus.processing, payloads.vendorAuth); - await apiUtils.updateOrderStatus(orderId, data.order.orderStatus.completed, payloads.vendorAuth); + [, productId, productName] = await apiUtils.createProduct(payloads.createProduct(), payloads.vendor2Auth); + const [, , orderId] = await apiUtils.createOrderWithStatus(productId, payloads.createOrderCod, data.order.orderStatus.processing, payloads.vendor2Auth); + await apiUtils.updateOrderStatus(orderId, data.order.orderStatus.completed, payloads.vendor2Auth); }); test.afterAll(async () => { await dbUtils.setDokanSettings(dbData.dokan.optionName.reverseWithdraw, { ...dbData.dokan.reverseWithdrawSettings, enabled: 'off' }); await aPage.close(); await vPage.close(); + await apiUtils.dispose(); }); - test('dokan admin reverse withdraw menu page is rendering properly @lite @explo', async () => { + test('dokan admin reverse withdraw menu page is rendering properly @lite @exp @a', async () => { await admin.adminReverseWithdrawRenderProperly(); }); - test.skip('filter reverse withdraws by store @lite', async () => { - await admin.filterReverseWithdraws(data.predefined.vendorStores.vendor1); + test.skip('admin can filter reverse withdraws by store @lite @a', async () => { + await admin.filterReverseWithdraws(data.predefined.vendorStores.vendor2); }); - test('admin can crete reverse withdraws @lite', async () => { - await admin.addReverseWithdrawal(data.reverseWithdraw); + test('admin can crete reverse withdraws @lite @a', async () => { + await admin.addReverseWithdrawal({ ...data.reverseWithdraw, store: data.predefined.vendorStores.vendor2, product: productName }); }); // vendor - test('vendor reverse withdrawal menu page is rendering properly @lite @explo', async () => { + test('vendor reverse withdrawal menu page is rendering properly @lite @exp @v', async () => { await vendor.vendorReverseWithdrawalRenderProperly(); }); - test('vendor can view reverse withdrawal notice @lite @explo', async () => { + test('vendor can view reverse withdrawal notice @lite @exp @v', async () => { await vendor.vendorViewReverseWithdrawalNotice(); }); - test('vendor can view reverse withdrawal announcement @pro @explo', async () => { + test('vendor can view reverse withdrawal announcement @pro @exp @v', async () => { await vendor.vendorViewReverseWithdrawalAnnouncement(); }); - test('vendor can filter reverse withdrawals @lite', async () => { + test('vendor can filter reverse withdrawals @lite @v', async () => { await vendor.vendorFilterReverseWithdrawals(data.date.dateRange); }); - test('vendor can pay reverse pay balance @lite', async () => { + test('vendor can pay reverse pay balance @lite @v', async () => { const orderId = await vendor.vendorPayReversePayBalance(); await apiUtils.updateOrderStatus(orderId, data.order.orderStatus.completed, payloads.adminAuth); }); diff --git a/tests/pw/tests/e2e/sellerBadges.spec.ts b/tests/pw/tests/e2e/sellerBadges.spec.ts index 4ac106c542..8c73c090b8 100644 --- a/tests/pw/tests/e2e/sellerBadges.spec.ts +++ b/tests/pw/tests/e2e/sellerBadges.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { SellerBadgesPage } from '@pages/sellerBadgesPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; @@ -10,7 +10,7 @@ test.describe('Seller badge test', () => { let aPage: Page, vPage: Page; let apiUtils: ApiUtils; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new SellerBadgesPage(aPage); @@ -19,81 +19,84 @@ test.describe('Seller badge test', () => { vPage = await vendorContext.newPage(); vendor = new SellerBadgesPage(vPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); await apiUtils.createSellerBadge(payloads.createSellerBadgeProductsPublished, payloads.adminAuth); }); test.afterAll(async () => { await aPage.close(); await vPage.close(); + await apiUtils.dispose(); }); - test('dokan seller badge menu page is rendering properly @pro @explo', async () => { + test('dokan seller badge menu page is rendering properly @pro @exp @a', async () => { await admin.adminSellerBadgeRenderProperly(); }); - test('admin can preview seller badge @pro @explo', async () => { + test('admin can preview seller badge @pro @exp @a', async () => { await admin.previewSellerBadge(data.sellerBadge.eventName.productsPublished); }); - test('admin can view seller badge details @pro @explo', async () => { + test('admin can view seller badge details @pro @exp @a', async () => { await admin.viewSellerBadge(data.sellerBadge.eventName.productsPublished); }); - test('admin can search seller badge @pro', async () => { + test('admin can search seller badge @pro @a', async () => { await admin.searchSellerBadge(data.sellerBadge.eventName.productsPublished); }); - test('admin can create seller badge @pro', async () => { + test('admin can create seller badge @pro @a', async () => { await admin.createSellerBadge({ ...data.sellerBadge, badgeName: data.sellerBadge.eventName.numberOfItemsSold }); }); - test('admin can edit seller badge @pro', async () => { + test('admin can edit seller badge @pro @a', async () => { await admin.editSellerBadge({ ...data.sellerBadge, badgeName: data.sellerBadge.eventName.productsPublished }); }); - // test.skip('admin can filter vendors by seller badge @pro', async ( ) => { - // await admin.filterVendorsByBadge(data.sellerBadge.eventName.productsPublished); - // }); + test.skip('admin can filter vendors by seller badge @pro @a', async () => { + // todo: need to wait 1 min after badge create; run via background process; + await admin.filterVendorsByBadge(data.sellerBadge.eventName.productsPublished); + }); - // test.skip('admin can view seller badge vendors @pro', async ( ) => { - // await admin.sellerBadgeVendors(data.sellerBadge.eventName.productsPublished); - // }); + test.skip('admin can view seller badge vendors @pro @a', async () => { + // todo: need to wait 1 min after badge create; run via background process; + await admin.sellerBadgeVendors(data.sellerBadge.eventName.productsPublished); + }); - test('admin can view seller badges acquired by vendor @pro', async () => { + test('admin can view seller badges acquired by vendor @pro @a', async () => { await admin.sellerBadgeAcquiredByVendor(data.predefined.vendorStores.vendor1); }); - test('admin can update seller badge status @pro', async () => { + test('admin can update seller badge status @pro @a', async () => { await apiUtils.createSellerBadge(payloads.createSellerBadgeExclusiveToPlatform, payloads.adminAuth); await admin.updateSellerBadge(data.sellerBadge.eventName.exclusiveToPlatform, 'draft'); }); - test('admin can delete seller badge @pro', async () => { + test('admin can delete seller badge @pro @a', async () => { await apiUtils.createSellerBadge(payloads.createSellerBadgeExclusiveToPlatform, payloads.adminAuth); await admin.updateSellerBadge(data.sellerBadge.eventName.exclusiveToPlatform, 'delete'); }); - test('admin can perform seller badge bulk action @pro', async () => { + test('admin can perform seller badge bulk action @pro @a', async () => { await apiUtils.createSellerBadge(payloads.createSellerBadgeFeatureProducts, payloads.adminAuth); await admin.sellerBadgeBulkAction('delete', data.sellerBadge.eventName.featuredProducts); }); // vendor - test('vendor badges menu page is rendering properly @pro @explo', async () => { + test('vendor badges menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorSellerBadgeRenderProperly(); }); - test('vendor can view badge acquired congratulation popup message action @pro', async () => { + test('vendor can view badge acquired congratulation popup message action @pro @v', async () => { await vendor.sellerBadgeCongratsPopup(); }); - test('vendor can search seller badge @pro', async () => { + test('vendor can search seller badge @pro @v', async () => { await vendor.vendorSearchSellerBadge(data.sellerBadge.eventName.productsPublished); }); - test('vendor can filter seller badges @pro', async () => { + test('vendor can filter seller badges @pro @v', async () => { await vendor.filterSellerBadges('available_badges'); }); }); diff --git a/tests/pw/tests/e2e/setting.spec.ts b/tests/pw/tests/e2e/setting.spec.ts new file mode 100644 index 0000000000..ab1bf11f97 --- /dev/null +++ b/tests/pw/tests/e2e/setting.spec.ts @@ -0,0 +1,143 @@ +import { test, request, Page } from '@playwright/test'; +import { SettingPage } from '@pages/settingPage'; +import { dbData } from '@utils/dbData'; +import { dbUtils } from '@utils/dbUtils'; +import { data } from '@utils/testData'; +import { helpers } from '@utils/helpers'; +import { ApiUtils } from '@utils/apiUtils'; +import { payloads } from '@utils/payloads'; + +const { CI, CUSTOMER_ID, PRODUCT_ID } = process.env; + +test.describe.skip('Settings test', () => { + let admin: SettingPage; + let vendor: SettingPage; + let customer: SettingPage; + let guest: SettingPage; + let aPage: Page, vPage: Page, cPage: Page, gPage: Page; + let apiUtils: ApiUtils; + + test.beforeAll(async ({ browser }) => { + const adminContext = await browser.newContext(data.auth.adminAuth); + aPage = await adminContext.newPage(); + admin = new SettingPage(aPage); + + const vendorContext = await browser.newContext(data.auth.vendorAuth); + vPage = await vendorContext.newPage(); + vendor = new SettingPage(vPage); + + const customerContext = await browser.newContext(data.auth.customerAuth); + cPage = await customerContext.newPage(); + customer = new SettingPage(cPage); + + const guestContext = await browser.newContext(data.auth.noAuth); + gPage = await guestContext.newPage(); + guest = new SettingPage(gPage); + }); + + test.afterAll(async () => { + await dbUtils.setDokanSettings(dbData.dokan.optionName.general, dbData.dokan.generalSettings); + await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, dbData.dokan.sellingSettings); + + await aPage.close(); + await vPage.close(); + await cPage.close(); + await gPage.close(); + }); + + // general settings + + test.skip('admin can set vendor store url (general settings) @lite @a', async () => { + // todo: need to run on serial mode, will fail other tests + await dbUtils.setDokanSettings(dbData.dokan.optionName.general, { ...dbData.dokan.generalSettings, custom_store_url: 'stores' }); + CI ? await helpers.exeCommand(data.command.permalink) : await helpers.exeCommand(data.command.permalinkLocal); + await admin.vendorStoreUrlSetting(data.predefined.vendorStores.vendor1, 'stores'); + + //reset + await dbUtils.setDokanSettings(dbData.dokan.optionName.general, dbData.dokan.generalSettings); + CI ? await helpers.exeCommand(data.command.permalink) : await helpers.exeCommand(data.command.permalinkLocal); + }); + + test('admin can set vendor setup wizard logo & message (general settings) @lite @a', async () => { + apiUtils = new ApiUtils(await request.newContext()); + const [responseBody] = await apiUtils.uploadFile(data.image.dokan, payloads.adminAuth); + const logoUrl = responseBody.source_url; + await dbUtils.setDokanSettings(dbData.dokan.optionName.general, { + ...dbData.dokan.generalSettings, + setup_wizard_logo_url: logoUrl, + setup_wizard_message: dbData.testData.dokan.generalSettings.setup_wizard_message, + }); + await admin.vendorSetupWizardLogoAndMessageSetting(logoUrl, dbData.testData.dokan.generalSettings.setup_wizard_message_without_html); + }); + + test('admin can disable vendor setup wizard (general settings) @lite @g', async () => { + await dbUtils.setDokanSettings(dbData.dokan.optionName.general, { ...dbData.dokan.generalSettings, disable_welcome_wizard: 'on' }); + await guest.disableVendorSetupWizardSetting(); + }); + + test('admin can set store terms and conditions (general settings) @lite @v', async () => { + await dbUtils.setDokanSettings(dbData.dokan.optionName.general, { ...dbData.dokan.generalSettings, seller_enable_terms_and_conditions: 'on' }); + await vendor.setStoreTermsAndConditions('on'); + + await dbUtils.setDokanSettings(dbData.dokan.optionName.general, { ...dbData.dokan.generalSettings, seller_enable_terms_and_conditions: 'off' }); + await vendor.setStoreTermsAndConditions('off'); + }); + + test('admin can set store products per page (general settings) @lite @c', async () => { + await dbUtils.setDokanSettings(dbData.dokan.optionName.general, { ...dbData.dokan.generalSettings, store_products_per_page: '1' }); + await customer.setStoreProductsPerPage(data.predefined.vendorStores.vendor1, 1); + }); + + test('admin can enable address fields on registration (general settings) @lite @g', async () => { + await dbUtils.setDokanSettings(dbData.dokan.optionName.general, { ...dbData.dokan.generalSettings, enabled_address_on_reg: 'on' }); + await guest.enableAddressFieldsOnRegistration('on'); + + await dbUtils.setDokanSettings(dbData.dokan.optionName.general, { ...dbData.dokan.generalSettings, enabled_address_on_reg: 'off' }); + await guest.enableAddressFieldsOnRegistration('off'); + }); + + test('admin can enable store terms and conditions on registration (general settings) @pro @v', async () => { + await dbUtils.setDokanSettings(dbData.dokan.optionName.general, { ...dbData.dokan.generalSettings, enable_tc_on_reg: 'on' }); + await vendor.enableStoreTermsAndConditionsOnRegistration('on'); + + await dbUtils.setDokanSettings(dbData.dokan.optionName.general, { ...dbData.dokan.generalSettings, enable_tc_on_reg: 'off' }); + await vendor.enableStoreTermsAndConditionsOnRegistration('off'); + }); + + test('admin can set show vendor info (general settings) @lite @c', async () => { + await dbUtils.setDokanSettings(dbData.dokan.optionName.general, { ...dbData.dokan.generalSettings, show_vendor_info: 'on' }); + await customer.setShowVendorInfo(data.predefined.simpleProduct.product1.name, 'on'); + + await dbUtils.setDokanSettings(dbData.dokan.optionName.general, { ...dbData.dokan.generalSettings, show_vendor_info: 'off' }); + await customer.setShowVendorInfo(data.predefined.simpleProduct.product1.name, 'off'); + }); + + test('admin can enable more products tab (general settings) @lite @c', async () => { + await dbUtils.setDokanSettings(dbData.dokan.optionName.general, { ...dbData.dokan.generalSettings, enabled_more_products_tab: 'on' }); + await customer.enableMoreProductsTab(data.predefined.simpleProduct.product1.name, 'on'); + + await dbUtils.setDokanSettings(dbData.dokan.optionName.general, { ...dbData.dokan.generalSettings, enabled_more_products_tab: 'off' }); + await customer.enableMoreProductsTab(data.predefined.simpleProduct.product1.name, 'off'); + }); + + // selling settings + + test('admin can enable vendor selling (selling settings) @lite @g', async () => { + await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, new_seller_enable_selling: 'on' }); + await guest.enableVendorSelling('on'); + + await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, new_seller_enable_selling: 'off' }); + await guest.enableVendorSelling('off'); + }); + + test('admin can set order status change capability (selling settings) @lite @v', async () => { + apiUtils = new ApiUtils(await request.newContext()); + const [, , orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, { ...payloads.createOrder, customer_id: CUSTOMER_ID }, data.order.orderStatus.onhold, payloads.vendorAuth); + + await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, order_status_change: 'on' }); + await vendor.setOrderStatusChangeCapability(orderId, 'on'); + + await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, order_status_change: 'off' }); + await vendor.setOrderStatusChangeCapability(orderId, 'off'); + }); +}); diff --git a/tests/pw/tests/e2e/settings.spec.ts b/tests/pw/tests/e2e/settings.spec.ts index 3cfde1dc43..54686a2039 100644 --- a/tests/pw/tests/e2e/settings.spec.ts +++ b/tests/pw/tests/e2e/settings.spec.ts @@ -5,122 +5,122 @@ import { dbUtils } from '@utils/dbUtils'; import { data } from '@utils/testData'; test.describe('Settings test', () => { - let settingsPage: SettingsPage; + let admin: SettingsPage; let aPage: Page; test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); - settingsPage = new SettingsPage(aPage); + admin = new SettingsPage(aPage); }); test.afterAll(async () => { await aPage.close(); }); - test('dokan settings menu page is rendering properly @lite @explo', async () => { - await settingsPage.dokanSettingsRenderProperly(); + test('dokan settings menu page is rendering properly @lite @exp @a', async () => { + await admin.dokanSettingsRenderProperly(); }); - test('admin can scroll to top on settings @lite', async () => { - await settingsPage.scrollToTopSettings(); + test('admin can scroll to top on settings @lite @a', async () => { + await admin.scrollToTopSettings(); }); - test('admin can search settings @lite', async () => { - await settingsPage.searchSettings('Selling Options'); + test('admin can search settings @lite @a', async () => { + await admin.searchSettings('Selling Options'); }); // dokan settings - test('admin can set dokan general settings @lite', async () => { - await settingsPage.setDokanGeneralSettings(data.dokanSettings.general); + test('admin can set dokan general settings @lite @a', async () => { + await admin.setDokanGeneralSettings(data.dokanSettings.general); }); - test('admin can set dokan selling settings @lite', async () => { - await settingsPage.setDokanSellingSettings(data.dokanSettings.selling); + test('admin can set dokan selling settings @lite @a', async () => { + await admin.setDokanSellingSettings(data.dokanSettings.selling); }); - test('admin can set dokan withdraw settings @lite', async () => { - await settingsPage.setDokanWithdrawSettings(data.dokanSettings.withdraw); + test('admin can set dokan withdraw settings @lite @a', async () => { + await admin.setDokanWithdrawSettings(data.dokanSettings.withdraw); }); - test('admin can set dokan reverse withdraw settings @lite', async () => { - await settingsPage.setDokanReverseWithdrawSettings(data.dokanSettings.reverseWithdraw); + test('admin can set dokan reverse withdraw settings @lite @a', async () => { + await admin.setDokanReverseWithdrawSettings(data.dokanSettings.reverseWithdraw); }); - test('admin can set dokan page settings @lite', async () => { - await settingsPage.setPageSettings(data.dokanSettings.page); + test('admin can set dokan page settings @lite @a', async () => { + await admin.setPageSettings(data.dokanSettings.page); }); - test('admin can set dokan appearance settings @lite', async () => { - await settingsPage.setDokanAppearanceSettings(data.dokanSettings.appearance); + test('admin can set dokan appearance settings @lite @a', async () => { + await admin.setDokanAppearanceSettings(data.dokanSettings.appearance); }); - test('admin can set dokan privacy policy settings @lite', async () => { + test('admin can set dokan privacy policy settings @lite @a', async () => { const privacyPolicySettings = await dbUtils.getDokanSettings(dbData.dokan.optionName.privacyPolicy); - await settingsPage.setDokanPrivacyPolicySettings({ ...data.dokanSettings.privacyPolicy, privacyPage: privacyPolicySettings.privacyPage }); + await admin.setDokanPrivacyPolicySettings({ ...data.dokanSettings.privacyPolicy, privacyPage: privacyPolicySettings.privacyPage }); }); - test('admin can set dokan color settings @pro', async () => { - await settingsPage.setDokanColorSettings(data.dokanSettings.colors); + test('admin can set dokan color settings @pro @a', async () => { + await admin.setDokanColorSettings(data.dokanSettings.colors); }); - test('admin can set dokan live search settings @pro', async () => { - await settingsPage.setDokanLiveSearchSettings(data.dokanSettings.liveSearch); + test('admin can set dokan live search settings @pro @a', async () => { + await admin.setDokanLiveSearchSettings(data.dokanSettings.liveSearch); }); - test('admin can set dokan store support settings @pro', async () => { - await settingsPage.setDokanStoreSupportSettings(data.dokanSettings.storeSupport); + test('admin can set dokan store support settings @pro @a', async () => { + await admin.setDokanStoreSupportSettings(data.dokanSettings.storeSupport); }); - test('admin can set dokan email verification settings @pro', async () => { - await settingsPage.setDokanEmailVerificationSettings(data.dokanSettings.emailVerification); + test('admin can set dokan email verification settings @pro @a', async () => { + await admin.setDokanEmailVerificationSettings(data.dokanSettings.emailVerification); // reset settings await dbUtils.setDokanSettings(dbData.dokan.optionName.emailVerification, dbData.dokan.emailVerificationSettings); }); - test('admin can set dokan shipping status settings @pro', async () => { - await settingsPage.setDokanShippingStatusSettings(data.dokanSettings.shippingStatus); + test('admin can set dokan shipping status settings @pro @a', async () => { + await admin.setDokanShippingStatusSettings(data.dokanSettings.shippingStatus); }); - test('admin can set dokan quote settings @pro', async () => { - await settingsPage.setDokanQuoteSettings(data.dokanSettings.quote); + test('admin can set dokan quote settings @pro @a', async () => { + await admin.setDokanQuoteSettings(data.dokanSettings.quote); }); - test('admin can set dokan rma settings @pro', async () => { - await settingsPage.setDokanRmaSettings(data.dokanSettings.rma); + test('admin can set dokan rma settings @pro @a', async () => { + await admin.setDokanRmaSettings(data.dokanSettings.rma); }); - test('admin can set dokan wholesale settings @pro', async () => { - await settingsPage.setDokanWholesaleSettings(data.dokanSettings.wholesale); + test('admin can set dokan wholesale settings @pro @a', async () => { + await admin.setDokanWholesaleSettings(data.dokanSettings.wholesale); }); - test('admin can set dokan eu compliance settings @pro', async () => { - await settingsPage.setDokanEuComplianceSettings(data.dokanSettings.euCompliance); + test('admin can set dokan eu compliance settings @pro @a', async () => { + await admin.setDokanEuComplianceSettings(data.dokanSettings.euCompliance); }); - test('admin can set dokan delivery time settings @pro', async () => { - await settingsPage.setDokanDeliveryTimeSettings(data.dokanSettings.deliveryTime); + test('admin can set dokan delivery time settings @pro @a', async () => { + await admin.setDokanDeliveryTimeSettings(data.dokanSettings.deliveryTime); }); - test('admin can set dokan product advertising settings @pro', async () => { - await settingsPage.setDokanProductAdvertisingSettings(data.dokanSettings.productAdvertising); + test('admin can set dokan product advertising settings @pro @a', async () => { + await admin.setDokanProductAdvertisingSettings(data.dokanSettings.productAdvertising); }); - test('admin can set dokan geolocation settings @pro', async () => { - await settingsPage.setDokanGeolocationSettings(data.dokanSettings.geolocation); + test('admin can set dokan geolocation settings @pro @a', async () => { + await admin.setDokanGeolocationSettings(data.dokanSettings.geolocation); }); - test('admin can set dokan product report abuse settings @pro', async () => { - await settingsPage.setDokanProductReportAbuseSettings(data.dokanSettings.productReportAbuse); + test('admin can set dokan product report abuse settings @pro @a', async () => { + await admin.setDokanProductReportAbuseSettings(data.dokanSettings.productReportAbuse); }); - test('admin can set dokan spmv settings @pro', async () => { - await settingsPage.setDokanSpmvSettings(data.dokanSettings.spmv); + test('admin can set dokan spmv settings @pro @a', async () => { + await admin.setDokanSpmvSettings(data.dokanSettings.spmv); }); - test('admin can set dokan vendor subscription settings @pro', async () => { - await settingsPage.setDokanVendorSubscriptionSettings(data.dokanSettings.vendorSubscription); + test('admin can set dokan vendor subscription settings @pro @a', async () => { + await admin.setDokanVendorSubscriptionSettings(data.dokanSettings.vendorSubscription); await dbUtils.setDokanSettings(dbData.dokan.optionName.vendorSubscription, dbData.dokan.vendorSubscriptionSettings); }); }); diff --git a/tests/pw/tests/e2e/shop.spec.ts b/tests/pw/tests/e2e/shop.spec.ts index a67e1b08f9..cd4709fda2 100644 --- a/tests/pw/tests/e2e/shop.spec.ts +++ b/tests/pw/tests/e2e/shop.spec.ts @@ -1,20 +1,15 @@ import { test, Page } from '@playwright/test'; import { ShopPage } from '@pages/shopPage'; -// import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; -// import { payloads } from '@utils/payloads'; test.describe('Shop functionality test', () => { let customer: ShopPage; let cPage: Page; - // let apiUtils: ApiUtils; test.beforeAll(async ({ browser }) => { const customerContext = await browser.newContext(data.auth.customerAuth); cPage = await customerContext.newPage(); customer = new ShopPage(cPage); - - // apiUtils = new ApiUtils(request); }); test.afterAll(async () => { @@ -23,32 +18,31 @@ test.describe('Shop functionality test', () => { // shop page - test('shop page is rendering properly @lite @explo', async () => { + test('shop page is rendering properly @lite @exp @c', async () => { await customer.shopRenderProperly(); }); - test('customer can sort products @lite', async () => { + test('customer can sort products @lite @c', async () => { await customer.sortProducts('price'); }); - test('customer can search product @lite', async () => { + test('customer can search product @lite @c', async () => { await customer.searchProduct(data.predefined.simpleProduct.product1.name); }); - test('customer can filter products by category @pro', async () => { + test('customer can filter products by category @pro @c', async () => { await customer.filterProducts('by-category', 'uncategorized'); }); - test('customer can filter products by location @pro', async () => { + test('customer can filter products by location @pro @c', async () => { await customer.filterProducts('by-location', 'New York, NY, USA'); }); - test('customer can view products on map @pro', async () => { + test('customer can view products list on map @pro @c', async () => { await customer.productOnMap(); - // await customer.productOnMap(data.predefined.simpleProduct.product1.name); }); - test('customer can go to product details from shop @lite', async () => { + test('customer can go to product details from shop @lite @c', async () => { await customer.goToProductDetailsFromShop(data.predefined.simpleProduct.product1.name); }); }); diff --git a/tests/pw/tests/e2e/singleProduct.spec.ts b/tests/pw/tests/e2e/singleProduct.spec.ts index 20c94c20d8..02e5e722a8 100644 --- a/tests/pw/tests/e2e/singleProduct.spec.ts +++ b/tests/pw/tests/e2e/singleProduct.spec.ts @@ -1,19 +1,15 @@ import { test, Page } from '@playwright/test'; import { SingleProductPage } from '@pages/singleProductPage'; -// import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; -// import { payloads } from '@utils/payloads'; test.describe('Single product functionality test', () => { let customer: SingleProductPage; let cPage: Page; - // let apiUtils: ApiUtils; test.beforeAll(async ({ browser }) => { const customerContext = await browser.newContext(data.auth.customerAuth); cPage = await customerContext.newPage(); customer = new SingleProductPage(cPage); - // apiUtils = new ApiUtils(request); }); test.afterAll(async () => { @@ -22,35 +18,35 @@ test.describe('Single product functionality test', () => { // single product page - test('single product is rendering properly @lite @explo', async () => { + test('single product is rendering properly @lite @exp @c', async () => { await customer.singleProductRenderProperly(data.predefined.simpleProduct.product1.name); }); - test('customer can view highlighted vendor info @lite', async () => { + test('customer can view highlighted vendor info @lite @c', async () => { await customer.viewHighlightedVendorInfo(data.predefined.simpleProduct.product1.name); }); - test('customer can view product vendor info @lite', async () => { + test('customer can view product vendor info @lite @c', async () => { await customer.productVendorInfo(data.predefined.simpleProduct.product1.name); }); - test('customer can view product location @pro', async () => { + test('customer can view product location @pro @c', async () => { await customer.productLocation(data.predefined.simpleProduct.product1.name); }); - test('customer can view product warranty policy @pro', async () => { + test('customer can view product warranty policy @pro @c', async () => { await customer.productWarrantyPolicy(data.predefined.simpleProduct.product1.name); }); - test('customer can view more products @lite', async () => { + test('customer can view more products @lite @c', async () => { await customer.viewMoreProducts(data.predefined.simpleProduct.product1.name); }); - test('customer can view related products @lite', async () => { + test('customer can view related products @lite @c', async () => { await customer.viewRelatedProducts(data.predefined.simpleProduct.product1.name); }); - test('customer can review product @lite', async () => { + test('customer can review product @lite @c', async () => { await customer.reviewProduct(data.predefined.simpleProduct.product1.name, data.product.review); }); }); diff --git a/tests/pw/tests/e2e/singleStore.spec.ts b/tests/pw/tests/e2e/singleStore.spec.ts index cd3eea9327..8b52a10638 100644 --- a/tests/pw/tests/e2e/singleStore.spec.ts +++ b/tests/pw/tests/e2e/singleStore.spec.ts @@ -1,19 +1,15 @@ import { test, Page } from '@playwright/test'; import { SingleStorePage } from '@pages/singleStorePage'; -// import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; -// import { payloads } from '@utils/payloads'; test.describe('Single store functionality test', () => { let customer: SingleStorePage; let cPage: Page; - // let apiUtils: ApiUtils; test.beforeAll(async ({ browser }) => { const customerContext = await browser.newContext(data.auth.customerAuth); cPage = await customerContext.newPage(); customer = new SingleStorePage(cPage); - // apiUtils = new ApiUtils(request); }); test.afterAll(async () => { @@ -22,29 +18,29 @@ test.describe('Single store functionality test', () => { // single store page - test('dokan single store page is rendering properly @lite @explo', async () => { + test('dokan single store page is rendering properly @lite @exp @c', async () => { await customer.singleStoreRenderProperly(data.predefined.vendorStores.vendor1); }); - // test.skip('customer can view store open-close time on single store @lite', async ( ) => { - // // todo: pre: need store open close - // await customer.storeOpenCloseTime(data.predefined.vendorStores.vendor1); - // }); + test.skip('customer can view store open-close time on single store @lite @c', async () => { + // todo: pre: need store open close time + await customer.storeOpenCloseTime(data.predefined.vendorStores.vendor1); + }); - test('customer can search product on single store @lite', async () => { + test('customer can search product on single store @lite @c', async () => { await customer.singleStoreSearchProduct(data.predefined.vendorStores.vendor1, data.predefined.simpleProduct.product1.name); }); - test('customer can sort products on single store @lite', async () => { + test('customer can sort products on single store @lite @c', async () => { await customer.singleStoreSortProducts(data.predefined.vendorStores.vendor1, 'price'); }); - // test.skip('customer can view store terms and conditions @lite', async ( ) => { - // // todo: pre need toc on store and admin settings - // await customer.storeTermsAndCondition(data.predefined.vendorStores.vendor1, data.vendor.toc); - // }); + test.skip('customer can view store terms and conditions @lite @c', async () => { + // todo: pre need toc on store and admin settings + await customer.storeTermsAndCondition(data.predefined.vendorStores.vendor1, data.vendor.toc); + }); - test('customer can share store @pro', async () => { + test('customer can share store @pro @c', async () => { await customer.storeShare(data.predefined.vendorStores.vendor1, data.storeShare.facebook); }); }); diff --git a/tests/pw/tests/e2e/spmv.spec.ts b/tests/pw/tests/e2e/spmv.spec.ts index da62206f31..775fadf16d 100644 --- a/tests/pw/tests/e2e/spmv.spec.ts +++ b/tests/pw/tests/e2e/spmv.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { SpmvPage } from '@pages/spmvPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; @@ -13,10 +13,10 @@ test.describe('Vendor SPMV test', () => { let aPage: Page, vPage: Page, cPage: Page; let apiUtils: ApiUtils; let productName: string; - let productName1: string; + let productName2: string; let productId: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new SpmvPage(aPage); @@ -29,10 +29,10 @@ test.describe('Vendor SPMV test', () => { cPage = await customerContext.newPage(); customer = new SpmvPage(cPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, enable_min_max_quantity: 'off', enable_min_max_amount: 'off' }); // todo: might exists dokan issue -> min-max field is required on admin product edit [, , productName] = await apiUtils.createProduct({ ...payloads.createProduct(), name: data.predefined.spmv.productName() }, payloads.vendor2Auth); - [, productId, productName1] = await apiUtils.createProduct({ ...payloads.createProduct(), name: data.predefined.spmv.productName() }, payloads.vendor2Auth); + [, productId, productName2] = await apiUtils.createProduct({ ...payloads.createProduct(), name: data.predefined.spmv.productName() }, payloads.vendor2Auth); await apiUtils.addSpmvProductToStore(productId, payloads.vendorAuth); }); @@ -41,67 +41,71 @@ test.describe('Vendor SPMV test', () => { await aPage.close(); await vPage.close(); await cPage.close(); + await apiUtils.dispose(); }); - test('admin can assign SPMV product to other vendor @pro', async () => { + test('admin can assign SPMV product to other vendor @pro @a', async () => { + test.skip(true, 'test is failing for woocommerce booking v2.0.8'); const [, productId] = await apiUtils.createProduct({ ...payloads.createProduct(), name: data.predefined.spmv.productName() }, payloads.vendor2Auth); await admin.assignSpmvProduct(productId, data.predefined.vendorStores.vendor1); }); - test('vendor spmv menu page is rendering properly @pro @explo', async () => { + //vendor + + test('vendor spmv menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorSpmvRenderProperly(); }); - test('vendor can search similar product on spmv page @pro', async () => { + test('vendor can search similar product on spmv page @pro @v', async () => { await vendor.searchSimilarProduct(productName, 'spmv'); }); - test('vendor can search similar product on product popup @pro', async () => { + test('vendor can search similar product on product popup @pro @v', async () => { await vendor.searchSimilarProduct(productName, 'popup'); }); - test('vendor can search similar booking product @pro', async () => { + test('vendor can search similar booking product @pro @v', async () => { const [, , bookableProductName] = await apiUtils.createBookableProduct(payloads.createBookableProduct(), payloads.vendor2Auth); await vendor.searchSimilarProduct(bookableProductName, 'booking'); }); - test('vendor can search similar auction product @pro', async () => { + test('vendor can search similar auction product @pro @v', async () => { const [, , auctionProductName] = await apiUtils.createProduct(payloads.createAuctionProduct(), payloads.vendor2Auth); await vendor.searchSimilarProduct(auctionProductName, 'auction'); }); - test('vendor can go to own product edit from spmv page @pro', async () => { - await vendor.goToProductEditFromSPMV(data.predefined.simpleProduct.product1.name); + test('vendor can go to own product edit from spmv page @pro @v', async () => { + await vendor.goToProductEditFromSpmv(data.predefined.simpleProduct.product1.name); }); - test('vendor can sort spmv products @pro', async () => { + test('vendor can sort spmv products @pro @v', async () => { await vendor.sortSpmvProduct('price'); }); - test('vendor can clone product @pro', async () => { + test('vendor can clone product @pro @v', async () => { await vendor.cloneProduct(productName); }); - test('vendor can clone product via sell item button @pro', async () => { + test('vendor can clone product via sell item button @pro @v', async () => { const [, , productName] = await apiUtils.createProduct({ ...payloads.createProduct(), name: data.predefined.spmv.productName() }, payloads.vendor2Auth); await vendor.cloneProductViaSellItemButton(productName); }); // customer - test('customer can view other available vendors @pro', async () => { - await customer.viewOtherAvailableVendors(productName1); + test('customer can view other available vendors @pro @c', async () => { + await customer.viewOtherAvailableVendors(productName2); }); - test('customer can view other available vendor @pro', async () => { - await customer.viewOtherAvailableVendor(productName1, data.predefined.vendorStores.vendor1); + test('customer can view other available vendor @pro @c', async () => { + await customer.viewOtherAvailableVendor(productName2, data.predefined.vendorStores.vendor1); }); - test('customer can view other available vendor product @pro', async () => { - await customer.viewOtherAvailableVendorProduct(productName1, data.predefined.vendorStores.vendor1); + test('customer can view other available vendor product @pro @c', async () => { + await customer.viewOtherAvailableVendorProduct(productName2, data.predefined.vendorStores.vendor1); }); - test('customer can add to cart other available vendor product @pro', async () => { - await customer.addToCartOtherAvailableVendorsProduct(productName1, data.predefined.vendorStores.vendor1); + test('customer can add to cart other available vendor product @pro @c', async () => { + await customer.addToCartOtherAvailableVendorsProduct(productName2, data.predefined.vendorStores.vendor1); }); }); diff --git a/tests/pw/tests/e2e/storeAppearance.spec.ts b/tests/pw/tests/e2e/storeAppearance.spec.ts index cc2e2409d1..535d4078eb 100644 --- a/tests/pw/tests/e2e/storeAppearance.spec.ts +++ b/tests/pw/tests/e2e/storeAppearance.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { StoreAppearance } from '@pages/storeAppearance'; import { CustomerPage } from '@pages/customerPage'; import { ApiUtils } from '@utils/apiUtils'; @@ -15,32 +15,33 @@ test.describe.skip('Store Appearance test', () => { // todo: need to remove default dokan store sidebar content - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const customerContext = await browser.newContext(data.auth.customerAuth); cPage = await customerContext.newPage(); customerPage = new CustomerPage(cPage); customer = new StoreAppearance(cPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); privacyPolicySettings = await dbUtils.getDokanSettings(dbData.dokan.optionName.privacyPolicy); }); test.afterAll(async () => { await dbUtils.setDokanSettings(dbData.dokan.optionName.appearance, dbData.dokan.appearanceSettings); await cPage.close(); + await apiUtils.dispose(); }); - test('store map is disabled on store sidebar @lite', async () => { + test('store map is disabled on store sidebar @lite @c', async () => { await dbUtils.setDokanSettings(dbData.dokan.optionName.appearance, { ...dbData.dokan.appearanceSettings, store_map: 'off' }); await customer.disableMapOnStoreSidebar(data.predefined.vendorStores.vendor1); }); - test('store open-close time is disabled store sidebar @lite', async () => { + test('store open-close time is disabled store sidebar @lite @c', async () => { await dbUtils.setDokanSettings(dbData.dokan.optionName.appearance, { ...dbData.dokan.appearanceSettings, store_open_close: 'off' }); await customer.disableStoreOpenCloseTimeOnStoreSidebar(data.predefined.vendorStores.vendor1); }); - test.skip('vendor info is disabled on single store page @lite', async () => { + test.skip('vendor info is disabled on single store page @lite @c', async () => { // todo: need to fix console.log(await dbUtils.getDokanSettings(dbData.dokan.optionName.appearance)); await dbUtils.setDokanSettings(dbData.dokan.optionName.appearance, { diff --git a/tests/pw/tests/e2e/storeCategories.spec.ts b/tests/pw/tests/e2e/storeCategories.spec.ts index 31378dcf33..6777680c03 100644 --- a/tests/pw/tests/e2e/storeCategories.spec.ts +++ b/tests/pw/tests/e2e/storeCategories.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { StoreCategoriesPage } from '@pages/storeCategoriesPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; @@ -11,7 +11,7 @@ test.describe('Store categories test', () => { let apiUtils: ApiUtils; let categoryName: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new StoreCategoriesPage(aPage); @@ -20,45 +20,48 @@ test.describe('Store categories test', () => { vPage = await vendorContext.newPage(); vendor = new StoreCategoriesPage(vPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); [, , categoryName] = await apiUtils.createStoreCategory(payloads.createStoreCategory(), payloads.adminAuth); }); test.afterAll(async () => { await aPage.close(); await vPage.close(); + await apiUtils.dispose(); }); // store categories - test('admin store category page is rendering properly @pro @explo', async () => { + test('admin store category page is rendering properly @pro @exp @a', async () => { await admin.adminStoreCategoryRenderProperly(); }); - test('admin can add store category @pro', async () => { + test('admin can add store category @pro @a', async () => { await admin.addStoreCategory(data.storeCategory()); }); - test('admin can search store category @pro', async () => { + test('admin can search store category @pro @a', async () => { await admin.searchStoreCategory(categoryName); }); - test('admin can edit store category @pro', async () => { + test('admin can edit store category @pro @a', async () => { await admin.editStoreCategory({ ...data.storeCategory(), name: categoryName }); }); - test('admin can set default store category @pro', async () => { + test('admin can set default store category @pro @a', async () => { await admin.updateStoreCategory(categoryName, 'set-default'); // reset default category await apiUtils.setDefaultStoreCategory('Uncategorized', payloads.adminAuth); }); - test('admin can delete store category @pro', async () => { + test('admin can delete store category @pro @a', async () => { + const [, , categoryName] = await apiUtils.createStoreCategory(payloads.createStoreCategory(), payloads.adminAuth); await admin.updateStoreCategory(categoryName, 'delete'); }); - test('vendor can update own store category @pro', async () => { - const [, , categoryName] = await apiUtils.createStoreCategory(payloads.createStoreCategory(), payloads.adminAuth); + test('vendor can update own store category @pro @v', async () => { await vendor.vendorUpdateStoreCategory(categoryName); }); + + // todo: add multi store category tests }); diff --git a/tests/pw/tests/e2e/storeReviews.spec.ts b/tests/pw/tests/e2e/storeReviews.spec.ts index 4e4732aa97..4a87ce0c29 100644 --- a/tests/pw/tests/e2e/storeReviews.spec.ts +++ b/tests/pw/tests/e2e/storeReviews.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { StoreReviewsPage } from '@pages/storeReviewsPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; @@ -13,7 +13,7 @@ test.describe('Store Reviews test', () => { let aPage: Page, vPage: Page, cPage: Page; let apiUtils: ApiUtils; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new StoreReviewsPage(aPage); @@ -26,7 +26,7 @@ test.describe('Store Reviews test', () => { cPage = await customerContext.newPage(); customer = new StoreReviewsPage(cPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); await apiUtils.updateBatchStoreReviews('trash', [], payloads.adminAuth); await apiUtils.createStoreReview(VENDOR_ID, payloads.createStoreReview, payloads.customerAuth); @@ -38,58 +38,59 @@ test.describe('Store Reviews test', () => { await aPage.close(); await vPage.close(); await cPage.close(); + await apiUtils.dispose(); }); - test('dokan store reviews menu page is rendering properly @pro @explo', async () => { + test('dokan store reviews menu page is rendering properly @pro @exp @a', async () => { await admin.adminStoreReviewsRenderProperly(); }); - test('admin can view store review @pro @explo', async () => { + test('admin can view store review @pro @exp @a', async () => { await admin.viewStoreReview(); }); - test('admin can edit store review @pro', async () => { + test('admin can edit store review @pro @a', async () => { await admin.editStoreReview(data.storeReview.review()); }); - test('admin can filter store reviews by vendor @pro', async () => { + test('admin can filter store reviews by vendor @pro @a', async () => { await admin.filterStoreReviews(data.storeReview.filter.byVendor); }); - test('admin can delete store review @pro', async () => { - await admin.deleteStoreReview(); + test('admin can delete store review @pro @a', async () => { + await admin.updateStoreReview('trash'); }); - test('admin can restore deleted store review @pro', async () => { - await admin.restoreStoreReview(); + test('admin can restore deleted store review @pro @a', async () => { + await admin.updateStoreReview('permanently-delete'); }); - test('admin can permanently delete store review @pro', async () => { - await admin.permanentlyDeleteStoreReview(); + test('admin can permanently delete store review @pro @a', async () => { + await admin.updateStoreReview('restore'); }); - test('admin can perform store reviews bulk action @pro', async () => { + test('admin can perform store reviews bulk action @pro @a', async () => { await apiUtils.createStoreReview(VENDOR_ID, payloads.createStoreReview, payloads.customerAuth); await admin.storeReviewsBulkAction('trash'); }); - test('customer can review store @pro', async () => { + test('customer can review store @pro @c', async () => { // remove any previous reviews await apiUtils.updateBatchStoreReviews('trash', [], payloads.adminAuth); await customer.reviewStore(data.predefined.vendorStores.vendor1, data.storeReview.review(), 'create'); }); - test('customer can edit store review @pro', async () => { + test('customer can edit store review @pro @c', async () => { await customer.reviewStore(data.predefined.vendorStores.vendor1, data.storeReview.review(), 'edit'); }); - test('customer can view own review @pro', async () => { + test('customer can view own review @pro @c', async () => { await apiUtils.updateBatchStoreReviews('trash', [], payloads.adminAuth); await apiUtils.createStoreReview(VENDOR_ID, payloads.createStoreReview, payloads.customerAuth); await customer.viewOwnReview(data.predefined.vendorStores.vendor1); }); - test("vendor can't review own store @pro", async () => { + test("vendor can't review own store @pro @v", async () => { await vendor.cantReviewOwnStore(data.predefined.vendorStores.vendor1); }); }); diff --git a/tests/pw/tests/e2e/storeSupports.spec.ts b/tests/pw/tests/e2e/storeSupports.spec.ts index 0eea0deb5d..4aa0c9a296 100644 --- a/tests/pw/tests/e2e/storeSupports.spec.ts +++ b/tests/pw/tests/e2e/storeSupports.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { StoreSupportsPage } from '@pages/storeSupportsPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; @@ -12,74 +12,79 @@ test.describe('Store Support test (admin)', () => { let aPage: Page; let apiUtils: ApiUtils; let supportTicketId: string; - let closedSupportTicketId: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new StoreSupportsPage(aPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); [, supportTicketId] = await apiUtils.createSupportTicket({ ...payloads.createSupportTicket, author: CUSTOMER_ID, meta: { store_id: VENDOR_ID } }); - [, closedSupportTicketId] = await apiUtils.createSupportTicket({ ...payloads.createSupportTicket, status: 'closed', author: CUSTOMER_ID, meta: { store_id: VENDOR_ID } }); }); test.afterAll(async () => { await aPage.close(); + await apiUtils.dispose(); }); - test('dokan store support menu page is rendering properly @pro @explo', async () => { + //admin + + test('dokan store support menu page is rendering properly @pro @exp @a', async () => { await admin.adminStoreSupportRenderProperly(); }); - test('unread count decrease after admin viewing a support ticket @pro', async () => { + test('unread count decrease after admin viewing a support ticket @pro @a', async () => { await admin.decreaseUnreadSupportTicketCount(supportTicketId); }); - test('admin can view support ticket details @pro @explo', async () => { + test('admin can view support ticket details @pro @exp @a', async () => { await admin.adminViewSupportTicketDetails(supportTicketId); }); - test('admin can search support ticket @pro', async () => { + test('admin can search support ticket by ticket id @pro @a', async () => { await admin.searchSupportTicket(supportTicketId); - // await admin.searchSupportTicket(data.storeSupport.title); // todo: }); - test('admin can filter support tickets by vendor @pro', async () => { + test('admin can search support ticket by ticket title @pro @a', async () => { + await admin.searchSupportTicket(data.storeSupport.title); + }); + + test('admin can filter support tickets by vendor @pro @a', async () => { await admin.filterSupportTickets(data.storeSupport.filter.byVendor, 'by-vendor'); }); - test('admin can filter support tickets by customer @pro', async () => { + test('admin can filter support tickets by customer @pro @a', async () => { await admin.filterSupportTickets(data.storeSupport.filter.byCustomer, 'by-customer'); }); - test('admin can reply to support ticket as admin @pro', async () => { + test('admin can reply to support ticket as admin @pro @a', async () => { await admin.replySupportTicket(supportTicketId, data.storeSupport.chatReply.asAdmin); }); - test('admin can reply to support ticket as vendor @pro', async () => { + test('admin can reply to support ticket as vendor @pro @a', async () => { await admin.replySupportTicket(supportTicketId, data.storeSupport.chatReply.asVendor); }); - test('admin can disable support ticket email notification @pro', async () => { - // await apiUtils.updateSupportTicketEmailNotification(supportTicketId, { notification: true, }, payloads.adminAuth); + test('admin can disable support ticket email notification @pro @a', async () => { await admin.updateSupportTicketEmailNotification(supportTicketId, 'disable'); }); - test('admin can enable support ticket email notification @pro', async () => { + test('admin can enable support ticket email notification @pro @a', async () => { + const [, supportTicketId] = await apiUtils.createSupportTicket({ ...payloads.createSupportTicket, author: CUSTOMER_ID, meta: { store_id: VENDOR_ID } }); await apiUtils.updateSupportTicketEmailNotification(supportTicketId, { notification: false }, payloads.adminAuth); await admin.updateSupportTicketEmailNotification(supportTicketId, 'enable'); }); - test('admin can close support ticket @pro', async () => { + test('admin can close support ticket @pro @a', async () => { await admin.closeSupportTicket(supportTicketId); }); - test('admin can reopen closed support ticket @pro', async () => { + test('admin can reopen closed support ticket @pro @a', async () => { + const [, closedSupportTicketId] = await apiUtils.createSupportTicket({ ...payloads.createSupportTicket, status: 'closed', author: CUSTOMER_ID, meta: { store_id: VENDOR_ID } }); await admin.reopenSupportTicket(closedSupportTicketId); }); - test('admin can perform store support bulk action @pro', async () => { + test('admin can perform store support bulk action @pro @a', async () => { const [, supportTicketId] = await apiUtils.createSupportTicket({ ...payloads.createSupportTicket, author: CUSTOMER_ID, meta: { store_id: VENDOR_ID } }); await admin.storeSupportBulkAction('close', supportTicketId); }); @@ -88,74 +93,71 @@ test.describe('Store Support test (admin)', () => { test.describe('Store Support test (customer)', () => { let customer: StoreSupportsPage; let guest: StoreSupportsPage; - let cPage: Page, uPage: Page; + let cPage: Page; let apiUtils: ApiUtils; let orderId: string; let responseBody: responseBody; let supportTicketId: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const customerContext = await browser.newContext(data.auth.customerAuth); cPage = await customerContext.newPage(); customer = new StoreSupportsPage(cPage); - const guestContext = await browser.newContext(data.auth.noAuth); - uPage = await guestContext.newPage(); - guest = new StoreSupportsPage(uPage); - - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); [, responseBody, orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, { ...payloads.createOrder, customer_id: CUSTOMER_ID }, data.order.orderStatus.completed, payloads.vendorAuth); [, supportTicketId] = await apiUtils.createSupportTicket({ ...payloads.createSupportTicket, author: CUSTOMER_ID, meta: { store_id: VENDOR_ID, order_id: orderId } }); }); test.afterAll(async () => { await cPage.close(); - await uPage.close(); + await apiUtils.dispose(); }); - test('customer store support menu page is rendering properly @pro @explo', async () => { + test('customer store support menu page is rendering properly @pro @exp @c', async () => { await customer.customerStoreSupportRenderProperly(); }); - test('customer can view support ticket details @pro @explo', async () => { + test('customer can view support ticket details @pro @exp @c', async () => { await customer.customerViewSupportTicketDetails(supportTicketId); }); - test('customer can ask for store support on single product @pro', async () => { + test('customer can ask for store support on single product @pro @c', async () => { await customer.storeSupport(data.predefined.simpleProduct.product1.name, data.customer.getSupport, 'product'); }); - test('customer can ask for store support on single store @pro', async () => { + test('customer can ask for store support on single store @pro @c', async () => { await customer.storeSupport(data.predefined.vendorStores.vendor1, data.customer.getSupport, 'store'); }); - test('customer can ask for store support on order details @pro', async () => { + test('customer can ask for store support on order details @pro @c', async () => { await customer.storeSupport(orderId, data.customer.getSupport, 'order'); }); - test('customer can ask for store support on order received @pro', async () => { + test('customer can ask for store support on order received @pro @c', async () => { const orderKey = responseBody.order_key; await customer.storeSupport(orderId + ',' + orderKey, data.customer.getSupport, 'order-received'); }); - test('customer can ask for store support for order @pro', async () => { + test('customer can ask for store support for order @pro @c', async () => { await customer.storeSupport(data.predefined.vendorStores.vendor1, { ...data.customer.getSupport, orderId: orderId }, 'store'); }); - test('customer can view reference order number on support ticket @pro', async () => { + test('customer can view reference order number on support ticket @pro @c', async () => { await customer.viewOrderReferenceNumberOnSupportTicket(supportTicketId, orderId); }); - test('customer can send message to support ticket @pro', async () => { + test('customer can send message to support ticket @pro @c', async () => { await customer.sendMessageToSupportTicket(supportTicketId, data.customer.supportTicket); }); - test("customer can't send message to closed support ticket @pro", async () => { + test("customer can't send message to closed support ticket @pro @c", async () => { const [, supportTicketId] = await apiUtils.createSupportTicket({ ...payloads.createSupportTicket, status: 'closed', author: CUSTOMER_ID, meta: { store_id: VENDOR_ID, order_id: orderId } }); await customer.cantSendMessageToSupportTicket(supportTicketId); }); - test('guest customer need to login before asking for store support @pro', async () => { + test('guest customer need to login before asking for store support @pro @g', async ({ page }) => { + guest = new StoreSupportsPage(page); await guest.storeSupport(data.predefined.vendorStores.vendor1, data.customer.getSupport, 'store'); }); }); @@ -166,62 +168,66 @@ test.describe('Store Support test (vendor)', () => { let apiUtils: ApiUtils; let supportTicketId: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const vendorContext = await browser.newContext(data.auth.vendorAuth); vPage = await vendorContext.newPage(); vendor = new StoreSupportsPage(vPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); [, supportTicketId] = await apiUtils.createSupportTicket({ ...payloads.createSupportTicket, author: CUSTOMER_ID, meta: { store_id: VENDOR_ID } }); await apiUtils.createSupportTicket({ ...payloads.createSupportTicket, status: 'closed', author: CUSTOMER_ID, meta: { store_id: VENDOR_ID } }); }); test.afterAll(async () => { await vPage.close(); + await apiUtils.dispose(); }); // vendor - test('vendor store support menu page is rendering properly @pro @explo', async () => { + test('vendor store support menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorStoreSupportRenderProperly(); }); - test('vendor can view support ticket details @pro @explo', async () => { + test('vendor can view support ticket details @pro @exp @v', async () => { await vendor.vendorViewSupportTicketDetails(supportTicketId); }); - test('vendor can filter support tickets by customer @pro', async () => { + test('vendor can filter support tickets by customer @pro @v', async () => { await vendor.vendorFilterSupportTickets('by-customer', data.storeSupport.filter.byCustomer); }); - test('vendor can filter support tickets by date range @pro', async () => { + test('vendor can filter support tickets by date range @pro @v', async () => { await vendor.vendorFilterSupportTickets('by-date', data.date.dateRange); }); - test('vendor can search support ticket @pro', async () => { + test('vendor can search support ticket by ticket id @pro @v', async () => { await vendor.vendorSearchSupportTicket('id', supportTicketId); - // await vendor.vendorSearchSupportTicket('title', data.storeSupport.title); // todo: separate or in same test }); - test('vendor can reply to support ticket @pro', async () => { + test('vendor can search support ticket by ticket title @pro @v', async () => { + await vendor.vendorSearchSupportTicket('title', data.storeSupport.title); + }); + + test('vendor can reply to support ticket @pro @v', async () => { await vendor.vendorReplySupportTicket(supportTicketId, data.storeSupport.chatReply.reply); }); - test('vendor can close support ticket @pro', async () => { + test('vendor can close support ticket @pro @v', async () => { await vendor.vendorCloseSupportTicket(supportTicketId); }); - test('vendor can reopen closed support ticket @pro', async () => { + test('vendor can reopen closed support ticket @pro @v', async () => { const [, closedSupportTicketId] = await apiUtils.createSupportTicket({ ...payloads.createSupportTicket, status: 'closed', author: CUSTOMER_ID, meta: { store_id: VENDOR_ID } }); await vendor.vendorReopenSupportTicket(closedSupportTicketId); }); - test('vendor can close support ticket with a chat reply @pro', async () => { + test('vendor can close support ticket with a chat reply @pro @v', async () => { const [, supportTicketId] = await apiUtils.createSupportTicket({ ...payloads.createSupportTicket, author: CUSTOMER_ID, meta: { store_id: VENDOR_ID } }); await vendor.vendorCloseSupportTicketWithReply(supportTicketId, 'closing this ticket'); }); - test('vendor can reopen closed support ticket with a chat reply @pro', async () => { + test('vendor can reopen closed support ticket with a chat reply @pro @v', async () => { const [, closedSupportTicketId] = await apiUtils.createSupportTicket({ ...payloads.createSupportTicket, status: 'closed', author: CUSTOMER_ID, meta: { store_id: VENDOR_ID } }); await vendor.vendorReopenSupportTicketWithReply(closedSupportTicketId, 'reopening this ticket'); }); diff --git a/tests/pw/tests/e2e/storelisting.spec.ts b/tests/pw/tests/e2e/storelisting.spec.ts index d2dee11efb..c40e22046c 100644 --- a/tests/pw/tests/e2e/storelisting.spec.ts +++ b/tests/pw/tests/e2e/storelisting.spec.ts @@ -1,19 +1,15 @@ import { test, Page } from '@playwright/test'; import { StoreListingPage } from '@pages/storeListingPage'; -// import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; -// import { payloads } from '@utils/payloads'; test.describe('Store listing functionality test', () => { let customer: StoreListingPage; let cPage: Page; - // let apiUtils: ApiUtils; test.beforeAll(async ({ browser }) => { const customerContext = await browser.newContext(data.auth.customerAuth); cPage = await customerContext.newPage(); customer = new StoreListingPage(cPage); - // apiUtils = new ApiUtils(request); }); test.afterAll(async () => { @@ -22,48 +18,47 @@ test.describe('Store listing functionality test', () => { // store listing - test('dokan store list page is rendering properly @lite @explo', async () => { + test('dokan store list page is rendering properly @lite @exp @c', async () => { await customer.storeListRenderProperly(); }); - test('customer can sort stores @lite', async () => { + test('customer can sort stores @lite @c', async () => { await customer.sortStores(data.storeList.sort); }); - test('customer can change store view layout @lite', async () => { + test('customer can change store view layout @lite @c', async () => { await customer.storeViewLayout(data.storeList.layout.list); }); - test('customer can search store @lite', async () => { + test('customer can search store @lite @c', async () => { await customer.searchStore(data.predefined.vendorStores.vendor1); }); - test('customer can filter stores by category @pro', async () => { + test('customer can filter stores by category @pro @c', async () => { await customer.filterStores('by-category', 'Uncategorized'); }); - test('customer can filter stores by location @pro', async () => { + test('customer can filter stores by location @pro @c', async () => { await customer.filterStores('by-location', 'New York, NY, USA'); }); - test.skip('customer can filter stores by ratings @pro', async () => { + test.skip('customer can filter stores by ratings @pro @c', async () => { await customer.filterStores('by-ratings', '1'); }); - test('customer can filter featured stores @pro', async () => { + test('customer can filter featured stores @pro @c', async () => { await customer.filterStores('featured'); }); - test.skip('customer can filter open now stores @pro', async () => { + test.skip('customer can filter open now stores @pro @c', async () => { await customer.filterStores('open-now'); }); - test('customer can view stores on map @pro', async () => { + test('customer can view stores on map @pro @c', async () => { await customer.storeOnMap(); - // await customer.storeOnMap(data.predefined.vendorStores.vendor1); }); - test('customer can go to single store from store list @lite', async () => { + test('customer can go to single store from store list @lite @c', async () => { await customer.goToSingleStoreFromStoreListing(data.predefined.vendorStores.vendor1); }); }); diff --git a/tests/pw/tests/e2e/stores.spec.ts b/tests/pw/tests/e2e/stores.spec.ts index 836e0b6d42..5ef2553583 100644 --- a/tests/pw/tests/e2e/stores.spec.ts +++ b/tests/pw/tests/e2e/stores.spec.ts @@ -1,72 +1,74 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { StoresPage } from '@pages/storesPage'; -// import { ApiUtils } from '@utils/apiUtils'; +import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; -// import { payloads } from '@utils/payloads'; +import { payloads } from '@utils/payloads'; const { VENDOR_ID } = process.env; test.describe('Stores test', () => { let admin: StoresPage; let aPage: Page; - // let apiUtils: ApiUtils; - // let storeName: string; + let apiUtils: ApiUtils; test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new StoresPage(aPage); - // apiUtils = new ApiUtils(request); - // [,, storeName] = await apiUtils.createStore(payloads.createStore()); + + apiUtils = new ApiUtils(await request.newContext()); }); test.afterAll(async () => { await aPage.close(); + await apiUtils.dispose(); }); // stores - test('admin vendors menu page is rendering properly @lite @explo', async () => { + test('admin vendors menu page is rendering properly @lite @exp @a', async () => { await admin.adminVendorsRenderProperly(); }); - test('admin can view vendor details @pro', async () => { + test('admin can view vendor details @pro @a', async () => { await admin.viewVendorDetails(VENDOR_ID); }); - test('admin can email vendor @pro', async () => { + test('admin can email vendor @pro @a', async () => { await admin.emailVendor(VENDOR_ID, data.vendor.vendorInfo.sendEmail); }); - test('admin can add vendor @lite', async () => { + test('admin can add vendor @lite @a', async () => { await admin.addVendor(data.vendor.vendorInfo); }); - test('admin can search vendors @lite', async () => { + test('admin can search vendors @lite @a', async () => { await admin.searchVendor(data.predefined.vendorStores.vendor1); }); - test("admin can disable vendor's selling capability @lite", async () => { - await admin.updateVendor(data.predefined.vendorStores.vendor1, 'disable'); + test("admin can disable vendor's selling capability @lite @a", async () => { + const [, , storeName] = await apiUtils.createStore(payloads.createStore(), payloads.adminAuth); + await admin.updateVendor(storeName, 'disable'); }); - test("admin can enable vendor's selling capability @lite", async () => { - await admin.updateVendor(data.predefined.vendorStores.vendor1, 'enable'); + test("admin can enable vendor's selling capability @lite @a", async () => { + const [, , storeName] = await apiUtils.createStore(payloads.createStore(), payloads.adminAuth); + await admin.updateVendor(storeName, 'enable'); }); - test('admin can edit vendor info @lite', async () => { + test('admin can edit vendor info @lite @a', async () => { await admin.editVendor(data.vendor); }); - test('admin can view vendor products @lite', async () => { + test('admin can view vendor products @lite @a', async () => { await admin.viewVendor(data.predefined.vendorStores.vendor1, 'products'); }); - test('admin can view vendor orders @lite', async () => { + test('admin can view vendor orders @lite @a', async () => { await admin.viewVendor(data.predefined.vendorStores.vendor1, 'orders'); }); - test('admin can perform vendor bulk actions @lite', async () => { + test('admin can perform vendor bulk actions @lite @a', async () => { await admin.vendorBulkAction('approved'); }); }); diff --git a/tests/pw/tests/e2e/tools.spec.ts b/tests/pw/tests/e2e/tools.spec.ts index fbc1367c29..7908c21f77 100644 --- a/tests/pw/tests/e2e/tools.spec.ts +++ b/tests/pw/tests/e2e/tools.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { ToolsPage } from '@pages/toolsPage'; import { ApiUtils } from '@utils/apiUtils'; import { payloads } from '@utils/payloads'; @@ -9,52 +9,54 @@ test.describe('Tools test', () => { let aPage: Page; let apiUtils: ApiUtils; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new ToolsPage(aPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); }); test.afterAll(async () => { await aPage.close(); + await apiUtils.dispose(); }); - test('dokan tools menu page is rendering properly @pro @explo', async () => { + test('dokan tools menu page is rendering properly @pro @exp @a', async () => { await admin.adminToolsRenderProperly(); }); - test.skip('admin can perform dokan page Installation @pro', async () => { + test.skip('admin can perform dokan page Installation @pro @a', async () => { await admin.dokanPageInstallation(); }); - test('admin can regenerate order commission @pro', async () => { + test('admin can regenerate order commission @pro @a', async () => { await admin.regenerateOrderCommission(); }); - test('admin can check for duplicate orders @pro', async () => { + test('admin can check for duplicate orders @pro @a', async () => { await admin.checkForDuplicateOrders(); }); - test('admin can set dokan setup wizard @lite', async () => { + test('admin can set dokan setup wizard @lite @a', async () => { await admin.setDokanSetupWizard(data.dokanSetupWizard); }); - test('admin can regenerate variable product variations author IDs @pro', async () => { + test('admin can regenerate variable product variations author IDs @pro @a', async () => { await admin.regenerateVariableProductVariationsAuthorIds(); }); - // test.skip('admin can import dummy data @pro', async ( ) => { - // await admin.importDummyData(); - // }); + test.skip('admin can import dummy data @pro', async () => { + // todo: need to fix + await admin.importDummyData(); + }); - test('admin can clear dummy data @pro', async () => { + test('admin can clear dummy data @pro @a', async () => { await apiUtils.importDummyData(payloads.dummyData, payloads.adminAuth); await admin.clearDummyData(); }); - test('admin can test distance matrix API @pro', async () => { + test('admin can test distance matrix API @pro @a', async () => { await admin.testDistanceMatrixApi(data.tools.distanceMatrixApi); }); }); diff --git a/tests/pw/tests/e2e/vendor.spec.ts b/tests/pw/tests/e2e/vendor.spec.ts index 19eb23651b..7d961f8785 100644 --- a/tests/pw/tests/e2e/vendor.spec.ts +++ b/tests/pw/tests/e2e/vendor.spec.ts @@ -1,72 +1,60 @@ import { test, Page } from '@playwright/test'; import { LoginPage } from '@pages/loginPage'; import { VendorPage } from '@pages/vendorPage'; -// import { ApiUtils } from '@utils/apiUtils'; +import { dbData } from '@utils/dbData'; +import { dbUtils } from '@utils/dbUtils'; import { data } from '@utils/testData'; -// import { payloads } from '@utils/payloads'; -test.describe('Vendor user functionality test1', () => { - test.use({ storageState: { cookies: [], origins: [] } }); - - let loginPage: LoginPage; - let vendorPage: VendorPage; - let page: Page; +test.describe('Vendor functionality test', () => { + let vendor: VendorPage; + let vPage: Page; test.beforeAll(async ({ browser }) => { - const context = await browser.newContext(); - page = await context.newPage(); - loginPage = new LoginPage(page); - vendorPage = new VendorPage(page); + const vendorContext = await browser.newContext(data.auth.vendorAuth); + vPage = await vendorContext.newPage(); + vendor = new VendorPage(vPage); }); test.afterAll(async () => { - await page.close(); + await vPage.close(); }); - test('vendor can register @lite', async () => { + test('vendor can register @lite @v', async ({ page }) => { + const vendorPage = new VendorPage(page); await vendorPage.vendorRegister(data.vendor.vendorInfo, { ...data.vendorSetupWizard, choice: false }); }); - test('vendor can login @lite', async () => { - await loginPage.login(data.vendor); + test('vendor can register (address fields are enabled) @lite @v', async ({ page }) => { + const vendorPage = new VendorPage(page); + await dbUtils.setDokanSettings(dbData.dokan.optionName.general, { ...dbData.dokan.generalSettings, enabled_address_on_reg: 'on' }); + await vendorPage.vendorRegister({ ...data.vendor.vendorInfo, addressFieldsEnabled: true }, { ...data.vendorSetupWizard, choice: false }); + await dbUtils.setDokanSettings(dbData.dokan.optionName.general, { ...dbData.dokan.generalSettings, enabled_address_on_reg: 'off' }); }); - test('vendor can logout @lite', async () => { + test('vendor can login @lite @v', async ({ page }) => { + const loginPage = new LoginPage(page); await loginPage.login(data.vendor); - await loginPage.logout(); - }); -}); - -test.describe('Vendor functionality test', () => { - let vendor: VendorPage; - let vPage: Page; - // let apiUtils: ApiUtils; - - test.beforeAll(async ({ browser }) => { - const vendorContext = await browser.newContext(data.auth.vendorAuth); - vPage = await vendorContext.newPage(); - vendor = new VendorPage(vPage); - - // apiUtils = new ApiUtils(request); }); - test.afterAll(async () => { - await vPage.close(); + test('vendor can logout @lite @v', async ({ page }) => { + const loginPage = new LoginPage(page); + await loginPage.login(data.vendor); + await loginPage.logout(); }); - test('vendor can setup setup-wizard @lite', async () => { + test('vendor can setup setup-wizard @lite @v', async () => { await vendor.vendorSetupWizard(data.vendorSetupWizard); }); - test('vendor account details menu page is rendering properly @lite @explo', async () => { + test('vendor account details menu page is rendering properly @lite @exp @v', async () => { await vendor.vendorAccountDetailsRenderProperly(); }); - test('vendor update account details @lite', async () => { + test('vendor update account details @lite @v', async () => { await vendor.addVendorDetails(data.vendor); }); - test('vendor can visit own Store @lite', async () => { + test('vendor can visit own Store @lite @v', async () => { await vendor.visitStore(data.predefined.vendorStores.vendor1); }); }); diff --git a/tests/pw/tests/e2e/vendorAnalytics.spec.ts b/tests/pw/tests/e2e/vendorAnalytics.spec.ts index 925dbd8395..f4c1b63ad0 100644 --- a/tests/pw/tests/e2e/vendorAnalytics.spec.ts +++ b/tests/pw/tests/e2e/vendorAnalytics.spec.ts @@ -5,7 +5,6 @@ import { data } from '@utils/testData'; test.describe('Vendor analytics test', () => { let vendor: VendorAnalyticsPage; let vPage: Page; - // let apiUtils: ApiUtils; test.beforeAll(async ({ browser }) => { const vendorContext = await browser.newContext(data.auth.vendorAuth); @@ -17,7 +16,7 @@ test.describe('Vendor analytics test', () => { await vPage.close(); }); - test('vendor analytics menu page is rendering properly @pro @explo', async () => { + test('vendor analytics menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorAnalyticsRenderProperly(); }); }); diff --git a/tests/pw/tests/e2e/vendorAuction.spec.ts b/tests/pw/tests/e2e/vendorAuction.spec.ts index c1b86b233f..dfa734037c 100644 --- a/tests/pw/tests/e2e/vendorAuction.spec.ts +++ b/tests/pw/tests/e2e/vendorAuction.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { AuctionsPage } from '@pages/vendorAuctionsPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; @@ -12,7 +12,7 @@ test.describe('Auction Product test', () => { let apiUtils: ApiUtils; let auctionProductName: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new AuctionsPage(aPage); @@ -25,7 +25,7 @@ test.describe('Auction Product test', () => { cPage = await customerContext.newPage(); customer = new AuctionsPage(cPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); [, , auctionProductName] = await apiUtils.createProduct(payloads.createAuctionProduct(), payloads.vendorAuth); await customer.bidAuctionProduct(auctionProductName); }); @@ -34,58 +34,59 @@ test.describe('Auction Product test', () => { await aPage.close(); await vPage.close(); await cPage.close(); + await apiUtils.dispose(); }); - test('admin can add auction product @pro', async () => { + test('admin can add auction product @pro @a', async () => { await admin.adminAddAuctionProduct(data.product.auction); }); - test('vendor auction menu page is rendering properly @pro @explo', async () => { + test('vendor auction menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorAuctionRenderProperly(); }); - test('vendor can add auction product @pro', async () => { + test('vendor can add auction product @pro @v', async () => { await vendor.addAuctionProduct({ ...data.product.auction, name: data.product.auction.productName() }); }); - test('vendor can edit auction product @pro', async () => { + test('vendor can edit auction product @pro @v', async () => { await vendor.editAuctionProduct({ ...data.product.auction, name: auctionProductName }); }); - test('vendor can view auction product @pro', async () => { + test('vendor can view auction product @pro @v', async () => { await vendor.viewAuctionProduct(auctionProductName); }); - test("vendor can't bid own product @pro", async () => { + test("vendor can't bid own product @pro @v", async () => { await vendor.cantBidOwnProduct(auctionProductName); }); - test('vendor can search auction product @pro', async () => { + test('vendor can search auction product @pro @v', async () => { await vendor.searchAuctionProduct(auctionProductName); }); - test('vendor can permanently delete auction product @pro', async () => { + test('vendor can permanently delete auction product @pro @v', async () => { const [, , auctionProductName] = await apiUtils.createProduct(payloads.createAuctionProduct(), payloads.vendorAuth); await vendor.deleteAuctionProduct(auctionProductName); }); - test('vendor auction activity page is rendering properly @pro @explo', async () => { + test('vendor auction activity page is rendering properly @pro @exp @v', async () => { await vendor.vendorAuctionActivityRenderProperly(); }); - test('vendor can filter auction activity @pro', async () => { + test('vendor can filter auction activity @pro @v', async () => { await vendor.filterAuctionActivity(data.date.dateRange); }); - test('vendor can search auction activity @pro', async () => { + test('vendor can search auction activity @pro @v', async () => { await vendor.searchAuctionActivity(data.customer.username); }); - test('customer can bid auction product @pro', async () => { + test('customer can bid auction product @pro @c', async () => { await customer.bidAuctionProduct(auctionProductName); }); - test.skip('customer can buy auction product with buy it now price @pro', async () => { + test.skip('customer can buy auction product with buy it now price @pro @c', async () => { const [, , auctionProductName] = await apiUtils.createProduct(payloads.createAuctionProduct(), payloads.vendorAuth); // todo: buy it now price is not saved by api await customer.buyAuctionProduct(auctionProductName); }); diff --git a/tests/pw/tests/e2e/vendorBooking.spec.ts b/tests/pw/tests/e2e/vendorBooking.spec.ts index 1476287faa..56fecf24c0 100644 --- a/tests/pw/tests/e2e/vendorBooking.spec.ts +++ b/tests/pw/tests/e2e/vendorBooking.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { BookingPage } from '@pages/vendorBookingPage'; import { ApiUtils } from '@utils/apiUtils'; import { payloads } from '@utils/payloads'; @@ -11,9 +11,8 @@ test.describe('Booking Product test', () => { let aPage: Page, vPage: Page, cPage: Page; let apiUtils: ApiUtils; let bookableProductName: string; - const bookingResourceName = data.product.booking.resource.resourceName(); - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new BookingPage(aPage); @@ -26,102 +25,107 @@ test.describe('Booking Product test', () => { cPage = await customerContext.newPage(); customer = new BookingPage(cPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); [, , bookableProductName] = await apiUtils.createBookableProduct(payloads.createBookableProduct(), payloads.vendorAuth); - await vendor.addBookingResource(bookingResourceName); // todo: convert with api or db }); test.afterAll(async () => { await aPage.close(); await vPage.close(); await cPage.close(); + await apiUtils.dispose(); }); - test('admin can add booking product @pro', async () => { + test('admin can add booking product @pro @a', async () => { await admin.adminAddBookingProduct(data.product.booking); }); - test('vendor booking menu page is rendering properly @pro @explo', async () => { + test('vendor booking menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorBookingRenderProperly(); }); - test('vendor manage booking page is rendering properly @pro @explo', async () => { + test('vendor manage booking page is rendering properly @pro @exp @v', async () => { await vendor.vendorManageBookingRenderProperly(); }); - test('vendor booking calendar page is rendering properly @pro @explo', async () => { + test('vendor booking calendar page is rendering properly @pro @exp @v', async () => { await vendor.vendorBookingCalendarRenderProperly(); }); - test('vendor manage booking resource page is rendering properly @pro @explo', async () => { + test('vendor manage booking resource page is rendering properly @pro @exp @v', async () => { await vendor.vendorManageResourcesRenderProperly(); }); - test('vendor can add booking product @pro', async () => { + test('vendor can add booking product @pro @v', async () => { await vendor.addBookingProduct({ ...data.product.booking, name: data.product.booking.productName() }); }); - test('vendor can edit booking product @pro', async () => { + test('vendor can edit booking product @pro @v', async () => { await vendor.editBookingProduct({ ...data.product.booking, name: bookableProductName }); }); - test('vendor can filter booking products by date @pro', async () => { + test('vendor can filter booking products by date @pro @v', async () => { await vendor.filterBookingProducts('by-date', '1'); }); - test('vendor can filter booking products by category @pro', async () => { + test('vendor can filter booking products by category @pro @v', async () => { await vendor.filterBookingProducts('by-category', 'Uncategorized'); }); - test('vendor can filter booking products by other @pro', async () => { + test('vendor can filter booking products by other @pro @v', async () => { await vendor.filterBookingProducts('by-other', 'featured'); }); - test('vendor can view booking product @pro', async () => { + test('vendor can view booking product @pro @v', async () => { await vendor.viewBookingProduct(bookableProductName); }); - test("vendor can't buy own booking product @pro", async () => { + test("vendor can't buy own booking product @pro @v", async () => { await vendor.cantBuyOwnBookingProduct(bookableProductName); }); - test('vendor can search booking product @pro', async () => { + test('vendor can search booking product @pro @v', async () => { await vendor.searchBookingProduct(bookableProductName); }); - test('vendor can duplicate booking product @pro', async () => { + test('vendor can duplicate booking product @pro @v', async () => { await vendor.duplicateBookingProduct(bookableProductName); }); - test('vendor can permanently delete booking product @pro', async () => { + test('vendor can permanently delete booking product @pro @v', async () => { const [, , bookableProductName] = await apiUtils.createBookableProduct(payloads.createBookableProduct(), payloads.vendorAuth); await vendor.deleteBookingProduct(bookableProductName); }); - test('vendor can add booking resource @pro', async () => { + test('vendor can add booking resource @pro @v', async () => { await vendor.addBookingResource(data.product.booking.resource.resourceName()); }); - test('vendor can edit booking resource @pro', async () => { + test('vendor can edit booking resource @pro @v', async () => { + const bookingResourceName = data.product.booking.resource.resourceName(); + await vendor.addBookingResource(bookingResourceName); // todo: convert with woo api :fatal error exits on api + // const [responseBody, id] = await apiUtils.createPost({ ...payloads.createBookingResourceByDb(), author: process.env.VENDOR_ID }, payloads.adminAuth); + // await dbUtils.createBookingResource(id, process.env.BASE_URL); + // const bookingResourceName = responseBody.title.raw; await vendor.editBookingResource({ ...data.product.booking.resource, name: bookingResourceName }); }); - test('vendor can delete booking resource @pro', async () => { + test('vendor can delete booking resource @pro @v', async () => { const bookingResourceName = data.product.booking.resource.resourceName(); - await vendor.addBookingResource(bookingResourceName); + await vendor.addBookingResource(bookingResourceName); // todo: convert with woo api:fatal error exits on api await vendor.deleteBookingResource(bookingResourceName); }); - test('vendor can add booking for guest customer @pro', async () => { + test('vendor can add booking for guest customer @pro @v', async () => { await vendor.addBooking(bookableProductName, data.bookings); }); - test('vendor can add booking for existing customer @pro', async () => { + test.skip('vendor can add booking for existing customer @pro @v', async () => { await vendor.addBooking(bookableProductName, data.bookings, data.customer.username); }); - test.skip('customer can buy bookable product @pro', async () => { - // todo: customer storage state gets reset somehow (from previous tests) + test.skip('customer can buy bookable product @pro @c', async () => { + // todo: customer storage state gets reset from previous tests await customer.buyBookableProduct(bookableProductName, data.bookings); }); diff --git a/tests/pw/tests/e2e/vendorDashboard.spec.ts b/tests/pw/tests/e2e/vendorDashboard.spec.ts index 135fb7b852..c33f9d7ba8 100644 --- a/tests/pw/tests/e2e/vendorDashboard.spec.ts +++ b/tests/pw/tests/e2e/vendorDashboard.spec.ts @@ -16,7 +16,7 @@ test.describe('Vendor dashboard test', () => { await vPage.close(); }); - test('vendor dashboard is rendering properly @lite @explo', async () => { + test('vendor dashboard is rendering properly @lite @exp @v', async () => { await vendor.vendorDashboardRenderProperly(); }); }); diff --git a/tests/pw/tests/e2e/vendorDeliveryTime.spec.ts b/tests/pw/tests/e2e/vendorDeliveryTime.spec.ts index 9431b4fa0d..76ae816b8d 100644 --- a/tests/pw/tests/e2e/vendorDeliveryTime.spec.ts +++ b/tests/pw/tests/e2e/vendorDeliveryTime.spec.ts @@ -2,15 +2,12 @@ import { test, Page } from '@playwright/test'; import { VendorDeliveryTimePage } from '@pages/vendorDeliveryTimePage'; import { dbData } from '@utils/dbData'; import { dbUtils } from '@utils/dbUtils'; -// import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; -// import { payloads } from '@utils/payloads'; test.describe('Vendor delivery time test', () => { let vendor: VendorDeliveryTimePage; let customer: VendorDeliveryTimePage; let vPage: Page, cPage: Page; - // let apiUtils: ApiUtils; test.beforeAll(async ({ browser }) => { const vendorContext = await browser.newContext(data.auth.vendorAuth); @@ -20,8 +17,6 @@ test.describe('Vendor delivery time test', () => { const customerContext = await browser.newContext(data.auth.customerAuth); cPage = await customerContext.newPage(); customer = new VendorDeliveryTimePage(cPage); - - // apiUtils = new ApiUtils(request); }); test.afterAll(async () => { @@ -29,32 +24,32 @@ test.describe('Vendor delivery time test', () => { await cPage.close(); }); - test('vendor delivery time menu page is rendering properly @pro @explo', async () => { + test('vendor delivery time menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorDeliveryTimeRenderProperly(); }); - test('vendor delivery time settings menu page is rendering properly @pro @explo', async () => { + test('vendor delivery time settings menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorDeliveryTimeSettingsRenderProperly(); }); - test('vendor can set delivery time settings @pro', async () => { + test('vendor can set delivery time settings @pro @v', async () => { await vendor.setDeliveryTimeSettings(data.vendor.deliveryTime); }); - test('vendor can filter delivery time @pro', async () => { + test('vendor can filter delivery time @pro @v', async () => { await vendor.filterDeliveryTime('delivery'); }); - test('vendor can change view style of delivery time calender @pro', async () => { + test('vendor can change view style of delivery time calender @pro @v', async () => { await vendor.updateCalendarView('week'); }); - test.skip('customer can buy product with delivery time @pro', async () => { + test.skip('customer can buy product with delivery time @pro @c', async () => { await customer.addProductToCart(data.predefined.simpleProduct.product1.name, 'single-product'); await customer.placeOrderWithDeliverTimeStorePickup('delivery-time', data.deliveryTime); }); - test.skip('customer can buy product with store pickup @pro', async () => { + test.skip('customer can buy product with store pickup @pro @c', async () => { await dbUtils.setDokanSettings(dbData.dokan.optionName.deliveryTime, { ...dbData.dokan.deliveryTimeSettings, allow_vendor_override_settings: 'off' }); // todo: added for: previous test is disable store pickup await customer.addProductToCart(data.predefined.simpleProduct.product1.name, 'single-product'); await customer.placeOrderWithDeliverTimeStorePickup('store-pickup', data.deliveryTime); diff --git a/tests/pw/tests/e2e/vendorProductSubscription.spec.ts b/tests/pw/tests/e2e/vendorProductSubscription.spec.ts index 66a67c2fb4..dc9e141b09 100644 --- a/tests/pw/tests/e2e/vendorProductSubscription.spec.ts +++ b/tests/pw/tests/e2e/vendorProductSubscription.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { VendorProductSubscriptionPage } from '@pages/vendorProductSubscriptionPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; @@ -9,8 +9,9 @@ test.describe('Product subscriptions test', () => { let customer: VendorProductSubscriptionPage; let vPage: Page, cPage: Page; let apiUtils: ApiUtils; + let subscriptionId: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const vendorContext = await browser.newContext(data.auth.vendorAuth); vPage = await vendorContext.newPage(); vendor = new VendorProductSubscriptionPage(vPage); @@ -19,60 +20,65 @@ test.describe('Product subscriptions test', () => { cPage = await customerContext.newPage(); customer = new VendorProductSubscriptionPage(cPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); const [, productId, productName] = await apiUtils.createProduct(payloads.createSimpleSubscriptionProduct(), payloads.vendorAuth); }); test.afterAll(async () => { await vPage.close(); await cPage.close(); + await apiUtils.dispose(); }); - test('vendor user subscriptions menu page is rendering properly @pro @explo', async () => { + //vendor + + test('vendor user subscriptions menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorUserSubscriptionsRenderProperly(); }); - // test.skip('vendor can view product subscription details @pro @explo', async ( ) => { - // await vendor.filterProductSubscriptions('by-customer', data.customer.username); - // }); + test.skip('vendor can view product subscription details @pro @exp @v', async () => { + await vendor.filterProductSubscriptions('by-customer', data.customer.username); + }); - // test.skip('vendor can filter user subscriptions by customer @pro', async ( ) => { - // await vendor.filterProductSubscriptions('by-customer', data.customer.username); - // }); + test.skip('vendor can filter user subscriptions by customer @pro @v', async () => { + await vendor.filterProductSubscriptions('by-customer', data.customer.username); + }); - // test.skip('vendor can filter user subscriptions by date @pro', async ( ) => { - // await vendor.filterProductSubscriptions('by-date', data.date.previousDate); - // }); + test.skip('vendor can filter user subscriptions by date @pro @v', async () => { + await vendor.filterProductSubscriptions('by-date', data.date.previousDate); + }); - // test.skip('vendor can view user subscription @pro', async ( ) => { - // await vendor.viewProductSubscription(data.customer.username); - // }); + test.skip('vendor can view user subscription @pro @v', async () => { + await vendor.viewProductSubscription(data.customer.username); + }); - // test('customer can view product subscription details @pro @explo', async ( ) => { - // await customer.customerViewProductSubscription('2328'); - // }); + // customer - // test('customer can cancel subscription @pro', async ( ) => { - // await customer.cancelProductSubscription('2328'); - // }); + test.skip('customer can view product subscription details @pro @exp @c', async () => { + await customer.customerViewProductSubscription(subscriptionId); + }); - // test('customer can reactivate subscription @pro', async ( ) => { - // await customer.reactivateProductSubscription('2328'); - // }); + test.skip('customer can cancel subscription @pro @c', async () => { + await customer.cancelProductSubscription(subscriptionId); + }); - // test('customer can change address of subscription @pro', async ( ) => { - // await customer.changeAddressOfProductSubscription('2328', data.customer.customerInfo.shipping); - // }); + test.skip('customer can reactivate subscription @pro @c', async () => { + await customer.reactivateProductSubscription(subscriptionId); + }); + + test.skip('customer can change address of subscription @pro @c', async () => { + await customer.changeAddressOfProductSubscription(subscriptionId, data.customer.customerInfo.shipping); + }); - // test('customer can change payment of subscription @pro', async ( ) => { - // await customer.changePaymentOfProductSubscription('2328'); - // }); + test.skip('customer can change payment of subscription @pro @c', async () => { + await customer.changePaymentOfProductSubscription(subscriptionId); + }); - // test('customer can renew subscription @pro', async ( ) => { - // await customer.renewProductSubscription('2328'); - // }); + test.skip('customer can renew subscription @pro @c', async () => { + await customer.renewProductSubscription(subscriptionId); + }); - // test('customer can buy product subscription @pro', async ( ) => { - // await customer.buyProductSubscription(data.predefined.simpleSubscription.product1); - // }); + test.skip('customer can buy product subscription @pro @c', async () => { + await customer.buyProductSubscription(data.predefined.simpleSubscription.product1); + }); }); diff --git a/tests/pw/tests/e2e/vendorReports.spec.ts b/tests/pw/tests/e2e/vendorReports.spec.ts index 61b29decdb..e73fae5080 100644 --- a/tests/pw/tests/e2e/vendorReports.spec.ts +++ b/tests/pw/tests/e2e/vendorReports.spec.ts @@ -1,31 +1,26 @@ import { test, Page } from '@playwright/test'; import { VendorReportsPage } from '@pages/vendorReportsPage'; -// import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; -// import { payloads } from '@utils/payloads'; test.describe('Vendor analytics test', () => { let vendor: VendorReportsPage; let vPage: Page; - // let apiUtils: ApiUtils; test.beforeAll(async ({ browser }) => { const vendorContext = await browser.newContext(data.auth.vendorAuth); vPage = await vendorContext.newPage(); vendor = new VendorReportsPage(vPage); - - // apiUtils = new ApiUtils(request); }); test.afterAll(async () => { await vPage.close(); }); - test('vendor reports menu page is rendering properly @pro @explo', async () => { + test('vendor reports menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorReportsRenderProperly(); }); - test('vendor can export statement @pro', async () => { + test('vendor can export statement @pro @v', async () => { await vendor.exportStatement(); }); }); diff --git a/tests/pw/tests/e2e/vendorReturnRequest.spec.ts b/tests/pw/tests/e2e/vendorReturnRequest.spec.ts index 250adcc34d..e53a3fdc34 100644 --- a/tests/pw/tests/e2e/vendorReturnRequest.spec.ts +++ b/tests/pw/tests/e2e/vendorReturnRequest.spec.ts @@ -35,7 +35,7 @@ test.describe.skip('Vendor RMA test', () => { await vendor1.updateOrderStatusOnTable(orderId, 'processing'); await customer.customerRequestWarranty(orderId, data.predefined.simpleProduct.product1.name, data.rma.requestWarranty); - // apiUtils = new ApiUtils(request); + // apiUtils = new ApiUtils(await request.newContext()); // [,, orderId, ] = await apiUtils.createOrderWithStatus(PRODUCT_ID, { ...payloads.createOrder, customer_id: CUSTOMER_ID }, data.order.orderStatus.processing, payloads.vendorAuth); // [,, orderId, ] = await apiUtils.createOrderWithStatus(payloads.createProduct(), { ...payloads.createOrder, customer_id: CUSTOMER_ID }, data.order.orderStatus.processing, payloads.vendorAuth); @@ -44,45 +44,46 @@ test.describe.skip('Vendor RMA test', () => { test.afterAll(async () => { await vPage.close(); await cPage.close(); + // await apiUtils.dispose(); }); - test('vendor return request menu page is rendering properly @pro @explo', async () => { + test('vendor return request menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorReturnRequestRenderProperly(); }); - test('vendor can view return request details @pro @explo', async () => { + test('vendor can view return request details @pro @exp @v', async () => { await vendor.vendorViewRmaDetails(orderId); }); - test('customer can send rma message @pro', async () => { + test('customer can send rma message @pro @c', async () => { await customer.customerSendRmaMessage(orderId, 'test customer rma message'); }); - test('vendor can send rma message @pro', async () => { + test('vendor can send rma message @pro @v', async () => { // todo: depends on customer can request warranty, remove dependency await vendor.vendorSendRmaMessage(orderId, 'test vendor rma message'); }); - test('vendor can update rma status @pro', async () => { + test('vendor can update rma status @pro @v', async () => { await vendor.vendorUpdateRmaStatus(orderId, 'processing'); }); - test('vendor can rma refund @pro', async () => { + test('vendor can rma refund @pro @v', async () => { await vendor.vendorRmaRefund(orderId, data.predefined.simpleProduct.product1.name, 'processing'); }); - test('vendor can delete rma request @pro', async () => { + test('vendor can delete rma request @pro @v', async () => { // todo:need separate rma request await vendor.vendorDeleteRmaRequest(orderId); }); // customer - test('customer return request menu page is rendering properly @pro @explo', async () => { + test('customer return request menu page is rendering properly @pro @exp @c', async () => { await customer.customerReturnRequestRenderProperly(); }); - test('customer can request warranty @pro', async () => { + test('customer can request warranty @pro @c', async () => { await customer1.addProductToCartFromSingleProductPage(data.predefined.simpleProduct.product1.name); await customer1.goToCheckout(); const orderId = await customer1.paymentOrder(); diff --git a/tests/pw/tests/e2e/vendorSettings.spec.ts b/tests/pw/tests/e2e/vendorSettings.spec.ts index dab22c2021..7b9a598be1 100644 --- a/tests/pw/tests/e2e/vendorSettings.spec.ts +++ b/tests/pw/tests/e2e/vendorSettings.spec.ts @@ -1,46 +1,47 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { VendorSettingsPage } from '@pages/vendorSettingsPage'; import { dbData } from '@utils/dbData'; -// import { ApiUtils } from '@utils/apiUtils'; +import { ApiUtils } from '@utils/apiUtils'; import { dbUtils } from '@utils/dbUtils'; -// import { helpers } from '@utils/helpers'; import { data } from '@utils/testData'; -// import { payloads } from '@utils/payloads'; +import { payloads } from '@utils/payloads'; test.describe('Vendor settings test', () => { let vendor: VendorSettingsPage; let vPage: Page; - // let apiUtils: ApiUtils; + let apiUtils: ApiUtils; test.beforeAll(async ({ browser }) => { const vendorContext = await browser.newContext(data.auth.vendorAuth); vPage = await vendorContext.newPage(); vendor = new VendorSettingsPage(vPage); - // apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); }); test.afterAll(async () => { + await apiUtils.setStoreSettings(payloads.defaultStoreSettings, payloads.vendorAuth); await vPage.close(); + await apiUtils.dispose(); }); - test('vendor store settings menu page is rendering properly @lite @explo', async () => { + test('vendor store settings menu page is rendering properly @lite @exp @v', async () => { await vendor.vendorStoreSettingsRenderProperly(); }); - test('vendor shipstation settings menu page is rendering properly @pro @explo', async () => { + test('vendor shipstation settings menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorShipstationSettingsRenderProperly(); }); - test('vendor social profile settings menu page is rendering properly @pro @explo', async () => { + test('vendor social profile settings menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorSocialProfileSettingsRenderProperly(); }); - test('vendor rma settings menu page is rendering properly @pro @explo', async () => { + test('vendor rma settings menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorRmaSettingsRenderProperly(); }); - test('vendor store seo settings menu page is rendering properly @pro @explo', async () => { + test('vendor store seo settings menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorStoreSeoSettingsRenderProperly(); }); @@ -48,35 +49,35 @@ test.describe('Vendor settings test', () => { // todo: ensure which settings need to reset, and test data should be what - test('vendor can set store basic settings @lite', async () => { + test('vendor can set store basic settings @lite @v', async () => { await vendor.setStoreSettings(data.vendor.vendorInfo, 'basic'); }); - test('vendor can set store address settings @lite', async () => { + test('vendor can set store address settings @lite @v', async () => { await vendor.setStoreSettings(data.vendor.vendorInfo, 'address'); }); - test('vendor can set company info settings @pro', async () => { + test('vendor can set company info settings @pro @v', async () => { await vendor.setStoreSettings(data.vendor.vendorInfo, 'company-info'); }); - test('vendor can set map settings @lite', async () => { + test('vendor can set map settings @lite @v', async () => { await vendor.setStoreSettings(data.vendor.vendorInfo, 'map'); }); - test('vendor can set terms and conditions settings @lite', async () => { + test('vendor can set terms and conditions settings @lite @v', async () => { await vendor.setStoreSettings(data.vendor.vendorInfo, 'toc'); }); - test('vendor can set open-close settings @lite', async () => { + test('vendor can set open-close settings @lite @v', async () => { await vendor.setStoreSettings(data.vendor.vendorInfo, 'open-close'); }); - test('vendor can set vacation settings @pro', async () => { + test('vendor can set vacation settings @pro @v', async () => { await vendor.setStoreSettings(data.vendor.vendorInfo, 'vacation'); }); - test('vendor can set catalog settings @lite', async () => { + test('vendor can set catalog settings @lite @v', async () => { await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, dbData.dokan.sellingSettings); await vendor.setStoreSettings(data.vendor.vendorInfo, 'catalog'); // await vendor.resetCatalog(); @@ -85,37 +86,37 @@ test.describe('Vendor settings test', () => { await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, catalog_mode_hide_add_to_cart_button: 'off', catalog_mode_hide_product_price: 'off' }); }); - test('vendor can set discount settings @pro', async () => { + test('vendor can set discount settings @pro @v', async () => { await vendor.setStoreSettings(data.vendor.vendorInfo, 'discount'); }); - test('vendor can set biography settings @pro', async () => { + test('vendor can set biography settings @pro @v', async () => { await vendor.setStoreSettings(data.vendor.vendorInfo, 'biography'); }); - test('vendor can set store support settings @pro', async () => { + test('vendor can set store support settings @pro @v', async () => { await vendor.setStoreSettings(data.vendor.vendorInfo, 'store-support'); }); - test('vendor can set min-max settings @pro', async () => { + test('vendor can set min-max settings @pro @v', async () => { await vendor.setStoreSettings(data.vendor.vendorInfo, 'min-max'); // disable min-max await dbUtils.setDokanSettings(dbData.dokan.optionName.selling, { ...dbData.dokan.sellingSettings, enable_min_max_quantity: 'off', enable_min_max_amount: 'off' }); }); - test('vendor can set shipStation settings @pro', async () => { + test('vendor can set shipStation settings @pro @v', async () => { await vendor.setShipStation(data.vendor.shipStation); }); - test('vendor can set social profile settings @pro', async () => { + test('vendor can set social profile settings @pro @v', async () => { await vendor.setSocialProfile(data.vendor.socialProfileUrls); }); - test('vendor can set rma settings @pro', async () => { + test('vendor can set rma settings @pro @v', async () => { await vendor.setRmaSettings(data.vendor.rma); }); - test('vendor can set store seo settings @pro', async () => { + test('vendor can set store seo settings @pro @v', async () => { await vendor.setStoreSeo(data.vendor.seo); }); }); diff --git a/tests/pw/tests/e2e/vendorShipping.spec.ts b/tests/pw/tests/e2e/vendorShipping.spec.ts index 0eae6c4956..84871f8954 100644 --- a/tests/pw/tests/e2e/vendorShipping.spec.ts +++ b/tests/pw/tests/e2e/vendorShipping.spec.ts @@ -14,47 +14,48 @@ test.describe('Vendor shipping test', () => { vPage = await vendorContext.newPage(); vendor = new VendorShippingPage(vPage); - // apiUtils = new ApiUtils(request); + // apiUtils = new ApiUtils(await request.newContext()); }); test.afterAll(async () => { await vPage.close(); + // await apiUtils.dispose(); }); - test('vendor shipping settings menu page is rendering properly @pro @explo', async () => { + test('vendor shipping settings menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorShippingSettingsRenderProperly(); }); - test('vendor can set shipping policy @pro', async () => { + test('vendor can set shipping policy @pro @v', async () => { await vendor.setShippingPolicies(data.vendor.shipping.shippingPolicy); }); - test('vendor can add flat rate shipping @pro', async () => { + test('vendor can add flat rate shipping @pro @v', async () => { await vendor.addShippingMethod(data.vendor.shipping.shippingMethods.flatRate); }); - test('vendor can add free shipping @pro', async () => { + test('vendor can add free shipping @pro @v', async () => { await vendor.addShippingMethod(data.vendor.shipping.shippingMethods.freeShipping); }); - test('vendor can add local pickup shipping @pro', async () => { + test('vendor can add local pickup shipping @pro @v', async () => { await vendor.addShippingMethod(data.vendor.shipping.shippingMethods.localPickup); }); - test('vendor can add table rate shipping @pro', async () => { + test('vendor can add table rate shipping @pro @v', async () => { await vendor.addShippingMethod(data.vendor.shipping.shippingMethods.tableRateShipping); }); - test('vendor can add dokan distance rate shipping @pro', async () => { + test('vendor can add dokan distance rate shipping @pro @v', async () => { await vendor.addShippingMethod(data.vendor.shipping.shippingMethods.distanceRateShipping); }); - test('vendor can edit shipping method @pro', async () => { + test('vendor can edit shipping method @pro @v', async () => { await vendor.addShippingMethod(data.vendor.shipping.shippingMethods.localPickup, false, true); await vendor.addShippingMethod(data.vendor.shipping.shippingMethods.localPickup); }); - test('vendor can delete shipping method @pro', async () => { + test('vendor can delete shipping method @pro @v', async () => { await vendor.addShippingMethod(data.vendor.shipping.shippingMethods.flatRate, true, true); // todo: add with api v2 settings group await vendor.deleteShippingMethod(data.vendor.shipping.shippingMethods.flatRate); }); diff --git a/tests/pw/tests/e2e/vendorStaff.spec.ts b/tests/pw/tests/e2e/vendorStaff.spec.ts index 0c1b926b17..38d0a45e0e 100644 --- a/tests/pw/tests/e2e/vendorStaff.spec.ts +++ b/tests/pw/tests/e2e/vendorStaff.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { VendorStaffPage } from '@pages/vendorStaffPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; @@ -10,36 +10,37 @@ test.describe('Vendor staff test', () => { let apiUtils: ApiUtils; const staff = data.staff(); - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const vendorContext = await browser.newContext(data.auth.vendorAuth); vPage = await vendorContext.newPage(); vendor = new VendorStaffPage(vPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); await apiUtils.createVendorStaff({ ...payloads.createStaff(), first_name: staff.firstName, last_name: staff.lastName }, payloads.vendorAuth); }); test.afterAll(async () => { await vPage.close(); + await apiUtils.dispose(); }); - test('vendor staff menu page is rendering properly @pro @explo', async () => { + test('vendor staff menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorStaffRenderProperly(); }); - test('vendor can add new staff @pro', async () => { + test('vendor can add new staff @pro @v', async () => { await vendor.addStaff(data.staff()); }); - test('vendor can edit staff @pro', async () => { + test('vendor can edit staff @pro @v', async () => { await vendor.editStaff(staff); }); - test('vendor can manage staff permission @pro', async () => { + test('vendor can manage staff permission @pro @v', async () => { await vendor.manageStaffPermission(staff.firstName + ' ' + staff.lastName); }); - test('vendor can delete staff @pro', async () => { + test('vendor can delete staff @pro @v', async () => { await vendor.deleteStaff(staff.firstName + ' ' + staff.lastName); }); }); diff --git a/tests/pw/tests/e2e/vendorTools.spec.ts b/tests/pw/tests/e2e/vendorTools.spec.ts index 64df8ca151..2eb457e7a1 100644 --- a/tests/pw/tests/e2e/vendorTools.spec.ts +++ b/tests/pw/tests/e2e/vendorTools.spec.ts @@ -16,23 +16,23 @@ test.describe('Vendor tools test', () => { await vPage.close(); }); - test('vendor tools menu page is rendering properly @pro @explo', async () => { + test('vendor tools menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorToolsRenderProperly(); }); - test('vendor can export product as xml @pro', async () => { + test('vendor can export product as xml @pro @v', async () => { await vendor.exportProduct('xml'); }); - test('vendor can export product as csv @pro', async () => { + test('vendor can export product as csv @pro @v', async () => { await vendor.exportProduct('csv'); }); - test('vendor can import product as xml @pro', async () => { + test('vendor can import product as xml @pro @v', async () => { await vendor.importProduct('xml', 'utils/sampleData/products.xml'); }); - test('vendor can import product as csv @pro', async () => { + test('vendor can import product as csv @pro @v', async () => { await vendor.importProduct('csv', 'utils/sampleData/products.csv'); }); }); diff --git a/tests/pw/tests/e2e/vendorVerifications.spec.ts b/tests/pw/tests/e2e/vendorVerifications.spec.ts index 51b8b2b701..4a6eed883c 100644 --- a/tests/pw/tests/e2e/vendorVerifications.spec.ts +++ b/tests/pw/tests/e2e/vendorVerifications.spec.ts @@ -24,51 +24,51 @@ test.describe('Verifications test', () => { // vendor - test('vendor verifications settings menu page is rendering properly @pro @explo', async () => { + test('vendor verifications settings menu page is rendering properly @pro @exp @v', async () => { await vendor.vendorVerificationsSettingsRenderProperly(); }); - test('vendor can send id verification request @pro', async () => { + test('vendor can send id verification request @pro @v', async () => { await vendor.sendIdVerificationRequest(data.vendor.verification); }); - test('vendor can send address verification request @pro', async () => { + test('vendor can send address verification request @pro @v', async () => { await vendor.sendAddressVerificationRequest(data.vendor.verification); }); - test('vendor can send company verification request @pro', async () => { + test('vendor can send company verification request @pro @v', async () => { await vendor.sendCompanyVerificationRequest(data.vendor.verification); }); // todo: remove dependency: admin tests depends on vendor tests - test('admin verifications menu page is rendering properly @pro @explo', async () => { + test('admin verifications menu page is rendering properly @pro @exp @a', async () => { await admin.adminVerificationsRenderProperly(); }); - // test('admin can approve ID verification request @pro', async ( ) => { + // test('admin can approve ID verification request @pro @a', async ( ) => { // await admin.approveVerificationRequest(data.predefined.vendorInfo.username, 'id', 'approve'); // }); - // test('admin can approve address verification request @pro', async ( ) => { + // test('admin can approve address verification request @pro @a', async ( ) => { // await admin.approveVerificationRequest(data.predefined.vendorInfo.username, 'address', 'approve'); // }); - // test('admin can approve company verification request @pro', async ( ) => { + // test('admin can approve company verification request @pro @a', async ( ) => { // await admin.approveVerificationRequest(data.predefined.vendorInfo.username, 'company', 'approve'); // }); // todo: admin can reject requests - // test('admin can disapprove approved ID verification request @pro', async ( ) => { + // test('admin can disapprove approved ID verification request @pro @a', async ( ) => { // await admin.disapproveVerificationRequest(data.predefined.vendorInfo.username, 'id'); // }); - // test('admin can disapprove approved address verification request @pro', async ( ) => { + // test('admin can disapprove approved address verification request @pro @a', async ( ) => { // await admin.disapproveVerificationRequest(data.predefined.vendorInfo.username, 'address'); // }); - // test('admin can disapprove approved company verification request @pro', async ( ) => { + // test('admin can disapprove approved company verification request @pro @a', async ( ) => { // await admin.disapproveVerificationRequest(data.predefined.vendorInfo.username, 'company'); // }); }); diff --git a/tests/pw/tests/e2e/wholesaleCustomers.spec.ts b/tests/pw/tests/e2e/wholesaleCustomers.spec.ts index 9d7602021a..a67e81baba 100644 --- a/tests/pw/tests/e2e/wholesaleCustomers.spec.ts +++ b/tests/pw/tests/e2e/wholesaleCustomers.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { WholesaleCustomersPage } from '@pages/wholesaleCustomersPage'; import { CustomerPage } from '@pages/customerPage'; import { ApiUtils } from '@utils/apiUtils'; @@ -14,17 +14,17 @@ test.describe('Wholesale customers test (admin)', () => { let aPage: Page, cPage: Page; let apiUtils: ApiUtils; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new WholesaleCustomersPage(aPage); - const customerContext = await browser.newContext({ storageState: { cookies: [], origins: [] } }); + const customerContext = await browser.newContext(data.auth.noAuth); cPage = await customerContext.newPage(); customerPage = new CustomerPage(cPage); customer = new WholesaleCustomersPage(cPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); await apiUtils.createWholesaleCustomer(payloads.createCustomer(), payloads.adminAuth); await apiUtils.createWholesaleCustomer(payloads.createCustomer1, payloads.adminAuth); @@ -34,46 +34,47 @@ test.describe('Wholesale customers test (admin)', () => { test.afterAll(async () => { await aPage.close(); await cPage.close(); + await apiUtils.dispose(); }); - test('dokan wholesale customers menu page is rendering properly @pro @explo', async () => { + test('dokan wholesale customers menu page is rendering properly @pro @exp @a', async () => { await admin.adminWholesaleCustomersRenderProperly(); }); - test('admin can search wholesale customer @pro', async () => { + test('admin can search wholesale customer @pro @a', async () => { await admin.searchWholesaleCustomer(data.predefined.customerInfo.username1); }); - test("admin can disable customer's wholesale capability @pro", async () => { + test("admin can disable customer's wholesale capability @pro @a", async () => { await admin.updateWholesaleCustomer(data.predefined.customerInfo.username1, 'disable'); }); - test("admin can enable customer's wholesale capability @pro", async () => { + test("admin can enable customer's wholesale capability @pro @a", async () => { await admin.updateWholesaleCustomer(data.predefined.customerInfo.username1, 'enable'); }); - test('admin can edit wholesale customer @pro', async () => { + test('admin can edit wholesale customer @pro @a', async () => { await admin.editWholesaleCustomer(data.customer); }); - test('admin can view wholesale customer orders @pro', async () => { + test('admin can view wholesale customer orders @pro @a', async () => { await admin.viewWholesaleCustomerOrders(data.predefined.customerInfo.username1); }); - test('admin can delete wholesale customer @pro', async () => { + test('admin can delete wholesale customer @pro @a', async () => { await admin.updateWholesaleCustomer(data.predefined.customerInfo.username1, 'delete'); }); - test('admin can perform wholesale customer bulk action @pro', async () => { + test('admin can perform wholesale customer bulk action @pro @a', async () => { await admin.wholesaleCustomerBulkAction('activate'); }); - test('customer can become a wholesale customer', async () => { + test('customer can become a wholesale customer @pro @c', async () => { await customerPage.customerRegister(data.customer.customerInfo); await customer.customerBecomeWholesaleCustomer(); }); - test('customer can request for become a wholesale customer', async () => { + test('customer can request for become a wholesale customer @pro @c', async () => { await dbUtils.setDokanSettings(dbData.dokan.optionName.wholesale, { ...dbData.dokan.wholesaleSettings, need_approval_for_wholesale_customer: 'on' }); await customerPage.customerRegister(data.customer.customerInfo); await customer.customerRequestForBecomeWholesaleCustomer(); @@ -89,13 +90,13 @@ test.describe.skip('Wholesale customers test customer', () => { let wholesalePrice: string; let minimumWholesaleQuantity: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const customerContext = await browser.newContext(data.auth.customerAuth); cPage = await customerContext.newPage(); customerPage = new CustomerPage(cPage); customer = new WholesaleCustomersPage(cPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); await apiUtils.createWholesaleCustomer(payloads.createCustomer1, payloads.adminAuth); // todo: need to update customer auth if created wholesale or move to env setup const [responseBody, ,] = await apiUtils.createProduct(payloads.createWholesaleProduct(), payloads.vendorAuth); @@ -108,11 +109,11 @@ test.describe.skip('Wholesale customers test customer', () => { await cPage.close(); }); - test('customer can see wholesale price on shop archive', async () => { + test('customer can see wholesale price on shop archive @pro @c', async () => { await customer.viewWholeSalePrice(productName); }); - test('customer can buy wholesale product', async () => { + test('customer can buy wholesale product @pro @c', async () => { await customerPage.addProductToCart(productName, 'single-product', true, minimumWholesaleQuantity); await customer.assertWholesalePrice(wholesalePrice, minimumWholesaleQuantity); await customerPage.paymentOrder(); diff --git a/tests/pw/tests/e2e/withdraws.spec.ts b/tests/pw/tests/e2e/withdraws.spec.ts index 1c7ce15934..5881bbd188 100644 --- a/tests/pw/tests/e2e/withdraws.spec.ts +++ b/tests/pw/tests/e2e/withdraws.spec.ts @@ -1,4 +1,4 @@ -import { test, Page } from '@playwright/test'; +import { test, request, Page } from '@playwright/test'; import { WithdrawsPage } from '@pages/withdrawsPage'; import { ApiUtils } from '@utils/apiUtils'; import { data } from '@utils/testData'; @@ -14,7 +14,7 @@ test.describe('Withdraw test', () => { let currentBalance: string; let minimumWithdrawLimit: string; - test.beforeAll(async ({ browser, request }) => { + test.beforeAll(async ({ browser }) => { const adminContext = await browser.newContext(data.auth.adminAuth); aPage = await adminContext.newPage(); admin = new WithdrawsPage(aPage); @@ -23,7 +23,7 @@ test.describe('Withdraw test', () => { vPage = await vendorContext.newPage(); vendor = new WithdrawsPage(vPage); - apiUtils = new ApiUtils(request); + apiUtils = new ApiUtils(await request.newContext()); [currentBalance, minimumWithdrawLimit] = await apiUtils.getMinimumWithdrawLimit(payloads.vendorAuth); await apiUtils.createOrderWithStatus(PRODUCT_ID, { ...payloads.createOrder, line_items: [{ quantity: 10 }] }, 'wc-completed', payloads.vendorAuth); await apiUtils.createWithdraw({ ...payloads.createWithdraw, amount: minimumWithdrawLimit }, payloads.vendorAuth); @@ -32,77 +32,78 @@ test.describe('Withdraw test', () => { test.afterAll(async () => { await aPage.close(); await vPage.close(); + await apiUtils.dispose(); }); - test('admin withdraw menu page is rendering properly @lite @explo', async () => { + test('admin withdraw menu page is rendering properly @lite @exp @a', async () => { await admin.adminWithdrawsRenderProperly(); }); - test('admin can filter withdraws by vendor @lite', async () => { + test('admin can filter withdraws by vendor @lite @a', async () => { await admin.filterWithdraws(data.predefined.vendorStores.vendor1, 'by-vendor'); }); - test('admin can filter withdraws by payment methods @lite', async () => { + test('admin can filter withdraws by payment methods @lite @a', async () => { await admin.filterWithdraws(data.vendor.withdraw.defaultWithdrawMethod.paypal, 'by-payment-method'); }); - test('admin can export withdraws', async () => { + test('admin can export withdraws @lite @a', async () => { await admin.exportWithdraws(); }); - test('admin can add note to withdraw request @lite', async () => { + test('admin can add note to withdraw request @lite @a', async () => { await admin.addNoteWithdrawRequest(data.predefined.vendorStores.vendor1, 'test withdraw note'); }); - test('admin can approve withdraw request @lite', async () => { + test('admin can approve withdraw request @lite @a', async () => { await admin.updateWithdrawRequest(data.predefined.vendorStores.vendor1, 'approve'); }); - test('admin can cancel withdraw request @lite', async () => { + test('admin can cancel withdraw request @lite @a', async () => { await apiUtils.createWithdraw({ ...payloads.createWithdraw, amount: minimumWithdrawLimit }, payloads.vendorAuth); await admin.updateWithdrawRequest(data.predefined.vendorStores.vendor1, 'cancel'); }); - test('admin can delete withdraw request @lite', async () => { + test('admin can delete withdraw request @lite @a', async () => { await apiUtils.createWithdraw({ ...payloads.createWithdraw, amount: minimumWithdrawLimit }, payloads.vendorAuth); await admin.updateWithdrawRequest(data.predefined.vendorStores.vendor1, 'delete'); }); - test('admin can perform withdraw bulk actions @lite', async () => { + test('admin can perform withdraw bulk actions @lite @a', async () => { await apiUtils.createWithdraw({ ...payloads.createWithdraw, amount: minimumWithdrawLimit }, payloads.vendorAuth); await admin.withdrawBulkAction('cancelled'); }); // vendor - test('vendor withdraw menu page is rendering properly @lite @explo', async () => { + test('vendor withdraw menu page is rendering properly @lite @exp @v', async () => { await vendor.vendorWithdrawRenderProperly(); }); - test('vendor withdraw requests page is rendering properly @lite @explo', async () => { + test('vendor withdraw requests page is rendering properly @lite @exp @v', async () => { await vendor.vendorWithdrawRequestsRenderProperly(); }); - test.skip('vendor can request withdraw @lite', async () => { + test.skip('vendor can request withdraw @lite @v', async () => { await apiUtils.cancelWithdraw('', payloads.vendorAuth); await vendor.requestWithdraw({ ...data.vendor.withdraw, minimumWithdrawAmount: minimumWithdrawLimit, currentBalance: currentBalance }); }); - test("vendor can't request withdraw when pending request exits @lite", async () => { + test("vendor can't request withdraw when pending request exits @lite @v", async () => { await apiUtils.createWithdraw({ ...payloads.createWithdraw, amount: minimumWithdrawLimit }, payloads.vendorAuth); await vendor.cantRequestWithdraw(); }); - test('vendor can cancel request withdraw @lite', async () => { + test('vendor can cancel request withdraw @lite @v', async () => { await apiUtils.createWithdraw({ ...payloads.createWithdraw, amount: minimumWithdrawLimit }, payloads.vendorAuth); await vendor.cancelWithdrawRequest(); }); - test('vendor can add auto withdraw disbursement schedule @pro', async () => { + test('vendor can add auto withdraw disbursement schedule @pro @v', async () => { await vendor.addAutoWithdrawDisbursementSchedule({ ...data.vendor.withdraw, minimumWithdrawAmount: minimumWithdrawLimit }); }); - test('vendor can add default withdraw payment methods @lite', async () => { + test('vendor can add default withdraw payment methods @lite @v', async () => { await vendor.addDefaultWithdrawPaymentMethods(data.vendor.withdraw.defaultWithdrawMethod.bankTransfer); // Cleanup await vendor.addDefaultWithdrawPaymentMethods(data.vendor.withdraw.defaultWithdrawMethod.paypal); diff --git a/tests/pw/types/environment.d.ts b/tests/pw/types/environment.d.ts index de27faeb8b..c4379bb438 100644 --- a/tests/pw/types/environment.d.ts +++ b/tests/pw/types/environment.d.ts @@ -16,9 +16,11 @@ declare global { CUSTOMER_ID: string; PRODUCT_ID: string; V2_PRODUCT_ID: string; + CI: string; GMAP: string; LICENSE_KEY: string; DOKAN_PRO: string; + SITE_PATH: string; BASE_URL: string; QUERY: string; HEADLESS: string; @@ -39,6 +41,7 @@ declare global { DB_PREFIX: string; API_TEST_RESULT: string; E2E_TEST_RESULT: string; + API_COVERAGE: string; } } } diff --git a/tests/pw/utils/apiEndPoints.ts b/tests/pw/utils/apiEndPoints.ts index d262b95319..f0beed65f0 100644 --- a/tests/pw/utils/apiEndPoints.ts +++ b/tests/pw/utils/apiEndPoints.ts @@ -1,6 +1,7 @@ import 'dotenv/config'; -const { SERVER_URL } = process.env; +// const { BASE_URL, SERVER_URL } = process.env; +const SERVER_URL = process.env.SERVER_URL ? process.env.SERVER_URL : process.env.BASE_URL + '/wp-json'; export const endPoints = { serverUrl: `${SERVER_URL}`, @@ -325,6 +326,20 @@ export const endPoints = { getSpmvProducts: `${SERVER_URL}/dokan/v1/spmv-product/search`, addToStore: `${SERVER_URL}/dokan/v1/spmv-product/add-to-store`, // post + // product question answere + getAllProductQuestions: `${SERVER_URL}/dokan/v1/product-questions`, + getSingleProductQuestion: (questionId: string) => `${SERVER_URL}/dokan/v1/product-questions/${questionId}`, + createProductQuestion: `${SERVER_URL}/dokan/v1/product-questions`, + updateProductQuestion: (questionId: string) => `${SERVER_URL}/dokan/v1/product-questions/${questionId}`, + deleteProductQuestion: (questionId: string) => `${SERVER_URL}/dokan/v1/product-questions/${questionId}`, + updateBatchProductQuestions: `${SERVER_URL}/dokan/v1/product-questions/bulk_action`, // method: delete, read, unread + + getAllProductQuestionAnswers: `${SERVER_URL}/dokan/v1/product-answers`, + getSingleProductQuestionAnswer: (answerId: string) => `${SERVER_URL}/dokan/v1/product-answers/${answerId}`, + createProductQuestionAnswer: `${SERVER_URL}/dokan/v1/product-answers`, + updateProductQuestionAnswer: (answerId: string) => `${SERVER_URL}/dokan/v1/product-answers/${answerId}`, + deleteProductQuestionAnswer: (answerId: string) => `${SERVER_URL}/dokan/v1/product-answers/${answerId}`, + wc: { // coupons getAllCoupons: `${SERVER_URL}/wc/v3/coupons`, @@ -523,10 +538,10 @@ export const endPoints = { productAddons: { getAllProductAddons: `${SERVER_URL}/wc-product-add-ons/v1/product-add-ons`, - getSingleProductAddon: (productId: string) => `${SERVER_URL}/wc-product-add-ons/v1/product-add-ons${productId}`, + getSingleProductAddon: (productId: string) => `${SERVER_URL}/wc-product-add-ons/v1/product-add-ons/${productId}`, createProductAddon: `${SERVER_URL}/wc-product-add-ons/v1/product-add-ons`, - updateProductAddon: (productId: string) => `${SERVER_URL}/wc-product-add-ons/v1/product-add-ons${productId}`, - deleteProductAddon: (productId: string) => `${SERVER_URL}/wc-product-add-ons/v1/product-add-ons${productId}`, + updateProductAddon: (productId: string) => `${SERVER_URL}/wc-product-add-ons/v1/product-add-ons/${productId}`, + deleteProductAddon: (productId: string) => `${SERVER_URL}/wc-product-add-ons/v1/product-add-ons/${productId}`, }, }, @@ -566,7 +581,7 @@ export const endPoints = { // posts getAllPosts: `${SERVER_URL}/wp/v2/posts`, getSinglePost: (postId: string) => `${SERVER_URL}/wp/v2/posts/${postId}`, - createPost: `${SERVER_URL}/wp/v2/pots/posts`, + createPost: `${SERVER_URL}/wp/v2/posts`, createCustomPost: (postType: string) => `${SERVER_URL}/wp/v2/${postType}`, updatePost: (postId: string) => `${SERVER_URL}/wp/v2/posts/${postId}`, deletePost: (postId: string) => `${SERVER_URL}/wp/v2/posts/${postId}`, diff --git a/tests/pw/utils/apiUtils.ts b/tests/pw/utils/apiUtils.ts index cc757090ea..7a760c2662 100644 --- a/tests/pw/utils/apiUtils.ts +++ b/tests/pw/utils/apiUtils.ts @@ -1,9 +1,9 @@ -import { expect, type APIRequestContext, APIResponse, Request } from '@playwright/test'; +import { expect, Request, APIRequestContext, APIResponse } from '@playwright/test'; import { endPoints } from '@utils/apiEndPoints'; import { payloads } from '@utils/payloads'; import { helpers } from '@utils/helpers'; import fs from 'fs'; -import { auth, user_api, taxRate, coupon_api, marketPlaceCoupon, reqOptions, headers, storageState, responseBody } from '@utils/interfaces'; +import { auth, user_api, taxRate, coupon_api, marketPlaceCoupon, reqOptions, params, headers, storageState, responseBody } from '@utils/interfaces'; const { VENDOR_ID, CUSTOMER_ID } = process.env; @@ -82,16 +82,16 @@ export class ApiUtils { return response; } + // dispose api request context + async dispose(): Promise { + await this.request.dispose(); + } + // get storageState async storageState(path?: string | undefined): Promise { return await this.request.storageState({ path: path }); } - // dispose api context - async disposeApiRequestContext(): Promise { - await this.request.dispose(); - } - // get responseBody async getResponseBody(response: APIResponse, assert = true): Promise { try { @@ -167,7 +167,7 @@ export class ApiUtils { } // create store - async createStore(payload: any, auth?: auth): Promise<[responseBody, string, string]> { + async createStore(payload: any, auth?: auth, addUserAddress: boolean = false): Promise<[responseBody, string, string]> { const [response, responseBody] = await this.post(endPoints.createStore, { data: payload, headers: auth }, false); let sellerId: string; let storeName: string; @@ -185,6 +185,10 @@ export class ApiUtils { sellerId = String(responseBody?.id); storeName = String(responseBody?.store_name); } + + // add vendor user address + addUserAddress && (await this.updateCustomer(sellerId, payloads.updateAddress, payloads.adminAuth)); + return [responseBody, sellerId, storeName]; } @@ -267,8 +271,11 @@ export class ApiUtils { } // delete all products - async deleteAllProducts(productName?: string, auth?: auth): Promise { - // todo: apply multiple optional parameter + async deleteAllProducts(productName?: any, auth?: auth): Promise { + if (arguments.length === 1 && typeof productName === 'object') { + auth = productName as auth; + productName = undefined; + } const allProducts = await this.getAllProducts(auth); if (!allProducts?.length) { console.log('No product exists'); @@ -732,14 +739,14 @@ export class ApiUtils { } // get activate modules - async activateModules(moduleIds: string, auth?: auth): Promise { - const [, responseBody] = await this.put(endPoints.activateModule, { data: { module: [moduleIds] }, headers: auth }); + async activateModules(moduleIds: string[], auth?: auth): Promise { + const [, responseBody] = await this.put(endPoints.activateModule, { data: { module: moduleIds }, headers: auth }); return responseBody; } // get deactivated modules - async deactivateModules(moduleIds: string, auth?: auth): Promise { - const [, responseBody] = await this.put(endPoints.deactivateModule, { data: { module: [moduleIds] }, headers: auth }); + async deactivateModules(moduleIds: string[], auth?: auth): Promise { + const [, responseBody] = await this.put(endPoints.deactivateModule, { data: { module: moduleIds }, headers: auth }); return responseBody; } @@ -840,12 +847,13 @@ export class ApiUtils { } // create a product advertisement - async createProductAdvertisement(product: object, auth?: auth): Promise<[responseBody, string]> { + async createProductAdvertisement(product: object, auth?: auth): Promise<[responseBody, string, string]> { const [body, productId] = await this.createProduct(product, auth); const sellerId = body.store.id; const [, responseBody] = await this.post(endPoints.createProductAdvertisement, { data: { vendor_id: sellerId, product_id: productId }, headers: payloads.adminAuth }); - const productAdvertisementId = String(responseBody?.id); - return [responseBody, productAdvertisementId]; + const advertisementId = String(responseBody?.id); + const advertisedProduct = responseBody?.product_title; + return [responseBody, advertisementId, advertisedProduct]; } /** @@ -865,6 +873,18 @@ export class ApiUtils { return abuseReportId; } + // delete all abuse reports + async deleteAllAbuseReports(auth?: auth): Promise { + const allAbuseReports = await this.getAllAbuseReports(auth); + if (!allAbuseReports?.length) { + console.log('No abuse report exists'); + return; + } + const allAbuseReportIds = allAbuseReports.map((o: { id: unknown }) => o.id); + const [, responseBody] = await this.delete(endPoints.deleteBatchAbuseReports, { data: { items: allAbuseReportIds }, headers: auth }); + return responseBody; + } + /** * announcements api methods */ @@ -912,6 +932,17 @@ export class ApiUtils { return responseBody; } + // delete all announcements + async deleteAllAnnouncements(auth?: auth): Promise { + const allAnnouncemens = await this.getAllAnnouncements(auth); + if (!allAnnouncemens?.length) { + console.log('No announcement exists'); + return; + } + const allAnnouncementIds = allAnnouncemens.map((o: { id: unknown }) => o.id); + await this.updateBatchAnnouncements('delete', allAnnouncementIds, auth); + } + /** * product reviews api methods */ @@ -1010,16 +1041,21 @@ export class ApiUtils { */ // get all quote rules - async getAllQuoteRules(auth?: auth): Promise { - const [, responseBody] = await this.get(endPoints.getAllQuoteRules, { params: { per_page: 100 }, headers: auth }); + async getAllQuoteRules(params: params = { per_page: 100 }, auth?: auth): Promise { + if (arguments.length === 1 && 'Authorization' in params) { + auth = params as auth; + params = undefined; + } + const [, responseBody] = await this.get(endPoints.getAllQuoteRules, { params, headers: auth }); return responseBody; } // create quote rule - async createQuoteRule(payload: object, auth?: auth): Promise<[responseBody, string]> { + async createQuoteRule(payload: object, auth?: auth): Promise<[responseBody, string, string]> { const [, responseBody] = await this.post(endPoints.createQuoteRule, { data: payload, headers: auth }); const quoteRuleId = String(responseBody?.id); - return [responseBody, quoteRuleId]; + const quoteRuleName = responseBody?.rule_name; + return [responseBody, quoteRuleId, quoteRuleName]; } // delete quote rule @@ -1030,15 +1066,28 @@ export class ApiUtils { // delete all quote rules async deleteAllQuoteRules(auth?: auth): Promise { - const allQuoteRuleIds = (await this.getAllQuoteRules(auth)).map((o: { id: unknown }) => o.id); - if (!allQuoteRuleIds?.length) { + const allQuoteRules = await this.getAllQuoteRules(auth); + if (!allQuoteRules?.length) { console.log('No quote rule exists'); return; } + const allQuoteRuleIds = allQuoteRules.map((o: { id: unknown }) => o.id); const [, responseBody] = await this.put(endPoints.updateBatchQuoteRules, { data: { trash: allQuoteRuleIds }, headers: auth }); return responseBody; } + // delete all quote rules trashed + async deleteAllQuoteRulesTrashed(auth?: auth): Promise { + const allQuoteRules = await this.getAllQuoteRules({ status: 'trash', per_page: 100 }, auth); + if (!allQuoteRules?.length) { + console.log('No quote rule exists'); + return; + } + const allQuoteRuleIds = allQuoteRules.map((o: { id: unknown }) => o.id); + const [, responseBody] = await this.put(endPoints.updateBatchQuoteRules, { data: { delete: allQuoteRuleIds }, headers: auth }); + return responseBody; + } + /** * quote requests api methods */ @@ -1065,11 +1114,12 @@ export class ApiUtils { // delete all quote requests async deleteAllQuoteRequests(auth?: auth): Promise { - const allQuoteIds = (await this.getAllQuoteRequests(auth)).map((o: { id: unknown }) => o.id); - if (!allQuoteIds?.length) { + const allQuotes = await this.getAllQuoteRequests(auth); + if (!allQuotes?.length) { console.log('No quote request exists'); return; } + const allQuoteIds = allQuotes.map((o: { id: unknown }) => o.id); const [, responseBody] = await this.put(endPoints.updateBatchRequestQuotes, { data: { trash: allQuoteIds }, headers: auth }); return responseBody; } @@ -1203,6 +1253,48 @@ export class ApiUtils { return [response, responseBody]; } + /** + * product questions answers + */ + + // get all product questions + async getAllProductQuestions(auth?: auth): Promise { + const [, responseBody] = await this.get(endPoints.getAllProductQuestions, { params: { per_page: 100 }, headers: auth }); + return responseBody; + } + + // create product question + async createProductQuestion(payload: object, auth?: auth): Promise<[responseBody, string]> { + const [, responseBody] = await this.post(endPoints.createProductQuestion, { data: payload, headers: auth }); + const questionId = String(responseBody?.id); + return [responseBody, questionId]; + } + + // update product question + async updateProductQuestion(questionId: string, payload: object, auth?: auth): Promise { + const [, responseBody] = await this.put(endPoints.updateProductQuestion(questionId), { data: payload, headers: auth }); + return responseBody; + } + + // delete all product questions + async deleteAllProductQuestions(auth?: auth): Promise { + const allProductQuestions = await this.getAllProductQuestions(); + if (!allProductQuestions?.length) { + console.log('No product question exists'); + return; + } + const allProductQuestionIds = allProductQuestions.map((o: { id: unknown }) => o.id); + const [, responseBody] = await this.put(endPoints.updateBatchProductQuestions, { data: { action: 'delete', ids: allProductQuestionIds }, headers: auth }); + return responseBody; + } + + // create product question answer + async createProductQuestionAnswer(payload: object, auth?: auth): Promise<[responseBody, string]> { + const [, responseBody] = await this.post(endPoints.createProductQuestionAnswer, { data: payload, headers: auth }); + const answerId = String(responseBody?.id); + return [responseBody, answerId]; + } + /** * wp api methods */ @@ -1380,9 +1472,10 @@ export class ApiUtils { } // create post - async createPost(payload: object, auth?: auth): Promise { + async createPost(payload: object, auth?: auth): Promise<[responseBody, string]> { const [, responseBody] = await this.post(endPoints.wp.createPost, { data: payload, headers: auth }); - return responseBody; + const postId = String(responseBody?.id); + return [responseBody, postId]; } // get all pages @@ -1482,10 +1575,11 @@ export class ApiUtils { } // create category - async createCategory(payload: object, auth?: auth): Promise<[responseBody, string]> { + async createCategory(payload: object, auth?: auth): Promise<[responseBody, string, string]> { const [, responseBody] = await this.post(endPoints.wc.createCategory, { data: payload, headers: auth }); const categoryId = String(responseBody?.id); - return [responseBody, categoryId]; + const categoryName = String(responseBody?.name); + return [responseBody, categoryId, categoryName]; } // update category @@ -1693,11 +1787,8 @@ export class ApiUtils { // get system status async getSystemStatus(auth?: auth): Promise<[responseBody, object]> { const [, responseBody] = await this.get(endPoints.wc.getAllSystemStatus, { headers: auth }); - let activePlugins = responseBody.active_plugins.map((a: { plugin: string; version: string }) => a.plugin.split('/')[0] + ' v' + a.version); + const activePlugins = responseBody.active_plugins.map((a: { plugin: string; version: string }) => a.plugin.split('/')[0] + ' v' + a.version); activePlugins.sort(); - const conditions = ['Basic-Auth', 'bookings', 'addons', 'auctions', 'subscriptions', 'ba', 'wa', 'wb', 'ws', 'wps']; - activePlugins = activePlugins.filter((e: string | string[]) => !conditions.some(el => e.includes(el))); - // activePlugins = activePlugins.slice(1, -4); const compactInfo = { wpVersion: 'WordPress Version: ' + responseBody?.environment.wp_version, phpVersion: 'PHP Version: ' + responseBody?.environment.php_version, @@ -1708,4 +1799,81 @@ export class ApiUtils { }; return [responseBody, compactInfo]; } + + // get order details + orderDetails(responseBody: responseBody) { + const orderDetails = { + id: responseBody.id, + status: responseBody.status, + order: { + total: responseBody.total, + }, + tax: { + prices_include_tax: responseBody.prices_include_tax, + cart_tax: responseBody.cart_tax, + shipping_tax: responseBody.shipping_tax, + discount_tax: responseBody.discount_tax, + total_tax: responseBody.total_tax, + // tax_total: responseBody.tax_lines.tax_total, + // shipping_tax_total: responseBody.tax_lines.shipping_tax_total, + }, + shipping: { + shipping_total: responseBody.shipping_total, + shipping_tax: responseBody.shipping_tax, + // total: responseBody.shipping_lines.total, + // total_tax: responseBody.shipping_lines.total_tax, + }, + discount: { + discount_total: responseBody.discount_total, + discount_tax: responseBody.discount_tax, + }, + line_items: { + subtotal: responseBody.line_items.subtotal, + subtotal_tax: responseBody.line_items.subtotal_tax, + total: responseBody.line_items.total, + total_tax: responseBody.line_items.total_tax, + price: responseBody.line_items.price, + }, + }; + + return orderDetails; + } + + /** + * woocommerce product addon api methods + */ + + // get all product addons + async getAllProductAddons(auth?: auth): Promise { + const [, responseBody] = await this.get(endPoints.wc.productAddons.getAllProductAddons, { headers: auth }); + return responseBody; + } + + // create product addon + async createProductAddon(payload: object, auth?: auth): Promise<[responseBody, string, string, string]> { + const [, responseBody] = await this.post(endPoints.wc.productAddons.createProductAddon, { data: payload, headers: auth }); + const productAddonId = String(responseBody?.id); + const addonName = responseBody.name; + const addonFieldTitle = responseBody.fields[0].name; + return [responseBody, productAddonId, addonName, addonFieldTitle]; + } + + // delete product addon + async deleteProductAddon(productAddonId: string, auth?: auth): Promise { + const [, responseBody] = await this.delete(endPoints.wc.productAddons.deleteProductAddon(productAddonId), { headers: auth }); + return responseBody; + } + + // delete all product addons + async deleteAllProductAddons(auth?: auth): Promise { + const allProductAddons = await this.getAllProductAddons(auth); + if (!allProductAddons?.length) { + console.log('No product addon exists'); + return; + } + const allProductAddonIds = allProductAddons.map((o: { id: unknown }) => o.id); + for (const productAddonId of allProductAddonIds) { + await this.deleteProductAddon(productAddonId, auth); + } + } } diff --git a/tests/pw/utils/data.json b/tests/pw/utils/data.json deleted file mode 100644 index ee99d07aa0..0000000000 --- a/tests/pw/utils/data.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "SERVER_URL": "", - "CUSTOMER_ID": "", - "VENDOR_ID": "", - "VENDOR2_ID": "", - "PRODUCT_ID": "", - "V2_PRODUCT_ID": "", - "HPOS": "" -} diff --git a/tests/pw/utils/dbData.ts b/tests/pw/utils/dbData.ts index c5b67a7285..c180616fcd 100644 --- a/tests/pw/utils/dbData.ts +++ b/tests/pw/utils/dbData.ts @@ -70,7 +70,7 @@ export const dbData = { automatic_process_api_refund: 'off', // vendor capabilities - additional_fee: '', + additional_fee: '10', new_seller_enable_selling: 'on', one_step_product_create: 'on', disable_product_popup: 'off', @@ -640,4 +640,40 @@ export const dbData = { woocommerceSettings: { woocommerce_enable_myaccount_registration: 'yes', }, + + // test db data + + testData: { + dokan: { + generalSettings: { + // site settings + site_options: '', + admin_access: 'on', // vendor edit product test needs it to disable + custom_store_url: 'stores', + setup_wizard_logo_url: '', + setup_wizard_message: + '

Thank you for choosing The Marketplace to power your online store! This quick setup wizard will help you configure the basic settings. It’s completely optional and shouldn’t take longer than two minutes. Test wizard message.

', + setup_wizard_message_without_html: + 'Thank you for choosing The Marketplace to power your online store! This quick setup wizard will help you configure the basic settings. It’s completely optional and shouldn’t take longer than two minutes. Test wizard message.', + disable_welcome_wizard: 'off', + global_digital_mode: 'sell_both', + enable_shipstation_logging: 'off', + data_clear_on_uninstall: 'off', + + // vendor store settings + vendor_store_options: '', + seller_enable_terms_and_conditions: 'on', + store_products_per_page: '12', + enabled_address_on_reg: 'off', + enable_tc_on_reg: 'on', + enable_single_seller_mode: 'off', + store_category_type: 'multiple', // none, multiple + + // product page settings + product_page_options: '', + show_vendor_info: 'on', + enabled_more_products_tab: 'on', + }, + }, + }, }; diff --git a/tests/pw/utils/dbUtils.ts b/tests/pw/utils/dbUtils.ts index 7f851fd852..59948578e9 100644 --- a/tests/pw/utils/dbUtils.ts +++ b/tests/pw/utils/dbUtils.ts @@ -100,7 +100,7 @@ export const dbUtils = { }, // create refund - async createRefund(responseBody: any): Promise<[any, string]> { + async createRefundRequest(responseBody: any): Promise<[any, string]> { const refundId = (await this.getMaxId('id', 'dokan_refund')) + 1; const refund = { @@ -118,9 +118,28 @@ export const dbUtils = { method: 0, }; // console.log('refund data:', refund); - const queryInsert = `INSERT INTO ${dbPrefix}_dokan_refund VALUES ( '${refund.id}', '${refund.orderId}', '${refund.sellerId}', ${refund.refundAmount}, '${refund.refundReason}', '${refund.itemQtys}', '${refund.itemTotals}', '${refund.itemTaxTotals}', '${refund.restockItems}', '${refund.date}', '${refund.status}', '${refund.method}' );`; + const queryInsert = `INSERT INTO ${dbPrefix}_dokan_refund VALUES ( '${refund.id}', '${refund.orderId}', '${refund.sellerId}', ${refund.refundAmount}, + '${refund.refundReason}', '${refund.itemQtys}', '${refund.itemTotals}', '${refund.itemTaxTotals}', '${refund.restockItems}', '${refund.date}', + '${refund.status}', '${refund.method}' );`; const res = await dbUtils.dbQuery(queryInsert); // console.log(res); return [res, refundId]; }, + + // update cell + async updateCell(id: any, value: any): Promise { + const queryUpdate = `UPDATE ${dbPrefix}_posts SET post_author = '${value}' WHERE ID = '${id}';`; + const res = await dbUtils.dbQuery(queryUpdate); + // console.log(res); + return res; + }, + + // create booking resource + async createBookingResource(postId: string, url: string): Promise { + const guid = url + '?post_type=bookable_resource&p=' + postId; + const queryUpdate = `UPDATE ${dbPrefix}_posts SET guid = '${guid}', post_type = 'bookable_resource' WHERE ID = '${postId}';`; + const res = await dbUtils.dbQuery(queryUpdate); + // console.log(res); + return res; + }, }; diff --git a/tests/pw/utils/gitTestSummary.ts b/tests/pw/utils/gitTestSummary.ts index 0b3bfe5b7c..f1f7b8d048 100644 --- a/tests/pw/utils/gitTestSummary.ts +++ b/tests/pw/utils/gitTestSummary.ts @@ -1,5 +1,5 @@ const fs = require('fs'); -const { SHA, PR_NUMBER, SYSTEM_INFO, API_TEST_RESULT, E2E_TEST_RESULT } = process.env; +const { SHA, PR_NUMBER, SYSTEM_INFO, API_TEST_RESULT, E2E_TEST_RESULT, API_COVERAGE } = process.env; const replace = obj => Object.keys(obj).forEach(key => (typeof obj[key] == 'object' ? replace(obj[key]) : (obj[key] = String(obj[key])))); const readFile = filePath => (fs.existsSync(filePath) ? JSON.parse(fs.readFileSync(filePath, 'utf8')) : false); @@ -13,19 +13,31 @@ const getTestResult = (suiteName, filePath) => { return testSummary; }; +const getCoverageReport = filePath => { + const coverageReport = readFile(filePath); + if (!coverageReport) { + return []; + } + return String(coverageReport.coverage); +}; + const addSummaryHeadingAndTable = core => { const tableHeader = [ { data: 'Test :test_tube:', header: true }, { data: 'Total :bar_chart:', header: true }, { data: 'Passed :white_check_mark:', header: true }, { data: 'Failed :rotating_light:', header: true }, - { data: 'Flaky :construction:', header: true }, + { data: 'Flaky :construction:', header: true }, { data: 'Skipped :next_track_button:', header: true }, { data: 'Duration :alarm_clock:', header: true }, + { data: 'Coverage :checkered_flag:', header: true }, ]; const apiTesResult = getTestResult('API Tests', API_TEST_RESULT); const e2eTesResult = getTestResult('E2E Tests', E2E_TEST_RESULT); - core.summary.addHeading('Tests Summary').addRaw(`Commit SHA: ${SHA}`).addBreak().addBreak().addTable([tableHeader, apiTesResult, e2eTesResult]); + apiTesResult.push(getCoverageReport(API_COVERAGE)); + e2eTesResult.push('-'); + const commit_sha = SHA ? `Commit SHA: ${SHA}` : ''; + core.summary.addHeading('Tests Summary').addRaw(commit_sha).addBreak().addBreak().addTable([tableHeader, apiTesResult, e2eTesResult]); }; const addList = core => { diff --git a/tests/pw/utils/helpers.ts b/tests/pw/utils/helpers.ts index 83fb0ef9ac..0362729e52 100644 --- a/tests/pw/utils/helpers.ts +++ b/tests/pw/utils/helpers.ts @@ -1,5 +1,6 @@ // const open = require( 'open' ); import fs from 'fs'; +import { execSync } from 'child_process'; import { Browser, BrowserContextOptions, Page } from '@playwright/test'; export const helpers = { @@ -78,7 +79,7 @@ export const helpers = { // remove dollar sign removeCurrencySign: (str: string): string => str.replace(/[^\d\-.,\\s]/g, ''), - // dateFormat // todo: remove all datetime , and update date to return date as required formate // also method to return as site date format + // dateFormat // todo: remove all date-time , and update date to return date as required formate // also method to return as site date format dateFormatFYJ: (date: string) => new Date(date).toLocaleDateString('en-CA', { year: 'numeric', month: 'long', day: 'numeric' }), // current year @@ -149,6 +150,13 @@ export const helpers = { return subtotal.reduce((a, b) => a + b, 0); }, + lineItemsToSubtotal(lineItems: object[]) { + const arrOfPriceQuantity = lineItems.map(({ price, quantity }) => [price, quantity]); + // const arrOfSubtotals = res.map(([price, quantity]) => price * quantity) + const subtotal = arrOfPriceQuantity.reduce((sum, [price, quantity]) => sum + price * quantity, 0); + return subtotal; + }, + // discount discount(subTotal: number, discount: any) { let discount_total = 0; @@ -344,6 +352,12 @@ export const helpers = { this.writeFile(filePath, JSON.stringify(envData, null, 2)); }, + // execute command + async exeCommand(command: string) { + const output = execSync(command, { encoding: 'utf-8' }); + console.log(output); + }, + async createPage(browser: Browser, options?: BrowserContextOptions | undefined) { const browserContext = await browser.newContext(options); return browserContext.newPage(); diff --git a/tests/pw/utils/interfaces.ts b/tests/pw/utils/interfaces.ts index 04f9bdaab7..affb101453 100644 --- a/tests/pw/utils/interfaces.ts +++ b/tests/pw/utils/interfaces.ts @@ -594,7 +594,7 @@ export interface payment { card: string; ideal: string; }; - iDealBanks: string; + iDealBanks: string[]; disbursementMode: string; customerBankStatement: string; paymentRequestButtonType: string; @@ -623,6 +623,7 @@ export interface dokanSetupWizard { // Vendor Setup Wizard export interface vendorSetupWizard { choice: boolean; + setupWizardEnabled: boolean; storeProductsPerPage: string; street1: string; street2: string; @@ -667,6 +668,11 @@ export interface vendor { lastname: string; storeName: string; + vendor2: { + username: string; + password: string; + }; + vendorInfo: { email: () => string; // emailDomain: string; @@ -712,6 +718,8 @@ export interface vendor { biography: string; supportButtonText: string; + addressFieldsEnabled: boolean; + openingClosingTime: { days: string[]; statusLite: string; @@ -792,44 +800,44 @@ export interface vendor { shippingCountry: string; methods: string; - shippingMethod: { - shippingZone: string; - shippingCountry: string; - selectShippingMethod: string; - shippingMethod: string; - taxStatus: string; - shippingCost: string; - description: string; - calculationType: string; - shippingMethodSaveSuccessMessage: string; - zoneSaveSuccessMessage: string; - saveSuccessMessage: string; - - freeShippingRequires: string; - freeShippingMinimumOrderAmount: string; - - taxIncludedInShippingCosts: string; - handlingFee: string; - maximumShippingCost: string; - - handlingFeePerOrder: string; - minimumCostPerOrder: string; - maximumCostPerOrder: string; - - tableRateSaveSuccessMessage: string; - - transportationMode: string; - avoid: string; - distanceUnit: string; - street1: string; - street2: string; - city: string; - zipCode: string; - state: string; - country: string; - - distanceRateSaveSuccessMessage: string; - }; + // shippingMethod: { + // shippingZone: string; + // shippingCountry: string; + // selectShippingMethod: string; + // shippingMethod: string; + // taxStatus: string; + // shippingCost: string; + // description: string; + // calculationType: string; + // shippingMethodSaveSuccessMessage: string; + // zoneSaveSuccessMessage: string; + // saveSuccessMessage: string; + + // freeShippingRequires: string; + // freeShippingMinimumOrderAmount: string; + + // taxIncludedInShippingCosts: string; + // handlingFee: string; + // maximumShippingCost: string; + + // handlingFeePerOrder: string; + // minimumCostPerOrder: string; + // maximumCostPerOrder: string; + + // tableRateSaveSuccessMessage: string; + + // transportationMode: string; + // avoid: string; + // distanceUnit: string; + // street1: string; + // street2: string; + // city: string; + // zipCode: string; + // state: string; + // country: string; + + // distanceRateSaveSuccessMessage: string; + // }; shippingMethods: { flatRate: { @@ -1025,13 +1033,12 @@ export interface vendor { // addon addon: { - randomName: () => string; name: string; priority: string; category: string; type: string; displayAs: string; - titleRequired: string; + title: string; formatTitle: string; addDescription: string; enterAnOption: string; @@ -1787,6 +1794,8 @@ export interface reqOptions { timeout?: number | undefined; } +export type params = Record | undefined; + export type headers = Record; export interface storageState { @@ -1829,3 +1838,14 @@ export interface storeContactData { email: string; message: string; } + +export interface questionsAnswers { + question: string; + editQuestion: string; + answer: string; + editAnswer: string; + user: { + username: string; + password: string; + }; +} diff --git a/tests/pw/utils/payloads.ts b/tests/pw/utils/payloads.ts index 9bd6244bbd..09ed56d120 100644 --- a/tests/pw/utils/payloads.ts +++ b/tests/pw/utils/payloads.ts @@ -103,7 +103,7 @@ export const payloads = { createProduct: () => ({ name: faker.commerce.productName() + ' (Simple)', type: 'simple', - regular_price: faker.finance.amount(100, 200, faker.helpers.arrayElement([0, 2])), + regular_price: faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([0, 2]) }), // regular_price: '114.15' , // failed for this price & 5% tax & 10% commission dokan .1 issue status: 'publish', categories: [ @@ -212,7 +212,7 @@ export const payloads = { createWholesaleProduct: () => ({ name: faker.commerce.productName() + ' (wholesale)', type: 'simple', - regular_price: faker.finance.amount(100, 110, faker.helpers.arrayElement([0, 2])), + regular_price: { min: 100, max: 110, dec: faker.helpers.arrayElement([0, 2]) }, // regular_price: '114.15' , // failed for this price & 5% tax & 10% commission dokan .1 issue status: 'publish', categories: [ @@ -230,7 +230,7 @@ export const payloads = { key: '_dokan_wholesale_meta', value: { enable_wholesale: 'yes', - price: faker.finance.amount(90, 99, faker.helpers.arrayElement([0, 2])), + regular_price: { min: 90, max: 99, dec: faker.helpers.arrayElement([0, 2]) }, // price: '100', quantity: '10', }, @@ -241,7 +241,7 @@ export const payloads = { createVariableProduct: () => ({ name: faker.commerce.productName() + ' (Variable)', type: 'variable', - regular_price: faker.finance.amount(100, 200, faker.helpers.arrayElement([0, 2])), + regular_price: faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([0, 2]) }), status: 'publish', categories: [ { @@ -266,7 +266,7 @@ export const payloads = { createProductVariation: { // id: '47', - regular_price: faker.finance.amount(100, 200, faker.helpers.arrayElement([0, 2])), + regular_price: faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([0, 2]) }), status: 'publish', categories: [ { @@ -293,7 +293,7 @@ export const payloads = { name: faker.commerce.productName() + ' (Downloadable)', type: 'simple', downloadable: true, - regular_price: faker.finance.amount(100, 200, faker.helpers.arrayElement([0, 2])), + regular_price: faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([0, 2]) }), downloads: [], // download_limit: 100, // download_expiry: 100, @@ -382,8 +382,8 @@ export const payloads = { // max_date_unit : 'month' }), - createBookingResource: { - name: 'resource1', + createBookingResource: () => ({ + name: 'resource_' + faker.string.nanoid(10), qty: '1', availability: [ { @@ -396,7 +396,15 @@ export const payloads = { ], base_cost: 5, block_cost: 6, - }, + }), + + createBookingResourceByDb: () => ({ + author: 1, + title: 'resource_' + faker.string.nanoid(10), + status: 'publish', + comment_status: 'closed', + ping_status: 'closed', + }), createAuctionProduct: () => ({ name: faker.commerce.productName() + ' (Auction)', @@ -405,9 +413,11 @@ export const payloads = { featured: true, description: 'test description', short_description: 'test short description', - // regular_price : faker.finance.amount(200, 400, 2), - // price : '2232', - regular_price: '2232', + price: '2000', + regular_price: '2000', + purchasable: true, + virtual: false, + downloadable: false, categories: [{}], meta_data: [ { @@ -421,7 +431,7 @@ export const payloads = { { key: '_auction_start_price', - value: '10', // faker.finance.amount(10, 20, 2), + value: '10', // faker.finance.amount({min:10, max:20, dec:2}), }, { key: '_auction_bid_increment', @@ -484,8 +494,8 @@ export const payloads = { }), createProductAddons: () => ({ - name: 'Test Addons Group_1' + faker.string.nanoid(10), - priority: 1, + name: 'Test Addons Group_' + faker.string.nanoid(10), + priority: 10, restrict_to_categories: [], fields: [ { @@ -507,7 +517,13 @@ export const payloads = { options: [ { label: 'Option 1', - price: '30', + price: '10', + image: '', + price_type: 'flat_fee', + }, + { + label: 'Option 2', + price: '20', image: '', price_type: 'flat_fee', }, @@ -516,9 +532,9 @@ export const payloads = { ], }), - updateProduct: () => ({ regular_price: faker.finance.amount(100, 200, faker.helpers.arrayElement([0, 2])) }), + updateProduct: () => ({ regular_price: faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([0, 2]) }) }), - updateProductVariation: () => ({ regular_price: faker.finance.amount(100, 200, faker.helpers.arrayElement([0, 2])) }), + updateProductVariation: () => ({ regular_price: faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([0, 2]) }) }), createProductReview: () => ({ product_id: '', @@ -542,6 +558,10 @@ export const payloads = { // product category + createCategoryRandom: () => ({ + name: faker.string.nanoid(10), + }), + createCategory: { name: 'Clothing', }, @@ -675,6 +695,10 @@ export const payloads = { product_id: '', quantity: 1, }, + // { + // product_id: '', + // quantity: 1, + // }, ], shipping_lines: [ @@ -2201,6 +2225,46 @@ export const payloads = { // module + moduleIds: { + booking: 'booking', + colorSchemeCustomize: 'color_scheme_customizer', + deliveryTime: 'delivery_time', + elementor: 'elementor', + exportImport: 'export_import', + followStore: 'follow_store', + geolocation: 'geolocation', + germanized: 'germanized', + liveChat: 'live_chat', + liveSearch: 'live_search', + moip: 'moip', + paypalMarketplace: 'paypal_marketplace', + productAddon: 'product_addon', + productEnquiry: 'product_enquiry', + reportAbuse: 'report_abuse', + rma: 'rma', + sellerVacation: 'seller_vacation', + shipstation: 'shipstation', + auction: 'auction', + spmv: 'spmv', + storeReviews: 'store_reviews', + storeSupport: 'store_support', + stripe: 'stripe', + productAdvertising: 'product_advertising', + productSubscription: 'product_subscription', + vendorAnalytics: 'vendor_analytics', + vendorStaff: 'vendor_staff', + vsp: 'vsp', + vendorVerification: 'vendor_verification', + wholesale: 'wholesale', + rankMath: 'rank_math', + tableRateShipping: 'table_rate_shipping', + mangopay: 'mangopay', + orderMinMax: 'order_min_max', + sellerBadge: 'seller_badge', + stripeExpress: 'stripe_express', + requestForQuotation: 'request_for_quotation', + }, + deactivateModule: { module: ['booking'], }, @@ -2324,7 +2388,6 @@ export const payloads = { gravatar: '', gravatar_id: 0, shop_url: '', - products_per_page: 12, show_more_product_tab: true, toc_enabled: false, store_toc: '', @@ -2406,7 +2469,6 @@ export const payloads = { gravatar: '', gravatar_id: 0, shop_url: '', - products_per_page: 12, show_more_product_tab: true, toc_enabled: false, store_toc: '', @@ -2452,6 +2514,68 @@ export const payloads = { admin_commission_type: 'flat', }), + // always revert vendor settings to this after altering in tests + defaultStoreSettings: { + social: { + fb: 'http://dokan.test', + youtube: 'http://dokan.test', + twitter: 'http://dokan.test', + linkedin: 'http://dokan.test', + pinterest: 'http://dokan.test', + instagram: 'http://dokan.test', + flickr: 'http://dokan.test', + }, + phone: '0123456789', + show_email: 'yes', + address: { + street_1: 'abc street', + street_2: 'xyz street', + city: 'New York', + zip: '10003', + state: 'NY', + country: 'US', + }, + location: '40.7127753,-74.0059728', + banner: 0, + banner_id: 0, + gravatar: 0, + gravatar_id: 0, + show_more_product_tab: true, + enable_tnc: 'on', + store_tnc: 'test Vendor terms and conditions', + featured: 'yes', + // rating: { + // rating: '4.00', // todo: doesn't work on lite [might not implemented on lite] + // count: 1, + // }, + enabled: true, + payment: { + paypal: { + email: 'paypal@g.c', + }, + bank: { + ac_name: 'account name', + ac_type: 'personal', + ac_number: '1234567', + bank_name: 'bank name', + bank_addr: 'bank address', + routing_number: '123456', + iban: '123456', + swift: '12345', + }, + }, + trusted: true, + company_name: 'company name', + vat_number: '123456789', + company_id_number: '123456789', + bank_name: 'bank name', + bank_iban: 'bank iban', + categories: [{}], + admin_commission: '', + admin_additional_fee: '0.00', + admin_commission_type: 'flat', + }, + createStoreReview: { title: 'Test store review', content: 'Test store review content', @@ -2507,7 +2631,6 @@ export const payloads = { banner_id: 0, gravatar: 0, gravatar_id: 0, - products_per_page: 12, show_more_product_tab: true, enable_tnc: 'on', store_tnc: 'test Vendor terms and conditions', @@ -2632,7 +2755,132 @@ export const payloads = { banner_id: 0, gravatar: 0, gravatar_id: 0, - products_per_page: 12, + show_more_product_tab: true, + toc_enabled: true, // todo: doesn't work on lite + store_toc: 'test Vendor terms and conditions', + featured: true, + rating: { + rating: '4.00', // todo: doesn't work on lite + count: 1, + }, + enabled: true, + payment: { + paypal: { + 0: 'email', + email: 'paypal@g.c', + }, + bank: { + ac_name: 'account name', + ac_type: 'personal', + ac_number: '1234567', + bank_name: 'bank name', + bank_addr: 'bank address', + routing_number: '123456', + iban: '123456', + swift: '12345', + }, + stripe: false, + }, + trusted: true, + // store_open_close: { + // enabled: false, + // time: [], + // open_notice: 'Store is open', + // close_notice: 'Store is closed', + // }, + store_open_close: { + // todo: doesn't work on lite + enabled: true, + time: { + monday: { + status: 'open', // 'close' + opening_time: ['12:00 am'], // [] + closing_time: ['11:30 pm'], // [] + }, + tuesday: { + status: 'open', + opening_time: ['12:00 am'], + closing_time: ['11:30 pm'], + }, + wednesday: { + status: 'open', + opening_time: ['12:00 am'], + closing_time: ['11:30 pm'], + }, + thursday: { + status: 'open', + opening_time: ['12:00 am'], + closing_time: ['11:30 pm'], + }, + friday: { + status: 'open', + opening_time: ['12:00 am'], + closing_time: ['11:30 pm'], + }, + saturday: { + status: 'open', + opening_time: ['12:00 am'], + closing_time: ['11:30 pm'], + }, + sunday: { + status: 'open', + opening_time: ['12:00 am'], + closing_time: ['11:30 pm'], + }, + }, + open_notice: 'Store is open', + close_notice: 'Store is closed', + }, + company_name: '', + vat_number: '', + company_id_number: '', + bank_name: '', + bank_iban: '', + categories: [ + { + // id: 74, + // name: 'Uncategorized', + // slug: 'uncategorized' + }, + ], + admin_commission: '', + admin_additional_fee: '', + admin_commission_type: '', + }, + + createStore3: { + user_login: process.env.VENDOR3, + user_pass: process.env.USER_PASSWORD, + user_nicename: process.env.VENDOR3 + 'store', + role: 'seller', + email: process.env.VENDOR3 + '@yopmail.com', + store_name: process.env.VENDOR3 + 'store', + first_name: process.env.VENDOR3, + last_name: 'v', + social: { + fb: 'http://dokan.test', + youtube: 'http://dokan.test', + twitter: 'http://dokan.test', + linkedin: 'http://dokan.test', + pinterest: 'http://dokan.test', + instagram: 'http://dokan.test', + flickr: 'http://dokan.test', + }, + phone: '0123456789', + show_email: true, // todo: doesn't work on lite + address: { + street_1: 'abc street', + street_2: 'xyz street', + city: 'New York', + zip: '10003', + state: 'NY', + country: 'US', + }, + location: '40.7127753,-74.0059728', + banner: 0, + banner_id: 0, + gravatar: 0, + gravatar_id: 0, show_more_product_tab: true, toc_enabled: true, // todo: doesn't work on lite store_toc: 'test Vendor terms and conditions', @@ -2763,7 +3011,7 @@ export const payloads = { updateAddress: { billing: { first_name: faker.person.firstName(), - last_name: 'c1', + last_name: faker.person.lastName(), company: '', address_1: 'abc street', address_2: 'xyz street', @@ -2776,7 +3024,7 @@ export const payloads = { }, shipping: { first_name: faker.person.firstName(), - last_name: 'c1', + last_name: faker.person.lastName(), company: '', address_1: 'abc street', address_2: 'xyz street', @@ -2945,6 +3193,27 @@ export const payloads = { ], }, + // product questions answeres + + createProductQuestion: () => ({ + question: 'test question_' + faker.string.nanoid(10), + product_id: '', + }), + + updateProductQuestion: () => ({ + question: 'test question updated_' + faker.string.nanoid(10), + status: 'hidden', + }), + + createProductQuestionAnswer: () => ({ + answer: 'test answer_' + faker.string.nanoid(10), + question_id: '', + }), + + updateProductQuestionAnswer: () => ({ + answer: 'test anser updated_' + faker.string.nanoid(10), + }), + // reverse withdrawal amountToPay: { diff --git a/tests/pw/utils/pwMatchers.ts b/tests/pw/utils/pwMatchers.ts index 9b52cae244..aaa9bfa3c0 100644 --- a/tests/pw/utils/pwMatchers.ts +++ b/tests/pw/utils/pwMatchers.ts @@ -18,24 +18,24 @@ export const customMatchers = { }, toBeSecureHeader(headers: any) { - // todo: implement this - // let pass; - // pass = headers['content-type'] === 'application/json; charset=UTF-8'; - // pass = headers['x-content-type-options'] === 'nosniff'; - // pass = headers['access-control-expose-headers'] === 'X-WP-Total, X-WP-TotalPages, Link'; - // pass = headers['access-control-allow-headers'] === 'Authorization, X-WP-Nonce, Content-Disposition, Content-MD5, Content-Type'; - // pass = headers['allow'] === 'GET, POST, df'; - // if (pass) { - // return { - // message: () => 'passed', - // pass: true, - // }; - // } else { - // return { - // message: () => 'failed', - // pass: false, - // }; - // } + // todo: update this method + let pass; + pass = headers['content-type'] === 'application/json; charset=UTF-8'; + pass = headers['x-content-type-options'] === 'nosniff'; + pass = headers['access-control-expose-headers'] === 'X-WP-Total, X-WP-TotalPages, Link'; + pass = headers['access-control-allow-headers'] === 'Authorization, X-WP-Nonce, Content-Disposition, Content-MD5, Content-Type'; + pass = headers['allow'] === 'GET, POST,'; + if (pass) { + return { + message: () => 'passed', + pass: true, + }; + } else { + return { + message: () => 'failed', + pass: false, + }; + } }, toBeWithinRange(received: number, floor: number, ceiling: number) { @@ -56,7 +56,7 @@ export const customMatchers = { export const customExpect = { toMatchSchema: customMatchers.toMatchSchema, - toBeSecureHeader: customMatchers.toBeSecureHeader, + // toBeSecureHeader: customMatchers.toBeSecureHeader, toBeWithinRange: customMatchers.toBeWithinRange, }; diff --git a/tests/pw/utils/sampleData/dokan.png b/tests/pw/utils/sampleData/dokan.png new file mode 100644 index 0000000000..9a6034610c Binary files /dev/null and b/tests/pw/utils/sampleData/dokan.png differ diff --git a/tests/pw/utils/schemas.ts b/tests/pw/utils/schemas.ts index 079c08a979..ad4733e94a 100644 --- a/tests/pw/utils/schemas.ts +++ b/tests/pw/utils/schemas.ts @@ -321,6 +321,57 @@ const supportTicketSchema = z.object({ _links: linksSchema, }); +const productQuestionSchema = z.object({ + id: z.number(), + product_id: z.number(), + question: z.string(), + user_id: z.number(), + read: z.number(), + status: z.string(), + created_at: z.string(), + updated_at: z.string(), + answer: z.object({ + id: z.number(), + question_id: z.number(), + answer: z.string(), + user_id: z.number(), + created_at: z.string(), + updated_at: z.string(), + human_readable_created_at: z.string(), + human_readable_updated_at: z.string(), + user_display_name: z.string(), + }), + user_display_name: z.string(), + human_readable_created_at: z.string(), + human_readable_updated_at: z.string(), + display_human_readable_created_at: z.boolean(), + display_human_readable_updated_at: z.boolean(), + product: z.object({ + id: z.number(), + title: z.string(), + image: z.string(), + }), + vendor: z.object({ + id: z.number(), + name: z.string(), + avatar: z.string(), + }), + _links: linksSchema, +}); + +const productQuestionAnswerSchema = z.object({ + id: z.number(), + question_id: z.number(), + answer: z.string(), + user_id: z.number(), + created_at: z.string(), + updated_at: z.string(), + human_readable_created_at: z.string(), + human_readable_updated_at: z.string(), + user_display_name: z.string(), + _links: linksSchema, +}); + export const schemas = { abuseReportsSchema: { abuseReportReasonsSchema: z.array( @@ -525,7 +576,7 @@ export const schemas = { vendor_name: z.string(), previous_order_total: z.string(), order_total: z.string(), - vendor_earning: z.string(), + vendor_earning: z.string().or(z.number()), commission: z.string(), dokan_gateway_fee: z.union([z.string(), z.number()]), gateway_fee_paid_by: z.string(), @@ -554,21 +605,23 @@ export const schemas = { adminExportLogsSchema: z.object({ step: z.string().or(z.number()), percentage: z.number(), - columns: z.object({ - order_id: z.string(), - vendor_id: z.string(), - vendor_name: z.string(), - previous_order_total: z.string(), - order_total: z.string(), - vendor_earning: z.string(), - commission: z.string(), - dokan_gateway_fee: z.string(), - gateway_fee_paid_by: z.string(), - shipping_total: z.string(), - tax_total: z.string(), - status: z.string(), - date: z.string(), - }), + columns: z + .object({ + order_id: z.string(), + vendor_id: z.string(), + vendor_name: z.string(), + previous_order_total: z.string(), + order_total: z.string(), + vendor_earning: z.string(), + commission: z.string(), + dokan_gateway_fee: z.string(), + gateway_fee_paid_by: z.string(), + shipping_total: z.string(), + tax_total: z.string(), + status: z.string(), + date: z.string(), + }) + .or(z.null()), }), }, @@ -599,6 +652,7 @@ export const schemas = { }), }), + m: z.coerce.date(), announcementsSchema: z.array( z.object({ id: z.number(), @@ -609,7 +663,7 @@ export const schemas = { status: z.enum(['all', 'publish', 'pending', 'draft', 'future', 'trash']), read_status: z.enum(['read', 'unread', '']), date: z.coerce.date(), - date_gmt: z.coerce.date(), + date_gmt: z.coerce.date().or(z.string()), human_readable_date: z.string(), announcement_sellers: z.array( z.object({ @@ -1973,4 +2027,16 @@ export const schemas = { success: z.boolean(), }), }, //TODO: + + productQaSchema: { + productQuestionSchema: productQuestionSchema, + productQuestionsSchema: z.array(productQuestionSchema), + + batchUpdateproductQuestionsSchema: z.object({ + message: z.string(), + }), + + productQuestionAnswerSchema: productQuestionAnswerSchema, + productQuestionAnswersSchema: z.array(productQuestionAnswerSchema), + }, }; diff --git a/tests/pw/utils/summaryReporter.ts b/tests/pw/utils/summaryReporter.ts index 353a3f4dd7..6cae817671 100644 --- a/tests/pw/utils/summaryReporter.ts +++ b/tests/pw/utils/summaryReporter.ts @@ -78,8 +78,6 @@ export default class summaryReport implements Reporter { summary.skipped = results.filter(x => x === 'skipped').length; // console.log(summary); - // fs.writeFileSync('results.json', JSON.stringify(summary)); - if (this.options.outputFile) { const outputFile = this.options.outputFile; if (!fs.existsSync(path.dirname(outputFile))) { diff --git a/tests/pw/utils/testData.ts b/tests/pw/utils/testData.ts index 563c655918..d957cff562 100644 --- a/tests/pw/utils/testData.ts +++ b/tests/pw/utils/testData.ts @@ -1,4 +1,3 @@ -// import { request } from '@playwright/test'; import { faker } from '@faker-js/faker'; import { helpers } from '@utils/helpers'; import 'dotenv/config'; @@ -34,6 +33,7 @@ export const data = { auth: { adminAuthFile: 'playwright/.auth/adminStorageState.json', vendorAuthFile: 'playwright/.auth/vendorStorageState.json', + vendor2AuthFile: 'playwright/.auth/vendor2StorageState.json', customerAuthFile: 'playwright/.auth/customerStorageState.json', adminAuth: { @@ -44,6 +44,10 @@ export const data = { storageState: 'playwright/.auth/vendorStorageState.json', }, + vendor2Auth: { + storageState: 'playwright/.auth/vendor2StorageState.json', + }, + customerAuth: { storageState: 'playwright/.auth/customerStorageState.json', }, @@ -67,7 +71,7 @@ export const data = { dokanPro: ['dokan-pro'], activeClass: 'active', pluginName: { - dokanlite: 'dokan-lite', + dokanLite: 'dokan-lite', dokanPro: 'dokan-pro', }, }, @@ -135,11 +139,11 @@ export const data = { price: { // price : faker.commerce.price(100, 200, 2), // price : faker.number.int({ min: 1, max: 200, precision: 0.01 }), - // price : faker.finance.amount(1, 200, 2), - price_int: () => faker.finance.amount(100, 200, 0), - price_random: () => faker.finance.amount(100, 200, faker.helpers.arrayElement([0, 2])), // 0 = no decimals, 2 = 2 decimals - price_frac: () => faker.finance.amount(100, 200, faker.helpers.arrayElement([1, 2])), - price_frac_comma: () => faker.finance.amount(100, 200, faker.helpers.arrayElement([1, 2])).replace('.', ','), + // price: faker.finance.amount({ min: 1, max: 200, dec: 2 }), + price_int: () => faker.finance.amount({ min: 100, max: 200, dec: 0 }), + price_random: () => faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([0, 2]) }), // 0 = no decimals, 2 = 2 decimals + price_frac: () => faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([1, 2]) }), + price_frac_comma: () => faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([1, 2]) }).replace('.', ','), auctionPrice: () => faker.commerce.price({ min: 10, max: 100, dec: 0 }), price: () => data.product.price.price_frac_comma(), }, @@ -178,7 +182,7 @@ export const data = { productType: 'simple', productName: () => faker.commerce.productName() + ' (Simple)', category: 'Uncategorized', - regularPrice: () => faker.finance.amount(100, 200, faker.helpers.arrayElement([1, 2])).replace('.', ','), + regularPrice: () => faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([1, 2]) }).replace('.', ','), storeName: String(process.env.VENDOR) + 'store', status: 'publish', stockStatus: false, @@ -190,7 +194,7 @@ export const data = { productType: 'simple', productName: () => faker.commerce.productName() + ' (Downadable)', category: 'Uncategorized', - regularPrice: () => faker.finance.amount(100, 200, faker.helpers.arrayElement([1, 2])).replace('.', ','), + regularPrice: () => faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([1, 2]) }).replace('.', ','), storeName: String(process.env.VENDOR) + 'store', status: 'publish', stockStatus: false, @@ -209,7 +213,7 @@ export const data = { productType: 'simple', productName: () => faker.commerce.productName() + ' (Virtual)', category: 'Uncategorized', - regularPrice: () => faker.finance.amount(100, 200, faker.helpers.arrayElement([1, 2])).replace('.', ','), + regularPrice: () => faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([1, 2]) }).replace('.', ','), storeName: String(process.env.VENDOR) + 'store', status: 'publish', stockStatus: false, @@ -221,7 +225,7 @@ export const data = { productType: 'variable', productName: () => faker.commerce.productName() + ' (Variable)', category: 'Uncategorized', - regularPrice: () => faker.finance.amount(100, 200, faker.helpers.arrayElement([1, 2])).replace('.', ','), + regularPrice: () => faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([1, 2]) }).replace('.', ','), storeName: String(process.env.VENDOR) + 'store', status: 'publish', stockStatus: false, @@ -240,7 +244,7 @@ export const data = { productUrl: '/product/p1_v1-simple/', buttonText: 'Buy product', category: 'Uncategorized', - regularPrice: () => faker.finance.amount(100, 200, faker.helpers.arrayElement([1, 2])).replace('.', ','), + regularPrice: () => faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([1, 2]) }).replace('.', ','), storeName: String(process.env.VENDOR) + 'store', status: 'publish', saveSuccessMessage: 'Success! The product has been saved successfully. View Product →', @@ -250,8 +254,8 @@ export const data = { productType: 'subscription', productName: () => faker.commerce.productName() + ' (Simple Subscription)', category: 'Uncategorized', - regularPrice: () => faker.finance.amount(100, 200, faker.helpers.arrayElement([1, 2])).replace('.', ','), - subscriptionPrice: () => faker.finance.amount(100, 200, faker.helpers.arrayElement([1, 2])).replace('.', ','), + regularPrice: () => faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([1, 2]) }).replace('.', ','), + subscriptionPrice: () => faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([1, 2]) }).replace('.', ','), subscriptionPeriodInterval: '1', // '0', '1', '2', '3', '4', '5', '6' subscriptionPeriod: 'month', // 'day', 'week', 'month', 'year' expireAfter: '0', // '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24' @@ -266,8 +270,8 @@ export const data = { productType: 'variable-subscription', productName: () => faker.commerce.productName() + ' (Variable Subscription)', category: 'Uncategorized', - regularPrice: () => faker.finance.amount(100, 200, faker.helpers.arrayElement([1, 2])).replace('.', ','), - subscriptionPrice: () => faker.finance.amount(100, 200, faker.helpers.arrayElement([1, 2])).replace('.', ','), + regularPrice: () => faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([1, 2]) }).replace('.', ','), + subscriptionPrice: () => faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([1, 2]) }).replace('.', ','), subscriptionPeriodInterval: '1', subscriptionPeriod: 'month', expireAfter: '0', @@ -296,7 +300,7 @@ export const data = { }) + ' (Product Pack)', category: 'Uncategorized', - regularPrice: () => faker.finance.amount(100, 200, faker.helpers.arrayElement([1, 2])).replace('.', ','), + regularPrice: () => faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([1, 2]) }).replace('.', ','), numberOfProducts: '-1', packValidity: '0', advertisementSlot: '-1', @@ -341,10 +345,10 @@ export const data = { category: 'Uncategorized', itemCondition: 'new', // 'new', 'used' auctionType: 'normal', // 'normal', 'reverse' - regularPrice: () => faker.finance.amount(10, 100, faker.helpers.arrayElement([1, 2])).replace('.', ','), - bidIncrement: () => faker.finance.amount(40, 50, faker.helpers.arrayElement([1, 2])).replace('.', ','), - reservedPrice: () => faker.finance.amount(400, 500, faker.helpers.arrayElement([1, 2])).replace('.', ','), - buyItNowPrice: () => faker.finance.amount(900, 1000, faker.helpers.arrayElement([1, 2])).replace('.', ','), + regularPrice: () => faker.finance.amount({ min: 10, max: 100, dec: faker.helpers.arrayElement([1, 2]) }).replace('.', ','), + bidIncrement: () => faker.finance.amount({ min: 40, max: 50, dec: faker.helpers.arrayElement([1, 2]) }).replace('.', ','), + reservedPrice: () => faker.finance.amount({ min: 400, max: 500, dec: faker.helpers.arrayElement([1, 2]) }).replace('.', ','), + buyItNowPrice: () => faker.finance.amount({ min: 900, max: 1000, dec: faker.helpers.arrayElement([1, 2]) }).replace('.', ','), startDate: helpers.currentDateTime, endDate: helpers.addDays(helpers.currentDateTime, 20, 'full'), storeName: String(process.env.VENDOR) + 'store', @@ -739,6 +743,7 @@ export const data = { // Vendor Setup Wizard vendorSetupWizard: { + setupWizardEnabled: true, choice: true, storeProductsPerPage: '12', street1: 'abc street', @@ -814,6 +819,8 @@ export const data = { allLogs: 'wp-admin/admin.php?page=dokan#/reports?tab=logs', modules: 'wp-admin/admin.php?page=dokan#/modules', tools: 'wp-admin/admin.php?page=dokan#/tools', + productQA: 'wp-admin/admin.php?page=dokan#/product-qa', + questionDetails: (questionId: string) => `wp-admin/admin.php?page=dokan#/product-qa/${questionId}`, verifications: 'wp-admin/admin.php?page=dokan-seller-verifications', productAdvertising: 'wp-admin/admin.php?page=dokan#/product-advertising', wholeSaleCustomer: 'wp-admin/admin.php?page=dokan#/wholesale-customer', @@ -850,6 +857,7 @@ export const data = { requestForQuote: 'request-quote', requestedQuote: 'my-account/request-a-quote', accountMigration: 'my-account/account-migration', + myAccountToProductQA: 'my-account/?product_qa', orderCancel: 'cart/?cancel_order', orderAgain: 'cart/?order_again', orderPay: 'checkout/order-pay', @@ -911,6 +919,8 @@ export const data = { withdraw: 'dashboard/withdraw', withdrawRequests: 'dashboard/withdraw-requests', badges: 'dashboard/seller-badge', + productQA: 'dashboard/product-questions-answers', + questionDetails: (questionId: string) => `dashboard/product-questions-answers/?question_id=${questionId}`, reverseWithdrawal: 'dashboard/reverse-withdrawal', returnRequest: 'dashboard/return-request', staff: 'dashboard/staffs', @@ -970,6 +980,9 @@ export const data = { quoteRules: 'dokan/v1/request-for-quote/quote-rule', sellerBadge: 'dokan/v1/seller-badge', sellerBadgeEvent: 'dokan/v1/seller-badge/events', + productQuestions: 'dokan/v1/product-questions', + productQuestionsBulkActions: 'dokan/v1/product-questions/bulk_action', + productAnswers: 'dokan/v1/product-answers', }, wc: { @@ -1008,6 +1021,11 @@ export const data = { lastname: (String(process.env.VENDOR)[0] as string) + String(process.env.VENDOR)[String(process.env.VENDOR).length - 1], storeName: String(process.env.VENDOR) + 'store', + vendor2: { + username: String(process.env.VENDOR2), + password: String(process.env.USER_PASSWORD), + }, + vendorInfo: { emailDomain: '@email.com', // email : () => faker.internet.email(), @@ -1053,6 +1071,9 @@ export const data = { biography: 'Vendor biography', supportButtonText: 'Get Support', + // address fields enable flag (on vendor registration) + addressFieldsEnabled: false, + account: { updateSuccessMessage: 'Account details changed successfully.', }, @@ -1340,15 +1361,13 @@ export const data = { }, // addon - addon: { - randomName: () => 'Addons Group_' + faker.string.nanoid(10), - randomTitle: () => 'Add-on Title_' + faker.string.nanoid(10), - name: 'Addons Group_', + addon: () => ({ + name: 'Test Addons Group_' + faker.string.nanoid(10), priority: '10', category: 'Uncategorized', type: 'multiple_choice', // 'multiple_choice', 'checkbox', 'custom_text', 'custom_textarea', 'file_upload', 'custom_price', 'input_multiplier', 'heading' displayAs: 'select', // 'select', 'radiobutton', 'images' - titleRequired: 'Add-on Title_', + title: 'Test Add-on Title_' + faker.string.nanoid(10), formatTitle: 'label', // 'label', 'heading', 'hide' addDescription: 'Add-on description', enterAnOption: 'Option 1', @@ -1356,7 +1375,7 @@ export const data = { optionPriceInput: '30', saveSuccessMessage: 'Add-on saved successfully', deleteSuccessMessage: 'Add-on deleted successfully', - }, + }), registrationErrorMessage: 'Error: An account is already registered with your email address. Please log in.', }, @@ -1529,9 +1548,9 @@ export const data = { // Reverse withdraw reverseWithdraw: { - store: String(process.env.VENDOR) + 'store', + store: String(process.env.VENDOR2) + 'store', transactionType: 'manual_product', // manual_product, manual_order, other - product: 'p1_v1 (simple)', + product: '', withdrawalBalanceType: 'debit', // debit, credit amount: '500', note: 'test reverse withdraw note', @@ -1554,8 +1573,8 @@ export const data = { guest: 'guest', }, - quoteRule: { - title: () => 'test rule_' + faker.string.nanoid(10), + quoteRule: () => ({ + title: 'test rule_' + faker.string.nanoid(10), userRole: 'customer', product: 'p1_v1 (simple)', category: 'Uncategorized', @@ -1564,15 +1583,15 @@ export const data = { hideAddToCartButton: 'keep_and_add_new', // replace, keep_and_add_new customButtonLabel: 'Add to quote', order: '0', - }, + }), trashedQuoteRule: { - title: 'trashed quote rule ', + title: 'trashed quote rule', status: 'trash', }, - quote: { - title: () => 'test quote_' + faker.string.nanoid(10), + quote: () => ({ + title: 'test quote_' + faker.string.nanoid(10), user: 'customer1', // todo: update customer data via env and email domain fullName: 'Jhon Doe', email: 'customer1@g.com', @@ -1582,7 +1601,7 @@ export const data = { quantity: '5', offerPrice: '80', offerProductQuantity: '10', - }, + }), trashedQuote: { title: 'trashed quote', @@ -1657,6 +1676,23 @@ export const data = { badgeStatus: 'published', // published, draft }, + // question answeres + questionAnswers: { + question: 'test question', + editQuestion: 'edited test question', + answer: 'test answer', + editAnswer: 'edited test answer', + user: { + username: String(process.env.CUSTOMER), + password: String(process.env.USER_PASSWORD), + }, + + filter: { + byVendor: String(process.env.VENDOR) + 'store', + byProduct: 'p1_v1 (simple)', + }, + }, + // announcement announcement: { receiverType: { @@ -2077,6 +2113,7 @@ export const data = { followFromStoreListing: 'storeListing', followFromSingleStore: 'singleStore', vendor1: String(process.env.VENDOR) + 'store', + vendor2: String(process.env.VENDOR2) + 'store', vendor1FullName: String(process.env.VENDOR) + ' ' + 'v1', shopUrl: String(process.env.VENDOR) + 'store', }, @@ -2089,6 +2126,25 @@ export const data = { }, }, + status: { + on: 'on', + off: 'off', + }, + + // image + image: { + avatar: 'utils/sampleData/avatar.png', + dokan: 'utils/sampleData/dokan.png', + license: 'utils/sampleData/license.png', + }, + + // command + command: { + permalink: 'npm run wp-env run tests-cli wp rewrite structure /%postname%/', + permalinkLocal: `cd ${process.env.SITE_PATH} && wp rewrite structure /%postname%/ && wp rewrite flush`, + activateTheme: `cd ${process.env.SITE_PATH} && wp theme activate storefront`, + }, + // install wordpress installWp: { // db info