Repository navigation
fix(home): refresh recent activity after dashboard/chart delete #45589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
rusackas
wants to merge
13
commits into
master
Choose a base branch
from
fix/39528-home-recent-activity-refresh
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
db73980
fix(home): refresh recent activity after dashboard/chart delete
guptapuja 0966566
fix(home): forward config param in handleRefreshData
guptapuja ccc3f31
style: apply pre-commit autofixes (prettier, trailing whitespace)
rusackas 5622722
fix(home): guard delete-triggered activity refresh against stale data
rusackas 450b3df
fix(home): wrap getData in ChartTable so delete refresh covers all tabs
rusackas 8c1c703
chore: credit original author for home recent-activity refresh fix
rusackas 7e1fb07
fix(home): keep collapse/tab state on refresh, refresh Edited list, t…
rusackas 9eb39c2
test(home): cover delete-triggered recents refresh and stale-response…
rusackas b63264c
test(home): cover Mine-tab delete refresh, Edited refetch and collaps…
rusackas 0759172
Merge branch 'master' into fix/39528-home-recent-activity-refresh
rusackas c5204cd
test(home): cover stale-refresh rejection and editable-object orderin…
rusackas eaa66c2
test(home): drain refresh work by event-loop turns, fix store cast an…
rusackas 26e5340
test(home): add Playwright E2E coverage for Recents refresh after delete
rusackas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
203 changes: 203 additions & 0 deletions
203
superset-frontend/playwright/tests/home/recent-activity-refresh.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,203 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| /** | ||
| * Regression coverage for the Home page's "Recents" panel after a | ||
| * dashboard/chart is deleted from the Dashboards or Charts card list. | ||
| * | ||
| * Before this fix, deleting an item from some tabs (notably Mine) could | ||
| * leave its stale "Viewed" entry sitting in Recents after the delete had | ||
| * already succeeded, which reads as if the delete silently failed. Each | ||
| * test here creates a throwaway dashboard/chart, views it to seed a real | ||
| * Recents entry, deletes it from a specific tab, and asserts the Recents | ||
| * entry disappears promptly rather than polling/sleeping for a fixed | ||
| * window -- a regression that reintroduces staleness should fail here | ||
| * instead of flaking. | ||
| */ | ||
| import { testWithAssets, expect } from '../../helpers/fixtures'; | ||
| import { apiPostDashboard } from '../../helpers/api/dashboard'; | ||
| import { apiPostChart } from '../../helpers/api/chart'; | ||
| import { getDatasetByName } from '../../helpers/api/dataset'; | ||
| import { apiPost } from '../../helpers/api/requests'; | ||
| import { DashboardPage } from '../../pages/DashboardPage'; | ||
| import { ExplorePage } from '../../pages/ExplorePage'; | ||
| import { HomePage, HomeListTab } from '../../pages/HomePage'; | ||
| import { Toast } from '../../components/core'; | ||
| import { TIMEOUT } from '../../utils/constants'; | ||
|
|
||
| // Uncomment to force video recording when running this file locally (e.g. to | ||
| // produce a demo recording). CI relies on the 'retain-on-failure' policy in | ||
| // playwright.config.ts instead, so this stays off for the contributed test. | ||
| // testWithAssets.use({ video: 'on' }); | ||
|
|
||
| const DATASET_NAME = 'birth_names'; | ||
|
|
||
| /** Short, readable, still worker-unique: no epoch timestamps in the title. */ | ||
| function assetName(prefix: string, testInfo: { parallelIndex: number }) { | ||
| return `${prefix}_${testInfo.parallelIndex}`; | ||
| } | ||
|
|
||
| for (const tab of ['Favorite', 'Mine', 'All'] as HomeListTab[]) { | ||
| testWithAssets( | ||
| `deleting a dashboard from the ${tab} tab refreshes Recents`, | ||
| async ({ page, testAssets }, testInfo) => { | ||
| const name = assetName(`PR_Dash_${tab}`, testInfo); | ||
|
|
||
| const createResp = await apiPostDashboard(page, { | ||
| dashboard_title: name, | ||
| }); | ||
| expect(createResp.ok()).toBe(true); | ||
| const { id: dashboardId } = await createResp.json(); | ||
| testAssets.trackDashboard(dashboardId); | ||
|
|
||
| if (tab === 'Favorite') { | ||
| const favResp = await apiPost( | ||
| page, | ||
| `api/v1/dashboard/${dashboardId}/favorites/`, | ||
| ); | ||
| expect(favResp.ok()).toBe(true); | ||
| } | ||
|
|
||
| // View it so a "mount_dashboard" log entry seeds a real Recents card. | ||
| // Logging is debounced client-side (loggerMiddleware batches events up | ||
| // to 1s before sending), so wait for the actual beacon request rather | ||
| // than assuming it has landed once the page itself has loaded. | ||
| const dashboardPage = new DashboardPage(page); | ||
| const logRequest = page.waitForResponse( | ||
| resp => | ||
| resp.request().method() === 'POST' && | ||
| resp.url().includes('/log/') && | ||
| (resp.request().postData() ?? '').includes('mount_dashboard'), | ||
| { timeout: TIMEOUT.API_RESPONSE }, | ||
| ); | ||
| await dashboardPage.gotoById(dashboardId); | ||
| await dashboardPage.waitForLoad(); | ||
| await logRequest; | ||
|
|
||
| const homePage = new HomePage(page); | ||
| await homePage.goto(); | ||
| await homePage.expandRecents(); | ||
|
|
||
| await expect(async () => { | ||
| expect(await homePage.getRecentsViewedCount(name)).toBeGreaterThan(0); | ||
| }).toPass({ timeout: TIMEOUT.API_RESPONSE }); | ||
|
|
||
| await homePage.switchTab('Dashboards', tab); | ||
| await expect(homePage.getCard('Dashboards', name)).toBeVisible(); | ||
|
|
||
| await homePage.deleteCardViaMenu( | ||
| 'Dashboards', | ||
| name, | ||
| 'dashboard-card-menu', | ||
| 'dashboard-card-option-delete-button', | ||
| ); | ||
|
|
||
| const toast = new Toast(page); | ||
| await expect(toast.getSuccess()).toBeVisible(); | ||
|
|
||
| await expect(homePage.getCard('Dashboards', name)).toHaveCount(0); | ||
| await expect(async () => { | ||
| expect(await homePage.getRecentsViewedCount(name)).toBe(0); | ||
| }).toPass({ timeout: TIMEOUT.API_RESPONSE }); | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| for (const tab of ['Favorite', 'Mine', 'All'] as HomeListTab[]) { | ||
| testWithAssets( | ||
| `deleting a chart from the ${tab} tab refreshes Recents`, | ||
| async ({ page, testAssets }, testInfo) => { | ||
| testWithAssets.setTimeout(TIMEOUT.SLOW_TEST); | ||
| const name = assetName(`PR_Chart_${tab}`, testInfo); | ||
|
|
||
| const dataset = await getDatasetByName(page, DATASET_NAME); | ||
| if (!dataset) { | ||
| throw new Error(`Dataset ${DATASET_NAME} not found`); | ||
| } | ||
|
|
||
| const createResp = await apiPostChart(page, { | ||
| slice_name: name, | ||
| viz_type: 'table', | ||
| datasource_id: dataset.id, | ||
| datasource_type: 'table', | ||
| params: JSON.stringify({ | ||
| viz_type: 'table', | ||
| datasource: `${dataset.id}__table`, | ||
| query_mode: 'aggregate', | ||
| groupby: ['name'], | ||
| metrics: ['count'], | ||
| adhoc_filters: [], | ||
| row_limit: 5, | ||
| }), | ||
| }); | ||
| expect(createResp.ok()).toBe(true); | ||
| const chartBody = await createResp.json(); | ||
| const chartId: number = chartBody.result?.id ?? chartBody.id; | ||
| testAssets.trackChart(chartId); | ||
|
|
||
| if (tab === 'Favorite') { | ||
| const favResp = await apiPost( | ||
| page, | ||
| `api/v1/chart/${chartId}/favorites/`, | ||
| ); | ||
| expect(favResp.ok()).toBe(true); | ||
| } | ||
|
|
||
| // View it in Explore so a "mount_explorer" log entry seeds a real | ||
| // Recents card. See the dashboard test above for why this waits for | ||
| // the actual (debounced) log beacon rather than just the page load. | ||
| const explorePage = new ExplorePage(page); | ||
| const logRequest = page.waitForResponse( | ||
| resp => | ||
| resp.request().method() === 'POST' && | ||
| resp.url().includes('/log/') && | ||
| (resp.request().postData() ?? '').includes('mount_explorer'), | ||
| { timeout: TIMEOUT.API_RESPONSE }, | ||
| ); | ||
| await explorePage.goto(chartId); | ||
| await logRequest; | ||
|
|
||
| const homePage = new HomePage(page); | ||
| await homePage.goto(); | ||
| await homePage.expandRecents(); | ||
|
|
||
| await expect(async () => { | ||
| expect(await homePage.getRecentsViewedCount(name)).toBeGreaterThan(0); | ||
| }).toPass({ timeout: TIMEOUT.API_RESPONSE }); | ||
|
|
||
| await homePage.switchTab('Charts', tab); | ||
| await expect(homePage.getCard('Charts', name)).toBeVisible(); | ||
|
|
||
| await homePage.deleteCardViaMenu( | ||
| 'Charts', | ||
| name, | ||
| 'chart-card-menu', | ||
| 'chart-list-delete-option', | ||
| ); | ||
|
|
||
| const toast = new Toast(page); | ||
| await expect(toast.getSuccess()).toBeVisible(); | ||
|
|
||
| await expect(homePage.getCard('Charts', name)).toHaveCount(0); | ||
| await expect(async () => { | ||
| expect(await homePage.getRecentsViewedCount(name)).toBe(0); | ||
| }).toPass({ timeout: TIMEOUT.API_RESPONSE }); | ||
| }, | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.