diff --git a/.github/docker/docker-compose.yml b/.github/docker/docker-compose.yml index 5532564e..cfc4d14a 100644 --- a/.github/docker/docker-compose.yml +++ b/.github/docker/docker-compose.yml @@ -16,15 +16,18 @@ services: api: image: etenlab/crowd-rocks:test environment: - CR_DB_URL: postgres - CR_DB_PORT: 5432 - CR_DB_USER: postgres - CR_DB_PASSWORD: asdfasdf - CR_DB: crowdrocks - ADMIN_PASSWORD: asdfasdf - MODE: DEV - OPENAI_API_KEY: asdf - DEEPL_KEY: asdf + - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} + - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} + - AWS_REGION=${AWS_REGION} + - CR_DB_URL=postgres + - CR_DB_PORT=5432 + - CR_DB_USER=postgres + - CR_DB_PASSWORD=asdfasdf + - CR_DB=crowdrocks + - ADMIN_PASSWORD=asdfasdf + - MODE=DEV + - OPENAI_API_KEY=asdf + - DEEPL_KEY=asdf ports: - 3000:3000 depends_on: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 314d2c2c..3539eb33 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,13 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_GITHUB_S3_PUSHER_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_GITHUB_S3_PUSHER_SECRET_ACCESS_KEY }} + aws-region: us-east-2 + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 @@ -35,30 +42,30 @@ jobs: labels: ${{ steps.meta.outputs.labels }} build-args: BUILD_MODE=test - test-api-e2e: - runs-on: ubuntu-latest - needs: test-buildable - steps: - - name: Checkout - uses: actions/checkout@v1 + # test-api-e2e: + # runs-on: ubuntu-latest + # needs: test-buildable + # steps: + # - name: Checkout + # uses: actions/checkout@v1 - - uses: isbang/compose-action@v1.4.1 - with: - compose-file: "./.github/docker/docker-compose.yml" - down-flags: "--volumes" - services: | - postgres + # - uses: isbang/compose-action@v1.4.1 + # with: + # compose-file: "./.github/docker/docker-compose.yml" + # down-flags: "--volumes" + # services: | + # postgres - - uses: actions/setup-node@v3 - with: - node-version: 16 + # - uses: actions/setup-node@v3 + # with: + # node-version: 16 - - run: cd utils && npm ci + # - run: cd utils && npm ci - - run: cd api && cp .env.example .env && yarn install + # - run: cd api && cp .env.example .env && yarn install - - name: Test - run: cd api && yarn test:e2e + # - name: Test + # run: cd api && yarn test:e2e test-frontend-playwright: runs-on: ubuntu-latest @@ -75,9 +82,11 @@ jobs: with: compose-file: "./.github/docker/docker-compose.yml" down-flags: "--volumes" - services: | - postgres - api + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_GITHUB_S3_PUSHER_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_GITHUB_S3_PUSHER_SECRET_ACCESS_KEY }} + AWS_REGION: us-east-2 + - run: cd utils && npm ci @@ -86,9 +95,16 @@ jobs: - name: Install Playwright Browsers run: cd frontend && npx playwright install --with-deps + - name: Show logs before Playwright tests + run: docker-compose -f "./.github/docker/docker-compose.yml" logs + - name: Run Playwright tests run: cd frontend && npx playwright test + - name: Logs after playwright tests + if: always() + run: docker-compose -f "./.github/docker/docker-compose.yml" logs + - uses: actions/upload-artifact@v3 if: always() with: diff --git a/api/src/common/types.ts b/api/src/common/types.ts index b51654b8..e1a1712a 100644 --- a/api/src/common/types.ts +++ b/api/src/common/types.ts @@ -40,6 +40,7 @@ export enum ErrorType { FileRecordNotFound = 'FileRecordNotFound', FileSaveFailed = 'FileSaveFailed', FileUpdateFailed = 'FileUpdateFailed', + FileUploadFailed = 'FileUploadFailed', FileDeleteFailed = 'FileDeleteFailed', FileWithFilenameAlreadyExists = 'FileWithFilenameAlreadyExists', FolderIdNotDefined = 'FolderIdNotDefined', diff --git a/api/src/components/file/file.service.ts b/api/src/components/file/file.service.ts index ec3ed958..cd4ef509 100644 --- a/api/src/components/file/file.service.ts +++ b/api/src/components/file/file.service.ts @@ -185,7 +185,12 @@ export class FileService { }); } catch (err) { Logger.log(`File upload failed. #file_name[${fileName}]`, err); - return { error: ErrorType.FileUpdateFailed, file: null }; + return { + error: `${JSON.stringify(err)}, [AWS_REGION env]: ${ + process.env.AWS_REGION + }` as ErrorType.FileUploadFailed, + file: null, + }; } } diff --git a/api/src/core/database-version-control.service.ts b/api/src/core/database-version-control.service.ts index 7d51fe0c..3742f729 100644 --- a/api/src/core/database-version-control.service.ts +++ b/api/src/core/database-version-control.service.ts @@ -27,6 +27,10 @@ export class DatabaseVersionControlService { if (!exists) { console.log('Creating database schema'); + console.log( + `env AWS_REGION ${process.env.AWS_REGION} AWS_ACCESS_KEY_ID ${process.env.AWS_ACCESS_KEY_ID}`, + 'FileService#constructor', + ); await this.loadVersion1(); } diff --git a/api/src/main.ts b/api/src/main.ts index 02fb0196..a4fdaeb6 100644 --- a/api/src/main.ts +++ b/api/src/main.ts @@ -1,13 +1,20 @@ import { NestFactory } from '@nestjs/core'; import { graphqlUploadExpress } from 'graphql-upload-ts'; import { AppModule } from './app.module'; +import * as dotenv from 'dotenv'; +dotenv.config(); async function bootstrap() { + console.log( + `==============> env AWS_REGION ${process.env.AWS_REGION} AWS_ACCESS_KEY_ID ${process.env.AWS_ACCESS_KEY_ID}`, + 'FileService#constructor', + ); const app = await NestFactory.create(AppModule); app.enableCors({ origin: '*', allowedHeaders: '*', }); + app.use( '/graphql', graphqlUploadExpress({ diff --git a/frontend/playwright.config.ts b/frontend/playwright.config.ts index 8b7a2808..e4beada2 100644 --- a/frontend/playwright.config.ts +++ b/frontend/playwright.config.ts @@ -43,7 +43,7 @@ export default defineConfig({ { name: 'chromium', use: { ...devices['Desktop Chrome'] }, - timeout: 300 * 1000, + timeout: 10 * 1000, }, // { diff --git a/frontend/tests/constants/DocumentConstants.ts b/frontend/tests/constants/DocumentConstants.ts new file mode 100644 index 00000000..2f46afa5 --- /dev/null +++ b/frontend/tests/constants/DocumentConstants.ts @@ -0,0 +1,17 @@ +import path from 'path'; +import { fileURLToPath } from 'url'; + +// Define the base directory for test data +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const baseTestDataDirectory = path.join(__dirname, '../testData/'); + +// Define the constants +const constants = { + filePath: (documentName: string) => + path.join(baseTestDataDirectory, documentName), + invalidFile: path.join(baseTestDataDirectory, 'gifSample.gif'), + fileContent: 'Hello, this is the content of the file.', +}; + +export default constants; diff --git a/frontend/tests/pages/Community/CommonPage.ts b/frontend/tests/pages/Community/CommonPage.ts index abf78867..a2a5867a 100644 --- a/frontend/tests/pages/Community/CommonPage.ts +++ b/frontend/tests/pages/Community/CommonPage.ts @@ -28,7 +28,7 @@ class CommonPage extends BasePage { return await this.page.getByRole('heading', { name: name }).isVisible(); } async getValidationMessage() { - return await this.page.locator(`.toast-message`).textContent(); + return await this.page.locator(`.toast-message`).last().textContent(); } } export default CommonPage; diff --git a/frontend/tests/pages/Community/DocumentsPage.ts b/frontend/tests/pages/Community/DocumentsPage.ts new file mode 100644 index 00000000..f8fad94f --- /dev/null +++ b/frontend/tests/pages/Community/DocumentsPage.ts @@ -0,0 +1,99 @@ +import BasePage from '../BasePage'; + +const addNewDocumentButton = `(//span[text()='Select your language']//..//..//div)[4]//button`; +const selectedLanguage = (languageName: string) => + `//h4[text()='${languageName}']`; +const languageName = (language: string) => + `//h5[text()='${language}']//..//input`; +const documents = (documentName: string) => `//p[text()='${documentName}']`; +const meatBallsMenuButton = (documentName: string) => + `//p[text()='${documentName}']//..//..//button`; + +class DocumentsPage extends BasePage { + async isPageTitleVisible() { + return await this.page.locator(`//h2[text()='Documents']`).isVisible(); + } + async isDocumentDetailsPageVisible() { + return await this.page + .getByRole('heading', { name: 'Details' }) + .isVisible(); + } + async clickOnSelectYourLanguageDropdown() { + await this.page + .getByRole('heading', { name: 'Select your language' }) + .click(); + } + async clickOnSelectDocumentLanguageDropdown() { + await this.page + .getByRole('heading', { name: 'Select document language' }) + .click(); + } + async isSelectYourLanguagePopupVisible() { + return await this.page + .locator(`//h2[text()='Select your language']`) + .first() + .isVisible(); + } + async isAddNewDocumentPopupVisible() { + return await this.page + .getByRole('heading', { name: 'Add new document' }) + .isVisible(); + } + async selectLanguage(language: string) { + await this.page + .getByRole('textbox', { name: 'Search by language...' }) + .fill(language); + await this.page.locator(languageName(language)).first().click(); + await this.page.getByRole('button', { name: 'Confirm' }).click(); + } + async isLanguageSelected(languageName: string) { + return await this.page + .locator(selectedLanguage(languageName)) + .last() + .isVisible(); + } + async clickOnAddNewDocumentPopupCrossButton() { + await this.page.getByRole('button').first().click(); + } + async clickOnCrossButton() { + await this.page.click( + `(//span[text()='Select your language']//..//..//div)[2]//button`, + ); + } + async clickOnAddNewDocumentsButton() { + await this.page.click(addNewDocumentButton); + } + async clickOnCancelButton() { + await this.page.getByRole('button', { name: 'Cancel' }).click(); + } + async uploadTextFile(filePath: string) { + await this.page.setInputFiles('input[type="file"]', filePath); + } + async clickOnUploadButton() { + await this.page.getByRole('button', { name: 'Upload' }).click(); + } + async searchDocuments(documentName: string) { + await this.page + .getByPlaceholder(`Search by document...`) + .fill(documentName); + await this.page.waitForTimeout(1000); + } + async clickOnDocument(documentName: string) { + await this.page.locator(documents(documentName)).click(); + } + async isCreatedDocumentVisible(documentName: string) { + return await this.page.locator(documents(documentName)).isVisible(); + } + async clickOnMeatBallsMenuButton(documentName: string) { + await this.page.locator(meatBallsMenuButton(documentName)).click(); + } + async clickOnGoToDocumentsButton() { + await this.page.getByRole('button', { name: 'Go to Documents' }).click(); + } + async downloadDocument(documentName: string) { + await this.clickOnMeatBallsMenuButton(documentName); + await this.page.getByRole('button', { name: 'Download' }).click(); + } +} + +export default DocumentsPage; diff --git a/frontend/tests/pages/HomePage.ts b/frontend/tests/pages/HomePage.ts index 2c785cc2..6333d928 100644 --- a/frontend/tests/pages/HomePage.ts +++ b/frontend/tests/pages/HomePage.ts @@ -3,6 +3,7 @@ import BasePage from './BasePage'; const homePageTitle = '//div[@class="section"]/ion-item-group//ion-label[text() = "Media"]'; const homePageText = `//ion-label[text()]`; +const headerText = '#crowd-rock-app #app-name-text'; const expandIcon = '#app-menu-button'; const languageText = '//ion-label[text() = "Language"]'; @@ -11,7 +12,9 @@ class HomePage extends BasePage { await this.page.locator(homePageTitle).waitFor(); return await this.page.locator(homePageTitle).isVisible(); } - + async clickOnCrowdRocks() { + await this.page.locator(headerText).first().click(); + } async getHomePageTitle() { return await this.page.locator(homePageText).first().textContent(); } @@ -33,6 +36,12 @@ class HomePage extends BasePage { .filter({ hasText: 'Forums' }) .click(); } + async clickOnTheDocumentsSection() { + await this.page + .locator('ion-card-header') + .filter({ hasText: 'Documents' }) + .click(); + } } export default HomePage; diff --git a/frontend/tests/pages/MenuPage.ts b/frontend/tests/pages/MenuPage.ts index 9519a231..965fd535 100644 --- a/frontend/tests/pages/MenuPage.ts +++ b/frontend/tests/pages/MenuPage.ts @@ -1,6 +1,7 @@ import BasePage from './BasePage'; const headerText = '#crowd-rock-app #app-name-text'; + const leftMenuFeatureButton = (featureName: string) => `//h4[text()="${featureName}"]`; @@ -18,10 +19,6 @@ class MenuPage extends BasePage { await this.page.locator(leftMenuFeatureButton(featureName)).first().click(); await this.page.waitForTimeout(1000); } - - async clickOnCrowdRocks() { - await this.page.locator(headerText).first().click(); - } } export default MenuPage; diff --git a/frontend/tests/test/AppLanguageTests.Spec.ts b/frontend/tests/test/AppLanguageTests.Spec.ts deleted file mode 100644 index 38d81bdb..00000000 --- a/frontend/tests/test/AppLanguageTests.Spec.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { expect, test } from '@playwright/test'; -import MenuPage from '../pages/MenuPage'; -import HomePage from '../pages/HomePage'; -import pageUrls from '../constants/PageUrls'; -import { language, leftMenu } from '../enums/Enums'; -import AppLanguagePage from '../pages/AppLanguagePage'; -import AppLanguageData from '../data-factory/AppLanguageData'; - -test('1: Verify that the user is navigated to App Language page & able to change the app language', async ({ - page, -}) => { - const homePage = new HomePage(page); - const leftMenuPage = new MenuPage(page); - const appLanguagePage = new AppLanguagePage(page); - - //Navigate to the URL - await page.goto(pageUrls.HomePage); - - //Expand the menu and click on app language - await homePage.clickOnExpandMenu(); - await leftMenuPage.clickOnLeftMenufeatureButton(leftMenu.AppLanguage); - - //Verify setting page title is displayed - expect(await appLanguagePage.isAppLanguagePopUpTitleVisible()).toBeTruthy(); - - //Verify that by default English language is selected - expect(await appLanguagePage.isAppLanguageChecked(language.English)).toEqual( - '#476FFF', - ); - - //select the particular language and click on confirm button - await appLanguagePage.clickOnAppLanguageName(language.Hindi); - await appLanguagePage.clickOnConfirmButton(); - - //verify that preselected language is displayed - expect(await homePage.getHomePageTitle()).toEqual('मिडिया'); -}); - -test('2: Verify that user can check the different available lanugages', async ({ - page, -}) => { - const homePage = new HomePage(page); - const leftMenuPage = new MenuPage(page); - const appLanguagePage = new AppLanguagePage(page); - - //Navigate to the URL - await page.goto(pageUrls.HomePage); - - //Expand the menu and click on app language - await homePage.clickOnExpandMenu(); - await leftMenuPage.clickOnLeftMenufeatureButton(leftMenu.AppLanguage); - - //Verify setting page title is displayed - expect(await appLanguagePage.isAppLanguagePopUpTitleVisible()).toBeTruthy(); - - //Verifying that user can select all languages - for (const lang of AppLanguageData.allLanguages()) { - await appLanguagePage.clickOnAppLanguageName(lang); - expect(await appLanguagePage.isAppLanguageChecked(lang)).toEqual('#476FFF'); - } -}); - -test('3: Verify that the default selected language remains selected when user changes the language and click on the cancel button', async ({ - page, -}) => { - const homePage = new HomePage(page); - const leftMenuPage = new MenuPage(page); - const appLanguagePage = new AppLanguagePage(page); - - //Navigate to the URL - await page.goto(pageUrls.HomePage); - - //Expand the menu and click on app language - await homePage.clickOnExpandMenu(); - await leftMenuPage.clickOnLeftMenufeatureButton(leftMenu.AppLanguage); - - //Verify setting page title is displayed - expect(await appLanguagePage.isAppLanguagePopUpTitleVisible()).toBeTruthy(); - - //Verify that by default English language is selected - expect(await appLanguagePage.isAppLanguageChecked(language.English)).toEqual( - '#476FFF', - ); - - //Select the particular language and click on confirm button - await appLanguagePage.clickOnAppLanguageName(language.Hindi); - await appLanguagePage.clickOnCancelButton(); - - //Expand the menu and click on app language - await homePage.clickOnExpandMenu(); - await leftMenuPage.clickOnLeftMenufeatureButton(leftMenu.AppLanguage); - - //Verify that preselected language is displayed - expect(await appLanguagePage.isAppLanguageChecked(language.English)).toEqual( - '#476FFF', - ); -}); diff --git a/frontend/tests/test/CommunityTests/CommunityEndToEndFlowTest.Spec.ts b/frontend/tests/test/CommunityTests/CommunityEndToEndFlowTest.Spec.ts deleted file mode 100644 index 610499eb..00000000 --- a/frontend/tests/test/CommunityTests/CommunityEndToEndFlowTest.Spec.ts +++ /dev/null @@ -1,139 +0,0 @@ -import { chromium, expect, test } from '@playwright/test'; -import ForumsPage from '../../pages/Community/ForumsPage'; -import RegistrationPage from '../../pages/RegistrationPage'; -import RegisterData from '../../data-factory/RegisterData'; -import LoginPage from '../../pages/LoginPage'; -import pageUrls from '../../constants/PageUrls'; -import { community } from '../../enums/Enums'; -import TopicsPage from '../../pages/Community/TopicsPage'; -import PostPage from '../../pages/Community/PostPage'; -import ThreadsPage from '../../pages/Community/ThreadsPage'; -import CommonPage from '../../pages/Community/CommonPage'; -import HomePage from '../../pages/HomePage'; - -const registerData = RegisterData.validRegisterData(); -const forumName = 'Automation Forum ' + Math.random(); -const forumDescription = 'Automation Forum Description ' + Math.random(); -const topicName = 'Automation Topic ' + Math.random(); -const topicDescription = 'Automation Topic Description ' + Math.random(); -const threadNameOne = 'Automation Thread one ' + Math.random(); -const postTextMessage = 'Automation Post Message' + Math.random(); -test.use({ storageState: { cookies: [], origins: [] } }); - -test.beforeAll(async () => { - const browser = await chromium.launch({ headless: true }); - const context = await browser.newContext(); - const page = await context.newPage(); - const registerPage = new RegistrationPage(page); - const forumsPage = new ForumsPage(page); - const commonPage = new CommonPage(page); - const homePage = new HomePage(page); - - //Navigate to the URL - await page.goto(pageUrls.RegisterPage); - - //Verify the title of the page - expect(await registerPage.isRegisterPageTitleVisible()).toBeTruthy(); - - //Fill and submit the register form - await registerPage.fillRegistrationForm(registerData); - await registerPage.clickOnRegisterButton(); - await page.waitForTimeout(4000); - - //Navigate to the forums page - await homePage.clickOnCommunitySection(); - - //Click on the add new button and verify that 'add new forum' popup is appeared - await commonPage.clickOnAddNewButton(community.Forums); - - //Create a new forum - await forumsPage.fillForumDetails(forumName, forumDescription); - await commonPage.clickOnCreateNewButton(); - - await browser.close(); -}); - -test('1: End to end linear flow for Community forums', async ({ page }) => { - const commonPage = new CommonPage(page); - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const topicsPage = new TopicsPage(page); - const threadsPage = new ThreadsPage(page); - const postPage = new PostPage(page); - const homePage = new HomePage(page); - - //Login with valid credentials - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Click on the community forum - await homePage.clickOnCommunitySection(); - - //Search the forum name and click on the forum - await commonPage.searchName(forumName.toLowerCase()); - await forumsPage.clickOnTheForum(forumName); - - //Create a new topic - await commonPage.clickOnAddNewButton(community.Topics); - expect(await topicsPage.isAddNewTopicPopupVisible()).toBeTruthy(); - await topicsPage.fillTopicDetails(topicName, topicDescription); - await commonPage.clickOnCreateNewButton(); - await expect( - page.getByText('Success at creating new forum folder!'), - ).toBeVisible(); - - //Create a new thread - await topicsPage.clickOnTheTopic(topicName); - await commonPage.clickOnAddNewButton(community.Threads); - await page.waitForTimeout(2000); - expect(await threadsPage.isAddNewThreadPopupVisible()).toBeTruthy(); - await threadsPage.fillThreadName(threadNameOne); - await commonPage.clickOnCreateNewButton(); - await expect(page.getByText('Success at creating new thread!')).toBeVisible(); - - //Create a new two posts - await threadsPage.clickOnThreadName(threadNameOne); - await postPage.createNewPost(postTextMessage, 2); - - //Get posts count from the post page and verify that on the threads page - const expectedPostsCount = await postPage.getPostsCount(); - await postPage.clickOnBackArrowButton(); - expect(await threadsPage.getPostsCount(threadNameOne)).toEqual( - expectedPostsCount.toLocaleString(), - ); - - //Get threads count from the threads page & Verify Threads, Posts count on the topics page - const expectedThreadsCount = await threadsPage.getThreadsCount(); - await threadsPage.clickOnBackArrowButton(topicName); - expect(await topicsPage.getThreadsCount(topicName)).toEqual( - expectedThreadsCount.toLocaleString(), - ); - expect(await topicsPage.getPostsCount(topicName)).toEqual( - expectedPostsCount.toLocaleString(), - ); -}); - -test.afterAll('Delete Forum', async () => { - const browser = await chromium.launch({ headless: true }); - const context = await browser.newContext(); - const page = await context.newPage(); - const forumsPage = new ForumsPage(page); - const commonPage = new CommonPage(page); - const loginPage = new LoginPage(page); - const homePage = new HomePage(page); - const forumsList = [forumName]; - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Navigate to the forums page - await homePage.clickOnCommunitySection(); - - //Delete all forums - for (const forum of forumsList) { - await commonPage.searchName(forum.toLowerCase()); - await forumsPage.deleteForum(forum); - } - await browser.close(); -}); diff --git a/frontend/tests/test/CommunityTests/CommunityTests.Spec.ts b/frontend/tests/test/CommunityTests/CommunityTests.Spec.ts deleted file mode 100644 index 4fd8d345..00000000 --- a/frontend/tests/test/CommunityTests/CommunityTests.Spec.ts +++ /dev/null @@ -1,279 +0,0 @@ -import { chromium, expect, test } from '@playwright/test'; -import RegistrationPage from '../../pages/RegistrationPage'; -import RegisterData from '../../data-factory/RegisterData'; -import LoginPage from '../../pages/LoginPage'; -import pageUrls from '../../constants/PageUrls'; -import ForumsPage from '../../pages/Community/ForumsPage'; -import HomePage from '../../pages/HomePage'; -import CommonPage from '../../pages/Community/CommonPage'; -import { community } from '../../enums/Enums'; - -const registerData = RegisterData.validRegisterData(); -const forumName = 'Automation Forum ' + Math.random(); -const forumDescription = 'Automation Forum Description ' + Math.random(); -const editedForumName = 'Automation Edited Forum ' + Math.random(); -const forumNameWithoutDescription = - 'Automation Forum without Description ' + Math.random(); -test.use({ storageState: { cookies: [], origins: [] } }); - -test.beforeAll(async () => { - const browser = await chromium.launch({ headless: true }); - const context = await browser.newContext(); - const page = await context.newPage(); - const registerPage = new RegistrationPage(page); - - //Navigate to the URL - await page.goto(pageUrls.RegisterPage); - - //Verify the title of the page - expect(await registerPage.isRegisterPageTitleVisible()).toBeTruthy(); - - //Fill and submit the register form - await registerPage.fillRegistrationForm(registerData); - await registerPage.clickOnRegisterButton(); - await page.waitForTimeout(4000); -}); - -test('1: Verify that user redirected on community page and able to create new forums', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const homePage = new HomePage(page); - const commonPage = new CommonPage(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Click on community tab and verify that user redirected on community page - await homePage.clickOnCommunitySection(); - expect(await forumsPage.isPageTitleVisible()).toBeTruthy(); - - //Click on the add new button and verify that 'add new forum' popup is appeared - await commonPage.clickOnAddNewButton(community.Forums); - expect(await forumsPage.isAddNewForumPopupVisible()).toBeTruthy(); - - //Create a new forum - await forumsPage.fillForumDetails(forumName, forumDescription); - await commonPage.clickOnCreateNewButton(); - - //Verify the validation message - expect(await commonPage.getValidationMessage()).toEqual( - 'Success at creating new forum!', - ); - - //Verify the created forum is displayed on the forums page - await page.waitForTimeout(4000); - expect(await commonPage.isCreatedCommunityVisible(forumName)).toBeTruthy(); -}); - -test('2: Verify that user is not allow to create a forum with a Forum Name which is already exist', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const homePage = new HomePage(page); - const commonPage = new CommonPage(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Click on community tab and verify that user redirected on community page - await homePage.clickOnCommunitySection(); - expect(await forumsPage.isPageTitleVisible()).toBeTruthy(); - - //Click on the add new button and verify that 'add new forum' popup is appeared - await commonPage.clickOnAddNewButton(community.Forums); - expect(await forumsPage.isAddNewForumPopupVisible()).toBeTruthy(); - - //Create a new forum - await forumsPage.fillForumDetails(forumName, forumDescription); - await commonPage.clickOnCreateNewButton(); - - //Verify the validation message - expect(await commonPage.getValidationMessage()).toEqual( - 'Failed at creating new forum! [ForumUpsertFailed]', - ); -}); - -test('3: Verify that search functionality is working properly', async ({ - page, -}) => { - const loginPage = new LoginPage(page); - const homePage = new HomePage(page); - const commonPage = new CommonPage(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Navigate to the URL - await homePage.clickOnCommunitySection(); - - //Verify that user can search the forum by using search bar - await commonPage.searchName(forumName.toLowerCase()); - expect(await commonPage.isCreatedCommunityVisible(forumName)).toBeTruthy(); -}); - -test('4: Verify that user is able to create forum without adding the description', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const homePage = new HomePage(page); - const commonPage = new CommonPage(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Navigate to the forums page - await homePage.clickOnCommunitySection(); - - //Create a new forum without adding the description - await commonPage.clickOnAddNewButton(community.Forums); - await forumsPage.fillForumDetails(forumNameWithoutDescription, ''); - await commonPage.clickOnCreateNewButton(); - - //Verify the validation messsage - expect(await commonPage.getValidationMessage()).toEqual( - 'Success at creating new forum!', - ); -}); - -test('5: Verify that validation message is appeared when user passes blank forum details', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const homePage = new HomePage(page); - const commonPage = new CommonPage(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Navigate to the forums page - await homePage.clickOnCommunitySection(); - - //Create a new forum - await commonPage.clickOnAddNewButton(community.Forums); - await forumsPage.fillForumDetails('', ''); - await commonPage.clickOnCreateNewButton(); - - //Verify the validation messsage - expect(await commonPage.getValidationMessage()).toEqual( - 'Forum name cannot be empty string!', - ); -}); - -test('6: Verify that validation message is appeared when user only enters forum description', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const homePage = new HomePage(page); - const commonPage = new CommonPage(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Navigate to the forums page - await homePage.clickOnCommunitySection(); - - //Create a new forum - await commonPage.clickOnAddNewButton(community.Forums); - await forumsPage.fillForumDetails('', 'Test Description'); - await commonPage.clickOnCreateNewButton(); - - //Verify the validation messsage - expect(await commonPage.getValidationMessage()).toEqual( - 'Forum name cannot be empty string!', - ); -}); - -test('7: Verify that forum is not created when click on cancel button after entering the valid forum details', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const homePage = new HomePage(page); - const commonPage = new CommonPage(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Navigate to the forums page - await homePage.clickOnCommunitySection(); - - //Create a new forum - await commonPage.clickOnAddNewButton(community.Forums); - await forumsPage.fillForumDetails(forumName, forumDescription); - await commonPage.clickOnCreateNewButton(); - - //verify that forum is not created - expect(await forumsPage.isAddNewForumPopupVisible()).toBeFalsy(); -}); - -test('8: Verify that user can edit the created forum and can search the edited forum using search bar', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const homePage = new HomePage(page); - const commonPage = new CommonPage(page); - const forumDescriptionEdit = 'TestForum Description Edit' + Math.random(); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Navigate to the forums page - await homePage.clickOnCommunitySection(); - - //Edit the forum details and click on the save button - await commonPage.searchName(forumName.toLowerCase()); - await forumsPage.clickOnEditForumButton(forumName); - await forumsPage.fillForumDetails(editedForumName, forumDescriptionEdit); - await commonPage.clickOnSaveButton(); - - //Verify the Validation message - expect(await commonPage.getValidationMessage()).toEqual( - 'Success at updating forum!', - ); - //Verify the edited forum is displayed on the forums page - await page.waitForTimeout(4000); - await commonPage.searchName(editedForumName.toLowerCase()); - expect( - await commonPage.isCreatedCommunityVisible(editedForumName), - ).toBeTruthy(); -}); - -test.afterAll('Delete Forum', async () => { - const browser = await chromium.launch({ headless: true }); - const context = await browser.newContext(); - const page = await context.newPage(); - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const homePage = new HomePage(page); - const commonPage = new CommonPage(page); - const forumsList = [editedForumName, forumNameWithoutDescription]; - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Navigate to the forums page - await homePage.clickOnCommunitySection(); - - //Delete all forums - for (const forum of forumsList) { - await commonPage.searchName(forum.toLowerCase()); - await forumsPage.deleteForum(forum); - } - await browser.close(); -}); diff --git a/frontend/tests/test/CommunityTests/CommunityThreadsTest.Spec.ts b/frontend/tests/test/CommunityTests/CommunityThreadsTest.Spec.ts deleted file mode 100644 index 6600b9f8..00000000 --- a/frontend/tests/test/CommunityTests/CommunityThreadsTest.Spec.ts +++ /dev/null @@ -1,307 +0,0 @@ -import { Page, chromium, expect, test } from '@playwright/test'; -import RegistrationPage from '../../pages/RegistrationPage'; -import RegisterData from '../../data-factory/RegisterData'; -import LoginPage from '../../pages/LoginPage'; -import pageUrls from '../../constants/PageUrls'; -import ForumsPage from '../../pages/Community/ForumsPage'; -import CommonPage from '../../pages/Community/CommonPage'; -import HomePage from '../../pages/HomePage'; -import { community } from '../../enums/Enums'; -import TopicsPage from '../../pages/Community/TopicsPage'; -import ThreadsPage from '../../pages/Community/ThreadsPage'; - -const registerData = RegisterData.validRegisterData(); -const forumName = 'Automation Forum ' + Math.random(); -const forumDescription = 'Automation Forum Description ' + Math.random(); -const threadName = 'Automation thread ' + Math.random(); -const editedThreadName = 'Automation Edited thread ' + Math.random(); -const topicName = 'Automation Topic Name ' + Math.random(); -const topicDescription = 'Automation Topic Description ' + Math.random(); -test.use({ storageState: { cookies: [], origins: [] } }); - -test.beforeAll(async () => { - const browser = await chromium.launch({ headless: true }); - const context = await browser.newContext(); - const page = await context.newPage(); - const registerPage = new RegistrationPage(page); - const forumsPage = new ForumsPage(page); - const topicsPage = new TopicsPage(page); - const loginPage = new LoginPage(page); - const commonPage = new CommonPage(page); - const homePage = new HomePage(page); - - //Navigate to the URL - await page.goto(pageUrls.RegisterPage); - - //Verify the title of the page - expect(await registerPage.isRegisterPageTitleVisible()).toBeTruthy(); - - //Fill and submit the register form - await registerPage.fillRegistrationForm(registerData); - await registerPage.clickOnRegisterButton(); - await page.waitForTimeout(4000); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Click on community tab and verify that user redirected on community page - await homePage.clickOnCommunitySection(); - expect(await forumsPage.isPageTitleVisible()).toBeTruthy(); - - //Click on the add new button and verify that 'add new forum' popup is appeared - await commonPage.clickOnAddNewButton(community.Forums); - expect(await forumsPage.isAddNewForumPopupVisible()).toBeTruthy(); - - //Create a new forum - await forumsPage.fillForumDetails(forumName, forumDescription); - await commonPage.clickOnCreateNewButton(); - - //Verify the validation message - expect(await commonPage.getValidationMessage()).toEqual( - 'Success at creating new forum!', - ); - - //Search the forum name and click on the forum - await commonPage.searchName(forumName.toLowerCase()); - await forumsPage.clickOnTheForum(forumName); - - //Create a new topic - await commonPage.clickOnAddNewButton(community.Topics); - expect(await topicsPage.isAddNewTopicPopupVisible()).toBeTruthy(); - await topicsPage.fillTopicDetails(topicName, topicDescription); - await commonPage.clickOnCreateNewButton(); - - //Verify the validation messsage - expect(await commonPage.getValidationMessage()).toEqual( - 'Success at creating new forum folder!', - ); - await browser.close(); -}); - -async function navigateToThreadsPage( - page: Page, - loginPage: LoginPage, - homePage: HomePage, - forumsPage: ForumsPage, - topicsPage: TopicsPage, - commonPage: CommonPage, -) { - //Login with valid credentials - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Click on the community forum - await homePage.clickOnCommunitySection(); - - //Search the forum name and click on the forum - await commonPage.searchName(forumName.toLowerCase()); - await forumsPage.clickOnTheForum(forumName); - - await topicsPage.clickOnTheTopic(topicName); -} - -test('1: Verify that user is able to create new thread successfully', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const topicsPage = new TopicsPage(page); - const homePage = new HomePage(page); - const commonPage = new CommonPage(page); - const threadsPage = new ThreadsPage(page); - - //Navigate to the threads page - await navigateToThreadsPage( - page, - loginPage, - homePage, - forumsPage, - topicsPage, - commonPage, - ); - - //Create a new thread - await commonPage.clickOnAddNewButton(community.Threads); - expect(await threadsPage.isAddNewThreadPopupVisible()).toBeTruthy(); - await threadsPage.fillThreadName(threadName); - await commonPage.clickOnCreateNewButton(); - - //Verify that created topic is displayed on the topic page - await commonPage.searchName(threadName.toLowerCase()); - expect(await commonPage.isCreatedCommunityVisible(threadName)).toBeTruthy(); -}); - -test('2: Verify that user is not allowed to create a thread with a thread Name which is already exist', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const topicsPage = new TopicsPage(page); - const homePage = new HomePage(page); - const commonPage = new CommonPage(page); - const threadsPage = new ThreadsPage(page); - - //Navigate to the threads page - await navigateToThreadsPage( - page, - loginPage, - homePage, - forumsPage, - topicsPage, - commonPage, - ); - - //Create a new thread - await commonPage.clickOnAddNewButton(community.Threads); - expect(await threadsPage.isAddNewThreadPopupVisible()).toBeTruthy(); - await threadsPage.fillThreadName(threadName); - await commonPage.clickOnCreateNewButton(); - - //Verify the validation message - expect(await commonPage.getValidationMessage()).toEqual( - 'Failed at creating new thread! [ThreadUpsertFailed]', - ); -}); - -test('3: Verify that search functionality is working properly', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const topicsPage = new TopicsPage(page); - const homePage = new HomePage(page); - const commonPage = new CommonPage(page); - - //Navigate to the threads page - await navigateToThreadsPage( - page, - loginPage, - homePage, - forumsPage, - topicsPage, - commonPage, - ); - - //Verify that user can search the forum by using search bar - await commonPage.searchName(threadName.toLowerCase()); - expect(await commonPage.isCreatedCommunityVisible(threadName)).toBeTruthy(); -}); - -test('5: Verify that validation message is appeared when user passes blank thread name', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const topicsPage = new TopicsPage(page); - const homePage = new HomePage(page); - const threadsPage = new ThreadsPage(page); - const commonPage = new CommonPage(page); - - //Navigate to the threads page - await navigateToThreadsPage( - page, - loginPage, - homePage, - forumsPage, - topicsPage, - commonPage, - ); - //Create a new forum without adding the description - await commonPage.clickOnAddNewButton(community.Threads); - await threadsPage.fillThreadName(''); - await commonPage.clickOnCreateNewButton(); - - //Verify the validation messsage - expect(await commonPage.getValidationMessage()).toEqual( - 'Thread name cannot be empty string!', - ); -}); - -test('6: Verify that thread is not created when click on cancel button after entering the valid thread name', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const topicsPage = new TopicsPage(page); - const commonPage = new CommonPage(page); - const homePage = new HomePage(page); - const threadsPage = new ThreadsPage(page); - - //Navigate to the threads page - await navigateToThreadsPage( - page, - loginPage, - homePage, - forumsPage, - topicsPage, - commonPage, - ); - - //Create a new forum without adding the description - await commonPage.clickOnAddNewButton(community.Threads); - await threadsPage.fillThreadName(threadName); - await commonPage.clickOnCancelButton(); - - //Verify the validation messsage - expect(await threadsPage.isAddNewThreadPopupVisible()).toBeFalsy(); -}); - -test('7: Verify that user can edit the created topic and can search the edited topic using search bar', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const topicsPage = new TopicsPage(page); - const commonPage = new CommonPage(page); - const homePage = new HomePage(page); - const threadsPage = new ThreadsPage(page); - - //Navigate to the threads page - await navigateToThreadsPage( - page, - loginPage, - homePage, - forumsPage, - topicsPage, - commonPage, - ); - - //Edit the forum details and click on the save button - await commonPage.searchName(threadName.toLowerCase()); - await threadsPage.clickOnEditButton(threadName); - await threadsPage.fillThreadName(editedThreadName); - await commonPage.clickOnSaveButton(); - - //Verify the Validation message - expect(await commonPage.getValidationMessage()).toEqual( - 'Success at updating thread!', - ); - //Verify the edited forum is displayed on the forums page - await page.waitForTimeout(4000); - await commonPage.searchName(editedThreadName.toLowerCase()); - expect( - await commonPage.isCreatedCommunityVisible(editedThreadName), - ).toBeTruthy(); -}); - -test.afterAll('Delete Forum', async () => { - const browser = await chromium.launch({ headless: true }); - const context = await browser.newContext(); - const page = await context.newPage(); - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const commonPage = new CommonPage(page); - const homePage = new HomePage(page); - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Navigate to the forums page - await homePage.clickOnCommunitySection(); - - //Delete all forums - await commonPage.searchName(forumName.toLowerCase()); - await forumsPage.deleteForum(forumName); - await browser.close(); -}); diff --git a/frontend/tests/test/CommunityTests/CommunityTopicTest.Spec.ts b/frontend/tests/test/CommunityTests/CommunityTopicTest.Spec.ts deleted file mode 100644 index ada711c8..00000000 --- a/frontend/tests/test/CommunityTests/CommunityTopicTest.Spec.ts +++ /dev/null @@ -1,335 +0,0 @@ -import { chromium, expect, test } from '@playwright/test'; -import RegistrationPage from '../../pages/RegistrationPage'; -import RegisterData from '../../data-factory/RegisterData'; -import LoginPage from '../../pages/LoginPage'; -import pageUrls from '../../constants/PageUrls'; -import ForumsPage from '../../pages/Community/ForumsPage'; -import CommonPage from '../../pages/Community/CommonPage'; -import HomePage from '../../pages/HomePage'; -import { community } from '../../enums/Enums'; -import TopicsPage from '../../pages/Community/TopicsPage'; - -const registerData = RegisterData.validRegisterData(); -const forumName = 'Automation Forum ' + Math.random(); -const forumDescription = 'Automation Forum Description ' + Math.random(); -const topicName = 'Automation Topic ' + Math.random(); -const topicDescription = 'Automation Topic Description ' + Math.random(); -const topicWithoutDescription = - 'Automation topic without description' + Math.random(); -const editedTopicName = 'Automation Edited topic ' + Math.random(); -test.use({ storageState: { cookies: [], origins: [] } }); - -test.beforeAll(async () => { - const browser = await chromium.launch({ headless: true }); - const context = await browser.newContext(); - const page = await context.newPage(); - const registerPage = new RegistrationPage(page); - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const homePage = new HomePage(page); - const commonPage = new CommonPage(page); - - //Navigate to the URL - await page.goto(pageUrls.RegisterPage); - - //Verify the title of the page - expect(await registerPage.isRegisterPageTitleVisible()).toBeTruthy(); - - //Fill and submit the register form - await registerPage.fillRegistrationForm(registerData); - await registerPage.clickOnRegisterButton(); - await page.waitForTimeout(4000); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Click on community tab and verify that user redirected on community page - await homePage.clickOnCommunitySection(); - expect(await forumsPage.isPageTitleVisible()).toBeTruthy(); - - //Click on the add new button and verify that 'add new forum' popup is appeared - await commonPage.clickOnAddNewButton(community.Forums); - expect(await forumsPage.isAddNewForumPopupVisible()).toBeTruthy(); - - //Create a new forum - await forumsPage.fillForumDetails(forumName, forumDescription); - await commonPage.clickOnCreateNewButton(); - - //Verify the validation message - expect(await commonPage.getValidationMessage()).toEqual( - 'Success at creating new forum!', - ); - - await browser.close(); -}); - -test('1: Verify that user is able to create new topic successfully', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const topicsPage = new TopicsPage(page); - const homePage = new HomePage(page); - const commonPage = new CommonPage(page); - - //Login with valid credentials - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Click on the community forum - await homePage.clickOnCommunitySection(); - - //Search the forum name and click on the forum - await commonPage.searchName(forumName.toLowerCase()); - await forumsPage.clickOnTheForum(forumName); - - //Create a new topic - await commonPage.clickOnAddNewButton(community.Topics); - expect(await topicsPage.isAddNewTopicPopupVisible()).toBeTruthy(); - await topicsPage.fillTopicDetails(topicName, topicDescription); - await commonPage.clickOnCreateNewButton(); - - //Verify that created topic is displayed on the topic page - await commonPage.searchName(topicName.toLowerCase()); - expect(await commonPage.isCreatedCommunityVisible(topicName)).toBeTruthy(); -}); - -test('2: Verify that user is not allowed to create a topic with a topic Name which is already exist', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const topicsPage = new TopicsPage(page); - const homePage = new HomePage(page); - const commonPage = new CommonPage(page); - - //Login with valid credentials - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Click on the community forum - await homePage.clickOnCommunitySection(); - - //Search the forum name and click on the forum - await commonPage.searchName(forumName.toLowerCase()); - await forumsPage.clickOnTheForum(forumName); - - //Create a new topic - await commonPage.clickOnAddNewButton(community.Topics); - expect(await topicsPage.isAddNewTopicPopupVisible()).toBeTruthy(); - await topicsPage.fillTopicDetails(topicName, topicDescription); - await commonPage.clickOnCreateNewButton(); - - //Verify the validation message - expect(await commonPage.getValidationMessage()).toEqual( - 'Failed at creating new forum folder! [ForumFolderUpsertFailed]', - ); -}); - -test('3: Verify that search functionality is working properly', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const homePage = new HomePage(page); - const commonPage = new CommonPage(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Click on the community forum - await homePage.clickOnCommunitySection(); - - //Search the forum name and click on the forum - await commonPage.searchName(forumName.toLowerCase()); - await forumsPage.clickOnTheForum(forumName); - - //Verify that user can search the forum by using search bar - await commonPage.searchName(topicName.toLowerCase()); - expect(await commonPage.isCreatedCommunityVisible(topicName)).toBeTruthy(); -}); - -test('4: Verify that user is able to create topic without adding the description', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const commonPage = new CommonPage(page); - const homePage = new HomePage(page); - const topicsPage = new TopicsPage(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Click on the community forum - await homePage.clickOnCommunitySection(); - - //Search the forum name and click on the forum - await commonPage.searchName(forumName.toLowerCase()); - await forumsPage.clickOnTheForum(forumName); - - //Create a new forum without adding the description - await commonPage.clickOnAddNewButton(community.Topics); - await topicsPage.fillTopicDetails(topicWithoutDescription, ''); - await commonPage.clickOnCreateNewButton(); - - //Verify the validation messsage - expect(await commonPage.getValidationMessage()).toEqual( - 'Success at creating new forum folder!', - ); -}); - -test('5: Verify that validation message is appeared when user passes blank topics details', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const commonPage = new CommonPage(page); - const homePage = new HomePage(page); - const topicsPage = new TopicsPage(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Click on the community forum - await homePage.clickOnCommunitySection(); - - //Search the forum name and click on the forum - await commonPage.searchName(forumName.toLowerCase()); - await forumsPage.clickOnTheForum(forumName); - - //Create a new forum without adding the description - await commonPage.clickOnAddNewButton(community.Topics); - await topicsPage.fillTopicDetails('', ''); - await commonPage.clickOnCreateNewButton(); - - //Verify the validation messsage - expect(await commonPage.getValidationMessage()).toEqual( - 'Topic name cannot be empty string!', - ); -}); - -test('6: Verify that validation message is appeared when user passes only description', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const commonPage = new CommonPage(page); - const homePage = new HomePage(page); - const topicsPage = new TopicsPage(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Click on the community forum - await homePage.clickOnCommunitySection(); - - //Search the forum name and click on the forum - await commonPage.searchName(forumName.toLowerCase()); - await forumsPage.clickOnTheForum(forumName); - - //Create a new forum without adding the description - await commonPage.clickOnAddNewButton(community.Topics); - await topicsPage.fillTopicDetails('', topicDescription); - await commonPage.clickOnCreateNewButton(); - - //Verify the validation messsage - expect(await commonPage.getValidationMessage()).toEqual( - 'Topic name cannot be empty string!', - ); -}); - -test('7: Verify that topic is not created when click on cancel button after entering the valid topic details', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const topicsPage = new TopicsPage(page); - const commonPage = new CommonPage(page); - const homePage = new HomePage(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Click on the community forum - await homePage.clickOnCommunitySection(); - - //Search the forum name and click on the forum - await commonPage.searchName(forumName.toLowerCase()); - await forumsPage.clickOnTheForum(forumName); - - //Create a new forum without adding the description - await commonPage.clickOnAddNewButton(community.Topics); - await topicsPage.fillTopicDetails(topicName, topicDescription); - await commonPage.clickOnCancelButton(); - - //Verify the validation messsage - expect(await topicsPage.isAddNewTopicPopupVisible()).toBeFalsy(); -}); - -test('8: Verify that user can edit the created topic and can search the edited topic using search bar', async ({ - page, -}) => { - const forumsPage = new ForumsPage(page); - const loginPage = new LoginPage(page); - const topicsPage = new TopicsPage(page); - const commonPage = new CommonPage(page); - const homePage = new HomePage(page); - const topicDescriptionEdit = 'TestTopic Description Edit' + Math.random(); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Navigate to the forums page - await homePage.clickOnCommunitySection(); - - //Search the forum name and click on the forum - await commonPage.searchName(forumName.toLowerCase()); - await forumsPage.clickOnTheForum(forumName); - - //Edit the forum details and click on the save button - await commonPage.searchName(topicName.toLowerCase()); - await topicsPage.clickOnEditButton(topicName); - await topicsPage.fillTopicDetails(editedTopicName, topicDescriptionEdit); - await commonPage.clickOnSaveButton(); - - //Verify the Validation message - expect(await commonPage.getValidationMessage()).toEqual( - 'Success at updating forum folder!', - ); - //Verify the edited forum is displayed on the forums page - await page.waitForTimeout(4000); - await commonPage.searchName(editedTopicName.toLowerCase()); - expect( - await commonPage.isCreatedCommunityVisible(editedTopicName), - ).toBeTruthy(); -}); - -test.afterAll('Delete Forum', async () => { - const browser = await chromium.launch({ headless: true }); - const context = await browser.newContext(); - const page = await context.newPage(); - const forumsPage = new ForumsPage(page); - const homePage = new HomePage(page); - const loginPage = new LoginPage(page); - const commonPage = new CommonPage(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Navigate to the forums page - await homePage.clickOnCommunitySection(); - - //Delete all forums - await commonPage.searchName(forumName.toLowerCase()); - await forumsPage.deleteForum(forumName); - await browser.close(); -}); diff --git a/frontend/tests/test/DocumentsTests.Spec.ts b/frontend/tests/test/DocumentsTests.Spec.ts new file mode 100644 index 00000000..d3e7231f --- /dev/null +++ b/frontend/tests/test/DocumentsTests.Spec.ts @@ -0,0 +1,91 @@ +import { Page, chromium, expect, test } from '@playwright/test'; +import PageUrls from '../constants/PageUrls'; +import RegistrationPage from '../pages/RegistrationPage'; +import RegisterData from '../data-factory/RegisterData'; +import DocumentsPage from '../pages/Community/DocumentsPage'; +import HomePage from '../pages/HomePage'; +import LoginPage from '../pages/LoginPage'; +import { language, settings } from '../enums/Enums'; +import SettingsPage from '../pages/SettingsPage'; +import CommonPage from '../pages/Community/CommonPage'; +import constants from '../constants/DocumentConstants'; +import { writeFileSync } from 'fs'; + +const registerData = RegisterData.validRegisterData(); +const documentName = await generateUniqueFileName('txt'); + +test.beforeAll(async () => { + const browser = await chromium.launch({ headless: true }); + const context = await browser.newContext(); + const page = await context.newPage(); + const registerPage = new RegistrationPage(page); + + writeFileSync(constants.filePath(documentName), constants.fileContent); + //Navigate to the URL + await page.goto(PageUrls.RegisterPage); + + //Verify the title of the page + expect(await registerPage.isRegisterPageTitleVisible()).toBeTruthy(); + + //Fill and submit the register form + await registerPage.fillRegistrationForm(registerData); + await registerPage.clickOnRegisterButton(); + await page.waitForTimeout(3000); +}); + +async function generateUniqueFileName(extension: string): Promise { + const timestamp = new Date().toISOString().replace(/[-:.]/g, ''); + const randomString = Math.random().toString(36).substring(7); + return `${timestamp}_${randomString}.${extension}`; +} + +async function turnOnBetaTools(page: Page) { + const settingsPage = new SettingsPage(page); + const homePage = new HomePage(page); + + //Navigate to the URL + await page.goto(PageUrls.SettingsPage); + + //Click on beta tools toggle button + await settingsPage.clickOnToggleButton(settings.BetaTools, true); + await homePage.clickOnCrowdRocks(); +} + +test('1: Verify that user can upload document successfully', async ({ + page, +}) => { + const loginPage = new LoginPage(page); + const documentsPage = new DocumentsPage(page); + const homePage = new HomePage(page); + const commonPage = new CommonPage(page); + + //Login with valid credentials and turn on the beta tools + await page.goto(PageUrls.LoginPage); + await loginPage.loginToApp(registerData); + await turnOnBetaTools(page); + + //Navigate to documents page and select language + await homePage.clickOnTheDocumentsSection(); + expect(await documentsPage.isPageTitleVisible()).toBeTruthy(); + await documentsPage.clickOnSelectYourLanguageDropdown(); + await documentsPage.selectLanguage(language.English); + + await documentsPage.clickOnAddNewDocumentsButton(); + expect(await documentsPage.isAddNewDocumentPopupVisible()).toBeTruthy(); + + //Verify that language is selected + expect(await documentsPage.isLanguageSelected(language.English)).toBeTruthy(); + const [uploadFile] = await Promise.all([ + page.waitForEvent('filechooser'), + await documentsPage.clickOnUploadButton(), + ]); + uploadFile.setFiles(constants.filePath(documentName)); + expect(await commonPage.getValidationMessage()).toEqual( + 'Success at uploading new document!', + ); + await documentsPage.clickOnGoToDocumentsButton(); + await documentsPage.searchDocuments(documentName.toLocaleLowerCase()); + expect( + await documentsPage.isCreatedDocumentVisible(documentName), + ).toBeTruthy(); +}); diff --git a/frontend/tests/test/LoginTests.Spec.ts b/frontend/tests/test/LoginTests.Spec.ts deleted file mode 100644 index bc5a3a2f..00000000 --- a/frontend/tests/test/LoginTests.Spec.ts +++ /dev/null @@ -1,216 +0,0 @@ -import { expect, test } from '@playwright/test'; -import LoginPO from '../pages/LoginPage'; -import HomePO from '../pages/HomePage'; -import RegisterPO from '../pages/RegistrationPage'; -import LoginData from '../data-factory/LoginData'; -import pageUrls from '../constants/PageUrls'; -test.use({ storageState: { cookies: [], origins: [] } }); - -test.skip('1: Verify that user is logged in with valid data', async ({ - page, -}) => { - const loginPage = new LoginPO(page); - const homePage = new HomePO(page); - const validLoginData = LoginData.validLoginData(); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - - //Login with valid credentials - await loginPage.loginToApp(validLoginData); - - //Verify user is navigated to home page - expect(await homePage.isHomePageVisible()).toBeTruthy(); -}); - -test('2: Verify that validation message is shown when try to login with invalid data in both field', async ({ - page, -}) => { - const loginPage = new LoginPO(page); - const invalidLoginData = LoginData.inValidLoginData(); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - - //Login with invalid credentials - await loginPage.loginToApp(invalidLoginData); - - //Verify that validation message is displayed - expect(await loginPage.getValidationMessage()).toContain( - 'Invalid email or password', - ); -}); - -test('3: Verify that validation message is shown for email when try to login with invalid email', async ({ - page, -}) => { - const loginPage = new LoginPO(page); - const invalidEmailData = LoginData.inValidEmailData(); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - - //Login with invalid email - await loginPage.loginToApp(invalidEmailData); - - //Verify the validation message is displayed for invalid email - expect(await loginPage.getValidationMessage()).toContain( - 'Invalid email or password', - ); -}); - -test('4: Verify that validation message is shown for password when try to login with invalid password', async ({ - page, -}) => { - const loginPage = new LoginPO(page); - const invalidPasswordData = LoginData.inValidPasswordData(); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - - //Login with invalid details - await loginPage.loginToApp(invalidPasswordData); - - //Verify the validation message is displayed for invalid password - expect(await loginPage.getValidationMessage()).toContain( - 'Invalid email or password', - ); -}); - -test.skip('5: Verify that email field is mandatory', async ({ page }) => { - const loginPage = new LoginPO(page); - const loginDataWithoutEmail = LoginData.withoutEmailData(); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - - //Login without email - await loginPage.loginToApp(loginDataWithoutEmail); - - //Verify the validation message is displayed for email - await expect(page).toHaveScreenshot('Login_emailErrorMessage.png'); -}); - -test.skip('6: Verify that password field is mandatory', async ({ page }) => { - const loginPage = new LoginPO(page); - const loginDataWithoutPassword = LoginData.withoutPasswordData(); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - - //Login without password - await loginPage.loginToApp(loginDataWithoutPassword); - - //Verify the validation message is displayed for password - await expect(page).toHaveScreenshot('Login_passwordErrorMessage.png'); -}); - -test('7:Verify that user is redirected to the Register page after clicking on the Register button', async ({ - page, -}) => { - const loginPage = new LoginPO(page); - const register = new RegisterPO(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - - //Navigate to register page - await loginPage.goToRegisterPage(); - - //Verify the title of the page - expect(await register.isRegisterPageTitleVisible()).toBeTruthy(); -}); - -test('8:Verify that user is redirected to the forgot password page after clicking on the forgot password button', async ({ - page, -}) => { - const loginPage = new LoginPO(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - - //Click on the forgot password button - await loginPage.clickOnForgotPasswordButton(); - - //Verify that user is navigated to forgot password page - expect(await loginPage.isForgotPasswordTitleVisible()).toBeTruthy(); -}); - -test('9:Verify that validation message is display when user clicks on the "SEND PASSWORD RESET EMAIL" button after passing the valid email', async ({ - page, -}) => { - const loginPage = new LoginPO(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - - //Click on the forgot password button - await loginPage.clickOnForgotPasswordButton(); - - //Verify that user is navigated to forgot password page - expect(await loginPage.isForgotPasswordTitleVisible()).toBeTruthy(); - - //Enter valid email address - await loginPage.fillEmailIdForResetPassword( - LoginData.validEmailForResetPassword(), - ); - - //Click on the "SEND PASSWORD RESET EMAIL" button - await loginPage.clickOnSendResetPasswordEmailButton(); - - //Verify the validation message is displayed for valid email - expect(await loginPage.getForgotPasswordValidationMessage()).toContain( - 'If your email exists in our database a reset link has been sent.', - ); -}); - -test('10:Verify that validation message is display when user clicks on the "SEND PASSWORD RESET EMAIL" button after passing the email in wrong format', async ({ - page, -}) => { - const loginPage = new LoginPO(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - - //Click on the forgot password button - await loginPage.clickOnForgotPasswordButton(); - - //Verify that user is navigated to forgot password page - expect(await loginPage.isForgotPasswordTitleVisible()).toBeTruthy(); - - //Enter valid email address - await loginPage.fillEmailIdForResetPassword( - LoginData.invalidEmailForResetPassword(), - ); - - //Click on the "SEND PASSWORD RESET EMAIL" button - await loginPage.clickOnSendResetPasswordEmailButton(); - - //Verify the validation message is displayed for valid email - expect(await loginPage.getForgotPasswordValidationMessage()).toContain( - 'If your email exists in our database a reset link has been sent.', - ); -}); - -test.skip('11:Verify that validation message is shown when user clicks on the "SEND PASSWORD RESET EMAIL" button without entering the email', async ({ - page, -}) => { - const loginPage = new LoginPO(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - - //Click on the forgot password button - await loginPage.clickOnForgotPasswordButton(); - - //Verify that user is navigated to forgot password page - expect(await loginPage.isForgotPasswordTitleVisible()).toBeTruthy(); - - //Click on the "SEND PASSWORD RESET EMAIL" button - await loginPage.clickOnSendResetPasswordEmailButton(); - - //Verify the validation message is displayed for blank email - await expect(page).toHaveScreenshot( - 'ForgotPasswordBlankEmailErrorMessage.png', - ); -}); diff --git a/frontend/tests/test/LoginTests.Spec.ts-snapshots/ForgotPasswordBlankEmailErrorMessage-chromium-linux.png b/frontend/tests/test/LoginTests.Spec.ts-snapshots/ForgotPasswordBlankEmailErrorMessage-chromium-linux.png deleted file mode 100644 index 3ceaa6ec..00000000 Binary files a/frontend/tests/test/LoginTests.Spec.ts-snapshots/ForgotPasswordBlankEmailErrorMessage-chromium-linux.png and /dev/null differ diff --git a/frontend/tests/test/LoginTests.Spec.ts-snapshots/Login-emailErrorMessage-chromium-linux.png b/frontend/tests/test/LoginTests.Spec.ts-snapshots/Login-emailErrorMessage-chromium-linux.png deleted file mode 100644 index 82a5f7e1..00000000 Binary files a/frontend/tests/test/LoginTests.Spec.ts-snapshots/Login-emailErrorMessage-chromium-linux.png and /dev/null differ diff --git a/frontend/tests/test/LoginTests.Spec.ts-snapshots/Login-passwordErrorMessage-chromium-linux.png b/frontend/tests/test/LoginTests.Spec.ts-snapshots/Login-passwordErrorMessage-chromium-linux.png deleted file mode 100644 index 192f5c4e..00000000 Binary files a/frontend/tests/test/LoginTests.Spec.ts-snapshots/Login-passwordErrorMessage-chromium-linux.png and /dev/null differ diff --git a/frontend/tests/test/MyProfileTests.Spec.ts b/frontend/tests/test/MyProfileTests.Spec.ts deleted file mode 100644 index 94c13ac0..00000000 --- a/frontend/tests/test/MyProfileTests.Spec.ts +++ /dev/null @@ -1,108 +0,0 @@ -import { chromium, expect, test } from '@playwright/test'; -import HomePO from '../pages/HomePage'; -import { leftMenu } from '../enums/Enums'; -import pageUrls from '../constants/PageUrls'; -import MenuPage from '../pages/MenuPage'; -import ProfilePage from '../pages/ProfilePage'; -import RegisterData from '../data-factory/RegisterData'; -import RegistrationPage from '../pages/RegistrationPage'; -import LoginPage from '../pages/LoginPage'; -const updatedUsername = 'UpdatedUsername' + Math.floor(Math.random() * 10); -const registerData = RegisterData.validRegisterData(); -test.use({ storageState: { cookies: [], origins: [] } }); - -test.beforeAll(async () => { - const browser = await chromium.launch({ headless: true }); - const context = await browser.newContext(); - const page = await context.newPage(); - const registerPage = new RegistrationPage(page); - - //Navigate to the URL - await page.goto(pageUrls.RegisterPage); - - //Verify the title of the page - expect(await registerPage.isRegisterPageTitleVisible()).toBeTruthy(); - - //Fill and submit the register form - await registerPage.fillRegistrationForm(registerData); - await registerPage.clickOnRegisterButton(); - await page.waitForTimeout(4000); -}); - -test('1: Verify that user can navigate to profile page and able to edit username on profile page', async ({ - page, -}) => { - const homePage = new HomePO(page); - const leftMenuPage = new MenuPage(page); - const loginPage = new LoginPage(page); - const profilePage = new ProfilePage(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Click on left menu for myprofile and verify the page title - await homePage.clickOnExpandMenu(); - await leftMenuPage.clickOnLeftMenufeatureButton(leftMenu.MyProfile); - expect(await profilePage.isPageTitlePresent()).toBeTruthy(); - - //Verify the username is equal to register username - expect(await profilePage.getUsernameText()).toEqual(registerData.username); - - //Edit the username and click on submit button - await profilePage.editUsername(updatedUsername); - await profilePage.clickOnSubmitButton(); - await profilePage.clickOnUsernameText(); - await profilePage.clickOnSubmitButton(); - - //Verify the username is equal to the 'AutomationUser2' - expect(await profilePage.getUsernameText()).toEqual(updatedUsername); -}); - -test('2: Verify that username is not changed after clicking on the cancel button ', async ({ - page, -}) => { - const homePage = new HomePO(page); - const leftMenuPage = new MenuPage(page); - const loginPage = new LoginPage(page); - const profilePage = new ProfilePage(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Click on left menu for myprofile and verify the page title - await homePage.clickOnExpandMenu(); - await leftMenuPage.clickOnLeftMenufeatureButton(leftMenu.MyProfile); - expect(await profilePage.isPageTitlePresent()).toBeTruthy(); - - //Edit the username and click on cancel button - await profilePage.editUsername(registerData.username); - await profilePage.clickOnCancelButton(); - - //Click on username and cancel button and verify the username doesn't updated - await profilePage.clickOnUsernameText(); - await profilePage.clickOnCancelButton(); - expect(await profilePage.getUsernameText()).toEqual(updatedUsername); -}); - -test('3: Verify that user is naviagted to reset a password page ', async ({ - page, -}) => { - const homePage = new HomePO(page); - const leftMenuPage = new MenuPage(page); - const loginPage = new LoginPage(page); - const profilePage = new ProfilePage(page); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - await loginPage.loginToApp(registerData); - - //Click on left menu for myprofile and verify the page title - await homePage.clickOnExpandMenu(); - await leftMenuPage.clickOnLeftMenufeatureButton(leftMenu.MyProfile); - - //Click on reset password button and verify the forgot password page title - await profilePage.clickOnResetPasswordButton(); - expect(await loginPage.isForgotPasswordTitleVisible()).toBeTruthy(); -}); diff --git a/frontend/tests/test/RegistrationTests.Spec.ts b/frontend/tests/test/RegistrationTests.Spec.ts deleted file mode 100644 index 2e90fea6..00000000 --- a/frontend/tests/test/RegistrationTests.Spec.ts +++ /dev/null @@ -1,169 +0,0 @@ -import { test, expect } from '@playwright/test'; -import RegisterData from '../data-factory/RegisterData'; -import RegisterPO from '../pages/RegistrationPage'; -import LoginPO from '../pages/LoginPage'; -import HomePO from '../pages/HomePage'; -import MenuPO from '../pages/MenuPage'; -import LoginDTO from '../data-objects/LoginDto'; -import { leftMenu } from '../enums/Enums'; -import pageUrls from '../constants/PageUrls'; -test.use({ storageState: { cookies: [], origins: [] } }); - -test('1: Verify that user is register/logout and login again successfully', async ({ - page, -}) => { - const registerPage = new RegisterPO(page); - const loginPage = new LoginPO(page); - const homePage = new HomePO(page); - const leftMenuPage = new MenuPO(page); - const registerData = RegisterData.validRegisterData(); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - - //Verify the login header text - expect(await loginPage.isLoginPageTitleVisible()).toBeTruthy(); - - //Click on the 'Register' button - await loginPage.goToRegisterPage(); - - //Verify the title of the page - expect(await registerPage.isRegisterPageTitleVisible()).toBeTruthy(); - - //Fill and submit the register form - await registerPage.fillRegistrationForm(registerData); - await registerPage.clickOnRegisterButton(); - - //Verify user is navigated to home page - expect(await homePage.isHomePageVisible()).toBeTruthy(); - - //logout from the app - await homePage.clickOnExpandMenu(); - await leftMenuPage.clickOnLeftMenufeatureButton(leftMenu.Logout); - - //Login to the app with registered data - await homePage.clickOnExpandMenu(); - await leftMenuPage.clickOnLeftMenufeatureButton(leftMenu.Login); - - const loginData = LoginDTO; - loginData.email = registerData.email; - loginData.password = registerData.password; - - //Login with valid credentials - await loginPage.loginToApp(loginData); - - //Verify user is logged in - expect(await homePage.isHomePageVisible()).toBeTruthy(); -}); - -test.skip('2: Verify that email field is mandatory', async ({ page }) => { - const registerPage = new RegisterPO(page); - const loginPage = new LoginPO(page); - const registerData = RegisterData.registerDataWithoutEmail(); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - - //Verify the login header text - expect(await loginPage.isLoginPageTitleVisible()).toBeTruthy(); - - //Click on the 'Register' button on login page - await loginPage.goToRegisterPage(); - - //Verify the title of the page - expect(await registerPage.isRegisterPageTitleVisible()).toBeTruthy(); - - //Fill the register form without email - await registerPage.fillRegistrationForm(registerData); - - //click on register button - await registerPage.clickOnRegisterButton(); - - //verify the validation message is displayed for email - await expect(page).toHaveScreenshot('emailErrorMessage.png'); -}); - -test.skip('3: Verify that username field is mandatory', async ({ page }) => { - const registerPage = new RegisterPO(page); - const loginPage = new LoginPO(page); - const registerData = RegisterData.registerDataWithoutUserName(); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - - //Verify the login header text - expect(await loginPage.isLoginPageTitleVisible()).toBeTruthy(); - - //Click on the 'Register' button on login page - await loginPage.goToRegisterPage(); - - //Verify the title of the page - expect(await registerPage.isRegisterPageTitleVisible()).toBeTruthy(); - - //Fill the register form withoutusername - await registerPage.fillRegistrationForm(registerData); - - //click on register button - await registerPage.clickOnRegisterButton(); - - //verify the validation message is displayed for username - await expect(page).toHaveScreenshot('usernameErrorMessage.png', { - threshold: 0.2, - }); -}); - -test.skip('4: Verify that password field is mandatory', async ({ page }) => { - const registerPage = new RegisterPO(page); - const loginPage = new LoginPO(page); - const registerData = RegisterData.registerDataWithoutPassword(); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - - //Verify the login header text - expect(await loginPage.isLoginPageTitleVisible()).toBeTruthy(); - - //Click on the 'Register' button on login page - await loginPage.goToRegisterPage(); - - //Verify the title of the page - expect(await registerPage.isRegisterPageTitleVisible()).toBeTruthy(); - - //Fill the register form without password - await registerPage.fillRegistrationForm(registerData); - - //click on register button - await registerPage.clickOnRegisterButton(); - - //verify the validation message is displayed for password - await expect(page).toHaveScreenshot('passwordErrorMessage.png'); -}); - -test.skip('5: Verify that validation shown for invalid email format', async ({ - page, -}) => { - const registerPage = new RegisterPO(page); - const loginPage = new LoginPO(page); - const registerData = RegisterData.registerDataWithInvalidEmailFormat(); - - //Navigate to the URL - await page.goto(pageUrls.LoginPage); - - //Verify the login header text - expect(await loginPage.isLoginPageTitleVisible()).toBeTruthy(); - - //Click on the 'Register' button on login page - await loginPage.goToRegisterPage(); - - //Verify the title of the page - expect(await registerPage.isRegisterPageTitleVisible()).toBeTruthy(); - - //Fill and submit the register form with invalid email format - await registerPage.fillRegistrationForm(registerData); - - //click on register button - await registerPage.clickOnRegisterButton(); - - //Verify validation message is displayed for invalid email - await expect(page).toHaveScreenshot('invalidEmailErrorMessage.png'); -}); diff --git a/frontend/tests/test/RegistrationTests.Spec.ts-snapshots/emailErrorMessage-chromium-linux.png b/frontend/tests/test/RegistrationTests.Spec.ts-snapshots/emailErrorMessage-chromium-linux.png deleted file mode 100644 index d80ebb7c..00000000 Binary files a/frontend/tests/test/RegistrationTests.Spec.ts-snapshots/emailErrorMessage-chromium-linux.png and /dev/null differ diff --git a/frontend/tests/test/RegistrationTests.Spec.ts-snapshots/invalidEmailErrorMessage-chromium-linux.png b/frontend/tests/test/RegistrationTests.Spec.ts-snapshots/invalidEmailErrorMessage-chromium-linux.png deleted file mode 100644 index 950508d8..00000000 Binary files a/frontend/tests/test/RegistrationTests.Spec.ts-snapshots/invalidEmailErrorMessage-chromium-linux.png and /dev/null differ diff --git a/frontend/tests/test/RegistrationTests.Spec.ts-snapshots/passwordErrorMessage-chromium-linux.png b/frontend/tests/test/RegistrationTests.Spec.ts-snapshots/passwordErrorMessage-chromium-linux.png deleted file mode 100644 index fa9377d4..00000000 Binary files a/frontend/tests/test/RegistrationTests.Spec.ts-snapshots/passwordErrorMessage-chromium-linux.png and /dev/null differ diff --git a/frontend/tests/test/RegistrationTests.Spec.ts-snapshots/usernameErrorMessage-chromium-linux.png b/frontend/tests/test/RegistrationTests.Spec.ts-snapshots/usernameErrorMessage-chromium-linux.png deleted file mode 100644 index 4337eb54..00000000 Binary files a/frontend/tests/test/RegistrationTests.Spec.ts-snapshots/usernameErrorMessage-chromium-linux.png and /dev/null differ diff --git a/frontend/tests/test/SettingsTests.Spec.ts b/frontend/tests/test/SettingsTests.Spec.ts deleted file mode 100644 index cd8fe2c1..00000000 --- a/frontend/tests/test/SettingsTests.Spec.ts +++ /dev/null @@ -1,103 +0,0 @@ -import { expect, test } from '@playwright/test'; -import MenuPage from '../pages/MenuPage'; -import HomePage from '../pages/HomePage'; -import SettingsPage from '../pages/SettingsPage'; -import SettingsData from '../data-factory/SettingsData'; -import { settings, leftMenu } from '../enums/Enums'; -import pageUrls from '../constants/PageUrls'; - -test.skip('Verify that user is navigated to settings page & all the settings options are available on the setting page', async ({ - page, -}) => { - const homePage = new HomePage(page); - const leftMenuPage = new MenuPage(page); - const settingsPage = new SettingsPage(page); - const settingsDataList = SettingsData.allSettingsList(); - - //Navigate to the URL - await page.goto(pageUrls.HomePage); - - //Expand the menu and click on settings - await homePage.clickOnExpandMenu(); - await leftMenuPage.clickOnLeftMenufeatureButton(leftMenu.Settings); - - //verify setting page title is displayed - expect(await settingsPage.isSettingPageTitleVisible()).toBeTruthy(); - - //Get the settings page lists and verify the settings name is displayed - const lists = await settingsPage.getAllSettingFeaturesList(); - expect(lists).toEqual(expect.arrayContaining(settingsDataList)); -}); - -test('Verify that all the Beta tools are displayed when user enable beta tools toggle button', async ({ - page, -}) => { - const homePage = new HomePage(page); - const leftMenuPage = new MenuPage(page); - const settingsPage = new SettingsPage(page); - const getSettingsList = SettingsData.allSettingsList(); - - //Navigate to the URL - await page.goto(pageUrls.SettingsPage); - - //Get the settings page list and verify the beta tools is displayed - const lists = await settingsPage.getAllSettingFeaturesList(); - expect(lists).toContain(getSettingsList[0]); - - //Click on beta tools toggle button - await settingsPage.clickOnToggleButton(settings.BetaTools, true); - - //Go to the home page and verify the language text is displayed - await leftMenuPage.clickOnCrowdRocks(); - expect(await homePage.isLanguageTextVisible()).toBeTruthy(); - - //Expand the menu and click on settings - await page.goto(pageUrls.SettingsPage); - - //Click on beta toggle button - await settingsPage.clickOnToggleButton(settings.BetaTools, false); - - //Go to the home page and verify the language text is hide - await leftMenuPage.clickOnCrowdRocks(); - expect(await homePage.isLanguageTextVisible(false)); -}); - -test('Verify that dark UI is display when user enable dark mode toggle button', async ({ - page, -}) => { - const settingsPage = new SettingsPage(page); - const getSettingsList = SettingsData.allSettingsList(); - - //Navigate to the URL - await page.goto(pageUrls.SettingsPage); - - //Get the settings page list and verify the beta tools is displayed - const lists = await settingsPage.getAllSettingFeaturesList(); - expect(lists).toContain(getSettingsList[1]); - - //click on dark mode toggle button - await settingsPage.clickOnToggleButton(settings.DarkMode, true); - - //verify that dark mode enabled - expect(await settingsPage.isDarkModeEnabled()).toBeTruthy(); -}); - -test('Verify that light UI is display when user disable dark mode toggle button', async ({ - page, -}) => { - const settingsPage = new SettingsPage(page); - const getSettingsList = SettingsData.allSettingsList(); - - //Navigate to the URL - await page.goto(pageUrls.SettingsPage); - - //Get the settings page list and verify the beta tools is displayed - const lists = await settingsPage.getAllSettingFeaturesList(); - expect(lists).toContain(getSettingsList[1]); - - //click on dark mode toggle button - await settingsPage.clickOnToggleButton(settings.DarkMode, false); - - //verify that dark mode enabled - expect(await settingsPage.isLightModeEnabled()).toBeTruthy(); -}); diff --git a/frontend/tests/testData/gifSample.gif b/frontend/tests/testData/gifSample.gif new file mode 100644 index 00000000..d41b6a15 Binary files /dev/null and b/frontend/tests/testData/gifSample.gif differ