Skip to content

Commit

Permalink
Merge pull request #2310 from gouyang/update_selector
Browse files Browse the repository at this point in the history
update selectors for e2e tests
  • Loading branch information
openshift-merge-bot[bot] authored Dec 16, 2024
2 parents 6b5bc33 + 0ceb522 commit 48d3d80
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 99 deletions.
61 changes: 45 additions & 16 deletions cypress/tests/e2e/check-tab-yaml.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,56 @@ describe('Check all virtualization pages can be loaded', () => {
tab.navigateToDiagnostics();
cy.contains('Status conditions').should('be.visible');

tab.navigateToDiagnosticsGuestSystemLog();
cy.contains('Guest system logs').should('be.visible');

// sub-tabs in configuration tab
tab.navigateToConfiguration();
cy.contains('Headless mode').should('be.visible');

tab.navigateToStorage();
tab.navigateToConfigurationStorage();
cy.contains('rootdisk').should('be.visible');

tab.navigateToNetwork();
tab.navigateToConfigurationNetwork();
cy.contains('Pod networking').should('be.visible');

tab.navigateToScheduling();
tab.navigateToConfigurationScheduling();
cy.contains('Scheduling and resource requirements').should('be.visible');

tab.navigateToSSH();
tab.navigateToConfigurationSSH();
cy.contains('SSH access').should('be.visible');

tab.navigateToInitialRun();
tab.navigateToConfigurationInitialRun();
cy.contains('Cloud-init').should('be.visible');

tab.navigateToMetadata();
tab.navigateToConfigurationMetadata();
cy.contains('Annotations').should('be.visible');
});

it('vmi tabs are loaded', () => {
tab.navigateToOverview();
cy.contains('VirtualMachineInstance').should('be.visible');
cy.byLegacyTestID(Example).click();

cy.contains('Annotations').should('be.visible');

tab.navigateToYAML();
cy.contains('Download').should('be.visible');

tab.navigateToScheduling();
cy.contains('Tolerations').should('be.visible');

tab.navigateToEvents();
cy.contains('event').should('be.visible');

tab.navigateToConsole();
cy.contains('Guest login credentials').should('be.visible');

tab.navigateToNetworks();
cy.contains('Pod networking').should('be.visible');

tab.navigateToDisks();
cy.contains('rootdisk').should('be.visible');
});
});

Expand All @@ -106,19 +135,19 @@ describe('Check all virtualization pages can be loaded', () => {
tab.navigateToYAML();
cy.contains('Download').should('be.visible');

tab.navigateToTScheduling();
tab.navigateToScheduling();
cy.contains('Tolerations').should('be.visible');

tab.navigateToTNetworks();
tab.navigateToNetworks();
cy.contains('Pod networking').should('be.visible');

tab.navigateToTDisks();
tab.navigateToDisks();
cy.contains('rootdisk').should('be.visible');

tab.navigateToTScripts();
tab.navigateToScripts();
cy.contains('Cloud-init').should('be.visible');

tab.navigateToTParameters();
tab.navigateToParameters();
cy.contains('DATA_SOURCE_NAME').should('be.visible');
});

