Skip to content

Commit

Permalink
screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
manolo committed Jan 17, 2025
1 parent f9e49d8 commit c24d64f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
20 changes: 15 additions & 5 deletions scripts/pit/its/cc-install-apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ if (!email) {
return;
}

const screenshots = "screenshots.out"
let sscount = 0;
async function takeScreenshot(page, name) {
const path = `${screenshots}/${++sscount}-${name}-${mode}.png`;
await page.waitForTimeout(1000);
await page.screenshot({ path });
log(`Screenshot taken: ${path}\n`);
}

(async () => {
const browser = await chromium.launch({
headless: headless,
Expand All @@ -40,23 +49,24 @@ if (!email) {

fs.writeFileSync('domain.pem', `${process.env.CC_CERT.replace(/\\n/g, "\n")}\n${process.env.CC_KEY.replace(/\\n/g, "\n")}`);

// Open new page
const page = await context.newPage();
page.on('console', msg => console.log("> CONSOLE:", (msg.text() + ' - ' + msg.location().url).replace(/\s+/g, ' ')));
page.on('pageerror', err => console.log("> PAGEERROR:", ('' + err).replace(/\s+/g, ' ')));

await page.goto(`${url}`);

await expect(page.getByLabel('Email')).toBeVisible();
await takeScreenshot(page, 'view-loaded');

await page.getByLabel('Email').fill(email);
await page.getByLabel('Password').fill(pass);
await page.waitForTimeout(500);
await page.getByRole('button', {name: 'Sign In'}).click()

await takeScreenshot(page, 'logged-in');

await page.getByRole('listitem').filter({ hasText: 'Settings'}).click()
await page.getByRole('button', {name: 'Deploy'}).click()
await takeScreenshot(page, 'form-opened');

await page.getByLabel('Application Name', {exact: true}).fill('App1')
await page.getByLabel('Image', {exact: true}).fill('k8sdemos/bakery-cc:latest')
Expand All @@ -67,17 +77,17 @@ if (!email) {
await page.getByText('Browse').click();
const fileChooser = await fileChooserPromise;
await fileChooser.setFiles('domain.pem');

fileChooserPromise.then(await page.locator('.detail-layout').getByRole('button', {name: 'Deploy'}).click())
await takeScreenshot(page, 'pem-uploaded');

await page.getByRole('listitem').filter({ hasText: 'Settings'}).click()

await expect(await page.getByRole('listitem')
.filter({ hasText: 'Applications'})
.textContent()).toEqual('Applications1');

console.log(`Application app1 deployed successfully`);
// ---------------------
await takeScreenshot(page, 'application-created');

await context.close();
await browser.close();
})();
27 changes: 16 additions & 11 deletions scripts/pit/its/cc-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ if (!email) {
return;
}

const screenshots = "screenshots.out"
let sscount = 0;
async function takeScreenshot(page, name) {
const path = `${screenshots}/${++sscount}-${name}-${mode}.png`;
await page.waitForTimeout(1000);
await page.screenshot({ path });
log(`Screenshot taken: ${path}\n`);
}

(async () => {
if (!tmppass) {
tmppass = await run(`kubectl -n control-center get secret control-center-user -o go-template="{{ .data.password | base64decode | println }}"`);
Expand All @@ -51,34 +60,30 @@ if (!email) {

await page.goto(`${url}`);

await takeScreenshot(page, 'view-loaded');
await expect(page.getByLabel('Email')).toBeVisible();

await page.getByLabel('Email').fill(email);
await page.getByLabel('Password').fill(tmppass);
await page.waitForTimeout(500);
await page.getByRole('button', {name: 'Sign In'}).click()

console.log(email, tmppass, pass)

await page.waitForTimeout(1000);
await takeScreenshot(page, 'logged-in');

await page.getByLabel('New Password').fill(pass);
await page.getByLabel('Confirm Password').fill(pass);
await page.waitForTimeout(500);
await page.getByRole('button', { name: 'Submit' }).click();

await takeScreenshot(page, 'password-changed');

await page.getByLabel('First Name').fill(email);
await page.getByLabel('Last Name').fill(email);
await page.waitForTimeout(500);
await page.getByRole('button', { name: 'Submit' }).click();
await page.waitForTimeout(500);
await page.getByRole('button', { name: 'Manage applications' }).click();
await page.waitForTimeout(500);

await takeScreenshot(page, 'user-configured');

await page.getByRole('button', { name: 'Manage applications' }).click();
await expect(page.getByRole('heading', { name: 'Applications' })).toBeVisible();

console.log(`User ${email} confgigured with password ${pass}`);

await context.close();
await browser.close();
})();

0 comments on commit c24d64f

Please sign in to comment.