Skip to content

Commit a173799

Browse files
authored
Merge pull request #1261 from kravciak/slide-in-config
Update tests for slide-in config in rancher 2.12
2 parents e766db9 + 7049926 commit a173799

3 files changed

Lines changed: 22 additions & 8 deletions

File tree

tests/e2e/30-policyservers.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ test('Create with custom values', async({ page, ui, nav }) => {
8888
await psPage.create(ps, { wait: false })
8989

9090
await nav.pservers(ps.name)
91-
await ui.button('Config').click()
91+
await ui.showConfiguration()
9292
await expect(ui.input('Name*')).toHaveValue(ps.name)
9393
await expect(ui.input('Image URL')).toHaveValue(ps.image)
9494
await expect(ui.input('Replicas*')).toHaveValue(ps.replicas.toString())
95+
await ui.hideConfiguration()
9596

9697
await psPage.delete(ps.name)
9798
})

tests/e2e/40-policies.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async function checkPolicy(p: Policy, polPage: BasePolicyPage, ui: RancherUI) {
4848
})
4949

5050
await test.step(`Check config page: ${p.name}`, async() => {
51-
await ui.button('Config').click()
51+
await ui.showConfiguration()
5252
await expect(polPage.name).toHaveValue(p.name)
5353
if (p.title === 'Custom Policy') await expect(polPage.module).toHaveValue(module)
5454
await expect(polPage.mode(mode)).toBeChecked()
@@ -57,6 +57,7 @@ async function checkPolicy(p: Policy, polPage: BasePolicyPage, ui: RancherUI) {
5757
if (isAP(polPage)) {
5858
await expect(polPage.namespace).toContainText(namespace)
5959
}
60+
await ui.hideConfiguration()
6061
})
6162

6263
await test.step(`Check edit config: ${p.name}`, async() => {
@@ -230,9 +231,10 @@ test('Recommended policies', async({ page, ui, nav }) => {
230231

231232
const capPage = new ClusterAdmissionPoliciesPage(page)
232233
await nav.capolicies('no-privileged-pod')
233-
await ui.button('Config').click()
234+
await ui.showConfiguration()
234235
await capPage.selectTab('Settings')
235236
// await expect(ui.codeMirror).toContainText('skip_init_containers: true')
236237
await expect(ui.checkbox('Skip init containers')).toBeChecked()
238+
await ui.hideConfiguration()
237239
})
238240
})

tests/e2e/components/rancher-ui.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ export class RancherUI {
2424

2525
// Button
2626
button(name: string|RegExp) {
27-
return this.page.getByRole('button', { name, exact: true }).or(
28-
this.page.locator('a.btn').filter({ has: this.page.getByText(name, { exact: true }) })
29-
)
27+
return this.page.getByRole('button', { name, exact: true })
28+
.or(this.page.locator('a.btn,button', { has: this.page.getByText(name, { exact: true }) }))
3029
}
3130

3231
// Labeled Input
@@ -72,6 +71,18 @@ export class RancherUI {
7271
return base.getByRole('combobox', { name: 'Search for option' })
7372
}
7473

74+
// Slide-in drawer or old config
75+
async showConfiguration() {
76+
const configBtn = RancherUI.isVersion('>=2.12') ? 'Show Configuration' : 'Config'
77+
await this.button(configBtn).click()
78+
}
79+
80+
// Handling for second "Close" button on policy readme
81+
async hideConfiguration() {
82+
if (RancherUI.isVersion('>=2.12'))
83+
await this.button(/^Close.*Configuration drawer$/).last().click()
84+
}
85+
7586
// Select option from (un)labeled Select
7687
async selectOption(label: string|Locator, option: string | RegExp | number) {
7788
const select = (typeof label === 'string')
@@ -162,8 +173,8 @@ export class RancherUI {
162173
}
163174

164175
/**
165-
* Call await ui.retry(async()=> { <code> }, 'Reason')
166-
*/
176+
* Call await ui.retry(async()=> { <code> }, 'Reason')
177+
*/
167178
async retry(code: () => Promise<void>, message: string, options?: { reload?: boolean }) {
168179
const optReload = options?.reload || true
169180
try {

0 commit comments

Comments
 (0)