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

Function chooseLocalFile

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

Source from the content-addressed store, hash-verified

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