Skip to content

Commit

Permalink
feature(download_file): Updated file download tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chalapkoStanislav committed Nov 25, 2024
1 parent 593b552 commit 375b62f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 64 deletions.
19 changes: 6 additions & 13 deletions pages/dashboard/dashboard-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ exports.DashboardPage = class DashboardPage extends BasePage {
.getByRole('button', { name: 'New File 1' })
.locator(`div[class*="dashboard_grid__library"]`);
this.downloadFilePenpotMenuItem = page.getByTestId('download-binary-file');
this.downloadFileStandardMenuItem = page.getByTestId('download-standard-file');
this.dashboardSection = page.locator('[class="main_ui_dashboard__dashboard"]');
this.downloadFileTickIcon = page.locator('svg[class="icon-tick"]');
this.downloadFileCloseButton = page
Expand Down Expand Up @@ -350,25 +349,19 @@ exports.DashboardPage = class DashboardPage extends BasePage {
await expect(this.sharedLibraryIcon).not.toBeVisible();
}

async downloadFileViaRightClick(isStandardFile = true) {
async downloadFileViaRightClick() {
await this.fileTile.click({ button: 'right' });
if (isStandardFile) {
await this.downloadFileStandardMenuItem.click();
} else {
await this.downloadFilePenpotMenuItem.click();
}
await this.downloadFilePenpotMenuItem.click();

await this.page.waitForEvent('download');
await expect(this.downloadFileTickIcon).toBeVisible();
await this.downloadFileCloseButton.click();
}

async downloadFileViaOptionsIcon(isStandardFile = true) {
async downloadFileViaOptionsIcon() {
await this.clickOnFileOptions();
if (isStandardFile) {
await this.downloadFileStandardMenuItem.click();
} else {
await this.downloadFilePenpotMenuItem.click();
}
await this.downloadFilePenpotMenuItem.click();

await this.page.waitForEvent('download');
await expect(this.downloadFileTickIcon).toBeVisible();
await this.downloadFileCloseButton.click();
Expand Down
47 changes: 4 additions & 43 deletions tests/dashboard/dashboard-files.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,7 @@ mainTest(
);

mainTest(
qase(67, 'DA-13 Download Penpot file in Drafts via right click'),
async ({ page }) => {
const dashboardPage = new DashboardPage(page);
const mainPage = new MainPage(page);
await dashboardPage.createFileViaPlaceholder();
await mainPage.clickPencilBoxButton();
await dashboardPage.downloadFileViaRightClick(false);
},
);

mainTest(
qase(69, 'DA-15 Download standard file in Drafts via right click'),
qase(1913, 'Download Penpot file (.penpot) (in Drafts) via right click'),
async ({ page }) => {
const dashboardPage = new DashboardPage(page);
const mainPage = new MainPage(page);
Expand Down Expand Up @@ -330,35 +319,7 @@ mainTest(
);

mainTest(
qase(1121, 'DA-35-1 Download Penpot file in Project via right click'),
async ({ page }) => {
const dashboardPage = new DashboardPage(page);
const mainPage = new MainPage(page);
await dashboardPage.clickAddProjectButton();
await dashboardPage.setProjectName('Test Project');
await dashboardPage.isProjectTitleDisplayed('Test Project');
await dashboardPage.createFileViaPlaceholder();
await mainPage.clickPencilBoxButton();
await dashboardPage.downloadFileViaRightClick(false);
},
);

mainTest(
qase(1121, 'DA-35-2 Download Penpot file in Project via Options icon'),
async ({ page }) => {
const dashboardPage = new DashboardPage(page);
const mainPage = new MainPage(page);
await dashboardPage.clickAddProjectButton();
await dashboardPage.setProjectName('Test Project');
await dashboardPage.isProjectTitleDisplayed('Test Project');
await dashboardPage.createFileViaPlaceholder();
await mainPage.clickPencilBoxButton();
await dashboardPage.downloadFileViaOptionsIcon(false);
},
);

mainTest(
qase(1122, 'DA-36-1 Download standard file in Project via right click'),
qase(1121, 'Download Penpot file (.penpot) (in project) via right click'),
async ({ page }) => {
const dashboardPage = new DashboardPage(page);
const mainPage = new MainPage(page);
Expand All @@ -372,7 +333,7 @@ mainTest(
);

mainTest(
qase(1122, 'DA-36-2 Download standard file in Project via Options icon'),
qase(1121, 'Download Penpot file (.penpot) (in project) via Options icon'),
async ({ page }) => {
const dashboardPage = new DashboardPage(page);
const mainPage = new MainPage(page);
Expand All @@ -381,7 +342,7 @@ mainTest(
await dashboardPage.isProjectTitleDisplayed('Test Project');
await dashboardPage.createFileViaPlaceholder();
await mainPage.clickPencilBoxButton();
await dashboardPage.downloadFileViaOptionsIcon();
await dashboardPage.downloadFileViaOptionsIcon(false);
},
);

Expand Down
9 changes: 1 addition & 8 deletions tests/panels-features/panels-features-main-menu.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,20 +196,13 @@ mainTest(
},
);

mainTest(qase(829, 'PF-111 Download penpot file .penpot'), async ({ page }) => {
mainTest(qase(1911, 'Download Penpot file (.penpot)'), async ({ page }) => {
const mainPage = new MainPage(page);
await mainPage.clickMainMenuButton();
await mainPage.clickFileMainMenuItem();
await mainPage.downloadPenpotFileViaMenu();
});

mainTest(qase(830, 'PF-112 Download standard file .svg+.json'), async ({ page }) => {
const mainPage = new MainPage(page);
await mainPage.clickMainMenuButton();
await mainPage.clickFileMainMenuItem();
await mainPage.downloadStandardFileViaMenu();
});

mainTest(qase(831, 'PF-113 Add/Remove as shared library'), async ({ page }) => {
const mainPage = new MainPage(page);
const assetsPanelPage = new AssetsPanelPage(page);
Expand Down

0 comments on commit 375b62f

Please sign in to comment.