MCPcopy Create free account
hub / github.com/Rello/analytics / chooseLocalFile

Function chooseLocalFile

tests/playwright/common.js:766–798  ·  view source on GitHub ↗
(page, fileName)

Source from the content-addressed store, hash-verified

764}
765
766async function chooseLocalFile(page, fileName) {
767 await page.locator('.dialog__name, .oc-dialog-title').filter({ hasText: 'Select file' }).first()
768 .waitFor({ state: 'visible', timeout: 15000 });
769
770 const homeButton = page.locator('.home-icon, .home-icon > .material-design-icon__svg').first();
771 if (await homeButton.isVisible().catch(() => false)) {
772 await homeButton.click();
773 await page.waitForTimeout(300);
774 }
775
776 let fileRow = page.locator('.file-picker__row').filter({ hasText: fileName }).first();
777 if (!(await fileRow.count().catch(() => 0))) {
778 const analyticsFolder = page.locator('.file-picker__row .file-picker__file-name').filter({ hasText: /^Analytics$/ }).first();
779 const folderName = (await analyticsFolder.count().catch(() => 0))
780 ? analyticsFolder
781 : page.locator('.file-picker__row .file-picker__file-name').first();
782 await folderName.waitFor({ state: 'visible', timeout: 15000 });
783 await folderName.click();
784 await page.waitForTimeout(500);
785 fileRow = page.locator('.file-picker__row').filter({ hasText: fileName }).first();
786 }
787
788 if (!(await fileRow.count().catch(() => 0))) {
789 throw new Error(`Could not find local file "${fileName}" in file picker`);
790 }
791
792 await fileRow.locator('.file-picker__name-container, .file-picker__file-name').first().click();
793 await clickFirst(
794 page,
795 ['.dialog__actions > .button-vue', '.oc-dialog-buttonrow .primary', `button:has-text("${fileName}")`],
796 'file picker choose'
797 );
798}
799
800async function ensureStoredReportWithDefaultData(page, reportName, reportSubheader, options = {}) {
801 const reportAction = await openOrCreateStoredReport(page, reportName, reportSubheader, options);

Calls 5

clickFirstFunction · 0.85
filterMethod · 0.80
isVisibleMethod · 0.80
countMethod · 0.80
firstMethod · 0.45

Tested by

no test coverage detected