Skip to content

Commit

Permalink
Documents Tests Added_5Dec
Browse files Browse the repository at this point in the history
  • Loading branch information
Piyush Patel committed Dec 5, 2023
1 parent ad09068 commit f36995e
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 100 deletions.
15 changes: 15 additions & 0 deletions frontend/tests/constants/DocumentConstants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import path from 'path';

// Define the base directory for test data
const baseTestDataDirectory =
'D:/Etenlabs/Repos/Latest/crowd.rocks/frontend/tests/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;
36 changes: 34 additions & 2 deletions frontend/tests/pages/Community/DocumentsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@ 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' })
Expand Down Expand Up @@ -58,10 +66,34 @@ class DocumentsPage extends BasePage {
async clickOnCancelButton() {
await this.page.getByRole('button', { name: 'Cancel' }).click();
}
async uploadTextFile() {
const filePath = 'C:/Users/Piyush Patel/Desktop/sample3.txt';
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;
Loading

0 comments on commit f36995e

Please sign in to comment.