Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update(test): update files tests #125

Merged
merged 2 commits into from
Aug 15, 2024
Merged
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
20 changes: 19 additions & 1 deletion playwright/PageObjects/FilesScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class FilesPage extends MainPage {
readonly contextOptionDelete: Locator;
readonly contextOptionDownload: Locator;
readonly contextOptionRename: Locator;
readonly filePreviewImage: Locator;
readonly freeSpaceLabel: Locator;
readonly freeSpaceValue: Locator;
readonly inputFileFolderName: Locator;
Expand Down Expand Up @@ -41,6 +42,7 @@ export class FilesPage extends MainPage {
"context-menu-option-Download",
);
this.contextOptionRename = page.getByTestId("context-menu-option-Rename");
this.filePreviewImage = page.getByTestId("file-preview-image");
this.freeSpaceLabel = page.getByTestId("label-files-free-space");
this.freeSpaceValue = page.getByTestId("text-files-free-space");
this.inputFileFolderName = page.getByTestId("input-file-folder-name");
Expand Down Expand Up @@ -76,7 +78,8 @@ export class FilesPage extends MainPage {

async navigateToFolder(folderName: string) {
const folder = await this.getFolderByName(folderName);
await folder.click();
await folder.dblclick();
await folder.waitFor({ state: "detached" });
}

async renameFile(fileName: string, newName: string) {
Expand Down Expand Up @@ -173,6 +176,21 @@ export class FilesPage extends MainPage {
await expect(svgIcon).toBeVisible();
}

async validateUploadedImageInfo(
name: string,
extension: string,
expectedSize: string,
) {
const file = await this.getFileByName(name);
expect(file).toBeTruthy();
const fileName = file.getByTestId("file-folder-name");
expect(fileName).toHaveText(`${name}.${extension}`);
const fileSizeElement = file.getByTestId("file-folder-size");
expect(fileSizeElement).toHaveText(expectedSize);
const imagePreview = file.getByTestId("file-preview-image");
await expect(imagePreview).toBeVisible();
}

async uploadFile(filePath: string) {
await this.uploadFileButton.click();
await this.uploadFileInput.setInputFiles(filePath);
Expand Down
66 changes: 39 additions & 27 deletions playwright/specs/24-files.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,40 @@ test.describe("Files Page Tests", () => {
},
);

/*
test.skip("F1 - Highlighted border should appear when user clicks Sync", async ({
page,
}) => {
// Test code for F1
});

test.skip("F2 - Highlighted border should appear when user clicks Create Node", async ({
page,
}) => {
// Test code for F2
});

*/
test("F3, F4 - Amount of Free and Total should appear in Toolbar", async ({
filesPage,
}) => {
// Validate Free and Total space data
await filesPage.validateFreeSpaceInfo("2.15 GB");
await filesPage.validateTotalSpaceInfo("2.15 GB");

// F1 - Highlighted border should appear when user clicks Sync
await filesPage.buttonFilesSync.focus();
await expect(filesPage.buttonFilesSync).toHaveCSS(
"border-bottom-color",
"rgb(77, 77, 255)",
);

// F2 - Highlighted border should appear when user clicks Create Node
await filesPage.buttonFilesCreateNode.focus();
await expect(filesPage.buttonFilesCreateNode).toHaveCSS(
"border-bottom-color",
"rgb(77, 77, 255)",
);

// Highlighted border should appear when user clicks Gift Space
await filesPage.buttonFilesGiftSpace.focus();
await expect(filesPage.buttonFilesGiftSpace).toHaveCSS(
"border-bottom-color",
"rgb(77, 77, 255)",
);

// Highlighted border should appear when user clicks Rent Space
await filesPage.buttonFilesRentSpace.focus();
await expect(filesPage.buttonFilesRentSpace).toHaveCSS(
"border-bottom-color",
"rgb(77, 77, 255)",
);
});

test("F5 - Highlighted border should appaer when you click Create New Folder", async ({
Expand All @@ -83,7 +97,7 @@ test.describe("Files Page Tests", () => {
await filesPage.uploadFile("playwright/assets/banner.jpg");

// File uploaded should be displayed
await filesPage.validateUploadedFileInfo("banner", "jpg", "61.4 kB");
await filesPage.validateUploadedImageInfo("banner", "jpg", "61.4 kB");
});

test("F7 - User can create new folders on root", async ({ filesPage }) => {
Expand Down Expand Up @@ -143,11 +157,10 @@ test.describe("Files Page Tests", () => {

// User can upload an image file in subfolder
await filesPage.uploadFile("playwright/assets/banner.jpg");
await filesPage.validateUploadedFileInfo("banner", "jpg", "61.4 kB");
await filesPage.validateUploadedImageInfo("banner", "jpg", "61.4 kB");
});

// Skipping broken test due to open bug on logging back into the application
test.skip("F13 - Files and folders are still visible after logging out and login again", async ({
test("F13 - Files and folders are still visible after logging out and login again", async ({
chatsMainPage,
filesPage,
loginPinPage,
Expand All @@ -156,15 +169,15 @@ test.describe("Files Page Tests", () => {
}) => {
// User can upload an image file in root
await filesPage.uploadFile("playwright/assets/banner.jpg");
await filesPage.validateUploadedFileInfo("banner", "jpg", "61.4 kB");
await filesPage.validateUploadedImageInfo("banner", "jpg", "61.4 kB");

// Create a folder in root and enter on it
await filesPage.createNewFolder("NewFolder");
await filesPage.navigateToFolder("NewFolder");

// User can upload an image file in folder
await filesPage.uploadFile("playwright/assets/banner.jpg");
await filesPage.validateUploadedFileInfo("banner", "jpg", "61.4 kB");
await filesPage.validateUploadedImageInfo("banner", "jpg", "61.4 kB");

// Go back to root
await filesPage.goBackButton.click();
Expand All @@ -177,30 +190,29 @@ test.describe("Files Page Tests", () => {
await page.waitForURL("/auth");

// Log in again entering the same pin
await loginPinPage.waitUntilPageIsLoaded();
await loginPinPage.enterDefaultPin();
await loginPinPage.pinButtonConfirm.click();
await chatsMainPage.validateChatsMainPageIsShown();
await page.waitForURL("/pre");
await page.waitForURL("/chat");
await chatsMainPage.goToFiles();

// Validate files are still visible
await filesPage.validateUploadedFileInfo("banner", "jpg", "61.4 kB");
await filesPage.validateUploadedImageInfo("banner", "jpg", "61.4 kB");
await filesPage.validateNewFolderCreated("NewFolder", false, "61.4 kB");
await filesPage.navigateToFolder("NewFolder");
await filesPage.validateUploadedFileInfo("banner", "jpg", "61.4 kB");
await filesPage.validateUploadedImageInfo("banner", "jpg", "61.4 kB");
});

test("F14 - If user upload the same file again, file is uploaded but with different filename", async ({
filesPage,
}) => {
// Upload a file
await filesPage.uploadFile("playwright/assets/banner.jpg");
await filesPage.validateUploadedFileInfo("banner", "jpg", "61.4 kB");
await filesPage.validateUploadedImageInfo("banner", "jpg", "61.4 kB");

// Attempt to upload the same file again
await filesPage.uploadFile("playwright/assets/banner.jpg");

// File banner.jpg is uploaded again but with name "banner (1).jpg"
await filesPage.validateUploadedFileInfo("banner (1)", "jpg", "61.4 kB");
await filesPage.validateUploadedImageInfo("banner (1)", "jpg", "61.4 kB");
});
});
Loading