This is an automated email from the ASF dual-hosted git repository. tenthe pushed a commit to branch 4687-kiosk-mode-does-not-show-data-for-logged-out-users in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit 39e806698d425c6306b0c4d478027e116d070a0a Author: Philipp Zehnder <[email protected]> AuthorDate: Mon Jul 6 13:53:51 2026 +0000 test: validate logged-out kiosk table columns --- ui/cypress/support/utils/dashboard/Inspector.ts | 36 ++++++++++- ui/cypress/tests/chart/publicDashboardLink.spec.ts | 71 ++++++++++++++++------ 2 files changed, 88 insertions(+), 19 deletions(-) diff --git a/ui/cypress/support/utils/dashboard/Inspector.ts b/ui/cypress/support/utils/dashboard/Inspector.ts index 8f862fb981..d5075efd5f 100644 --- a/ui/cypress/support/utils/dashboard/Inspector.ts +++ b/ui/cypress/support/utils/dashboard/Inspector.ts @@ -42,7 +42,22 @@ export class Inspector { cy.visit(`#/dashboard-kiosk/${dashboardId}`); } - public static validateDashboardKioskWithTableChart(dashboardName: string) { + public static openDashboardKioskAsLoggedOutUser(dashboardId: string) { + cy.clearLocalStorage(); + cy.clearCookies(); + cy.visit(`#/dashboard-kiosk/${dashboardId}`, { + onBeforeLoad: win => { + win.localStorage.clear(); + win.sessionStorage.clear(); + expect(win.localStorage.getItem('auth-token')).to.equal(null); + }, + }); + } + + public static validateDashboardKioskWithTableChart( + dashboardName: string, + expectedColumns: string[] = [], + ) { cy.contains('.dashboard-title', dashboardName, { timeout: 10000, }).should('be.visible'); @@ -56,5 +71,24 @@ export class Inspector { ) .filter(':visible') .should('have.length.at.least', 1); + + expectedColumns.forEach(column => { + if (column === 'time') { + cy.dataCy('data-explorer-table-row-timestamp', { + timeout: 10000, + }) + .filter(':visible') + .should('have.length.at.least', 1); + } else { + cy.dataCy(`data-explorer-table-header-${column}`, { + timeout: 10000, + }).should('be.visible'); + cy.dataCy(`data-explorer-table-row-${column}`, { + timeout: 10000, + }) + .filter(':visible') + .should('have.length.at.least', 1); + } + }); } } diff --git a/ui/cypress/tests/chart/publicDashboardLink.spec.ts b/ui/cypress/tests/chart/publicDashboardLink.spec.ts index e88dceaea9..a2e506c92e 100644 --- a/ui/cypress/tests/chart/publicDashboardLink.spec.ts +++ b/ui/cypress/tests/chart/publicDashboardLink.spec.ts @@ -17,33 +17,68 @@ */ import { ChartUtils } from '../../support/utils/chart/ChartUtils'; +import { DataLakeSeedUtils } from '../../support/utils/dataset/DataLakeSeedUtils'; import { Inspector } from '../../support/utils/dashboard/Inspector'; import { PermissionUtils } from '../../support/utils/user/PermissionUtils'; -describe('Public dashboard links', () => { - const dashboardName = 'public-dashboard'; - const chartName = 'public-dashboard-chart'; +const dashboardName = 'public-dashboard'; +const chartName = 'public-dashboard-chart'; +const tableColumns = ['time', 'randombool', 'randomnumber', 'randomtext']; +describe('Public dashboard links', () => { beforeEach('Setup Test', () => { cy.initStreamPipesTest(); - ChartUtils.loadDataIntoDataLake('datalake/sample.csv'); + DataLakeSeedUtils.importCsvData({ + headers: ['timestamp', 'randombool', 'randomnumber', 'randomtext'], + rows: kioskTableRows(), + measurementName: ChartUtils.ADAPTER_NAME, + timestampColumn: 'timestamp', + columnOverrides: { + randomtext: { + propertyScope: 'DIMENSION_PROPERTY', + }, + }, + }); }); - it('allows anonymous users to view a dashboard with a chart', () => { - ChartUtils.addDataViewAndTableWidget(ChartUtils.ADAPTER_NAME); - ChartUtils.saveDataViewConfiguration(false, false, chartName); + it('allows logged-out users to view all table columns in kiosk mode', () => { + createPublicDashboardWithTableChart(); - ChartUtils.goToDashboard(); - ChartUtils.createAndEditDashboard(dashboardName); - ChartUtils.addDataViewToDashboard(chartName, true); - ChartUtils.saveDashboardConfiguration(); - - PermissionUtils.markElementAsAnonymousPublic(dashboardName); - PermissionUtils.validateAnonymousPublicLinkIsEnabled(dashboardName); - - Inspector.getDashboardIdByName(dashboardName).then(dashboardId => { - Inspector.openDashboardKioskAsAnonymous(dashboardId); - Inspector.validateDashboardKioskWithTableChart(dashboardName); + getDashboardId().then(dashboardId => { + cy.logout(); + cy.location('hash', { timeout: 10000 }).should('eq', '#/login'); + Inspector.openDashboardKioskAsLoggedOutUser(dashboardId); + Inspector.validateDashboardKioskWithTableChart( + dashboardName, + tableColumns, + ); }); }); }); + +function createPublicDashboardWithTableChart(): void { + ChartUtils.addDataViewAndTableWidget(ChartUtils.ADAPTER_NAME); + ChartUtils.saveDataViewConfiguration(false, false, chartName); + + ChartUtils.goToDashboard(); + ChartUtils.createAndEditDashboard(dashboardName); + ChartUtils.addDataViewToDashboard(chartName, true); + ChartUtils.saveDashboardConfiguration(); + + PermissionUtils.markElementAsAnonymousPublic(dashboardName); + PermissionUtils.validateAnonymousPublicLinkIsEnabled(dashboardName); +} + +function getDashboardId() { + return Inspector.getDashboardIdByName(dashboardName); +} + +function kioskTableRows(): string[][] { + const baseTimestamp = Date.now() - 60_000; + + return [ + [baseTimestamp.toString(), 'true', '62.0', 'c'], + [(baseTimestamp + 1_000).toString(), 'false', '46.0', 'a'], + [(baseTimestamp + 2_000).toString(), 'true', '41.0', 'b'], + ]; +}
