Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 30 additions & 27 deletions local-setup/e2e/test-register-and-navigate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ async function ensurePortalHome(page: Page) {

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

test.setTimeout(2*60*1000); // 2 minutes test timeout

test('Register and navigate to portal', async ({ page }) => {
await page.goto(portalBaseUrl);

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

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

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

await newPage.pause(); // for debugging

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

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

await newPage2.getByText('Accounts').click();
await newPage2.locator('[data-testid="accounts_accounts"]').click(); // data-testid="accounts_accounts"
// click on "Create" button
await newPage2.getByRole('button', { name: 'Create' }).click();

// await page2.pause();
await newPage2.locator('[test-id="generic-list-view-create-button"]').click(); // generic-list-view-create-button

await newPage2.locator('.ui5-select-icon > .ui5-icon-root').click();
await newPage2.locator('#ui5wc_10-content > .ui5-li-text-wrapper').click();
await newPage2.locator('#inner').nth(1).click();
await newPage2.locator('ui5-input').filter({ hasText: '<svg xmlns="http://www.w3.org' }).locator('#inner').click();
await newPage2.locator('ui5-input').filter({ hasText: '<svg xmlns="http://www.w3.org' }).locator('#inner').click();
await newPage2.locator('ui5-input').filter({ hasText: '<svg xmlns="http://www.w3.org' }).locator('#inner').press('Shift+Home');
await newPage2.locator('ui5-input').filter({ hasText: '<svg xmlns="http://www.w3.org' }).locator('#inner').fill(testAccountName);
await newPage2.getByRole('button', { name: 'Submit' }).click();
await newPage2.pause();

await newPage2.locator('[test-id="create-field-metadata_name"]').click();
await newPage2.locator('[test-id="create-field-spec_type"]').click();
await newPage2.locator('[test-id="create-field-spec_type-option-account"]').click();
await newPage2.locator('[test-id="create-field-metadata_name"]').getByRole('textbox').fill(testAccountName);
await newPage2.locator('[test-id="create-resource-submit"]').click();

const accountElement = await newPage2.getByText(testAccountName);
const accountElement = newPage2.locator('[test-id="generic-list-cell-0-metadata.name"]').getByText(testAccountName);
await expect(accountElement).toBeVisible( { timeout: 10000 } );

// Close the Mailpit page/tab if it's still open
const pages = newPage2.context().pages();
for (const p of pages) {
if (p.url().includes('mailpit') && p !== newPage2) {
await p.close();
}
}

await accountElement.click();
const download1Promise = newPage2.waitForEvent('download');
const downloadButton = await newPage2.getByRole('button', { name: 'Download kubeconfig' });
const downloadButton = newPage2.locator('[test-id="generic-detail-view-download"]');
await expect(downloadButton).toBeVisible( { timeout: 10000 } );
await downloadButton.click();
await expect(download1Promise).toBeDefined();
await newPage2.getByTestId('luigi-topnav-title').click();
await newPage2.getByTestId('accounts_accounts').click();

await newPage2.pause();

const accountText = await newPage2.getByText(testAccountName);
await expect(accountText).toBeVisible( { timeout: 10000 } );

const download1Promise = newPage2.waitForEvent('download');
await downloadButton.click();
const download = await download1Promise;
expect(download).toBeDefined();

});
});