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 20, 2024
1 parent 4874f47 commit c9a89a3
Showing 1 changed file with 108 additions and 6 deletions.
114 changes: 108 additions & 6 deletions test/functional/apps/visualize/_custom_branding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ 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('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:enableUserControl');
await PageObjects.settings.toggleAdvancedSettingCheckbox('theme:darkMode');
await PageObjects.common.navigateToApp('opensearch_dashboards_overview');
await testSubjects.existOrFail('osdOverviewPageHeaderLogo');
Expand All @@ -57,6 +56,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
);
expect(actualLabel.toUpperCase()).to.equal(expectedMarkLogoDarkMode.toUpperCase());
});

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());
});
});

describe('should render welcome page', async () => {
Expand Down Expand Up @@ -100,9 +114,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 @@ -112,6 +125,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
);
expect(actualLabel.toUpperCase()).to.equal(expectedMarkLogoDarkMode.toUpperCase());
});

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());
});
});

describe('should render home page', async () => {
Expand Down Expand Up @@ -180,10 +208,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 Expand Up @@ -236,6 +263,81 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(actualLabel.toUpperCase()).to.equal(expectedMarkLogoDarkMode.toUpperCase());
});
});

describe('OpenSearch Dashboards branding with user theme control enabled', async () => {
before(async function () {
await PageObjects.common.navigateToApp('management/opensearch-dashboards/settings');
await PageObjects.settings.toggleAdvancedSettingCheckbox('theme:enableUserControl');
await PageObjects.common.navigateToApp('home');
});

after(async function () {
await PageObjects.common.navigateToApp('management/opensearch-dashboards/settings');
await PageObjects.settings.clearAdvancedSettings('theme:enableUserControl');
});

it('should disable admin dark mode control when user control is enabled', async () => {
await PageObjects.common.navigateToApp('management/opensearch-dashboards/settings');
const darkModeButton = await testSubjects.find(
'advancedSetting-editField-theme:darkMode'
);
const isDisabled = (await darkModeButton.getAttribute('disabled')) !== null;
expect(isDisabled).to.be(true);
});

it('should display default full logo in header bar', async () => {
await globalNav.logoExistsOrFail(expectedFullLogo);
});

it('should display default mark logo button in header bar', async () => {
await globalNav.homeMarkExistsOrFail(expectedMarkLogo);
});

it('should display default mark logo in home dashboard card', async () => {
await testSubjects.existOrFail('dashboardCustomLogo');
const actualLabel = await testSubjects.getAttribute(
'dashboardCustomLogo',
'data-test-image-url'
);
expect(actualLabel.toUpperCase()).to.equal(expectedMarkLogo.toUpperCase());
});

it('should display default mark logo for OpenSearch in side menu', async () => {
await appsMenu.openCollapsibleNav();
await testSubjects.existOrFail('collapsibleNavGroup-opensearchDashboards');
const actualLabel = await testSubjects.getAttribute(
'collapsibleNavGroup-opensearchDashboards',
'data-test-opensearch-logo'
);
expect(actualLabel.toUpperCase()).to.equal(expectedMarkLogo.toUpperCase());
});

it('should navigate to home page when clicking the logo', async () => {
await PageObjects.common.navigateToApp('settings');
await globalNav.clickLogo();
await PageObjects.header.waitUntilLoadingHasFinished();
const url = await browser.getCurrentUrl();
expect(url.includes('/app/home')).to.be(true);
});

it('should navigate to home page when clicking the mark logo button', async () => {
await PageObjects.common.navigateToApp('settings');
await globalNav.clickHomeButton();
await PageObjects.header.waitUntilLoadingHasFinished();
const url = await browser.getCurrentUrl();
expect(url.includes('/app/home')).to.be(true);
});

it('should display default logo in OpenSearch Dashboards overview page', async () => {
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());
});
});
});
});
}

0 comments on commit c9a89a3

Please sign in to comment.