From 674953f77e39b241755d350028390ce31f1f8ac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brablo=C2=B0?= Date: Wed, 23 Oct 2024 14:50:48 +0200 Subject: [PATCH] #anotations --- .github/workflows/playwright.yml | 2 +- .github/workflows/tests.yml | 2 +- .../workflows/playwright_20241014104838.yml | 27 ++++ .../workflows/playwright_20241023144315.yml | 27 ++++ .../workflows/tests_20241023144354.yml | 34 +++++ .../workflows/tests_20241023144357.yml | 34 +++++ .history/data/testData_20241023130356.ts | 81 ++++++++++++ .history/data/testData_20241023132112.ts | 82 ++++++++++++ .history/data/testData_20241023132146.ts | 82 ++++++++++++ .history/data/testData_20241023132612.ts | 82 ++++++++++++ .history/data/urls_20241023124720.ts | 10 ++ .history/helpers/uiHelper_20241023124906.ts | 99 +++++++++++++++ .history/helpers/uiHelper_20241023125122.ts | 99 +++++++++++++++ .../pages/newCommunityPage_20241023124157.ts | 118 ++++++++++++++++++ .../pages/newCommunityPage_20241023124330.ts | 66 ++++++++++ .../pages/newCommunityPage_20241023124518.ts | 66 ++++++++++ .../pages/newCommunityPage_20241023124607.ts | 66 ++++++++++ .../pages/newCommunityPage_20241023125206.ts | 71 +++++++++++ .../pages/newCommunityPage_20241023125703.ts | 72 +++++++++++ .../pages/newCommunityPage_20241023131250.ts | 73 +++++++++++ .../pages/newCommunityPage_20241023131343.ts | 73 +++++++++++ .../pages/newCommunityPage_20241023131405.ts | 73 +++++++++++ .../pages/newCommunityPage_20241023131501.ts | 73 +++++++++++ .../pages/newCommunityPage_20241023131512.ts | 68 ++++++++++ .../pages/newCommunityPage_20241023132343.ts | 75 +++++++++++ .../pages/newCommunityPage_20241023132514.ts | 75 +++++++++++ .../pages/newCommunityPage_20241023132606.ts | 75 +++++++++++ .../pages/newCommunityPage_20241023133716.ts | 81 ++++++++++++ .../pages/newCommunityPage_20241023133903.ts | 87 +++++++++++++ .../pages/newCommunityPage_20241023133942.ts | 87 +++++++++++++ .../pages/newCommunityPage_20241023134641.ts | 93 ++++++++++++++ .../pages/newCommunityPage_20241023134654.ts | 93 ++++++++++++++ .history/tests/edit.spec_20241023142847.ts | 79 ++++++++++++ .history/tests/edit.spec_20241023142849.ts | 79 ++++++++++++ .history/tests/edit.spec_20241023142939.ts | 79 ++++++++++++ .history/tests/edit.spec_20241023144046.ts | 81 ++++++++++++ .history/tests/edit.spec_20241023144837.ts | 81 ++++++++++++ .../tests/newUpload.spec_20241023143850.ts | 45 +++++++ .../tests/newUpload.spec_20241023143945.ts | 45 +++++++ .../tests/newUpload.spec_20241023145048.ts | 45 +++++++ data/testData.ts | 3 +- data/urls.ts | 3 +- helpers/uiHelper.ts | 6 + pages/newCommunityPage.ts | 89 +++++-------- tests/edit.spec.ts | 5 +- tests/newUpload.spec.ts | 5 +- 46 files changed, 2728 insertions(+), 63 deletions(-) create mode 100644 .history/.github/workflows/playwright_20241014104838.yml create mode 100644 .history/.github/workflows/playwright_20241023144315.yml create mode 100644 .history/.github/workflows/tests_20241023144354.yml create mode 100644 .history/.github/workflows/tests_20241023144357.yml create mode 100644 .history/data/testData_20241023130356.ts create mode 100644 .history/data/testData_20241023132112.ts create mode 100644 .history/data/testData_20241023132146.ts create mode 100644 .history/data/testData_20241023132612.ts create mode 100644 .history/data/urls_20241023124720.ts create mode 100644 .history/helpers/uiHelper_20241023124906.ts create mode 100644 .history/helpers/uiHelper_20241023125122.ts create mode 100644 .history/pages/newCommunityPage_20241023124157.ts create mode 100644 .history/pages/newCommunityPage_20241023124330.ts create mode 100644 .history/pages/newCommunityPage_20241023124518.ts create mode 100644 .history/pages/newCommunityPage_20241023124607.ts create mode 100644 .history/pages/newCommunityPage_20241023125206.ts create mode 100644 .history/pages/newCommunityPage_20241023125703.ts create mode 100644 .history/pages/newCommunityPage_20241023131250.ts create mode 100644 .history/pages/newCommunityPage_20241023131343.ts create mode 100644 .history/pages/newCommunityPage_20241023131405.ts create mode 100644 .history/pages/newCommunityPage_20241023131501.ts create mode 100644 .history/pages/newCommunityPage_20241023131512.ts create mode 100644 .history/pages/newCommunityPage_20241023132343.ts create mode 100644 .history/pages/newCommunityPage_20241023132514.ts create mode 100644 .history/pages/newCommunityPage_20241023132606.ts create mode 100644 .history/pages/newCommunityPage_20241023133716.ts create mode 100644 .history/pages/newCommunityPage_20241023133903.ts create mode 100644 .history/pages/newCommunityPage_20241023133942.ts create mode 100644 .history/pages/newCommunityPage_20241023134641.ts create mode 100644 .history/pages/newCommunityPage_20241023134654.ts create mode 100644 .history/tests/edit.spec_20241023142847.ts create mode 100644 .history/tests/edit.spec_20241023142849.ts create mode 100644 .history/tests/edit.spec_20241023142939.ts create mode 100644 .history/tests/edit.spec_20241023144046.ts create mode 100644 .history/tests/edit.spec_20241023144837.ts create mode 100644 .history/tests/newUpload.spec_20241023143850.ts create mode 100644 .history/tests/newUpload.spec_20241023143945.ts create mode 100644 .history/tests/newUpload.spec_20241023145048.ts diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 3eb1314..3cb0c05 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -18,7 +18,7 @@ jobs: - name: Install Playwright Browsers run: npx playwright install --with-deps - name: Run Playwright tests - run: npx playwright test + run: QASE_MODE=testops npx playwright test - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 512627e..9d72396 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,7 +25,7 @@ jobs: - name: Install playwright browsers run: npx playwright install --with-deps - name: Run tests - run: npx playwright test + run: QASE_MODE=testops npx playwright test - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: diff --git a/.history/.github/workflows/playwright_20241014104838.yml b/.history/.github/workflows/playwright_20241014104838.yml new file mode 100644 index 0000000..3eb1314 --- /dev/null +++ b/.history/.github/workflows/playwright_20241014104838.yml @@ -0,0 +1,27 @@ +name: Playwright Tests +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Install dependencies + run: npm ci + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Run Playwright tests + run: npx playwright test + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/.history/.github/workflows/playwright_20241023144315.yml b/.history/.github/workflows/playwright_20241023144315.yml new file mode 100644 index 0000000..3cb0c05 --- /dev/null +++ b/.history/.github/workflows/playwright_20241023144315.yml @@ -0,0 +1,27 @@ +name: Playwright Tests +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Install dependencies + run: npm ci + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Run Playwright tests + run: QASE_MODE=testops npx playwright test + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/.history/.github/workflows/tests_20241023144354.yml b/.history/.github/workflows/tests_20241023144354.yml new file mode 100644 index 0000000..9d72396 --- /dev/null +++ b/.history/.github/workflows/tests_20241023144354.yml @@ -0,0 +1,34 @@ +on: + push: + branches: + - main + pull_request: + branches: + - main + +env: + QASE_TESTOPS_PROJECT: ${{ secrets.QASE_TESTOPS_PROJECT }} + QASE_TESTOPS_API_TOKEN: ${{ secrets.QASE_TESTOPS_API_TOKEN }} + QASE_ENVIRONMENT: ${{ secrets.QASE_ENVIRONMENT }} + HEADLESS: true + +jobs: + tests_e2e: + name: Run end-to-end tests + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + - name: Install dependencies + run: npm ci + - name: Install playwright browsers + run: npx playwright install --with-deps + - name: Run tests + run: QASE_MODE=testops npx playwright test + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/.history/.github/workflows/tests_20241023144357.yml b/.history/.github/workflows/tests_20241023144357.yml new file mode 100644 index 0000000..9d72396 --- /dev/null +++ b/.history/.github/workflows/tests_20241023144357.yml @@ -0,0 +1,34 @@ +on: + push: + branches: + - main + pull_request: + branches: + - main + +env: + QASE_TESTOPS_PROJECT: ${{ secrets.QASE_TESTOPS_PROJECT }} + QASE_TESTOPS_API_TOKEN: ${{ secrets.QASE_TESTOPS_API_TOKEN }} + QASE_ENVIRONMENT: ${{ secrets.QASE_ENVIRONMENT }} + HEADLESS: true + +jobs: + tests_e2e: + name: Run end-to-end tests + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + - name: Install dependencies + run: npm ci + - name: Install playwright browsers + run: npx playwright install --with-deps + - name: Run tests + run: QASE_MODE=testops npx playwright test + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/.history/data/testData_20241023130356.ts b/.history/data/testData_20241023130356.ts new file mode 100644 index 0000000..f534790 --- /dev/null +++ b/.history/data/testData_20241023130356.ts @@ -0,0 +1,81 @@ +// Import the required modules +import { faker } from '@faker-js/faker'; + +/** + * Test Data: + * Test data files store the input values and expected outputs used across test cases. + * They help separate the test logic from the data, ensuring tests remain flexible + * and reusable. By keeping data like form inputs, URLs, or expected messages in + * dedicated files, you can easily update and manage values without changing the + * test logic. This approach also allows for dynamic data generation using + * libraries like Faker, and ensures test cases remain clean and focused on + * behavior rather than hardcoded values. + */ + +// Test data for tests, static hardcoded and also autogenerated by faker +export const testData = { + + // User credentials for login - hardcoded + email: 'petr.brablc@gmail.com', + password: '123456', + + // User credentials for login - generated by faker + randomEmail: () => faker.internet.email(), + randomPassword: () => faker.internet.password(), + + // Generate a random embargo reason + randomEmbargoReason: () => faker.lorem.sentence(), + + // New upload test data + upload: { + recordTitle: () => faker.lorem.sentence(), // Function to generate a random title + familyName: () => faker.lorem.word(), // Function to generate a random family name + recordDescription: () => faker.lorem.paragraph(), // Function to generate a random description + communityName: () => faker.lorem.word(), // Function to generate a random community name + + // Dynamic resource type - Select randomly from a list, ensuring it's not the same as the currently selected type + resourceType: (currentlySelected: string | null): string => { + const resourceTypes = [ + 'Image', + 'Video', + 'Dataset', + 'Other', + 'Audio', + 'Software', + 'Workflow', + 'Poster', + 'Model', + 'Lesson', + 'Event' + ]; + + // Filter out the currently selected type from the available types + const availableTypes = currentlySelected + ? resourceTypes.filter(type => type !== currentlySelected) + : resourceTypes; + + // Select a random type from the available types + return faker.helpers.arrayElement(availableTypes); + }, + }, + + // Data for export selection tests + export: { + style: 'Harvard', // Hardcoded style option for the test + exportOption: 'JSON-LD' // Hardcoded export option for the test + }, + + // Method to get today's date plus one day in YYYY-MM-DD format + getDatePlusOne: (): string => { + const today = new Date(); + const tomorrow = new Date(today); + tomorrow.setDate(today.getDate() + 1); + + // Format the date as YYYY-MM-DD + const year = tomorrow.getFullYear(); + const month = String(tomorrow.getMonth() + 1).padStart(2, '0'); // Months are 0-based + const day = String(tomorrow.getDate()).padStart(2, '0'); + + return `${year}-${month}-${day}`; + } +}; \ No newline at end of file diff --git a/.history/data/testData_20241023132112.ts b/.history/data/testData_20241023132112.ts new file mode 100644 index 0000000..243655a --- /dev/null +++ b/.history/data/testData_20241023132112.ts @@ -0,0 +1,82 @@ +// Import the required modules +import { faker } from '@faker-js/faker'; + +/** + * Test Data: + * Test data files store the input values and expected outputs used across test cases. + * They help separate the test logic from the data, ensuring tests remain flexible + * and reusable. By keeping data like form inputs, URLs, or expected messages in + * dedicated files, you can easily update and manage values without changing the + * test logic. This approach also allows for dynamic data generation using + * libraries like Faker, and ensures test cases remain clean and focused on + * behavior rather than hardcoded values. + */ + +// Test data for tests, static hardcoded and also autogenerated by faker +export const testData = { + + // User credentials for login - hardcoded + email: 'petr.brablc@gmail.com', + password: '123456', + + // User credentials for login - generated by faker + randomEmail: () => faker.internet.email(), + randomPassword: () => faker.internet.password(), + + // Generate a random embargo reason + randomEmbargoReason: () => faker.lorem.sentence(), + + // New upload test data + upload: { + recordTitle: () => faker.lorem.sentence(), // Function to generate a random title + familyName: () => faker.lorem.word(), // Function to generate a random family name + recordDescription: () => faker.lorem.paragraph(), // Function to generate a random description + communityName: () => faker.lorem.word(), // Function to generate a random community name + communityIdentifier: () => faker.helpers.slugify(faker.lorem.sentence()), // Function to generate a random community identifier + + // Dynamic resource type - Select randomly from a list, ensuring it's not the same as the currently selected type + resourceType: (currentlySelected: string | null): string => { + const resourceTypes = [ + 'Image', + 'Video', + 'Dataset', + 'Other', + 'Audio', + 'Software', + 'Workflow', + 'Poster', + 'Model', + 'Lesson', + 'Event' + ]; + + // Filter out the currently selected type from the available types + const availableTypes = currentlySelected + ? resourceTypes.filter(type => type !== currentlySelected) + : resourceTypes; + + // Select a random type from the available types + return faker.helpers.arrayElement(availableTypes); + }, + }, + + // Data for export selection tests + export: { + style: 'Harvard', // Hardcoded style option for the test + exportOption: 'JSON-LD' // Hardcoded export option for the test + }, + + // Method to get today's date plus one day in YYYY-MM-DD format + getDatePlusOne: (): string => { + const today = new Date(); + const tomorrow = new Date(today); + tomorrow.setDate(today.getDate() + 1); + + // Format the date as YYYY-MM-DD + const year = tomorrow.getFullYear(); + const month = String(tomorrow.getMonth() + 1).padStart(2, '0'); // Months are 0-based + const day = String(tomorrow.getDate()).padStart(2, '0'); + + return `${year}-${month}-${day}`; + } +}; \ No newline at end of file diff --git a/.history/data/testData_20241023132146.ts b/.history/data/testData_20241023132146.ts new file mode 100644 index 0000000..31f33f2 --- /dev/null +++ b/.history/data/testData_20241023132146.ts @@ -0,0 +1,82 @@ +// Import the required modules +import { faker } from '@faker-js/faker'; + +/** + * Test Data: + * Test data files store the input values and expected outputs used across test cases. + * They help separate the test logic from the data, ensuring tests remain flexible + * and reusable. By keeping data like form inputs, URLs, or expected messages in + * dedicated files, you can easily update and manage values without changing the + * test logic. This approach also allows for dynamic data generation using + * libraries like Faker, and ensures test cases remain clean and focused on + * behavior rather than hardcoded values. + */ + +// Test data for tests, static hardcoded and also autogenerated by faker +export const testData = { + + // User credentials for login - hardcoded + email: 'petr.brablc@gmail.com', + password: '123456', + + // User credentials for login - generated by faker + randomEmail: () => faker.internet.email(), + randomPassword: () => faker.internet.password(), + + // Generate a random embargo reason + randomEmbargoReason: () => faker.lorem.sentence(), + + // New upload test data + upload: { + recordTitle: () => faker.lorem.sentence(), // Function to generate a random title + familyName: () => faker.lorem.word(), // Function to generate a random family name + recordDescription: () => faker.lorem.paragraph(), // Function to generate a random description + communityName: () => faker.lorem.word(), // Function to generate a random community name + communityIdentifier: () => faker.lorem.sentence(), // Function to generate a random community identifier + + // Dynamic resource type - Select randomly from a list, ensuring it's not the same as the currently selected type + resourceType: (currentlySelected: string | null): string => { + const resourceTypes = [ + 'Image', + 'Video', + 'Dataset', + 'Other', + 'Audio', + 'Software', + 'Workflow', + 'Poster', + 'Model', + 'Lesson', + 'Event' + ]; + + // Filter out the currently selected type from the available types + const availableTypes = currentlySelected + ? resourceTypes.filter(type => type !== currentlySelected) + : resourceTypes; + + // Select a random type from the available types + return faker.helpers.arrayElement(availableTypes); + }, + }, + + // Data for export selection tests + export: { + style: 'Harvard', // Hardcoded style option for the test + exportOption: 'JSON-LD' // Hardcoded export option for the test + }, + + // Method to get today's date plus one day in YYYY-MM-DD format + getDatePlusOne: (): string => { + const today = new Date(); + const tomorrow = new Date(today); + tomorrow.setDate(today.getDate() + 1); + + // Format the date as YYYY-MM-DD + const year = tomorrow.getFullYear(); + const month = String(tomorrow.getMonth() + 1).padStart(2, '0'); // Months are 0-based + const day = String(tomorrow.getDate()).padStart(2, '0'); + + return `${year}-${month}-${day}`; + } +}; \ No newline at end of file diff --git a/.history/data/testData_20241023132612.ts b/.history/data/testData_20241023132612.ts new file mode 100644 index 0000000..31f33f2 --- /dev/null +++ b/.history/data/testData_20241023132612.ts @@ -0,0 +1,82 @@ +// Import the required modules +import { faker } from '@faker-js/faker'; + +/** + * Test Data: + * Test data files store the input values and expected outputs used across test cases. + * They help separate the test logic from the data, ensuring tests remain flexible + * and reusable. By keeping data like form inputs, URLs, or expected messages in + * dedicated files, you can easily update and manage values without changing the + * test logic. This approach also allows for dynamic data generation using + * libraries like Faker, and ensures test cases remain clean and focused on + * behavior rather than hardcoded values. + */ + +// Test data for tests, static hardcoded and also autogenerated by faker +export const testData = { + + // User credentials for login - hardcoded + email: 'petr.brablc@gmail.com', + password: '123456', + + // User credentials for login - generated by faker + randomEmail: () => faker.internet.email(), + randomPassword: () => faker.internet.password(), + + // Generate a random embargo reason + randomEmbargoReason: () => faker.lorem.sentence(), + + // New upload test data + upload: { + recordTitle: () => faker.lorem.sentence(), // Function to generate a random title + familyName: () => faker.lorem.word(), // Function to generate a random family name + recordDescription: () => faker.lorem.paragraph(), // Function to generate a random description + communityName: () => faker.lorem.word(), // Function to generate a random community name + communityIdentifier: () => faker.lorem.sentence(), // Function to generate a random community identifier + + // Dynamic resource type - Select randomly from a list, ensuring it's not the same as the currently selected type + resourceType: (currentlySelected: string | null): string => { + const resourceTypes = [ + 'Image', + 'Video', + 'Dataset', + 'Other', + 'Audio', + 'Software', + 'Workflow', + 'Poster', + 'Model', + 'Lesson', + 'Event' + ]; + + // Filter out the currently selected type from the available types + const availableTypes = currentlySelected + ? resourceTypes.filter(type => type !== currentlySelected) + : resourceTypes; + + // Select a random type from the available types + return faker.helpers.arrayElement(availableTypes); + }, + }, + + // Data for export selection tests + export: { + style: 'Harvard', // Hardcoded style option for the test + exportOption: 'JSON-LD' // Hardcoded export option for the test + }, + + // Method to get today's date plus one day in YYYY-MM-DD format + getDatePlusOne: (): string => { + const today = new Date(); + const tomorrow = new Date(today); + tomorrow.setDate(today.getDate() + 1); + + // Format the date as YYYY-MM-DD + const year = tomorrow.getFullYear(); + const month = String(tomorrow.getMonth() + 1).padStart(2, '0'); // Months are 0-based + const day = String(tomorrow.getDate()).padStart(2, '0'); + + return `${year}-${month}-${day}`; + } +}; \ No newline at end of file diff --git a/.history/data/urls_20241023124720.ts b/.history/data/urls_20241023124720.ts new file mode 100644 index 0000000..2446a71 --- /dev/null +++ b/.history/data/urls_20241023124720.ts @@ -0,0 +1,10 @@ +// Direct URLS for a quick navigation + +export const urls = { + baseURL: 'https://inveniordm.web.cern.ch/', + profileURL: 'https://inveniordm.web.cern.ch/account/settings/profile', + newUploadURL: 'https://inveniordm.web.cern.ch/uploads/new', + myDashboardURL: 'https://inveniordm.web.cern.ch/me/uploads', + communitiesURL: 'https://inveniordm.web.cern.ch/communities', + newCommunityURL: 'https://inveniordm.web.cern.ch/communities/new' + }; \ No newline at end of file diff --git a/.history/helpers/uiHelper_20241023124906.ts b/.history/helpers/uiHelper_20241023124906.ts new file mode 100644 index 0000000..6685b21 --- /dev/null +++ b/.history/helpers/uiHelper_20241023124906.ts @@ -0,0 +1,99 @@ +import { Page } from '@playwright/test'; +import { urls } from '../data/urls'; // assuming URLs are stored here + +/** + * Helpers: + * Helpers are utility functions or classes designed to simplify and organize common + * tasks within your test suite, such as interacting with UI elements, handling file uploads, + * or generating test data. By abstracting repetitive code into helpers, you can maintain + * cleaner test files and promote reusability. Helpers reduce duplication and make your + * tests easier to maintain, improving overall test readability and structure. + */ + +// Helper provides utility methods for common UI interactions + +export class UIHelper { + constructor(private page: Page) {} + + // ------------------------------------------------------------------------- + // NAVIGATION HELPERS + // ------------------------------------------------------------------------- + + // Navigate to the base URL (homepage) + async navigateToHome() { + await this.page.goto(urls.baseURL); + await this.page.waitForURL(urls.baseURL); + } + + // Navigate to the communities page + async navigateToCommunities() { + await this.page.goto(urls.communitiesURL); + await this.page.waitForURL(urls.communitiesURL); + } + + // Navigate to the My Dashboard page + async navigateToMyDashboard() { + await this.page.getByRole('link', { name: 'My dashboard' }).click(); + } + + // Navigate to the new community page + async newCommunity() { + await this.page.goto(urls.newCommunityURL); + await this.page.waitForURL(urls.newCommunityURL); + } + + // Navigate to the detail of the first record + async firstRecordDetail() { + await this.page.waitForSelector('//a[contains(@href, "/records/")][1]', { state: 'visible' }); + await this.page.click('//a[contains(@href, "/records/")][1]'); + } + + // Navigate to a specific URL + async goto(url: string) { + await this.page.goto(url); + } + + // ------------------------------------------------------------------------- + // OTHER UI HELPERS + // ------------------------------------------------------------------------- + + // Define valid roles using a union of string literals (can add more as needed) + async clickByRole(role: 'button' | 'link' | 'checkbox' | 'heading' | 'menuitem' | 'textbox', name: string) { + await this.page.getByRole(role, { name }).click(); + } + + // Implement clickByLabel to handle clicking elements by their label + async clickByLabel(label: string) { + await this.page.getByLabel(label).click(); + } + + // Fill an input field by its placeholder text + async fillPlaceholder(placeholder: string, value: string) { + await this.page.getByPlaceholder(placeholder).fill(value); + } + + // Click an element by its text content + async clickByText(text: string) { + await this.page.click(`text=${text}`); + } + + // Wait for a specific text to be visible on the page and return its visibility status + async waitForText(text: string): Promise { + return await this.page.getByText(text).isVisible(); + } + + // Click a button based on its displayed text + async clickButtonByText(buttonText: string) { + await this.page.click(`text=${buttonText}`); + } + + // Wait for a specific element to become visible on the page + async waitForElement(selector: string) { + await this.page.waitForSelector(selector, { state: 'visible' }); + } + + // Check if an element is enabled on the page + async isElementEnabled(selector: string): Promise { + return await this.page.isEnabled(selector); + } +} diff --git a/.history/helpers/uiHelper_20241023125122.ts b/.history/helpers/uiHelper_20241023125122.ts new file mode 100644 index 0000000..637a6bd --- /dev/null +++ b/.history/helpers/uiHelper_20241023125122.ts @@ -0,0 +1,99 @@ +import { Page } from '@playwright/test'; +import { urls } from '../data/urls'; // assuming URLs are stored here + +/** + * Helpers: + * Helpers are utility functions or classes designed to simplify and organize common + * tasks within your test suite, such as interacting with UI elements, handling file uploads, + * or generating test data. By abstracting repetitive code into helpers, you can maintain + * cleaner test files and promote reusability. Helpers reduce duplication and make your + * tests easier to maintain, improving overall test readability and structure. + */ + +// Helper provides utility methods for common UI interactions + +export class UIHelper { + constructor(private page: Page) {} + + // ------------------------------------------------------------------------- + // NAVIGATION HELPERS + // ------------------------------------------------------------------------- + + // Navigate to the base URL (homepage) + async navigateToHome() { + await this.page.goto(urls.baseURL); + await this.page.waitForURL(urls.baseURL); + } + + // Navigate to the communities page + async navigateToCommunities() { + await this.page.goto(urls.communitiesURL); + await this.page.waitForURL(urls.communitiesURL); + } + + // Navigate to the My Dashboard page + async navigateToMyDashboard() { + await this.page.getByRole('link', { name: 'My dashboard' }).click(); + } + + // Navigate to the new community page + async navigateToNewCommunity() { + await this.page.goto(urls.newCommunityURL); + await this.page.waitForURL(urls.newCommunityURL); + } + + // Navigate to the detail of the first record + async firstRecordDetail() { + await this.page.waitForSelector('//a[contains(@href, "/records/")][1]', { state: 'visible' }); + await this.page.click('//a[contains(@href, "/records/")][1]'); + } + + // Navigate to a specific URL + async goto(url: string) { + await this.page.goto(url); + } + + // ------------------------------------------------------------------------- + // OTHER UI HELPERS + // ------------------------------------------------------------------------- + + // Define valid roles using a union of string literals (can add more as needed) + async clickByRole(role: 'button' | 'link' | 'checkbox' | 'heading' | 'menuitem' | 'textbox', name: string) { + await this.page.getByRole(role, { name }).click(); + } + + // Implement clickByLabel to handle clicking elements by their label + async clickByLabel(label: string) { + await this.page.getByLabel(label).click(); + } + + // Fill an input field by its placeholder text + async fillPlaceholder(placeholder: string, value: string) { + await this.page.getByPlaceholder(placeholder).fill(value); + } + + // Click an element by its text content + async clickByText(text: string) { + await this.page.click(`text=${text}`); + } + + // Wait for a specific text to be visible on the page and return its visibility status + async waitForText(text: string): Promise { + return await this.page.getByText(text).isVisible(); + } + + // Click a button based on its displayed text + async clickButtonByText(buttonText: string) { + await this.page.click(`text=${buttonText}`); + } + + // Wait for a specific element to become visible on the page + async waitForElement(selector: string) { + await this.page.waitForSelector(selector, { state: 'visible' }); + } + + // Check if an element is enabled on the page + async isElementEnabled(selector: string): Promise { + return await this.page.isEnabled(selector); + } +} diff --git a/.history/pages/newCommunityPage_20241023124157.ts b/.history/pages/newCommunityPage_20241023124157.ts new file mode 100644 index 0000000..5412305 --- /dev/null +++ b/.history/pages/newCommunityPage_20241023124157.ts @@ -0,0 +1,118 @@ +import { Page } from '@playwright/test'; +import { FileUploadHelper } from '../helpers/fileUploadHelper'; +import { UIHelper } from '../helpers/uiHelper'; +import { urls } from '../data/urls'; +import { testData } from '../data/testData'; + +export class newCommunity { + private fileUploadHelper: FileUploadHelper; + private uiHelper: UIHelper; + public uploadedTitle: string; + + constructor(private page: Page) { + this.fileUploadHelper = new FileUploadHelper(page); + this.uiHelper = new UIHelper(page); + this.uploadedTitle = testData.upload.recordTitle(); + } + +// NAVIGATION -------------------------------------------------------------------------- + + // Navigate to the homepage page using the helper + async navigateToHome() { + await this.uiHelper.navigateToHome(); + } + + // Navigate to the 'Communities' page using the helper + async navigateToCommunities() { + await this.uiHelper.navigateToCommunities(); + } + + // Navigate to the 'My Dashboard' page using the helper + async navigateToMyDashboard() { + await this.uiHelper.navigateToMyDashboard(); + } + + // Navigate to the detail of the first record using the helper + async firstRecordDetail() { + await this.uiHelper.firstRecordDetail(); + } + +// FIELDS ------------------------------------------------------------------------------ + + // Method to click the 'Style' dropdown and select a style + async selectStyle(style: string) { + await this.page.getByLabel('Style').locator('i').click(); + await this.page.getByText(style).click(); + } + + // Method to select the export option + async selectExportOption(option: string) { + await this.page.getByRole('option', { name: option }).dblclick(); + } + +// BUTTONS ----------------------------------------------------------------------------- + + // Method to click the 'Edit' button + async clickEdit() { + await this.page.click('#recordManagement > div > div:nth-child(1) > button'); + } + + // Method to click the 'Edit' button (alternative approach) + async clickEdit2() { + await this.page.getByRole('button', { name: 'Edit' }).click(); + } + + // Method to click the 'New version' button + async clickNewVersion() { + await this.page.click('#recordManagement > div > div:nth-child(2) > span > button'); + } + + // Method to click the 'New version' button (alternative approach) + async clickNewVersion2() { + await this.page.getByRole('button', { name: 'New version' }).click(); + } + + // Method to click the 'Share' button + async clickShare() { + await this.page.click('//div[@id="recordManagement"]//button[contains(@class, "ui") and contains(text(), "Share")]'); + } + + // Method to click the 'Share' button (alternative approach) + async clickShare2() { + await this.page.getByRole('button', { name: 'Share' }).click(); + } + + // Method to click the 'Export selection' button + async clickExportSelection() { + await this.page.getByLabel('Export selection').locator('i').click(); + } + + // Method to click the 'Export' button and wait for the download + async clickExportButton() { + const downloadPromise = this.page.waitForEvent('download'); + await this.page.getByRole('button', { name: 'Export' }).click(); + return downloadPromise; + } + + // Method to click the 'Download all' button + async clickDownloadAll() { + await this.page.getByRole('link', { name: 'Download all' }).click(); + } + + // Method to click the 'Preview' button + async clickPreview() { + await this.page.getByRole('link', { name: 'Preview' }).click(); + } + + // Method to click the 'Download' button + async clickDownload() { + await this.page.getByRole('link', { name: 'Download' }).click(); + } + +// VERIFICATION ------------------------------------------------------------------------ + + // Method for implicit waiting (2 seconds) + async waitForTwoSeconds() { + await this.page.waitForTimeout(2000); // Waits for 2 seconds + } +} \ No newline at end of file diff --git a/.history/pages/newCommunityPage_20241023124330.ts b/.history/pages/newCommunityPage_20241023124330.ts new file mode 100644 index 0000000..4d6055d --- /dev/null +++ b/.history/pages/newCommunityPage_20241023124330.ts @@ -0,0 +1,66 @@ +import { Page } from '@playwright/test'; +import { FileUploadHelper } from '../helpers/fileUploadHelper'; +import { UIHelper } from '../helpers/uiHelper'; +import { urls } from '../data/urls'; +import { testData } from '../data/testData'; + +export class newCommunity { + private fileUploadHelper: FileUploadHelper; + private uiHelper: UIHelper; + public uploadedTitle: string; + + constructor(private page: Page) { + this.fileUploadHelper = new FileUploadHelper(page); + this.uiHelper = new UIHelper(page); + this.uploadedTitle = testData.upload.recordTitle(); + } + +// NAVIGATION -------------------------------------------------------------------------- + + // Navigate to the homepage page using the helper + async navigateToHome() { + await this.uiHelper.navigateToHome(); + } + + // Navigate to the 'Communities' page using the helper + async navigateToCommunities() { + await this.uiHelper.navigateToCommunities(); + } + + // Navigate to the 'My Dashboard' page using the helper + async navigateToMyDashboard() { + await this.uiHelper.navigateToMyDashboard(); + } + + // Navigate to the detail of the first record using the helper + async firstRecordDetail() { + await this.uiHelper.firstRecordDetail(); + } + +// FIELDS ------------------------------------------------------------------------------ + + // Method to click the 'Style' dropdown and select a style + async selectStyle(style: string) { + await this.page.getByLabel('Style').locator('i').click(); + await this.page.getByText(style).click(); + } + + // Method to select the export option + async selectExportOption(option: string) { + await this.page.getByRole('option', { name: option }).dblclick(); + } + +// BUTTONS ----------------------------------------------------------------------------- + + // Method to click the 'Edit' button + async clickEdit() { + await this.page.click('#recordManagement > div > div:nth-child(1) > button'); + } + +// VERIFICATION ------------------------------------------------------------------------ + + // Method for implicit waiting (2 seconds) + async waitForTwoSeconds() { + await this.page.waitForTimeout(2000); // Waits for 2 seconds + } +} \ No newline at end of file diff --git a/.history/pages/newCommunityPage_20241023124518.ts b/.history/pages/newCommunityPage_20241023124518.ts new file mode 100644 index 0000000..8fe7ceb --- /dev/null +++ b/.history/pages/newCommunityPage_20241023124518.ts @@ -0,0 +1,66 @@ +import { Page } from '@playwright/test'; +import { FileUploadHelper } from '../helpers/fileUploadHelper'; +import { UIHelper } from '../helpers/uiHelper'; +import { urls } from '../data/urls'; +import { testData } from '../data/testData'; + +export class newCommunity { + private fileUploadHelper: FileUploadHelper; + private uiHelper: UIHelper; + public uploadedTitle: string; + + constructor(private page: Page) { + this.fileUploadHelper = new FileUploadHelper(page); + this.uiHelper = new UIHelper(page); + this.uploadedTitle = testData.upload.recordTitle(); + } + +// NAVIGATION -------------------------------------------------------------------------- + + // Navigate to the homepage page using the helper + async navigateToHome() { + await this.uiHelper.navigateToHome(); + } + + // Navigate to the 'Communities' page using the helper + async navigateToCommunities() { + await this.uiHelper.navigateToCommunities(); + } + + // Navigate to the 'My Dashboard' page using the helper + async navigateToMyDashboard() { + await this.uiHelper.navigateToMyDashboard(); + } + + // Navigate to the detail of the first record using the helper + async firstRecordDetail() { + await this.uiHelper.firstRecordDetail(); + } + +// FIELDS ------------------------------------------------------------------------------ + + // Method to click the 'Style' dropdown and select a style + async selectStyle(style: string) { + await this.page.getByLabel('Style').locator('i').click(); + await this.page.getByText(style).click(); + } + + // Method to select the export option + async selectExportOption(option: string) { + await this.page.getByRole('option', { name: option }).dblclick(); + } + +// BUTTONS ----------------------------------------------------------------------------- + + // Method to click the 'New community' button + async clickNewCommunity() { + await this.page.click('#recordManagement > div > div:nth-child(1) > button'); + } + +// VERIFICATION ------------------------------------------------------------------------ + + // Method for implicit waiting (2 seconds) + async waitForTwoSeconds() { + await this.page.waitForTimeout(2000); // Waits for 2 seconds + } +} \ No newline at end of file diff --git a/.history/pages/newCommunityPage_20241023124607.ts b/.history/pages/newCommunityPage_20241023124607.ts new file mode 100644 index 0000000..78056a6 --- /dev/null +++ b/.history/pages/newCommunityPage_20241023124607.ts @@ -0,0 +1,66 @@ +import { Page } from '@playwright/test'; +import { FileUploadHelper } from '../helpers/fileUploadHelper'; +import { UIHelper } from '../helpers/uiHelper'; +import { urls } from '../data/urls'; +import { testData } from '../data/testData'; + +export class newCommunity { + private fileUploadHelper: FileUploadHelper; + private uiHelper: UIHelper; + public uploadedTitle: string; + + constructor(private page: Page) { + this.fileUploadHelper = new FileUploadHelper(page); + this.uiHelper = new UIHelper(page); + this.uploadedTitle = testData.upload.recordTitle(); + } + +// NAVIGATION -------------------------------------------------------------------------- + + // Navigate to the homepage page using the helper + async navigateToHome() { + await this.uiHelper.navigateToHome(); + } + + // Navigate to the 'Communities' page using the helper + async navigateToCommunities() { + await this.uiHelper.navigateToCommunities(); + } + + // Navigate to the 'My Dashboard' page using the helper + async navigateToMyDashboard() { + await this.uiHelper.navigateToMyDashboard(); + } + + // Navigate to the detail of the first record using the helper + async firstRecordDetail() { + await this.uiHelper.firstRecordDetail(); + } + +// FIELDS ------------------------------------------------------------------------------ + + // Method to click the 'Style' dropdown and select a style + async selectStyle(style: string) { + await this.page.getByLabel('Style').locator('i').click(); + await this.page.getByText(style).click(); + } + + // Method to select the export option + async selectExportOption(option: string) { + await this.page.getByRole('option', { name: option }).dblclick(); + } + +// BUTTONS ----------------------------------------------------------------------------- + + // Method to click the 'New community' button + async clickNewCommunity() { + await this.page.getByRole('button', { name: 'New community' }).click(); + } + +// VERIFICATION ------------------------------------------------------------------------ + + // Method for implicit waiting (2 seconds) + async waitForTwoSeconds() { + await this.page.waitForTimeout(2000); // Waits for 2 seconds + } +} \ No newline at end of file diff --git a/.history/pages/newCommunityPage_20241023125206.ts b/.history/pages/newCommunityPage_20241023125206.ts new file mode 100644 index 0000000..ed34c89 --- /dev/null +++ b/.history/pages/newCommunityPage_20241023125206.ts @@ -0,0 +1,71 @@ +import { Page } from '@playwright/test'; +import { FileUploadHelper } from '../helpers/fileUploadHelper'; +import { UIHelper } from '../helpers/uiHelper'; +import { urls } from '../data/urls'; +import { testData } from '../data/testData'; + +export class newCommunity { + private fileUploadHelper: FileUploadHelper; + private uiHelper: UIHelper; + public uploadedTitle: string; + + constructor(private page: Page) { + this.fileUploadHelper = new FileUploadHelper(page); + this.uiHelper = new UIHelper(page); + this.uploadedTitle = testData.upload.recordTitle(); + } + +// NAVIGATION -------------------------------------------------------------------------- + + // Navigate to the homepage page using the helper + async navigateToHome() { + await this.uiHelper.navigateToHome(); + } + + // Navigate to the 'Communities' page using the helper + async navigateToCommunities() { + await this.uiHelper.navigateToCommunities(); + } + + // Navigate to the 'My Dashboard' page using the helper + async navigateToMyDashboard() { + await this.uiHelper.navigateToMyDashboard(); + } + + // Navigate to the "new community" page using the helper + async navigateToNewCommunity () { + await this.uiHelper.navigateToNewCommunity(); + } + + // Navigate to the detail of the first record using the helper + async firstRecordDetail() { + await this.uiHelper.firstRecordDetail(); + } + +// FIELDS ------------------------------------------------------------------------------ + + // Method to click the 'Style' dropdown and select a style + async selectStyle(style: string) { + await this.page.getByLabel('Style').locator('i').click(); + await this.page.getByText(style).click(); + } + + // Method to select the export option + async selectExportOption(option: string) { + await this.page.getByRole('option', { name: option }).dblclick(); + } + +// BUTTONS ----------------------------------------------------------------------------- + + // Method to click the 'New community' button + async clickNewCommunity() { + await this.page.getByRole('button', { name: 'New community' }).click(); + } + +// VERIFICATION ------------------------------------------------------------------------ + + // Method for implicit waiting (2 seconds) + async waitForTwoSeconds() { + await this.page.waitForTimeout(2000); // Waits for 2 seconds + } +} \ No newline at end of file diff --git a/.history/pages/newCommunityPage_20241023125703.ts b/.history/pages/newCommunityPage_20241023125703.ts new file mode 100644 index 0000000..790d900 --- /dev/null +++ b/.history/pages/newCommunityPage_20241023125703.ts @@ -0,0 +1,72 @@ +import { Page } from '@playwright/test'; +import { FileUploadHelper } from '../helpers/fileUploadHelper'; +import { UIHelper } from '../helpers/uiHelper'; +import { urls } from '../data/urls'; +import { testData } from '../data/testData'; + +export class newCommunity { + private fileUploadHelper: FileUploadHelper; + private uiHelper: UIHelper; + public uploadedTitle: string; + + constructor(private page: Page) { + this.fileUploadHelper = new FileUploadHelper(page); + this.uiHelper = new UIHelper(page); + this.uploadedTitle = testData.upload.recordTitle(); + } + +// NAVIGATION -------------------------------------------------------------------------- + + // Navigate to the homepage page using the helper + async navigateToHome() { + await this.uiHelper.navigateToHome(); + } + + // Navigate to the 'Communities' page using the helper + async navigateToCommunities() { + await this.uiHelper.navigateToCommunities(); + } + + // Navigate to the 'My Dashboard' page using the helper + async navigateToMyDashboard() { + await this.uiHelper.navigateToMyDashboard(); + } + + // Navigate to the "new community" page using the helper + async navigateToNewCommunity () { + await this.uiHelper.navigateToNewCommunity(); + } + + // Navigate to the detail of the first record using the helper + async firstRecordDetail() { + await this.uiHelper.firstRecordDetail(); + } + +// FIELDS ------------------------------------------------------------------------------ + + // Method to click the 'Style' dropdown and select a style + async selectStyle(style: string) { + await this.page.getByLabel('Style').locator('i').click(); + await this.page.getByText(style).click(); + } + + // Method to select the export option + async selectExportOption(option: string) { + await this.page.getByRole('option', { name: option }).dblclick(); + } + +// BUTTONS ----------------------------------------------------------------------------- + + // Method to click the 'New community' button + async clickNewCommunity() { + await this.page.getByRole('button', { name: 'New community' }).click(); + // await this.page.locator('a.ui.icon.left.labeled.positive.button').click(); + } + +// VERIFICATION ------------------------------------------------------------------------ + + // Method for implicit waiting (2 seconds) + async waitForTwoSeconds() { + await this.page.waitForTimeout(2000); // Waits for 2 seconds + } +} \ No newline at end of file diff --git a/.history/pages/newCommunityPage_20241023131250.ts b/.history/pages/newCommunityPage_20241023131250.ts new file mode 100644 index 0000000..2d1adbf --- /dev/null +++ b/.history/pages/newCommunityPage_20241023131250.ts @@ -0,0 +1,73 @@ +import { Page } from '@playwright/test'; +import { FileUploadHelper } from '../helpers/fileUploadHelper'; +import { UIHelper } from '../helpers/uiHelper'; +import { urls } from '../data/urls'; +import { testData } from '../data/testData'; + +export class newCommunity { + private fileUploadHelper: FileUploadHelper; + private uiHelper: UIHelper; + public uploadedTitle: string; + + constructor(private page: Page) { + this.fileUploadHelper = new FileUploadHelper(page); + this.uiHelper = new UIHelper(page); + this.uploadedTitle = testData.upload.recordTitle(); + } + +// NAVIGATION -------------------------------------------------------------------------- + + // Navigate to the homepage page using the helper + async navigateToHome() { + await this.uiHelper.navigateToHome(); + } + + // Navigate to the 'Communities' page using the helper + async navigateToCommunities() { + await this.uiHelper.navigateToCommunities(); + } + + // Navigate to the 'My Dashboard' page using the helper + async navigateToMyDashboard() { + await this.uiHelper.navigateToMyDashboard(); + } + + // Navigate to the "new community" page using the helper + async navigateToNewCommunity () { + await this.uiHelper.navigateToNewCommunity(); + } + + // Navigate to the detail of the first record using the helper + async firstRecordDetail() { + await this.uiHelper.firstRecordDetail(); + } + +// FIELDS ------------------------------------------------------------------------------ + + // Method to fill in the 'Community name' field using the community name from testData + async fillMetadataTitle() { + const communityName = testData.upload.communityName(); // Call the function to get the community name + await this.page.locator('#metadata\\.title').fill(communityName); + console.log(`Filled the metadata title field with: ${communityName}`); + } + + // Method to select the export option + async selectExportOption(option: string) { + await this.page.getByRole('option', { name: option }).dblclick(); + } + +// BUTTONS ----------------------------------------------------------------------------- + + // Method to click the 'New community' button + async clickNewCommunity() { + await this.page.getByRole('button', { name: 'New community' }).click(); + // await this.page.locator('a.ui.icon.left.labeled.positive.button').click(); + } + +// VERIFICATION ------------------------------------------------------------------------ + + // Method for implicit waiting (2 seconds) + async waitForTwoSeconds() { + await this.page.waitForTimeout(2000); // Waits for 2 seconds + } +} \ No newline at end of file diff --git a/.history/pages/newCommunityPage_20241023131343.ts b/.history/pages/newCommunityPage_20241023131343.ts new file mode 100644 index 0000000..18d2c5e --- /dev/null +++ b/.history/pages/newCommunityPage_20241023131343.ts @@ -0,0 +1,73 @@ +import { Page } from '@playwright/test'; +import { FileUploadHelper } from '../helpers/fileUploadHelper'; +import { UIHelper } from '../helpers/uiHelper'; +import { urls } from '../data/urls'; +import { testData } from '../data/testData'; + +export class newCommunity { + private fileUploadHelper: FileUploadHelper; + private uiHelper: UIHelper; + public uploadedTitle: string; + + constructor(private page: Page) { + this.fileUploadHelper = new FileUploadHelper(page); + this.uiHelper = new UIHelper(page); + this.uploadedTitle = testData.upload.recordTitle(); + } + +// NAVIGATION -------------------------------------------------------------------------- + + // Navigate to the homepage page using the helper + async navigateToHome() { + await this.uiHelper.navigateToHome(); + } + + // Navigate to the 'Communities' page using the helper + async navigateToCommunities() { + await this.uiHelper.navigateToCommunities(); + } + + // Navigate to the 'My Dashboard' page using the helper + async navigateToMyDashboard() { + await this.uiHelper.navigateToMyDashboard(); + } + + // Navigate to the "new community" page using the helper + async navigateToNewCommunity () { + await this.uiHelper.navigateToNewCommunity(); + } + + // Navigate to the detail of the first record using the helper + async firstRecordDetail() { + await this.uiHelper.firstRecordDetail(); + } + +// FIELDS ------------------------------------------------------------------------------ + + // Method to fill in the 'Community name' field (by faker) + async fillMetadataTitle() { + const communityName = testData.upload.communityName(); + await this.page.locator('#metadata\\.title').fill(communityName); + console.log(`Filled the metadata title field with: ${communityName}`); + } + + // Method to select the export option + async selectExportOption(option: string) { + await this.page.getByRole('option', { name: option }).dblclick(); + } + +// BUTTONS ----------------------------------------------------------------------------- + + // Method to click the 'New community' button + async clickNewCommunity() { + await this.page.getByRole('button', { name: 'New community' }).click(); + // await this.page.locator('a.ui.icon.left.labeled.positive.button').click(); + } + +// VERIFICATION ------------------------------------------------------------------------ + + // Method for implicit waiting (2 seconds) + async waitForTwoSeconds() { + await this.page.waitForTimeout(2000); // Waits for 2 seconds + } +} \ No newline at end of file diff --git a/.history/pages/newCommunityPage_20241023131405.ts b/.history/pages/newCommunityPage_20241023131405.ts new file mode 100644 index 0000000..d09ee7a --- /dev/null +++ b/.history/pages/newCommunityPage_20241023131405.ts @@ -0,0 +1,73 @@ +import { Page } from '@playwright/test'; +import { FileUploadHelper } from '../helpers/fileUploadHelper'; +import { UIHelper } from '../helpers/uiHelper'; +import { urls } from '../data/urls'; +import { testData } from '../data/testData'; + +export class newCommunity { + private fileUploadHelper: FileUploadHelper; + private uiHelper: UIHelper; + public uploadedTitle: string; + + constructor(private page: Page) { + this.fileUploadHelper = new FileUploadHelper(page); + this.uiHelper = new UIHelper(page); + this.uploadedTitle = testData.upload.recordTitle(); + } + +// NAVIGATION -------------------------------------------------------------------------- + + // Navigate to the homepage page using the helper + async navigateToHome() { + await this.uiHelper.navigateToHome(); + } + + // Navigate to the 'Communities' page using the helper + async navigateToCommunities() { + await this.uiHelper.navigateToCommunities(); + } + + // Navigate to the 'My Dashboard' page using the helper + async navigateToMyDashboard() { + await this.uiHelper.navigateToMyDashboard(); + } + + // Navigate to the "new community" page using the helper + async navigateToNewCommunity () { + await this.uiHelper.navigateToNewCommunity(); + } + + // Navigate to the detail of the first record using the helper + async firstRecordDetail() { + await this.uiHelper.firstRecordDetail(); + } + +// FIELDS ------------------------------------------------------------------------------ + + // Method to fill in the 'Community name' field (by faker) + async communityName() { + const communityName = testData.upload.communityName(); + await this.page.locator('#metadata\\.title').fill(communityName); + console.log(`Filled the metadata title field with: ${communityName}`); + } + + // Method to select the export option + async selectExportOption(option: string) { + await this.page.getByRole('option', { name: option }).dblclick(); + } + +// BUTTONS ----------------------------------------------------------------------------- + + // Method to click the 'New community' button + async clickNewCommunity() { + await this.page.getByRole('button', { name: 'New community' }).click(); + // await this.page.locator('a.ui.icon.left.labeled.positive.button').click(); + } + +// VERIFICATION ------------------------------------------------------------------------ + + // Method for implicit waiting (2 seconds) + async waitForTwoSeconds() { + await this.page.waitForTimeout(2000); // Waits for 2 seconds + } +} \ No newline at end of file diff --git a/.history/pages/newCommunityPage_20241023131501.ts b/.history/pages/newCommunityPage_20241023131501.ts new file mode 100644 index 0000000..d321c81 --- /dev/null +++ b/.history/pages/newCommunityPage_20241023131501.ts @@ -0,0 +1,73 @@ +import { Page } from '@playwright/test'; +import { FileUploadHelper } from '../helpers/fileUploadHelper'; +import { UIHelper } from '../helpers/uiHelper'; +import { urls } from '../data/urls'; +import { testData } from '../data/testData'; + +export class newCommunity { + private fileUploadHelper: FileUploadHelper; + private uiHelper: UIHelper; + public uploadedTitle: string; + + constructor(private page: Page) { + this.fileUploadHelper = new FileUploadHelper(page); + this.uiHelper = new UIHelper(page); + this.uploadedTitle = testData.upload.recordTitle(); + } + +// NAVIGATION -------------------------------------------------------------------------- + + // Navigate to the homepage page using the helper + async navigateToHome() { + await this.uiHelper.navigateToHome(); + } + + // Navigate to the 'Communities' page using the helper + async navigateToCommunities() { + await this.uiHelper.navigateToCommunities(); + } + + // Navigate to the 'My Dashboard' page using the helper + async navigateToMyDashboard() { + await this.uiHelper.navigateToMyDashboard(); + } + + // Navigate to the "new community" page using the helper + async navigateToNewCommunity () { + await this.uiHelper.navigateToNewCommunity(); + } + + // Navigate to the detail of the first record using the helper + async firstRecordDetail() { + await this.uiHelper.firstRecordDetail(); + } + +// FIELDS ------------------------------------------------------------------------------ + + // Method to fill in the 'Community name' field (by faker) + async fillCommunityName() { + const communityName = testData.upload.communityName(); + await this.page.locator('#metadata\\.title').fill(communityName); + console.log(`Filled the metadata title field with: ${communityName}`); + } + + // Method to select the export option + async selectExportOption(option: string) { + await this.page.getByRole('option', { name: option }).dblclick(); + } + +// BUTTONS ----------------------------------------------------------------------------- + + // Method to click the 'New community' button + async clickNewCommunity() { + await this.page.getByRole('button', { name: 'New community' }).click(); + // await this.page.locator('a.ui.icon.left.labeled.positive.button').click(); + } + +// VERIFICATION ------------------------------------------------------------------------ + + // Method for implicit waiting (2 seconds) + async waitForTwoSeconds() { + await this.page.waitForTimeout(2000); // Waits for 2 seconds + } +} \ No newline at end of file diff --git a/.history/pages/newCommunityPage_20241023131512.ts b/.history/pages/newCommunityPage_20241023131512.ts new file mode 100644 index 0000000..cb8d345 --- /dev/null +++ b/.history/pages/newCommunityPage_20241023131512.ts @@ -0,0 +1,68 @@ +import { Page } from '@playwright/test'; +import { FileUploadHelper } from '../helpers/fileUploadHelper'; +import { UIHelper } from '../helpers/uiHelper'; +import { urls } from '../data/urls'; +import { testData } from '../data/testData'; + +export class newCommunity { + private fileUploadHelper: FileUploadHelper; + private uiHelper: UIHelper; + public uploadedTitle: string; + + constructor(private page: Page) { + this.fileUploadHelper = new FileUploadHelper(page); + this.uiHelper = new UIHelper(page); + this.uploadedTitle = testData.upload.recordTitle(); + } + +// NAVIGATION -------------------------------------------------------------------------- + + // Navigate to the homepage page using the helper + async navigateToHome() { + await this.uiHelper.navigateToHome(); + } + + // Navigate to the 'Communities' page using the helper + async navigateToCommunities() { + await this.uiHelper.navigateToCommunities(); + } + + // Navigate to the 'My Dashboard' page using the helper + async navigateToMyDashboard() { + await this.uiHelper.navigateToMyDashboard(); + } + + // Navigate to the "new community" page using the helper + async navigateToNewCommunity () { + await this.uiHelper.navigateToNewCommunity(); + } + + // Navigate to the detail of the first record using the helper + async firstRecordDetail() { + await this.uiHelper.firstRecordDetail(); + } + +// FIELDS ------------------------------------------------------------------------------ + + // Method to fill in the 'Community name' field (by faker) + async fillCommunityName() { + const communityName = testData.upload.communityName(); + await this.page.locator('#metadata\\.title').fill(communityName); + console.log(`Filled the metadata title field with: ${communityName}`); + } + +// BUTTONS ----------------------------------------------------------------------------- + + // Method to click the 'New community' button + async clickNewCommunity() { + await this.page.getByRole('button', { name: 'New community' }).click(); + // await this.page.locator('a.ui.icon.left.labeled.positive.button').click(); + } + +// VERIFICATION ------------------------------------------------------------------------ + + // Method for implicit waiting (2 seconds) + async waitForTwoSeconds() { + await this.page.waitForTimeout(2000); // Waits for 2 seconds + } +} \ No newline at end of file diff --git a/.history/pages/newCommunityPage_20241023132343.ts b/.history/pages/newCommunityPage_20241023132343.ts new file mode 100644 index 0000000..d9d2115 --- /dev/null +++ b/.history/pages/newCommunityPage_20241023132343.ts @@ -0,0 +1,75 @@ +import { Page } from '@playwright/test'; +import { FileUploadHelper } from '../helpers/fileUploadHelper'; +import { UIHelper } from '../helpers/uiHelper'; +import { urls } from '../data/urls'; +import { testData } from '../data/testData'; + +export class newCommunity { + private fileUploadHelper: FileUploadHelper; + private uiHelper: UIHelper; + public uploadedTitle: string; + + constructor(private page: Page) { + this.fileUploadHelper = new FileUploadHelper(page); + this.uiHelper = new UIHelper(page); + this.uploadedTitle = testData.upload.recordTitle(); + } + +// NAVIGATION -------------------------------------------------------------------------- + + // Navigate to the homepage page using the helper + async navigateToHome() { + await this.uiHelper.navigateToHome(); + } + + // Navigate to the 'Communities' page using the helper + async navigateToCommunities() { + await this.uiHelper.navigateToCommunities(); + } + + // Navigate to the 'My Dashboard' page using the helper + async navigateToMyDashboard() { + await this.uiHelper.navigateToMyDashboard(); + } + + // Navigate to the "new community" page using the helper + async navigateToNewCommunity () { + await this.uiHelper.navigateToNewCommunity(); + } + + // Navigate to the detail of the first record using the helper + async firstRecordDetail() { + await this.uiHelper.firstRecordDetail(); + } + +// FIELDS ------------------------------------------------------------------------------ + + // Method to fill in the 'Community name' field (by faker) + async fillCommunityName() { + const communityName = testData.upload.communityName(); + await this.page.locator('#metadata\\.title').fill(communityName); + console.log(`Filled the metadata title field with: ${communityName}`); + } + + // Method to fill in the 'Identifier' field (by Faker) + async fillCommunityIdentifier() { + const generatedSlug = testData.upload.slug(); // Get the generated slug + await this.page.locator('#slug').fill(generatedSlug); // Fill the slug field + console.log(`Filled the slug field with: ${generatedSlug}`); + } + +// BUTTONS ----------------------------------------------------------------------------- + + // Method to click the 'New community' button + async clickNewCommunity() { + await this.page.getByRole('button', { name: 'New community' }).click(); + // await this.page.locator('a.ui.icon.left.labeled.positive.button').click(); + } + +// VERIFICATION ------------------------------------------------------------------------ + + // Method for implicit waiting (2 seconds) + async waitForTwoSeconds() { + await this.page.waitForTimeout(2000); // Waits for 2 seconds + } +} \ No newline at end of file diff --git a/.history/pages/newCommunityPage_20241023132514.ts b/.history/pages/newCommunityPage_20241023132514.ts new file mode 100644 index 0000000..7986336 --- /dev/null +++ b/.history/pages/newCommunityPage_20241023132514.ts @@ -0,0 +1,75 @@ +import { Page } from '@playwright/test'; +import { FileUploadHelper } from '../helpers/fileUploadHelper'; +import { UIHelper } from '../helpers/uiHelper'; +import { urls } from '../data/urls'; +import { testData } from '../data/testData'; + +export class newCommunity { + private fileUploadHelper: FileUploadHelper; + private uiHelper: UIHelper; + public uploadedTitle: string; + + constructor(private page: Page) { + this.fileUploadHelper = new FileUploadHelper(page); + this.uiHelper = new UIHelper(page); + this.uploadedTitle = testData.upload.recordTitle(); + } + +// NAVIGATION -------------------------------------------------------------------------- + + // Navigate to the homepage page using the helper + async navigateToHome() { + await this.uiHelper.navigateToHome(); + } + + // Navigate to the 'Communities' page using the helper + async navigateToCommunities() { + await this.uiHelper.navigateToCommunities(); + } + + // Navigate to the 'My Dashboard' page using the helper + async navigateToMyDashboard() { + await this.uiHelper.navigateToMyDashboard(); + } + + // Navigate to the "new community" page using the helper + async navigateToNewCommunity () { + await this.uiHelper.navigateToNewCommunity(); + } + + // Navigate to the detail of the first record using the helper + async firstRecordDetail() { + await this.uiHelper.firstRecordDetail(); + } + +// FIELDS ------------------------------------------------------------------------------ + + // Method to fill in the 'Community name' field (by faker) + async fillCommunityName() { + const communityName = testData.upload.communityName(); + await this.page.locator('#metadata\\.title').fill(communityName); + console.log(`Filled the metadata title field with: ${communityName}`); + } + + // Method to fill in the 'Identifier' field (by Faker) + async fillCommunityIdentifier() { + const communityIdentifier = testData.upload.communityIdentifier(); // Get the generated slug + await this.page.locator('#slug').fill(communityIdentifier); // Fill the slug field + console.log(`Filled the slug field with: ${communityIdentifier}`); + } + +// BUTTONS ----------------------------------------------------------------------------- + + // Method to click the 'New community' button + async clickNewCommunity() { + await this.page.getByRole('button', { name: 'New community' }).click(); + // await this.page.locator('a.ui.icon.left.labeled.positive.button').click(); + } + +// VERIFICATION ------------------------------------------------------------------------ + + // Method for implicit waiting (2 seconds) + async waitForTwoSeconds() { + await this.page.waitForTimeout(2000); // Waits for 2 seconds + } +} \ No newline at end of file diff --git a/.history/pages/newCommunityPage_20241023132606.ts b/.history/pages/newCommunityPage_20241023132606.ts new file mode 100644 index 0000000..e329a5d --- /dev/null +++ b/.history/pages/newCommunityPage_20241023132606.ts @@ -0,0 +1,75 @@ +import { Page } from '@playwright/test'; +import { FileUploadHelper } from '../helpers/fileUploadHelper'; +import { UIHelper } from '../helpers/uiHelper'; +import { urls } from '../data/urls'; +import { testData } from '../data/testData'; + +export class newCommunity { + private fileUploadHelper: FileUploadHelper; + private uiHelper: UIHelper; + public uploadedTitle: string; + + constructor(private page: Page) { + this.fileUploadHelper = new FileUploadHelper(page); + this.uiHelper = new UIHelper(page); + this.uploadedTitle = testData.upload.recordTitle(); + } + +// NAVIGATION -------------------------------------------------------------------------- + + // Navigate to the homepage page using the helper + async navigateToHome() { + await this.uiHelper.navigateToHome(); + } + + // Navigate to the 'Communities' page using the helper + async navigateToCommunities() { + await this.uiHelper.navigateToCommunities(); + } + + // Navigate to the 'My Dashboard' page using the helper + async navigateToMyDashboard() { + await this.uiHelper.navigateToMyDashboard(); + } + + // Navigate to the "new community" page using the helper + async navigateToNewCommunity () { + await this.uiHelper.navigateToNewCommunity(); + } + + // Navigate to the detail of the first record using the helper + async firstRecordDetail() { + await this.uiHelper.firstRecordDetail(); + } + +// FIELDS ------------------------------------------------------------------------------ + + // Method to fill in the 'Community name' field (by faker) + async fillCommunityName() { + const communityName = testData.upload.communityName(); + await this.page.locator('#metadata\\.title').fill(communityName); + console.log(`Filled the community name field with: ${communityName}`); + } + + // Method to fill in the 'Identifier' field (by Faker) + async fillCommunityIdentifier() { + const communityIdentifier = testData.upload.communityIdentifier(); // Get the generated slug + await this.page.locator('#slug').fill(communityIdentifier); // Fill the slug field + console.log(`Filled the community identifier field with: ${communityIdentifier}`); + } + +// BUTTONS ----------------------------------------------------------------------------- + + // Method to click the 'New community' button + async clickNewCommunity() { + await this.page.getByRole('button', { name: 'New community' }).click(); + // await this.page.locator('a.ui.icon.left.labeled.positive.button').click(); + } + +// VERIFICATION ------------------------------------------------------------------------ + + // Method for implicit waiting (2 seconds) + async waitForTwoSeconds() { + await this.page.waitForTimeout(2000); // Waits for 2 seconds + } +} \ No newline at end of file diff --git a/.history/pages/newCommunityPage_20241023133716.ts b/.history/pages/newCommunityPage_20241023133716.ts new file mode 100644 index 0000000..42cb7ea --- /dev/null +++ b/.history/pages/newCommunityPage_20241023133716.ts @@ -0,0 +1,81 @@ +import { Page } from '@playwright/test'; +import { FileUploadHelper } from '../helpers/fileUploadHelper'; +import { UIHelper } from '../helpers/uiHelper'; +import { urls } from '../data/urls'; +import { testData } from '../data/testData'; + +export class newCommunity { + private fileUploadHelper: FileUploadHelper; + private uiHelper: UIHelper; + public uploadedTitle: string; + + constructor(private page: Page) { + this.fileUploadHelper = new FileUploadHelper(page); + this.uiHelper = new UIHelper(page); + this.uploadedTitle = testData.upload.recordTitle(); + } + +// NAVIGATION -------------------------------------------------------------------------- + + // Navigate to the homepage page using the helper + async navigateToHome() { + await this.uiHelper.navigateToHome(); + } + + // Navigate to the 'Communities' page using the helper + async navigateToCommunities() { + await this.uiHelper.navigateToCommunities(); + } + + // Navigate to the 'My Dashboard' page using the helper + async navigateToMyDashboard() { + await this.uiHelper.navigateToMyDashboard(); + } + + // Navigate to the "new community" page using the helper + async navigateToNewCommunity () { + await this.uiHelper.navigateToNewCommunity(); + } + + // Navigate to the detail of the first record using the helper + async firstRecordDetail() { + await this.uiHelper.firstRecordDetail(); + } + +// FIELDS ------------------------------------------------------------------------------ + + // Method to fill in the 'Community name' field (by faker) + async fillCommunityName() { + const communityName = testData.upload.communityName(); + await this.page.locator('#metadata\\.title').fill(communityName); + console.log(`Filled the community name field with: ${communityName}`); + } + + // Method to fill in the 'Identifier' field (by Faker) + async fillCommunityIdentifier() { + const communityIdentifier = testData.upload.communityIdentifier(); // Get the generated slug + await this.page.locator('#slug').fill(communityIdentifier); // Fill the slug field + console.log(`Filled the community identifier field with: ${communityIdentifier}`); + } + +// BUTTONS ----------------------------------------------------------------------------- + + // Method to click the 'New community' button + async clickNewCommunity() { + await this.page.getByRole('button', { name: 'New community' }).click(); + // await this.page.locator('a.ui.icon.left.labeled.positive.button').click(); + } + + // Method to select the 'Public' radio button in 'Community visibility' + async selectFirstPublicRadio() { + await this.page.locator("(//input[@type='radio' and @value='public'])[1]").check(); + console.log('Selected Public community visibility.'); + } + +// VERIFICATION ------------------------------------------------------------------------ + + // Method for implicit waiting (2 seconds) + async waitForTwoSeconds() { + await this.page.waitForTimeout(2000); // Waits for 2 seconds + } +} \ No newline at end of file diff --git a/.history/pages/newCommunityPage_20241023133903.ts b/.history/pages/newCommunityPage_20241023133903.ts new file mode 100644 index 0000000..ee9f6b1 --- /dev/null +++ b/.history/pages/newCommunityPage_20241023133903.ts @@ -0,0 +1,87 @@ +import { Page } from '@playwright/test'; +import { FileUploadHelper } from '../helpers/fileUploadHelper'; +import { UIHelper } from '../helpers/uiHelper'; +import { urls } from '../data/urls'; +import { testData } from '../data/testData'; + +export class newCommunity { + private fileUploadHelper: FileUploadHelper; + private uiHelper: UIHelper; + public uploadedTitle: string; + + constructor(private page: Page) { + this.fileUploadHelper = new FileUploadHelper(page); + this.uiHelper = new UIHelper(page); + this.uploadedTitle = testData.upload.recordTitle(); + } + +// NAVIGATION -------------------------------------------------------------------------- + + // Navigate to the homepage page using the helper + async navigateToHome() { + await this.uiHelper.navigateToHome(); + } + + // Navigate to the 'Communities' page using the helper + async navigateToCommunities() { + await this.uiHelper.navigateToCommunities(); + } + + // Navigate to the 'My Dashboard' page using the helper + async navigateToMyDashboard() { + await this.uiHelper.navigateToMyDashboard(); + } + + // Navigate to the "new community" page using the helper + async navigateToNewCommunity () { + await this.uiHelper.navigateToNewCommunity(); + } + + // Navigate to the detail of the first record using the helper + async firstRecordDetail() { + await this.uiHelper.firstRecordDetail(); + } + +// FIELDS ------------------------------------------------------------------------------ + + // Method to fill in the 'Community name' field (by faker) + async fillCommunityName() { + const communityName = testData.upload.communityName(); + await this.page.locator('#metadata\\.title').fill(communityName); + console.log(`Filled the community name field with: ${communityName}`); + } + + // Method to fill in the 'Identifier' field (by Faker) + async fillCommunityIdentifier() { + const communityIdentifier = testData.upload.communityIdentifier(); // Get the generated slug + await this.page.locator('#slug').fill(communityIdentifier); // Fill the slug field + console.log(`Filled the community identifier field with: ${communityIdentifier}`); + } + +// BUTTONS ----------------------------------------------------------------------------- + + // Method to click the 'New community' button + async clickNewCommunity() { + await this.page.getByRole('button', { name: 'New community' }).click(); + // await this.page.locator('a.ui.icon.left.labeled.positive.button').click(); + } + + // Method to select the 'Public' radio button in 'Community visibility' + async selectPublicCommunityRadio() { + await this.page.locator("(//input[@type='radio' and @value='public'])[1]").check(); + console.log('Selected Public community visibility.'); + } + + // Method to select the 'Public' radio button in 'Community visibility' + async selectRestrictedCommunityRadio() { + await this.page.locator("(//input[@type='radio' and @value='public'])[1]").check(); + console.log('Selected Public community visibility.'); + } + +// VERIFICATION ------------------------------------------------------------------------ + + // Method for implicit waiting (2 seconds) + async waitForTwoSeconds() { + await this.page.waitForTimeout(2000); // Waits for 2 seconds + } +} \ No newline at end of file diff --git a/.history/pages/newCommunityPage_20241023133942.ts b/.history/pages/newCommunityPage_20241023133942.ts new file mode 100644 index 0000000..60a32f3 --- /dev/null +++ b/.history/pages/newCommunityPage_20241023133942.ts @@ -0,0 +1,87 @@ +import { Page } from '@playwright/test'; +import { FileUploadHelper } from '../helpers/fileUploadHelper'; +import { UIHelper } from '../helpers/uiHelper'; +import { urls } from '../data/urls'; +import { testData } from '../data/testData'; + +export class newCommunity { + private fileUploadHelper: FileUploadHelper; + private uiHelper: UIHelper; + public uploadedTitle: string; + + constructor(private page: Page) { + this.fileUploadHelper = new FileUploadHelper(page); + this.uiHelper = new UIHelper(page); + this.uploadedTitle = testData.upload.recordTitle(); + } + +// NAVIGATION -------------------------------------------------------------------------- + + // Navigate to the homepage page using the helper + async navigateToHome() { + await this.uiHelper.navigateToHome(); + } + + // Navigate to the 'Communities' page using the helper + async navigateToCommunities() { + await this.uiHelper.navigateToCommunities(); + } + + // Navigate to the 'My Dashboard' page using the helper + async navigateToMyDashboard() { + await this.uiHelper.navigateToMyDashboard(); + } + + // Navigate to the "new community" page using the helper + async navigateToNewCommunity () { + await this.uiHelper.navigateToNewCommunity(); + } + + // Navigate to the detail of the first record using the helper + async firstRecordDetail() { + await this.uiHelper.firstRecordDetail(); + } + +// FIELDS ------------------------------------------------------------------------------ + + // Method to fill in the 'Community name' field (by faker) + async fillCommunityName() { + const communityName = testData.upload.communityName(); + await this.page.locator('#metadata\\.title').fill(communityName); + console.log(`Filled the community name field with: ${communityName}`); + } + + // Method to fill in the 'Identifier' field (by Faker) + async fillCommunityIdentifier() { + const communityIdentifier = testData.upload.communityIdentifier(); // Get the generated slug + await this.page.locator('#slug').fill(communityIdentifier); // Fill the slug field + console.log(`Filled the community identifier field with: ${communityIdentifier}`); + } + +// BUTTONS ----------------------------------------------------------------------------- + + // Method to click the 'New community' button + async clickNewCommunity() { + await this.page.getByRole('button', { name: 'New community' }).click(); + // await this.page.locator('a.ui.icon.left.labeled.positive.button').click(); + } + + // Method to select the 'Public' radio button in 'Community visibility' + async selectPublicCommunityRadio() { + await this.page.locator("(//input[@type='radio' and @value='public'])[1]").check(); + console.log('Selected Public community visibility.'); + } + + // Method to select the 'Restricted' radio button in 'Community visibility' + async selectRestrictedCommunityRadio() { + await this.page.locator("(//input[@type='radio' and @value='public'])[2]").check(); + console.log('Selected Restricted community visibility.'); + } + +// VERIFICATION ------------------------------------------------------------------------ + + // Method for implicit waiting (2 seconds) + async waitForTwoSeconds() { + await this.page.waitForTimeout(2000); // Waits for 2 seconds + } +} \ No newline at end of file diff --git a/.history/pages/newCommunityPage_20241023134641.ts b/.history/pages/newCommunityPage_20241023134641.ts new file mode 100644 index 0000000..be7b024 --- /dev/null +++ b/.history/pages/newCommunityPage_20241023134641.ts @@ -0,0 +1,93 @@ +import { Page } from '@playwright/test'; +import { FileUploadHelper } from '../helpers/fileUploadHelper'; +import { UIHelper } from '../helpers/uiHelper'; +import { urls } from '../data/urls'; +import { testData } from '../data/testData'; + +export class newCommunity { + private fileUploadHelper: FileUploadHelper; + private uiHelper: UIHelper; + public uploadedTitle: string; + + constructor(private page: Page) { + this.fileUploadHelper = new FileUploadHelper(page); + this.uiHelper = new UIHelper(page); + this.uploadedTitle = testData.upload.recordTitle(); + } + +// NAVIGATION -------------------------------------------------------------------------- + + // Navigate to the homepage page using the helper + async navigateToHome() { + await this.uiHelper.navigateToHome(); + } + + // Navigate to the 'Communities' page using the helper + async navigateToCommunities() { + await this.uiHelper.navigateToCommunities(); + } + + // Navigate to the 'My Dashboard' page using the helper + async navigateToMyDashboard() { + await this.uiHelper.navigateToMyDashboard(); + } + + // Navigate to the "new community" page using the helper + async navigateToNewCommunity () { + await this.uiHelper.navigateToNewCommunity(); + } + + // Navigate to the detail of the first record using the helper + async firstRecordDetail() { + await this.uiHelper.firstRecordDetail(); + } + +// FIELDS ------------------------------------------------------------------------------ + + // Method to fill in the 'Community name' field (by faker) + async fillCommunityName() { + const communityName = testData.upload.communityName(); + await this.page.locator('#metadata\\.title').fill(communityName); + console.log(`Filled the community name field with: ${communityName}`); + } + + // Method to fill in the 'Identifier' field (by Faker) + async fillCommunityIdentifier() { + const communityIdentifier = testData.upload.communityIdentifier(); // Get the generated slug + await this.page.locator('#slug').fill(communityIdentifier); // Fill the slug field + console.log(`Filled the community identifier field with: ${communityIdentifier}`); + } + +// BUTTONS ----------------------------------------------------------------------------- + + // Method to click the 'New community' button + async clickNewCommunity() { + await this.page.getByRole('button', { name: 'New community' }).click(); + // await this.page.locator('a.ui.icon.left.labeled.positive.button').click(); + } + + // Method to select the 'Public' radio button in 'Community visibility' + async selectPublicCommunityRadio() { + await this.page.locator("(//input[@type='radio' and @value='public'])[1]").check(); + console.log('Selected Public community visibility.'); + } + + // Method to select the 'Restricted' radio button in 'Community visibility' + async selectRestrictedCommunityRadio() { + await this.page.locator("(//input[@type='radio' and @value='public'])[2]").check(); + console.log('Selected Restricted community visibility.'); + } + + // Method to click the 'Create community' button + async clickCreateCommunity() { + await this.page.locator('button.ui.icon.positive.left.labeled.button').click(); + console.log(`Clicked the Create community button.`); + } + +// VERIFICATION ------------------------------------------------------------------------ + + // Method for implicit waiting (2 seconds) + async waitForTwoSeconds() { + await this.page.waitForTimeout(2000); // Waits for 2 seconds + } +} \ No newline at end of file diff --git a/.history/pages/newCommunityPage_20241023134654.ts b/.history/pages/newCommunityPage_20241023134654.ts new file mode 100644 index 0000000..caf28f0 --- /dev/null +++ b/.history/pages/newCommunityPage_20241023134654.ts @@ -0,0 +1,93 @@ +import { Page } from '@playwright/test'; +import { FileUploadHelper } from '../helpers/fileUploadHelper'; +import { UIHelper } from '../helpers/uiHelper'; +import { urls } from '../data/urls'; +import { testData } from '../data/testData'; + +export class newCommunity { + private fileUploadHelper: FileUploadHelper; + private uiHelper: UIHelper; + public uploadedTitle: string; + + constructor(private page: Page) { + this.fileUploadHelper = new FileUploadHelper(page); + this.uiHelper = new UIHelper(page); + this.uploadedTitle = testData.upload.recordTitle(); + } + +// NAVIGATION -------------------------------------------------------------------------- + + // Navigate to the homepage page using the helper + async navigateToHome() { + await this.uiHelper.navigateToHome(); + } + + // Navigate to the 'Communities' page using the helper + async navigateToCommunities() { + await this.uiHelper.navigateToCommunities(); + } + + // Navigate to the 'My Dashboard' page using the helper + async navigateToMyDashboard() { + await this.uiHelper.navigateToMyDashboard(); + } + + // Navigate to the "new community" page using the helper + async navigateToNewCommunity () { + await this.uiHelper.navigateToNewCommunity(); + } + + // Navigate to the detail of the first record using the helper + async firstRecordDetail() { + await this.uiHelper.firstRecordDetail(); + } + +// FIELDS ------------------------------------------------------------------------------ + + // Method to fill in the 'Community name' field (by faker) + async fillCommunityName() { + const communityName = testData.upload.communityName(); + await this.page.locator('#metadata\\.title').fill(communityName); + console.log(`Filled the community name field with: ${communityName}`); + } + + // Method to fill in the 'Identifier' field (by Faker) + async fillCommunityIdentifier() { + const communityIdentifier = testData.upload.communityIdentifier(); // Get the generated slug + await this.page.locator('#slug').fill(communityIdentifier); // Fill the slug field + console.log(`Filled the community identifier field with: ${communityIdentifier}`); + } + +// BUTTONS ----------------------------------------------------------------------------- + + // Method to click the 'New community' button + async clickNewCommunity() { + await this.page.getByRole('button', { name: 'New community' }).click(); + // await this.page.locator('a.ui.icon.left.labeled.positive.button').click(); + } + + // Method to select the 'Public' radio button in 'Community visibility' + async selectPublicCommunity() { + await this.page.locator("(//input[@type='radio' and @value='public'])[1]").check(); + console.log('Selected Public community visibility.'); + } + + // Method to select the 'Restricted' radio button in 'Community visibility' + async selectRestrictedCommunity() { + await this.page.locator("(//input[@type='radio' and @value='public'])[2]").check(); + console.log('Selected Restricted community visibility.'); + } + + // Method to click the 'Create community' button + async clickCreateCommunity() { + await this.page.locator('button.ui.icon.positive.left.labeled.button').click(); + console.log(`Clicked the Create community button.`); + } + +// VERIFICATION ------------------------------------------------------------------------ + + // Method for implicit waiting (2 seconds) + async waitForTwoSeconds() { + await this.page.waitForTimeout(2000); // Waits for 2 seconds + } +} \ No newline at end of file diff --git a/.history/tests/edit.spec_20241023142847.ts b/.history/tests/edit.spec_20241023142847.ts new file mode 100644 index 0000000..1a8787f --- /dev/null +++ b/.history/tests/edit.spec_20241023142847.ts @@ -0,0 +1,79 @@ +import { test, expect } from '../utils/fixtures'; +import { UploadPage } from '../pages/uploadPage'; +import { testData } from '../data/testData'; +import { qase } from 'playwright-qase-reporter'; + +test.describe('Edit record', () => { + let uploadPage: UploadPage; + let currentlySelectedType: string | null = null; // Track the currently selected resource type + + // Setup: Log in, navigate to the upload page, and upload a file + test.beforeEach(async ({ loggedInPage, uploadFileSuccessfully }) => { + uploadPage = new UploadPage(loggedInPage); // Use the logged-in page + + // Uncomment the following line if you want to upload a file before each test + //await uploadFileSuccessfully(); + }); + + // Teardown: Take a screenshot on failure + test.afterEach(async ({ page }, testInfo) => { + if (testInfo.status === 'failed') { + await page.screenshot({ path: `screenshots/${testInfo.title}.png` }); + console.log(`Teardown complete: Screenshot taken for failed test - ${testInfo.title}.`); + } else { + console.log(`Teardown complete: Test ${testInfo.title} passed.`); + } + }); + + test('Edit Existing Record [Qase ID: RDM-12]', async () => { + // Navigate to 'My Dashboard' + await uploadPage.navigateToMyDashboard(); + + // Open detail page of the first record + await uploadPage.firstRecordDetail(); + + // Click 'Edit' button + console.log('Clicking the Edit button...'); + await uploadPage.clickEdit(); + + // Fill in 'Description' + const recordDescription = testData.upload.recordDescription(); + console.log(`Filling in record description: ${recordDescription}`); + await uploadPage.fillDescription(recordDescription); + + // Change 'Resource type' with fallback value + currentlySelectedType = currentlySelectedType || 'defaultType'; + console.log(`Selecting resource type: ${currentlySelectedType}`); + await uploadPage.changeResourceType(currentlySelectedType); + + // Edit the record 'Title' + const recordTitleEdit = testData.upload.recordTitle(); + console.log(`Editing the record title: ${recordTitleEdit}`); + await uploadPage.fillTitle(recordTitleEdit); + + // Click the 'Publish' button + console.log('Clicking the Publish button...'); + await uploadPage.clickPublish(); + + // Confirm the dialog by clicking 'Publish' button + console.log('Confirming the Publish action...'); + await uploadPage.clickPublishOnConfirmation(); + + // Wait for the record verification after editing + console.log('Verifying record existence after edit...'); + const recordExists = await uploadPage.checkRecordExists(); // Check if the record exists + expect(recordExists).toBe(true); // Assert that the record exists + + // Verify the edited values are correct + console.log('Verifying edited record details...'); + const actualDescription = await uploadPage.getRecordDescription(); + const actualTitle = await uploadPage.getRecordTitle(); + + // Assert that the edited description and title are correct + expect(actualDescription).toBe(recordDescription); + expect(actualTitle).toBe(recordTitleEdit); + + console.log(`Record verification completed. Expected: true, Actual: ${recordExists}`); + }); + +}); \ No newline at end of file diff --git a/.history/tests/edit.spec_20241023142849.ts b/.history/tests/edit.spec_20241023142849.ts new file mode 100644 index 0000000..1ea9540 --- /dev/null +++ b/.history/tests/edit.spec_20241023142849.ts @@ -0,0 +1,79 @@ +import { test, expect } from '../utils/fixtures'; +import { UploadPage } from '../pages/uploadPage'; +import { testData } from '../data/testData'; +import { qase } from 'playwright-qase-reporter'; + +test.describe('Edit record', () => { + let uploadPage: UploadPage; + let currentlySelectedType: string | null = null; // Track the currently selected resource type + + // Setup: Log in, navigate to the upload page, and upload a file + test.beforeEach(async ({ loggedInPage, uploadFileSuccessfully }) => { + uploadPage = new UploadPage(loggedInPage); // Use the logged-in page + + // Uncomment the following line if you want to upload a file before each test + //await uploadFileSuccessfully(); + }); + + // Teardown: Take a screenshot on failure + test.afterEach(async ({ page }, testInfo) => { + if (testInfo.status === 'failed') { + await page.screenshot({ path: `screenshots/${testInfo.title}.png` }); + console.log(`Teardown complete: Screenshot taken for failed test - ${testInfo.title}.`); + } else { + console.log(`Teardown complete: Test ${testInfo.title} passed.`); + } + }); + + test('Edit Existing Record [Qase ID: RDM-12]', async () => { + // Navigate to 'My Dashboard' + await uploadPage.navigateToMyDashboard(); + + // Open detail page of the first record + await uploadPage.firstRecordDetail(); + + // Click 'Edit' button + console.log('Clicking the Edit button...'); + await uploadPage.clickEdit(); + + // Fill in 'Description' + const recordDescription = testData.upload.recordDescription(); + console.log(`Filling in record description: ${recordDescription}`); + await uploadPage.fillDescription(recordDescription); + + // Change 'Resource type' with fallback value + currentlySelectedType = currentlySelectedType || 'defaultType'; + console.log(`Selecting resource type: ${currentlySelectedType}`); + await uploadPage.changeResourceType(currentlySelectedType); + + // Edit the record 'Title' + const recordTitleEdit = testData.upload.recordTitle(); + console.log(`Editing the record title: ${recordTitleEdit}`); + await uploadPage.fillTitle(recordTitleEdit); + + // Click the 'Publish' button + console.log('Clicking the Publish button...'); + await uploadPage.clickPublish(); + + // Confirm the dialog by clicking 'Publish' button + console.log('Confirming the Publish action...'); + await uploadPage.clickPublishOnConfirmation(); + + // Wait for the record verification after editing + console.log('Verifying record existence after edit...'); + const recordExists = await uploadPage.checkRecordExists(); // Check if the record exists + expect(recordExists).toBe(true); // Assert that the record exists + + // Verify the edited values are correct + console.log('Verifying edited record details...'); + const actualDescription = await uploadPage.getRecordDescription(); + const actualTitle = await uploadPage.getRecordTitle(); + + // Assert that the edited description and title are correct + expect(actualDescription).toBe(recordDescription); + expect(actualTitle).toBe(recordTitleEdit); + + console.log(`Record verification completed. Expected: true, Actual: ${recordExists}`); + }); + +}); \ No newline at end of file diff --git a/.history/tests/edit.spec_20241023142939.ts b/.history/tests/edit.spec_20241023142939.ts new file mode 100644 index 0000000..fa9df2f --- /dev/null +++ b/.history/tests/edit.spec_20241023142939.ts @@ -0,0 +1,79 @@ +import { test, expect } from '../utils/fixtures'; +import { UploadPage } from '../pages/uploadPage'; +import { testData } from '../data/testData'; +import { qase } from 'playwright-qase-reporter'; + +test.describe('Edit record', () => { + let uploadPage: UploadPage; + let currentlySelectedType: string | null = null; // Track the currently selected resource type + + // Setup: Log in, navigate to the upload page, and upload a file + test.beforeEach(async ({ loggedInPage, uploadFileSuccessfully }) => { + uploadPage = new UploadPage(loggedInPage); // Use the logged-in page + + // Uncomment the following line if you want to upload a file before each test + //await uploadFileSuccessfully(); + }); + + // Teardown: Take a screenshot on failure + test.afterEach(async ({ page }, testInfo) => { + if (testInfo.status === 'failed') { + await page.screenshot({ path: `screenshots/${testInfo.title}.png` }); + console.log(`Teardown complete: Screenshot taken for failed test - ${testInfo.title}.`); + } else { + console.log(`Teardown complete: Test ${testInfo.title} passed.`); + } + }); + + test(qase(12, 'Edit Existing Record'), async () => { // Qase ID: 12 + // Navigate to 'My Dashboard' + await uploadPage.navigateToMyDashboard(); + + // Open detail page of the first record + await uploadPage.firstRecordDetail(); + + // Click 'Edit' button + console.log('Clicking the Edit button...'); + await uploadPage.clickEdit(); + + // Fill in 'Description' + const recordDescription = testData.upload.recordDescription(); + console.log(`Filling in record description: ${recordDescription}`); + await uploadPage.fillDescription(recordDescription); + + // Change 'Resource type' with fallback value + currentlySelectedType = currentlySelectedType || 'defaultType'; + console.log(`Selecting resource type: ${currentlySelectedType}`); + await uploadPage.changeResourceType(currentlySelectedType); + + // Edit the record 'Title' + const recordTitleEdit = testData.upload.recordTitle(); + console.log(`Editing the record title: ${recordTitleEdit}`); + await uploadPage.fillTitle(recordTitleEdit); + + // Click the 'Publish' button + console.log('Clicking the Publish button...'); + await uploadPage.clickPublish(); + + // Confirm the dialog by clicking 'Publish' button + console.log('Confirming the Publish action...'); + await uploadPage.clickPublishOnConfirmation(); + + // Wait for the record verification after editing + console.log('Verifying record existence after edit...'); + const recordExists = await uploadPage.checkRecordExists(); // Check if the record exists + expect(recordExists).toBe(true); // Assert that the record exists + + // Verify the edited values are correct + console.log('Verifying edited record details...'); + const actualDescription = await uploadPage.getRecordDescription(); + const actualTitle = await uploadPage.getRecordTitle(); + + // Assert that the edited description and title are correct + expect(actualDescription).toBe(recordDescription); + expect(actualTitle).toBe(recordTitleEdit); + + console.log(`Record verification completed. Expected: true, Actual: ${recordExists}`); + }); + +}); \ No newline at end of file diff --git a/.history/tests/edit.spec_20241023144046.ts b/.history/tests/edit.spec_20241023144046.ts new file mode 100644 index 0000000..8df6838 --- /dev/null +++ b/.history/tests/edit.spec_20241023144046.ts @@ -0,0 +1,81 @@ +import { test, expect } from '../utils/fixtures'; +import { UploadPage } from '../pages/uploadPage'; +import { testData } from '../data/testData'; +import { qase } from 'playwright-qase-reporter'; + +test.describe('Edit record', () => { + let uploadPage: UploadPage; + let currentlySelectedType: string | null = null; // Track the currently selected resource type + + // Setup: Log in, navigate to the upload page, and upload a file + test.beforeEach(async ({ loggedInPage, uploadFileSuccessfully }) => { + uploadPage = new UploadPage(loggedInPage); // Use the logged-in page + + // Uncomment the following line if you want to upload a file before each test + //await uploadFileSuccessfully(); + }); + + // Teardown: Take a screenshot on failure + test.afterEach(async ({ page }, testInfo) => { + if (testInfo.status === 'failed') { + await page.screenshot({ path: `screenshots/${testInfo.title}.png` }); + console.log(`Teardown complete: Screenshot taken for failed test - ${testInfo.title}.`); + } else { + console.log(`Teardown complete: Test ${testInfo.title} passed.`); + } + }); + + test(qase(12, 'Edit Existing Record'), async () => { // Qase test case ID: + qase.fields({ 'severity': 'major', 'priority': 'high' }); // Qase test case values for severity and priority + + // Navigate to 'My Dashboard' + await uploadPage.navigateToMyDashboard(); + + // Open detail page of the first record + await uploadPage.firstRecordDetail(); + + // Click 'Edit' button + console.log('Clicking the Edit button...'); + await uploadPage.clickEdit(); + + // Fill in 'Description' + const recordDescription = testData.upload.recordDescription(); + console.log(`Filling in record description: ${recordDescription}`); + await uploadPage.fillDescription(recordDescription); + + // Change 'Resource type' with fallback value + currentlySelectedType = currentlySelectedType || 'defaultType'; + console.log(`Selecting resource type: ${currentlySelectedType}`); + await uploadPage.changeResourceType(currentlySelectedType); + + // Edit the record 'Title' + const recordTitleEdit = testData.upload.recordTitle(); + console.log(`Editing the record title: ${recordTitleEdit}`); + await uploadPage.fillTitle(recordTitleEdit); + + // Click the 'Publish' button + console.log('Clicking the Publish button...'); + await uploadPage.clickPublish(); + + // Confirm the dialog by clicking 'Publish' button + console.log('Confirming the Publish action...'); + await uploadPage.clickPublishOnConfirmation(); + + // Wait for the record verification after editing + console.log('Verifying record existence after edit...'); + const recordExists = await uploadPage.checkRecordExists(); // Check if the record exists + expect(recordExists).toBe(true); // Assert that the record exists + + // Verify the edited values are correct + console.log('Verifying edited record details...'); + const actualDescription = await uploadPage.getRecordDescription(); + const actualTitle = await uploadPage.getRecordTitle(); + + // Assert that the edited description and title are correct + expect(actualDescription).toBe(recordDescription); + expect(actualTitle).toBe(recordTitleEdit); + + console.log(`Record verification completed. Expected: true, Actual: ${recordExists}`); + }); + +}); \ No newline at end of file diff --git a/.history/tests/edit.spec_20241023144837.ts b/.history/tests/edit.spec_20241023144837.ts new file mode 100644 index 0000000..8df6838 --- /dev/null +++ b/.history/tests/edit.spec_20241023144837.ts @@ -0,0 +1,81 @@ +import { test, expect } from '../utils/fixtures'; +import { UploadPage } from '../pages/uploadPage'; +import { testData } from '../data/testData'; +import { qase } from 'playwright-qase-reporter'; + +test.describe('Edit record', () => { + let uploadPage: UploadPage; + let currentlySelectedType: string | null = null; // Track the currently selected resource type + + // Setup: Log in, navigate to the upload page, and upload a file + test.beforeEach(async ({ loggedInPage, uploadFileSuccessfully }) => { + uploadPage = new UploadPage(loggedInPage); // Use the logged-in page + + // Uncomment the following line if you want to upload a file before each test + //await uploadFileSuccessfully(); + }); + + // Teardown: Take a screenshot on failure + test.afterEach(async ({ page }, testInfo) => { + if (testInfo.status === 'failed') { + await page.screenshot({ path: `screenshots/${testInfo.title}.png` }); + console.log(`Teardown complete: Screenshot taken for failed test - ${testInfo.title}.`); + } else { + console.log(`Teardown complete: Test ${testInfo.title} passed.`); + } + }); + + test(qase(12, 'Edit Existing Record'), async () => { // Qase test case ID: + qase.fields({ 'severity': 'major', 'priority': 'high' }); // Qase test case values for severity and priority + + // Navigate to 'My Dashboard' + await uploadPage.navigateToMyDashboard(); + + // Open detail page of the first record + await uploadPage.firstRecordDetail(); + + // Click 'Edit' button + console.log('Clicking the Edit button...'); + await uploadPage.clickEdit(); + + // Fill in 'Description' + const recordDescription = testData.upload.recordDescription(); + console.log(`Filling in record description: ${recordDescription}`); + await uploadPage.fillDescription(recordDescription); + + // Change 'Resource type' with fallback value + currentlySelectedType = currentlySelectedType || 'defaultType'; + console.log(`Selecting resource type: ${currentlySelectedType}`); + await uploadPage.changeResourceType(currentlySelectedType); + + // Edit the record 'Title' + const recordTitleEdit = testData.upload.recordTitle(); + console.log(`Editing the record title: ${recordTitleEdit}`); + await uploadPage.fillTitle(recordTitleEdit); + + // Click the 'Publish' button + console.log('Clicking the Publish button...'); + await uploadPage.clickPublish(); + + // Confirm the dialog by clicking 'Publish' button + console.log('Confirming the Publish action...'); + await uploadPage.clickPublishOnConfirmation(); + + // Wait for the record verification after editing + console.log('Verifying record existence after edit...'); + const recordExists = await uploadPage.checkRecordExists(); // Check if the record exists + expect(recordExists).toBe(true); // Assert that the record exists + + // Verify the edited values are correct + console.log('Verifying edited record details...'); + const actualDescription = await uploadPage.getRecordDescription(); + const actualTitle = await uploadPage.getRecordTitle(); + + // Assert that the edited description and title are correct + expect(actualDescription).toBe(recordDescription); + expect(actualTitle).toBe(recordTitleEdit); + + console.log(`Record verification completed. Expected: true, Actual: ${recordExists}`); + }); + +}); \ No newline at end of file diff --git a/.history/tests/newUpload.spec_20241023143850.ts b/.history/tests/newUpload.spec_20241023143850.ts new file mode 100644 index 0000000..5d8d0f4 --- /dev/null +++ b/.history/tests/newUpload.spec_20241023143850.ts @@ -0,0 +1,45 @@ +import { test, expect } from '../utils/fixtures'; +import { UploadPage } from '../pages/uploadPage'; +import { testData } from '../data/testData'; +import { qase } from 'playwright-qase-reporter'; + +test.describe('New Upload', () => { + let uploadPage: UploadPage; + let currentlySelectedType: string | null = null; // Track the currently selected resource type + + test.beforeEach(async ({ loggedInPage }) => { + uploadPage = new UploadPage(loggedInPage); // Use the logged-in page + await uploadPage.navigateToUploadSection(); // Navigate to the upload section + }); + + test.afterEach(async ({ page }, testInfo) => { + if (testInfo.status === 'failed') { + await page.screenshot({ path: `screenshots/${testInfo.title}.png` }); + } + }); + + test('Upload a file successfully [Qase ID: RDM-7]', async () => { + qase.fields({ 'severity': 'major', 'priority': 'high' }); // Qase test case values for severity and priority + + // Fill in the record details + await uploadPage.fillTitle(testData.upload.recordTitle()); + await uploadPage.fillFamilyName(testData.upload.familyName()); + await uploadPage.selectDOIOption(true); // Adjust this based on your test needs + await uploadPage.selectResourceType(currentlySelectedType); + + // Upload a file + await uploadPage.uploadRandomFile(); + + // Click the Publish button + await uploadPage.clickPublish(); + + // Click the Publish button on the confirmation dialog + await uploadPage.clickPublishOnConfirmation(); + + // Check the title of the new created record in the detail + const recordExists = await uploadPage.checkRecordExists(); + expect(recordExists).toBe(true); // Assert that the record exists + + // await uploadPage.waitForFiveSeconds(); // Waiting 5s during debug + }); +}); \ No newline at end of file diff --git a/.history/tests/newUpload.spec_20241023143945.ts b/.history/tests/newUpload.spec_20241023143945.ts new file mode 100644 index 0000000..06f89af --- /dev/null +++ b/.history/tests/newUpload.spec_20241023143945.ts @@ -0,0 +1,45 @@ +import { test, expect } from '../utils/fixtures'; +import { UploadPage } from '../pages/uploadPage'; +import { testData } from '../data/testData'; +import { qase } from 'playwright-qase-reporter'; + +test.describe('New Upload', () => { + let uploadPage: UploadPage; + let currentlySelectedType: string | null = null; // Track the currently selected resource type + + test.beforeEach(async ({ loggedInPage }) => { + uploadPage = new UploadPage(loggedInPage); // Use the logged-in page + await uploadPage.navigateToUploadSection(); // Navigate to the upload section + }); + + test.afterEach(async ({ page }, testInfo) => { + if (testInfo.status === 'failed') { + await page.screenshot({ path: `screenshots/${testInfo.title}.png` }); + } + }); + + test(qase(7, 'Upload a file successfully'), async () => { + qase.fields({ 'severity': 'major', 'priority': 'high' }); // Qase test case values for severity and priority + + // Fill in the record details + await uploadPage.fillTitle(testData.upload.recordTitle()); + await uploadPage.fillFamilyName(testData.upload.familyName()); + await uploadPage.selectDOIOption(true); // Adjust this based on your test needs + await uploadPage.selectResourceType(currentlySelectedType); + + // Upload a file + await uploadPage.uploadRandomFile(); + + // Click the Publish button + await uploadPage.clickPublish(); + + // Click the Publish button on the confirmation dialog + await uploadPage.clickPublishOnConfirmation(); + + // Check the title of the new created record in the detail + const recordExists = await uploadPage.checkRecordExists(); + expect(recordExists).toBe(true); // Assert that the record exists + + // await uploadPage.waitForFiveSeconds(); // Waiting 5s during debug + }); +}); \ No newline at end of file diff --git a/.history/tests/newUpload.spec_20241023145048.ts b/.history/tests/newUpload.spec_20241023145048.ts new file mode 100644 index 0000000..82f4c26 --- /dev/null +++ b/.history/tests/newUpload.spec_20241023145048.ts @@ -0,0 +1,45 @@ +import { test, expect } from '../utils/fixtures'; +import { UploadPage } from '../pages/uploadPage'; +import { testData } from '../data/testData'; +import { qase } from 'playwright-qase-reporter'; + +test.describe('New Upload', () => { + let uploadPage: UploadPage; + let currentlySelectedType: string | null = null; // Track the currently selected resource type + + test.beforeEach(async ({ loggedInPage }) => { + uploadPage = new UploadPage(loggedInPage); // Use the logged-in page + await uploadPage.navigateToUploadSection(); // Navigate to the upload section + }); + + test.afterEach(async ({ page }, testInfo) => { + if (testInfo.status === 'failed') { + await page.screenshot({ path: `screenshots/${testInfo.title}.png` }); + } + }); + + test(qase(7, 'Upload a file successfully'), async () => { // Qase test case ID: + qase.fields({ 'severity': 'major', 'priority': 'high' }); // Qase test case values for severity and priority + + // Fill in the record details + await uploadPage.fillTitle(testData.upload.recordTitle()); + await uploadPage.fillFamilyName(testData.upload.familyName()); + await uploadPage.selectDOIOption(true); // Adjust this based on your test needs + await uploadPage.selectResourceType(currentlySelectedType); + + // Upload a file + await uploadPage.uploadRandomFile(); + + // Click the Publish button + await uploadPage.clickPublish(); + + // Click the Publish button on the confirmation dialog + await uploadPage.clickPublishOnConfirmation(); + + // Check the title of the new created record in the detail + const recordExists = await uploadPage.checkRecordExists(); + expect(recordExists).toBe(true); // Assert that the record exists + + // await uploadPage.waitForFiveSeconds(); // Waiting 5s during debug + }); +}); \ No newline at end of file diff --git a/data/testData.ts b/data/testData.ts index cc04c45..31f33f2 100644 --- a/data/testData.ts +++ b/data/testData.ts @@ -31,7 +31,8 @@ export const testData = { recordTitle: () => faker.lorem.sentence(), // Function to generate a random title familyName: () => faker.lorem.word(), // Function to generate a random family name recordDescription: () => faker.lorem.paragraph(), // Function to generate a random description - communityName: () => faker.lorem.word(), // Function to generate a random family name + communityName: () => faker.lorem.word(), // Function to generate a random community name + communityIdentifier: () => faker.lorem.sentence(), // Function to generate a random community identifier // Dynamic resource type - Select randomly from a list, ensuring it's not the same as the currently selected type resourceType: (currentlySelected: string | null): string => { diff --git a/data/urls.ts b/data/urls.ts index 013e433..2446a71 100644 --- a/data/urls.ts +++ b/data/urls.ts @@ -5,5 +5,6 @@ export const urls = { profileURL: 'https://inveniordm.web.cern.ch/account/settings/profile', newUploadURL: 'https://inveniordm.web.cern.ch/uploads/new', myDashboardURL: 'https://inveniordm.web.cern.ch/me/uploads', - communitiesURL: 'https://inveniordm.web.cern.ch/communities' + communitiesURL: 'https://inveniordm.web.cern.ch/communities', + newCommunityURL: 'https://inveniordm.web.cern.ch/communities/new' }; \ No newline at end of file diff --git a/helpers/uiHelper.ts b/helpers/uiHelper.ts index cea47e4..637a6bd 100644 --- a/helpers/uiHelper.ts +++ b/helpers/uiHelper.ts @@ -36,6 +36,12 @@ export class UIHelper { await this.page.getByRole('link', { name: 'My dashboard' }).click(); } + // Navigate to the new community page + async navigateToNewCommunity() { + await this.page.goto(urls.newCommunityURL); + await this.page.waitForURL(urls.newCommunityURL); + } + // Navigate to the detail of the first record async firstRecordDetail() { await this.page.waitForSelector('//a[contains(@href, "/records/")][1]', { state: 'visible' }); diff --git a/pages/newCommunityPage.ts b/pages/newCommunityPage.ts index 1baf4d6..caf28f0 100644 --- a/pages/newCommunityPage.ts +++ b/pages/newCommunityPage.ts @@ -4,7 +4,7 @@ import { UIHelper } from '../helpers/uiHelper'; import { urls } from '../data/urls'; import { testData } from '../data/testData'; -export class RecordDetail { +export class newCommunity { private fileUploadHelper: FileUploadHelper; private uiHelper: UIHelper; public uploadedTitle: string; @@ -32,6 +32,11 @@ export class RecordDetail { await this.uiHelper.navigateToMyDashboard(); } + // Navigate to the "new community" page using the helper + async navigateToNewCommunity () { + await this.uiHelper.navigateToNewCommunity(); + } + // Navigate to the detail of the first record using the helper async firstRecordDetail() { await this.uiHelper.firstRecordDetail(); @@ -39,74 +44,44 @@ export class RecordDetail { // FIELDS ------------------------------------------------------------------------------ - // Method to click the 'Style' dropdown and select a style - async selectStyle(style: string) { - await this.page.getByLabel('Style').locator('i').click(); - await this.page.getByText(style).click(); + // Method to fill in the 'Community name' field (by faker) + async fillCommunityName() { + const communityName = testData.upload.communityName(); + await this.page.locator('#metadata\\.title').fill(communityName); + console.log(`Filled the community name field with: ${communityName}`); } - // Method to select the export option - async selectExportOption(option: string) { - await this.page.getByRole('option', { name: option }).dblclick(); + // Method to fill in the 'Identifier' field (by Faker) + async fillCommunityIdentifier() { + const communityIdentifier = testData.upload.communityIdentifier(); // Get the generated slug + await this.page.locator('#slug').fill(communityIdentifier); // Fill the slug field + console.log(`Filled the community identifier field with: ${communityIdentifier}`); } // BUTTONS ----------------------------------------------------------------------------- - // Method to click the 'Edit' button - async clickEdit() { - await this.page.click('#recordManagement > div > div:nth-child(1) > button'); - } - - // Method to click the 'Edit' button (alternative approach) - async clickEdit2() { - await this.page.getByRole('button', { name: 'Edit' }).click(); - } - - // Method to click the 'New version' button - async clickNewVersion() { - await this.page.click('#recordManagement > div > div:nth-child(2) > span > button'); - } - - // Method to click the 'New version' button (alternative approach) - async clickNewVersion2() { - await this.page.getByRole('button', { name: 'New version' }).click(); + // Method to click the 'New community' button + async clickNewCommunity() { + await this.page.getByRole('button', { name: 'New community' }).click(); + // await this.page.locator('a.ui.icon.left.labeled.positive.button').click(); } - // Method to click the 'Share' button - async clickShare() { - await this.page.click('//div[@id="recordManagement"]//button[contains(@class, "ui") and contains(text(), "Share")]'); - } - - // Method to click the 'Share' button (alternative approach) - async clickShare2() { - await this.page.getByRole('button', { name: 'Share' }).click(); - } - - // Method to click the 'Export selection' button - async clickExportSelection() { - await this.page.getByLabel('Export selection').locator('i').click(); - } - - // Method to click the 'Export' button and wait for the download - async clickExportButton() { - const downloadPromise = this.page.waitForEvent('download'); - await this.page.getByRole('button', { name: 'Export' }).click(); - return downloadPromise; - } - - // Method to click the 'Download all' button - async clickDownloadAll() { - await this.page.getByRole('link', { name: 'Download all' }).click(); + // Method to select the 'Public' radio button in 'Community visibility' + async selectPublicCommunity() { + await this.page.locator("(//input[@type='radio' and @value='public'])[1]").check(); + console.log('Selected Public community visibility.'); } - // Method to click the 'Preview' button - async clickPreview() { - await this.page.getByRole('link', { name: 'Preview' }).click(); + // Method to select the 'Restricted' radio button in 'Community visibility' + async selectRestrictedCommunity() { + await this.page.locator("(//input[@type='radio' and @value='public'])[2]").check(); + console.log('Selected Restricted community visibility.'); } - // Method to click the 'Download' button - async clickDownload() { - await this.page.getByRole('link', { name: 'Download' }).click(); + // Method to click the 'Create community' button + async clickCreateCommunity() { + await this.page.locator('button.ui.icon.positive.left.labeled.button').click(); + console.log(`Clicked the Create community button.`); } // VERIFICATION ------------------------------------------------------------------------ diff --git a/tests/edit.spec.ts b/tests/edit.spec.ts index 239776d..8df6838 100644 --- a/tests/edit.spec.ts +++ b/tests/edit.spec.ts @@ -1,6 +1,7 @@ import { test, expect } from '../utils/fixtures'; import { UploadPage } from '../pages/uploadPage'; import { testData } from '../data/testData'; +import { qase } from 'playwright-qase-reporter'; test.describe('Edit record', () => { let uploadPage: UploadPage; @@ -24,7 +25,9 @@ test.describe('Edit record', () => { } }); - test('Edit Existing Record [Qase ID: RDM-12]', async () => { + test(qase(12, 'Edit Existing Record'), async () => { // Qase test case ID: + qase.fields({ 'severity': 'major', 'priority': 'high' }); // Qase test case values for severity and priority + // Navigate to 'My Dashboard' await uploadPage.navigateToMyDashboard(); diff --git a/tests/newUpload.spec.ts b/tests/newUpload.spec.ts index 3266fe6..82f4c26 100644 --- a/tests/newUpload.spec.ts +++ b/tests/newUpload.spec.ts @@ -1,6 +1,7 @@ import { test, expect } from '../utils/fixtures'; import { UploadPage } from '../pages/uploadPage'; import { testData } from '../data/testData'; +import { qase } from 'playwright-qase-reporter'; test.describe('New Upload', () => { let uploadPage: UploadPage; @@ -17,7 +18,9 @@ test.describe('New Upload', () => { } }); - test('Upload a file successfully [Qase ID: RDM-7]', async () => { + test(qase(7, 'Upload a file successfully'), async () => { // Qase test case ID: + qase.fields({ 'severity': 'major', 'priority': 'high' }); // Qase test case values for severity and priority + // Fill in the record details await uploadPage.fillTitle(testData.upload.recordTitle()); await uploadPage.fillFamilyName(testData.upload.familyName());