Skip to content

Commit af6f753

Browse files
authoredJan 6, 2025
Improve workspace import sample data tests (#1671)
* Improve workspace import sample data tests Signed-off-by: Lin Wang <wonglam@amazon.com> * Fix artifact upload failed for bundle snapshot Signed-off-by: Lin Wang <wonglam@amazon.com> --------- Signed-off-by: Lin Wang <wonglam@amazon.com>
1 parent d42d288 commit af6f753

File tree

2 files changed

+90
-109
lines changed

2 files changed

+90
-109
lines changed
 

‎.github/workflows/cypress-workflow-bundle-snapshot-based.yml

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
test-name: Core Dashboards using Bundle Snapshot
2121
test-command: env CYPRESS_NO_COMMAND_LOG=1 CYPRESS_ML_COMMONS_DASHBOARDS_ENABLED=true CYPRESS_VISBUILDER_ENABLED=true CYPRESS_UIMETRIC_ENABLED=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=true yarn cypress:run-with-security --browser chromium --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/**/*.js'
2222
osd-serve-args: --data_source.enabled=true --data_source.ssl.verificationMode=none --vis_builder.enabled=true --ml_commons_dashboards.enabled=true --usageCollection.uiMetric.enabled=true
23+
artifact-name-suffix: '-with-security'
2324

2425
tests-without-security:
2526
uses: ./.github/workflows/release-e2e-workflow-template.yml
@@ -28,3 +29,4 @@ jobs:
2829
test-command: env CYPRESS_NO_COMMAND_LOG=1 CYPRESS_ML_COMMONS_DASHBOARDS_ENABLED=true CYPRESS_VISBUILDER_ENABLED=true CYPRESS_UIMETRIC_ENABLED=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=true yarn cypress:run-without-security --browser chromium --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/**/*.js'
2930
osd-serve-args: --data_source.enabled=true --data_source.ssl.verificationMode=none --vis_builder.enabled=true --ml_commons_dashboards.enabled=true --usageCollection.uiMetric.enabled=true
3031
security-enabled: false
32+
artifact-name-suffix: '-without-security'

‎cypress/utils/dashboards/workspace-plugin/test-cases/mds_workspace_import_sample_data_to.cases.js

+88-109
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const MDSEnabled = Cypress.env('DATASOURCE_MANAGEMENT_ENABLED');
77

88
export const WorkspaceImportSampleDataTestCases = () => {
99
if (Cypress.env('WORKSPACE_ENABLED')) {
10-
describe('import sample data to workspace', () => {
10+
describe('workspace import sample data', () => {
1111
let workspaceId;
1212
let dataSourceId;
1313
let dataSourceTitle;
@@ -58,117 +58,96 @@ export const WorkspaceImportSampleDataTestCases = () => {
5858
}
5959
});
6060

61-
beforeEach(() => {
62-
cy.visit(`/w/${workspaceId}/app/import_sample_data`);
63-
if (MDSEnabled) {
64-
cy.selectTopRightNavigationDataSource(dataSourceTitle, dataSourceId);
65-
}
66-
});
67-
68-
it('should show Add data buttons if sample data not installed', () => {
69-
cy.getElementByTestId('addSampleDataSetecommerce').should('be.visible');
70-
cy.getElementByTestId('addSampleDataSetflights').should('be.visible');
71-
cy.getElementByTestId('addSampleDataSetlogs').should('be.visible');
72-
});
73-
74-
it('should show remove buttons after sample data installed', () => {
75-
cy.getElementByTestId('addSampleDataSetecommerce').click();
76-
cy.getElementByTestId('addSampleDataSetflights').click();
77-
cy.getElementByTestId('addSampleDataSetlogs').click();
78-
79-
cy.getElementByTestId('removeSampleDataSetecommerce').should(
80-
'be.visible'
81-
);
82-
cy.getElementByTestId('removeSampleDataSetflights').should(
83-
'be.visible'
84-
);
85-
cy.getElementByTestId('removeSampleDataSetlogs').should('be.visible');
86-
87-
cy.getElementByTestId('removeSampleDataSetecommerce').click();
88-
cy.getElementByTestId('removeSampleDataSetflights').click();
89-
cy.getElementByTestId('removeSampleDataSetlogs').click();
61+
describe('add and remove buttons', () => {
62+
beforeEach(() => {
63+
cy.visit(`/w/${workspaceId}/app/import_sample_data`);
64+
if (MDSEnabled) {
65+
cy.selectTopRightNavigationDataSource(
66+
dataSourceTitle,
67+
dataSourceId
68+
);
69+
}
70+
});
71+
72+
it('should show Add data buttons if sample data not installed', () => {
73+
cy.getElementByTestId('addSampleDataSetecommerce').should(
74+
'be.visible'
75+
);
76+
cy.getElementByTestId('addSampleDataSetflights').should('be.visible');
77+
cy.getElementByTestId('addSampleDataSetlogs').should('be.visible');
78+
});
79+
80+
it('should show remove buttons after sample data installed', () => {
81+
cy.intercept(
82+
{
83+
pathname: '/w/**/api/sample_data/**',
84+
times: 3,
85+
},
86+
{
87+
statusCode: 200,
88+
}
89+
).as('importSampleData');
90+
cy.getElementByTestId('addSampleDataSetecommerce').click();
91+
cy.wait('@importSampleData')
92+
.its('request.url')
93+
.should('include', 'ecommerce');
94+
95+
cy.getElementByTestId('addSampleDataSetflights').click();
96+
cy.wait('@importSampleData')
97+
.its('request.url')
98+
.should('include', 'flights');
99+
100+
cy.getElementByTestId('addSampleDataSetlogs').click();
101+
cy.wait('@importSampleData')
102+
.its('request.url')
103+
.should('include', 'logs');
104+
105+
cy.getElementByTestId('removeSampleDataSetecommerce').should(
106+
'be.visible'
107+
);
108+
cy.getElementByTestId('removeSampleDataSetflights').should(
109+
'be.visible'
110+
);
111+
cy.getElementByTestId('removeSampleDataSetlogs').should('be.visible');
112+
});
90113
});
91114

92115
it('should be able to visit ecommerce dashboard', () => {
93-
cy.getElementByTestId('addSampleDataSetecommerce').click();
94-
95-
cy.getElementByTestId('launchSampleDataSetecommerce')
96-
.should('be.visible')
97-
.click();
98-
99-
cy.location('href').should(
100-
'include',
101-
`/w/${workspaceId}/app/dashboards`
102-
);
103-
cy.getElementByTestId('headerAppActionMenu').should(
104-
'contain',
105-
getTitleWithDataSource('[eCommerce] Revenue Dashboard')
106-
);
107-
cy.get(
108-
`[data-title="${getTitleWithDataSource(
109-
'[eCommerce] Total Revenue'
110-
)}"]`
111-
).should('not.contain', 'No results found');
112-
cy.visit(`/w/${workspaceId}/app/import_sample_data`);
113-
114-
if (MDSEnabled) {
115-
cy.selectTopRightNavigationDataSource(dataSourceTitle, dataSourceId);
116-
}
117-
cy.getElementByTestId('removeSampleDataSetecommerce').click();
118-
});
119-
120-
it('should be able to visit flights dashboards', () => {
121-
cy.getElementByTestId('addSampleDataSetflights').click();
122-
123-
cy.getElementByTestId('launchSampleDataSetflights')
124-
.should('be.visible')
125-
.click();
126-
127-
cy.location('href').should(
128-
'include',
129-
`/w/${workspaceId}/app/dashboards`
130-
);
131-
cy.getElementByTestId('headerAppActionMenu').should(
132-
'contain',
133-
getTitleWithDataSource('[Flights] Global Flight Dashboard')
134-
);
135-
cy.get(
136-
`[data-title="${getTitleWithDataSource('[Flights] Flight Delays')}"]`
137-
).should('not.contain', 'No results found');
138-
cy.visit(`/w/${workspaceId}/app/import_sample_data`);
139-
140-
if (MDSEnabled) {
141-
cy.selectTopRightNavigationDataSource(dataSourceTitle, dataSourceId);
142-
}
143-
cy.getElementByTestId('removeSampleDataSetflights').click();
144-
});
145-
146-
it('should be able to visit logs dashboards', () => {
147-
cy.getElementByTestId('addSampleDataSetlogs').click();
148-
149-
cy.getElementByTestId('launchSampleDataSetlogs')
150-
.should('be.visible')
151-
.click();
152-
153-
cy.location('href').should(
154-
'include',
155-
`/w/${workspaceId}/app/dashboards`
156-
);
157-
cy.getElementByTestId('headerAppActionMenu').should(
158-
'contain',
159-
getTitleWithDataSource('[Logs] Web Traffic')
160-
);
161-
cy.get(
162-
`[data-title="${getTitleWithDataSource(
163-
'[Logs] Unique Visitors vs. Average Bytes'
164-
)}"]`
165-
).should('not.contain', 'No results found');
166-
cy.visit(`/w/${workspaceId}/app/import_sample_data`);
167-
168-
if (MDSEnabled) {
169-
cy.selectTopRightNavigationDataSource(dataSourceTitle, dataSourceId);
170-
}
171-
cy.getElementByTestId('removeSampleDataSetlogs').click();
116+
cy.loadSampleDataForWorkspace('ecommerce', workspaceId, dataSourceId)
117+
.then(() => {
118+
cy.visit(`/w/${workspaceId}/app/import_sample_data`);
119+
if (MDSEnabled) {
120+
cy.selectTopRightNavigationDataSource(
121+
dataSourceTitle,
122+
dataSourceId
123+
);
124+
}
125+
126+
cy.getElementByTestId('launchSampleDataSetecommerce')
127+
.should('be.visible')
128+
.click();
129+
130+
cy.location('href').should(
131+
'include',
132+
`/w/${workspaceId}/app/dashboards`
133+
);
134+
cy.getElementByTestId('headerAppActionMenu').should(
135+
'contain',
136+
getTitleWithDataSource('[eCommerce] Revenue Dashboard')
137+
);
138+
cy.get(
139+
`[data-title="${getTitleWithDataSource(
140+
'[eCommerce] Total Revenue'
141+
)}"]`
142+
).should('not.contain', 'No results found');
143+
})
144+
.then(() => {
145+
cy.removeSampleDataForWorkspace(
146+
'ecommerce',
147+
workspaceId,
148+
dataSourceId
149+
);
150+
});
172151
});
173152
});
174153
}

0 commit comments

Comments
 (0)