Skip to content

Commit 81f3a35

Browse files
committed
test updates
Signed-off-by: Rello <github@scherello.de>
1 parent 658a2ef commit 81f3a35

3 files changed

Lines changed: 91 additions & 9 deletions

File tree

tests/playwright/44_automation_dataload_csv_column_picker.js

Lines changed: 61 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const {
2929
const config = buildScenarioConfig('44');
3030
const reportName = buildUniqueName('Playwright Regression', process.env.REPORT_NAME);
3131
const dataloadName = 'Test Dataload';
32+
const customColumnValues = ['Solar', 'Manual month'];
3233

3334
(async () => {
3435
const browser = await chromium.launch({ headless: config.headless });
@@ -63,23 +64,76 @@ const dataloadName = 'Test Dataload';
6364
await page.locator('.analyticsDialogHeader, #analyticsDialogContainer h2').filter({ hasText: 'Column Picker' }).first()
6465
.waitFor({ state: 'visible', timeout: 10000 });
6566
await page.locator('[id="1"]').first().check();
66-
await page.locator('[id="2"]').first().check();
67-
await page.locator('[id="4"]').first().check();
68-
await page.locator('#sortable-list > li:nth-child(2)').dragTo(page.locator('#sortable-list > li:nth-child(1)'));
67+
for (const value of customColumnValues) {
68+
await clickFirst(page, ['#addColumnButton'], 'add custom column');
69+
const customEditor = page.locator('#sortable-list > li').filter({ hasText: 'Custom Column' }).locator('span[contenteditable]').last();
70+
await customEditor.fill(value);
71+
}
6972
await clickFirst(page, ['#analyticsDialogBtnGo', '.oc-dialog-buttonrow > .primary'], 'column picker confirm');
7073

7174
const columnsValue = await page.locator('#columns').first().inputValue();
72-
if (columnsValue !== '2,1,4') {
73-
throw new Error(`Expected selected columns "2,1,4", got "${columnsValue}"`);
75+
if (columnsValue !== `1,${customColumnValues.join(',')}`) {
76+
throw new Error(`Expected selected columns "1,${customColumnValues.join(',')}", got "${columnsValue}"`);
7477
}
7578

7679
await capture('dataload_csv_column_picker');
7780

78-
steps.push('update and execute local csv dataload');
81+
steps.push('update local csv dataload');
7982
await clickFirst(page, ['#dataloadUpdateButton'], 'update dataload');
8083
await waitForToastAndDismiss(page);
84+
85+
steps.push('reopen custom columns in column picker');
86+
await openReportAutomationTab(page, reportName);
87+
await openDataloadEntry(page, dataloadName);
88+
await clickFirst(page, ['#columns'], 'columns dialog with custom columns');
89+
await page.locator('.analyticsDialogHeader, #analyticsDialogContainer h2').filter({ hasText: 'Column Picker' }).first()
90+
.waitFor({ state: 'visible', timeout: 10000 });
91+
92+
const customRows = page.locator('#sortable-list > li').filter({ hasText: 'Custom Column' });
93+
await customRows.first().waitFor({ state: 'visible', timeout: 10000 });
94+
const customRowCount = await customRows.count();
95+
if (customRowCount !== customColumnValues.length) {
96+
throw new Error(`Expected ${customColumnValues.length} custom column rows, got ${customRowCount}`);
97+
}
98+
for (let index = 0; index < customColumnValues.length; index += 1) {
99+
const row = customRows.nth(index);
100+
const editor = row.locator('span[contenteditable]').first();
101+
const editorText = await editor.textContent();
102+
if (editorText !== customColumnValues[index]) {
103+
throw new Error(`Expected custom column value "${customColumnValues[index]}", got "${editorText}"`);
104+
}
105+
const backgroundColor = await row.evaluate((node) => getComputedStyle(node).backgroundColor);
106+
const expectedColor = await row.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue('--color-warning-hover').trim());
107+
const expectedColorProbe = await page.evaluate((color) => {
108+
const probe = document.createElement('div');
109+
probe.style.backgroundColor = color;
110+
document.body.appendChild(probe);
111+
const computedColor = getComputedStyle(probe).backgroundColor;
112+
probe.remove();
113+
return computedColor;
114+
}, expectedColor);
115+
if (backgroundColor !== expectedColorProbe) {
116+
throw new Error(`Expected custom column warning background "${expectedColorProbe}", got "${backgroundColor}"`);
117+
}
118+
}
119+
const obsoleteHintIdCount = await page.locator('#addColumnHint').count();
120+
const obsoleteHintTextCount = await page.getByText(/Previous Values|Vorherige Werte/).count();
121+
if (obsoleteHintIdCount !== 0 || obsoleteHintTextCount !== 0) {
122+
throw new Error('Previous Values hint should not be shown for editable custom columns');
123+
}
124+
await capture('dataload_csv_column_picker_custom_columns');
125+
await customRows.first().locator('span[contenteditable]').first().fill('Solar edited');
126+
await clickFirst(page, ['#analyticsDialogBtnGo', '.oc-dialog-buttonrow > .primary'], 'column picker custom confirm');
127+
const editedColumnsValue = await page.locator('#columns').first().inputValue();
128+
if (editedColumnsValue !== '1,Solar edited,Manual month') {
129+
throw new Error(`Expected edited custom columns "1,Solar edited,Manual month", got "${editedColumnsValue}"`);
130+
}
131+
await clickFirst(page, ['#dataloadUpdateButton'], 'update edited custom dataload');
132+
await waitForToastAndDismiss(page);
133+
134+
steps.push('execute local csv dataload');
81135
await clickFirst(page, ['#dataloadExecuteButton'], 'execute dataload');
82-
await assertSimulationData(page, '[["import 44","2022-09-06","44b"],["import 55","2022-09-07","55c"]]');
136+
await assertSimulationData(page, '[["2022-09-06","Solar edited","Manual month"],["2022-09-07","Solar edited","Manual month"]]');
83137
await closeAnalyticsDialog(page);
84138

85139
steps.push('persist schedule and reopen entry');

tests/playwright/common.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,36 @@ async function waitForToastAndDismiss(page, timeout = 15000) {
621621
}
622622

623623
async function openReportAutomationTab(page, reportName) {
624+
if (await reportExists(page, reportName)) {
625+
const menu = await openNavigationEntryMenu(page, reportName);
626+
const maintenance = menu.locator('#navigationMenuAdvanced, a:has-text("Dataset maintenance")').first();
627+
if (await maintenance.count().catch(() => 0)) {
628+
await maintenance.click();
629+
await waitForIdle(page, 15000);
630+
await clickFirst(
631+
page,
632+
['#tabHeaderDataload', '#tabHeaderDataload a', 'a:has-text("Automation")', 'a:has-text("Dataload")'],
633+
'automation tab'
634+
);
635+
await page.locator('#datasourceSelect').first().waitFor({ state: 'visible', timeout: 15000 });
636+
return;
637+
}
638+
}
639+
640+
let datasetId = await page.locator('#datasetId').first().inputValue().catch(() => '');
641+
if (!datasetId) {
642+
datasetId = await page.evaluate(() => String(window.OCA?.Analytics?.currentReportData?.options?.dataset || '')).catch(() => '');
643+
}
624644
await ensureNavigationSection(page, 'datasets');
625-
const datasetEntry = page.locator('#navigationDatasets a[data-item_type="dataset"]').filter({ hasText: reportName }).first();
645+
if (!datasetId) {
646+
datasetId = await page.locator('#datasetId').first().inputValue().catch(() => '');
647+
}
648+
let datasetEntry = datasetId
649+
? page.locator(`#navigationDatasets a[data-id="${datasetId}"][data-item_type="dataset"]`).first()
650+
: page.locator('#navigationDatasets a[data-item_type="dataset"]').filter({ hasText: reportName }).first();
651+
if (!(await datasetEntry.count().catch(() => 0))) {
652+
datasetEntry = page.locator('#navigationDatasets a[data-item_type="dataset"]').filter({ hasText: reportName }).first();
653+
}
626654
await datasetEntry.waitFor({ state: 'attached', timeout: 20000 });
627655
const entryVisible = await datasetEntry.isVisible().catch(() => false);
628656
if (entryVisible) {

tests/run-playwright.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
55
ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
66

77
PLAYWRIGHT_IMAGE="${PLAYWRIGHT_IMAGE:-analytics-playwright:local}"
8-
BASE_URL="${BASE_URL:-http://host.docker.internal:8032/apps/analytics/}"
8+
BASE_URL="${BASE_URL:-http://host.docker.internal:8033/apps/analytics/}"
99
NC_USER="${NC_USER:-admin}"
1010
NC_PASS="${NC_PASS:-admin}"
1111
REPORT_NAME="${REPORT_NAME:-Playwright Regression}"

0 commit comments

Comments
 (0)