Skip to content

Commit

Permalink
fix more tests
Browse files Browse the repository at this point in the history
Signed-off-by: Anan Zhuang <[email protected]>
  • Loading branch information
ananzh committed Aug 22, 2024
1 parent 4874f47 commit 498376f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ class TableListView extends React.Component<TableListViewProps, TableListViewSta
type: 'icon',
enabled: ({ error }: { error: string }) => !error,
onClick: this.props.editItem,
'data-test-subj': 'edit-dashboard-action',
},
];

Expand Down
45 changes: 40 additions & 5 deletions test/functional/apps/visualize/_custom_branding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(actualLabel.toUpperCase()).to.equal(expectedMarkLogo.toUpperCase());
});

it('with customized logo for opensearch overview header in dark mode', async () => {
it('if enable user control, admin customized dark mode logo for opensearch overview header is not applied', async () => {
await PageObjects.common.navigateToApp('management/opensearch-dashboards/settings');
await PageObjects.settings.toggleAdvancedSettingCheckbox('theme:enableUserControl');
const button = await testSubjects.find('advancedSetting-editField-theme:darkMode');
const isDisabled = (await button.getAttribute('disabled')) !== null;
expect(isDisabled).equal(true);
await PageObjects.common.navigateToApp('opensearch_dashboards_overview');
await testSubjects.existOrFail('osdOverviewPageHeaderLogo');
const actualLabel = await testSubjects.getAttribute(
'osdOverviewPageHeaderLogo',
'data-test-logo'
);
expect(actualLabel.toUpperCase()).to.equal(expectedMarkLogo.toUpperCase());
await PageObjects.common.navigateToApp('management/opensearch-dashboards/settings');
await PageObjects.settings.clearAdvancedSettings('theme:enableUserControl');
});

it('admin customized dark mode logo for opensearch overview header is applied', async () => {
await PageObjects.common.navigateToApp('management/opensearch-dashboards/settings');
await PageObjects.settings.toggleAdvancedSettingCheckbox('theme:darkMode');
await PageObjects.common.navigateToApp('opensearch_dashboards_overview');
await testSubjects.existOrFail('osdOverviewPageHeaderLogo');
Expand All @@ -56,6 +72,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
'data-test-logo'
);
expect(actualLabel.toUpperCase()).to.equal(expectedMarkLogoDarkMode.toUpperCase());
await PageObjects.common.navigateToApp('management/opensearch-dashboards/settings');
await PageObjects.settings.clearAdvancedSettings('theme:darkMode');
});
});

Expand Down Expand Up @@ -100,9 +118,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(actualLabel.toUpperCase()).to.equal(expectedWelcomeMessage.toUpperCase());
});

it('with customized logo in dark mode', async () => {
it('admin customized dark mode logo for home is applied', async () => {
await PageObjects.common.navigateToApp('management/opensearch-dashboards/settings');
await PageObjects.settings.toggleAdvancedSettingCheckbox('theme:enableUserControl');
await PageObjects.settings.toggleAdvancedSettingCheckbox('theme:darkMode');
await PageObjects.common.navigateToApp('home');
await testSubjects.existOrFail('welcomeCustomLogo');
Expand All @@ -111,6 +128,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
'data-test-image-url'
);
expect(actualLabel.toUpperCase()).to.equal(expectedMarkLogoDarkMode.toUpperCase());
await PageObjects.common.navigateToApp('management/opensearch-dashboards/settings');
await PageObjects.settings.clearAdvancedSettings('theme:darkMode');
});

it('if enable user control, admin customized dark mode logo for home is not applied', async () => {
await PageObjects.common.navigateToApp('management/opensearch-dashboards/settings');
await PageObjects.settings.toggleAdvancedSettingCheckbox('theme:enableUserControl');
const button = await testSubjects.find('advancedSetting-editField-theme:darkMode');
const isDisabled = (await button.getAttribute('disabled')) !== null;
expect(isDisabled).equal(true);
await PageObjects.common.navigateToApp('home');
await testSubjects.existOrFail('welcomeCustomLogo');
const actualLabel = await testSubjects.getAttribute(
'welcomeCustomLogo',
'data-test-image-url'
);
expect(actualLabel.toUpperCase()).to.equal(expectedMarkLogo.toUpperCase());
await PageObjects.common.navigateToApp('management/opensearch-dashboards/settings');
await PageObjects.settings.clearAdvancedSettings('theme:enableUserControl');
});
});

Expand Down Expand Up @@ -180,10 +216,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
});

describe('in dark mode', async () => {
describe('OpenSearch Dashboards branding configuration in dark mode', async () => {
before(async function () {
await PageObjects.common.navigateToApp('management/opensearch-dashboards/settings');
await PageObjects.settings.toggleAdvancedSettingCheckbox('theme:enableUserControl');
await PageObjects.settings.toggleAdvancedSettingCheckbox('theme:darkMode');
await PageObjects.common.navigateToApp('home');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export default function ({ getService, getPageObjects }) {

it('should be able to navigate to edit dashboard', async () => {
await listingTable.searchForItemWithName(dashboardName);
const editBttn = await find.allByCssSelector('.euiToolTipAnchor');
await editBttn[3].click();
const editBttn = await testSubjects.find('edit-dashboard-action');
await editBttn.click();
await PageObjects.dashboard.clickCancelOutOfEditMode();
await PageObjects.dashboard.gotoDashboardLandingPage();
});
Expand Down

0 comments on commit 498376f

Please sign in to comment.