Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions frontend/tests/constants/DocumentConstants.ts
Original file line number Diff line number Diff line change
@@ -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;
14 changes: 6 additions & 8 deletions frontend/tests/data-factory/RegisterData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,38 @@ import RegisterDto from '../data-objects/RegisterDto';

class RegisterData {
validRegisterData() {
const registerData = RegisterDto;
const x = Math.random() * 100;
registerData.email = 'AutomationUser' + x + '@mailinator.com';
const registerData = new RegisterDto();
registerData.email = 'AutomationUser' + Date.now() + '@mailinator.com';
registerData.username = 'Automation Avatar URL';
registerData.password = 'automation@123';
return registerData;
}

registerDataWithoutEmail() {
const registerData = RegisterDto;
const registerData = new RegisterDto();
registerData.email = '';
registerData.username = 'Automation Avatar URL';
registerData.password = 'automation@123';
return registerData;
}

registerDataWithoutPassword() {
const registerData = RegisterDto;
const registerData = new RegisterDto();
registerData.email = 'AutomationUser12333@mailinator.com';
registerData.username = 'Automation Avatar URL';
registerData.password = '';
return registerData;
}

registerDataWithoutUserName() {
const registerData = RegisterDto;
const registerData = new RegisterDto();
registerData.email = 'AutomationUser@mailinator.com';
registerData.username = '';
registerData.password = 'automation@123';
return registerData;
}

registerDataWithInvalidEmailFormat() {
const registerData = RegisterDto;
const registerData = new RegisterDto();
registerData.email = 'Aut';
registerData.username = 'Automation Avatar URL';
registerData.password = 'automation@123';
Expand Down
2 changes: 1 addition & 1 deletion frontend/tests/data-objects/RegisterDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export class RegisterDto {
username!: string;
password!: string;
}
export default new RegisterDto();
export default RegisterDto;
2 changes: 1 addition & 1 deletion frontend/tests/pages/Community/CommonPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
99 changes: 99 additions & 0 deletions frontend/tests/pages/Community/DocumentsPage.ts
Original file line number Diff line number Diff line change
@@ -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;
95 changes: 95 additions & 0 deletions frontend/tests/pages/Community/PericopeToolPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import BasePage from '../BasePage';

const languageName = (language: string) =>
`//h5[text()='${language}']//..//input`;
const randomText = "(//div[@data-test-id]/div[@data-index='0']//div/div)[1]";
const selectedLanguageName = "//button[text()='Edit mode']/..//.//span[text()]";
const likeDislikeButton =
"//div[@role='presentation']//div[3]//div//div//button";
const postButton = `//div[@role='presentation']//div[3]//button`;
const documentName = "//div[@class = 'section']//h4";

class PericopeToolPage extends BasePage {
async isPageTitleVisible() {
return await this.page.locator(`//h2[text()='Pericope Tool']`).isVisible();
}
async clickOnSelectYourLanguageDropdown() {
await this.page
.getByRole('heading', { name: 'Select your language' })
.click();
}
async clickOnSelectPericopeLanguageDropdown() {
await this.page
.getByRole('heading', { name: 'Select document language' })
.click();
}
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 clickOnEditMode() {
await this.page.locator("//button[text()='Edit mode']").click();
}
async isEditModeButtonDisabled() {
return await this.page.locator("//button[text()='Edit mode']").isDisabled();
}
async clickOnRandomTextForAddPericopeTool() {
await this.page.locator(randomText).click();
}
async clickOnAddPericopeTool() {
await this.page.getByRole('heading', { name: 'Add Pericope' }).click();
await this.page.waitForTimeout(1000);
}
async clickOnDeletePericopeTool() {
await this.page.getByRole('heading', { name: 'Delete Pericope' }).click();
await this.page.waitForTimeout(1000);
}
async isPericopeToolAdded() {
return await this.page.locator(randomText + '/div').isVisible();
}
async isPericopeToolVisible() {
return await this.page
.getByRole('heading', { name: 'Add Pericope' })
.isVisible();
}
async getSelectedLanguageName() {
return await this.page.locator(selectedLanguageName).textContent();
}
async clickOnLikeButton() {
await this.page.locator(likeDislikeButton).first().click();
await this.page.waitForTimeout(1000);
}
async getPericopeDotsColor() {
// Get background color using evaluate method
const backgroundColor = await this.page
.locator(randomText + '/div')
?.evaluate((element) => {
return window.getComputedStyle(element).backgroundColor;
});
return backgroundColor;
}
async clickOnDislikeButton() {
await this.page.locator(likeDislikeButton).last().click();
await this.page.waitForTimeout(1000);
}
async clickOnPostButton() {
await this.page.locator(postButton).last().click();
}
async getPostCount() {
return await this.page.locator(postButton).last().textContent();
}
async getTheLikeCount() {
return await this.page.locator(likeDislikeButton).first().textContent();
}
async getTheDislikeCount() {
return await this.page.locator(likeDislikeButton).last().textContent();
}
async isDocumentNameIsDisplayed() {
return await this.page.locator(documentName).first().textContent();
}
}

export default PericopeToolPage;
2 changes: 1 addition & 1 deletion frontend/tests/pages/Community/PostPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PostPage extends BasePage {
return await this.page.locator(totalPostsCount).count();
}

async createNewPost(message: string, count: number) {
async createNewPosts(message: string, count: number) {
for (let i = 0; i < count; i++) {
await this.clickOnTheAddNewPostButton();
await this.clickOnTextFieldForPostMessage();
Expand Down
17 changes: 16 additions & 1 deletion frontend/tests/pages/HomePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"]';

Expand All @@ -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();
}
Expand All @@ -33,6 +36,18 @@ class HomePage extends BasePage {
.filter({ hasText: 'Forums' })
.click();
}
async clickOnTheDocumentsSection() {
await this.page
.locator('ion-card-header')
.filter({ hasText: 'Documents' })
.click();
}
async clickOnThePericopeToolSection() {
await this.page
.locator('ion-card-header')
.filter({ hasText: 'Pericope Tool' })
.click();
}
}

export default HomePage;
5 changes: 1 addition & 4 deletions frontend/tests/pages/MenuPage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import BasePage from './BasePage';

const headerText = '#crowd-rock-app #app-name-text';

const leftMenuFeatureButton = (featureName: string) =>
`//h4[text()="${featureName}"]`;

Expand All @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ test('1: End to end linear flow for Community forums', async ({ page }) => {

//Create a new two posts
await threadsPage.clickOnThreadName(threadNameOne);
await postPage.createNewPost(postTextMessage, 2);
await postPage.createNewPosts(postTextMessage, 2);

//Get posts count from the post page and verify that on the threads page
const expectedPostsCount = await postPage.getPostsCount();
Expand Down
Loading