Expand All @@ -134,19 +163,19 @@ describe('Check all virtualization pages can be loaded', () => {
tab.navigateToYAML();
cy.contains('Download').should('be.visible');

tab.navigateToTScheduling();
tab.navigateToScheduling();
cy.contains('Tolerations').should('be.visible');

tab.navigateToTNetworks();
tab.navigateToNetworks();
cy.contains('Pod networking').should('be.visible');

tab.navigateToTDisks();
tab.navigateToDisks();
cy.contains('rootdisk').should('be.visible');

tab.navigateToTScripts();
tab.navigateToScripts();
cy.contains('Cloud-init').should('be.visible');

tab.navigateToTParameters();
tab.navigateToParameters();
cy.contains('CLOUD_USER_PASSWORD').should('be.visible');
});
});
Expand Down
188 changes: 105 additions & 83 deletions cypress/views/tab.ts
Original file line number Diff line number Diff line change
@@ -1,118 +1,140 @@
export enum vmTabs {
Configuration = 'horizontal-link-Configuration',
Console = 'horizontal-link-Console',
Diagnostics = 'horizontal-link-Diagnostics',
Disks = 'horizontal-link-Disks',
Environment = 'horizontal-link-Environment',
Events = 'horizontal-link-Events',
Metadata = 'horizontal-link-Metadata',
Metrics = 'horizontal-link-Metrics',
NetworkInterfaces = 'horizontal-link-Network interfaces',
Overview = 'horizontal-link-Overview',
Parameters = 'horizontal-link-Parameters',
Scheduling = 'horizontal-link-Scheduling',
Scripts = 'horizontal-link-Scripts',
Snapshots = 'horizontal-link-Snapshots',
YAML = 'horizontal-link-YAML',
export const configurationSubTab = (tabName: string) =>
`[data-test-id="vm-configuration-${tabName}"]`;
export const diagnosticsSubTab = (tabName: string) => `[data-test-id="vm-diagnostics-${tabName}"]`;
export const horizontalLink = (tabName: string) => `[data-test-id="horizontal-link-${tabName}"]`;

export enum tabName {
Configuration = 'Configuration',
Console = 'Console',
Diagnostics = 'Diagnostics',
Disks = 'Disks',
Environment = 'Environment',
Events = 'Events',
Metadata = 'Metadata',
Metrics = 'Metrics',
Migrations = 'Migrations',
NetworkInterfaces = 'Network interfaces',
Overview = 'Overview',
Parameters = 'Parameters',
Scheduling = 'Scheduling',
Scripts = 'Scripts',
Settings = 'Settings',
Snapshots = 'Snapshots',
TopConsumers = 'Top consumers',
YAML = 'YAML',
}

export enum overviewTabs {
Migrations = 'horizontal-link-Migrations',
Settings = 'horizontal-link-Settings',
// virt overview tabs
TopConsumers = 'horizontal-link-Top consumers',
export enum subTabName {
Details = 'details',
GuestSystemLog = 'guest-system-log',
InitialRun = 'initial',
Metadata = 'metadata',
Network = 'network',
Scheduling = 'scheduling',
SSH = 'ssh',
StatusConditions = 'status-conditions',
Storage = 'storage',
}

export const navigateToTab = (tab: string) => {
cy.byLegacyTestID(tab).should('be.visible');
cy.byLegacyTestID(tab).click();
export const navigateToTab = (name: string) => {
cy.get(horizontalLink(name)).should('be.visible');
cy.get(horizontalLink(name)).click();
};

export const navigateToConfigurationSubTab = (name: string) => {
navigateToTab(tabName.Configuration);
cy.get(configurationSubTab(name)).should('be.visible');
cy.get(configurationSubTab(name)).click();
};

export const navigateToDiagnosticsSubTab = (name: string) => {
navigateToTab(tabName.Diagnostics);
cy.get(diagnosticsSubTab(name)).should('be.visible');
cy.get(diagnosticsSubTab(name)).click();
};

export const tab = {
navigateToConfiguration: () => {
navigateToTab(vmTabs.Configuration);
},
navigateToConsole: () => {
navigateToTab(vmTabs.Console);
navigateToTab(tabName.Configuration);
},
// VM configuration sub-tabs
navigateToDetails: () => {
navigateToTab(vmTabs.Configuration);
cy.byButtonText('Details').click();
navigateToConfigurationDetails: () => {
navigateToConfigurationSubTab(subTabName.Details);
},
navigateToDiagnostics: () => {
navigateToTab(vmTabs.Diagnostics);
navigateToConfigurationInitialRun: () => {
navigateToConfigurationSubTab(subTabName.InitialRun);
},
navigateToEvents: () => {
navigateToTab(vmTabs.Events);
navigateToConfigurationMetadata: () => {
navigateToConfigurationSubTab(subTabName.Metadata);
},
navigateToInitialRun: () => {
navigateToTab(vmTabs.Configuration);
cy.byButtonText('Initial run').click();
navigateToConfigurationNetwork: () => {
navigateToConfigurationSubTab(subTabName.Network);
},
navigateToMetadata: () => {
navigateToTab(vmTabs.Configuration);
cy.byButtonText('Metadata').click();
navigateToConfigurationScheduling: () => {
navigateToConfigurationSubTab(subTabName.Scheduling);
},
navigateToMetrics: () => {
navigateToTab(vmTabs.Metrics);
navigateToConfigurationSSH: () => {
navigateToConfigurationSubTab(subTabName.SSH);
},
navigateToMigrations: () => {
navigateToTab(overviewTabs.Migrations);
navigateToConfigurationStorage: () => {
navigateToConfigurationSubTab(subTabName.Storage);
},
navigateToNetwork: () => {
navigateToTab(vmTabs.Configuration);
cy.contains('.pf-v5-c-tabs__item-text', 'Network').click();
navigateToConsole: () => {
navigateToTab(tabName.Console);
},
// VM tabs
navigateToOverview: () => {
navigateToTab(vmTabs.Overview);
navigateToDiagnostics: () => {
navigateToTab(tabName.Diagnostics);
},
navigateToScheduling: () => {
navigateToTab(vmTabs.Configuration);
cy.byButtonText('Scheduling').click();
// VM diagnostics sub-tabs
navigateToDiagnosticsGuestSystemLog: () => {
navigateToDiagnosticsSubTab(subTabName.GuestSystemLog);
},
navigateToSettings: () => {
navigateToTab(overviewTabs.Settings);
navigateToDiagnosticsStatusConditions: () => {
navigateToDiagnosticsSubTab(subTabName.StatusConditions);
},
navigateToSnapshots: () => {
navigateToTab(vmTabs.Snapshots);
navigateToDisks: () => {
navigateToTab(tabName.Disks);
},
navigateToSSH: () => {
navigateToTab(vmTabs.Configuration);
cy.byButtonText('SSH').click();
navigateToEnvironment: () => {
navigateToTab(tabName.Environment);
},
navigateToStorage: () => {
navigateToTab(vmTabs.Configuration);
cy.contains('.pf-v5-c-tabs__item-text', 'Storage').click();
navigateToEvents: () => {
navigateToTab(tabName.Events);
},
// template's tabs and vm creation tabs
navigateToTDisks: () => {
navigateToTab(vmTabs.Disks);
navigateToMetadata: () => {
navigateToTab(tabName.Metadata);
},
navigateToTEnvironment: () => {
navigateToTab(vmTabs.Environment);
navigateToMetrics: () => {
navigateToTab(tabName.Metrics);
},
navigateToTMetadata: () => {
navigateToTab(vmTabs.Metadata);
navigateToMigrations: () => {
navigateToTab(tabName.Migrations);
},
navigateToTNetworks: () => {
navigateToTab(vmTabs.NetworkInterfaces);
navigateToNetworks: () => {
navigateToTab(tabName.NetworkInterfaces);
},
// virt overview tabs
navigateToTopConsumers: () => {
navigateToTab(overviewTabs.TopConsumers);
navigateToOverview: () => {
navigateToTab(tabName.Overview);
},
navigateToTParameters: () => {
navigateToTab(vmTabs.Parameters);
navigateToParameters: () => {
navigateToTab(tabName.Parameters);
},
navigateToTScheduling: () => {
navigateToTab(vmTabs.Scheduling);
navigateToScheduling: () => {
navigateToTab(tabName.Scheduling);
},
navigateToScripts: () => {
navigateToTab(tabName.Scripts);
},
navigateToSettings: () => {
navigateToTab(tabName.Settings);
},
navigateToTScripts: () => {
navigateToTab(vmTabs.Scripts);
navigateToSnapshots: () => {
navigateToTab(tabName.Snapshots);
},
navigateToTopConsumers: () => {
navigateToTab(tabName.TopConsumers);
},
navigateToYAML: () => {
navigateToTab(vmTabs.YAML);
navigateToTab(tabName.YAML);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const CustomizeInstanceTypeConfigurationTab: FC = () => {
{tabs.map(({ Component, name, title }) => (
<Tab
className="ConfigurationTab--content"
data-test-id={`vm-configuration-${name}`}
eventKey={name}
key={name}
onClick={() => redirectTab(name)}
Expand Down

0 comments on commit 48d3d80

Please sign in to comment.