Skip to content

Commit 49210f7

Browse files
committed
chore(test): fetch elements using test IDs
On-behalf-of: @SAP [email protected] Signed-off-by: Angel Kafazov <[email protected]>
1 parent 77f0363 commit 49210f7

File tree

1 file changed

+16
-26
lines changed

1 file changed

+16
-26
lines changed

local-setup/e2e/test-register-and-navigate.test.ts

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ async function ensurePortalHome(page: Page) {
8080

8181
test.describe('Home Page', () => {
8282

83+
test.setTimeout(2*60*1000); // 2 minutes test timeout
84+
8385
test('Register and navigate to portal', async ({ page }) => {
8486
await page.goto(portalBaseUrl);
8587

@@ -94,16 +96,14 @@ test.describe('Home Page', () => {
9496

9597
await newPage.screenshot({ path: 'screenshot-beforeswitch.png' });
9698

97-
await newPage.pause(); // for debugging
9899
// onboard 'default' organization and switch to it
99-
await newPage.getByRole('textbox', { name: 'Onboard a new organization' }).fill(newOrgName);
100-
await newPage.getByRole('button', { name: 'Onboard' }).click();
100+
await newPage.locator('[test-id="organization-management-input"]').locator('input').fill(newOrgName);
101+
await newPage.locator('[test-id="organization-management-onboard-button"]').locator('button').click();
101102

102-
await newPage.pause(); // for debugging
103103

104104
// Wait for the "Switch" button (role-based to pierce shadow DOM), and in parallel open Mailpit link
105105
let welcomePage: Page;
106-
const switchButton = newPage.getByRole('button', { name: /Switch/i });
106+
const switchButton = await newPage.locator('[test-id="organization-management-switch-button"]').locator('button')
107107

108108
const [_, wp] = await Promise.all([
109109
switchButton.waitFor({ state: 'visible', timeout: 100000 }),
@@ -136,36 +136,26 @@ test.describe('Home Page', () => {
136136
// Be explicit: make sure we’re on the portal origin and the SPA has rendered
137137
await ensurePortalHome(newPage2);
138138

139-
await newPage2.getByText('Accounts').click();
139+
await newPage2.locator('[data-testid="accounts_accounts"]').click(); // data-testid="accounts_accounts"
140140
// click on "Create" button
141-
await newPage2.getByRole('button', { name: 'Create' }).click();
142-
143-
// await page2.pause();
141+
await newPage2.locator('[test-id="generic-list-view-create-button"]').click(); // generic-list-view-create-button
144142

145-
await newPage2.locator('.ui5-select-icon > .ui5-icon-root').click();
146-
await newPage2.locator('#ui5wc_10-content > .ui5-li-text-wrapper').click();
147-
await newPage2.locator('#inner').nth(1).click();
148-
await newPage2.locator('ui5-input').filter({ hasText: '<svg xmlns="http://www.w3.org' }).locator('#inner').click();
149-
await newPage2.locator('ui5-input').filter({ hasText: '<svg xmlns="http://www.w3.org' }).locator('#inner').click();
150-
await newPage2.locator('ui5-input').filter({ hasText: '<svg xmlns="http://www.w3.org' }).locator('#inner').press('Shift+Home');
151-
await newPage2.locator('ui5-input').filter({ hasText: '<svg xmlns="http://www.w3.org' }).locator('#inner').fill(testAccountName);
152-
await newPage2.getByRole('button', { name: 'Submit' }).click();
143+
await newPage2.pause();
144+
145+
await newPage2.locator('[test-id="create-field-metadata_name"]').click();
146+
await newPage2.locator('[test-id="create-field-spec_type"]').click();
147+
await newPage2.locator('[test-id="create-field-spec_type-option-account"]').click();
148+
await newPage2.locator('[test-id="create-field-metadata_name"]').getByRole('textbox').fill(testAccountName);
149+
await newPage2.locator('[test-id="create-resource-submit"]').click();
153150

154-
const accountElement = await newPage2.getByText(testAccountName);
151+
const accountElement = newPage2.locator('[test-id="generic-list-cell-0-metadata.name"]');
155152
await expect(accountElement).toBeVisible( { timeout: 10000 } );
156153
await accountElement.click();
157154
const download1Promise = newPage2.waitForEvent('download');
158-
const downloadButton = await newPage2.getByRole('button', { name: 'Download kubeconfig' });
155+
const downloadButton = await newPage2.locator('[test-id="generic-detail-view-download"]');
159156
await expect(downloadButton).toBeVisible( { timeout: 10000 } );
160157
await downloadButton.click();
161158
await expect(download1Promise).toBeDefined();
162-
await newPage2.getByTestId('luigi-topnav-title').click();
163-
await newPage2.getByTestId('accounts_accounts').click();
164-
165-
await newPage2.pause();
166-
167-
const accountText = await newPage2.getByText(testAccountName);
168-
await expect(accountText).toBeVisible( { timeout: 10000 } );
169159

170160
});
171161
});

0 commit comments

Comments
 (0)