Skip to content
Open
Show file tree
Hide file tree
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
45 changes: 45 additions & 0 deletions app/ide-desktop/client/tests/electronTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ export async function loginAsTestUser(page: Page) {
await page.getByRole('textbox', { name: 'password' }).fill(process.env.ENSO_TEST_USER_PASSWORD)
await page.getByRole('button', { name: TEXT.login, exact: true }).click()

await expect(
page
.getByRole('group', { name: TEXT.licenseAgreementCheckbox })
.getByText(TEXT.licenseAgreementCheckbox),
).toBeVisible({ timeout: 60000 })
await page
.getByRole('group', { name: TEXT.licenseAgreementCheckbox })
.getByText(TEXT.licenseAgreementCheckbox)
Expand Down Expand Up @@ -157,3 +162,43 @@ export async function getNewestProject(page: Page): Promise<Locator> {

return numbered.reduce((a, b) => (a.num > b.num ? a : b)).locator
}

/**
* Clicking the eye button and making visualization visible
*/
export async function visualizeData(page: Page) {
const showViz = page.getByLabel('Show visualization (Space)')
await expect(showViz).toBeVisible({ timeout: 5000 })
await showViz.click()
}

/**
* Creating new component tied to the last created one
*/
export async function createNewComponent(page: Page) {
const moreButton = page.getByTestId('more-button').getByRole('button', { name: 'More' }).last()
await expect(moreButton).toBeVisible()
await moreButton.click()

await page.keyboard.press('Enter')
}

/**
* Creating new component from the name of its parent component
*/
export async function createComponentText(page: Page, parentComponent: string) {
await page.getByText(parentComponent, { exact: true }).click({ button: 'right' })
await page.keyboard.press('Enter')
}

/**
* Creating new component from the name of its parent component
*/
export async function fillText(page: Page, containerName: string, value: string) {
const cont = page.getByText(containerName, { exact: true })

// Ensuring the texbox is empty
const box = cont.getByTestId('widget-text-content').filter({ hasText: /^(“”|‘’)?$/ })
await expect(box).toBeVisible()
await box.fill(value)
}
221 changes: 221 additions & 0 deletions app/ide-desktop/client/tests/gettingStarted2.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
/** @file A series of tests designed for testing 'Getting Started with Enso Analytics'. */

import { expect } from 'playwright/test'
import {
closeWelcome,
createComponentText,
createNewProject,
fillText,
loginAsTestUser,
test,
visualizeData,
} from './electronTest'

// First excercise in Enso Analytics 101
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// First excercise in Enso Analytics 101
// Second excercise in Enso Analytics 101

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also excercise -> exercise

test('Exercise 2', async ({ page }) => {
await loginAsTestUser(page)
await closeWelcome(page)

// ---------------- Objective 1 ----------------
await test.step('Objective 1: Let’s read a single sheet in from Excel', async () => {
await createNewProject(page)

// Close documentation
await page.getByRole('tab', { name: 'Documentation' }).click()

const addComponent = page.getByLabel('Add Component (Enter)')
await expect(addComponent).toBeVisible()
await addComponent.click()

const dataReadEntry = page.locator('.ComponentEntry', { hasText: /^Data\.read$/ })
await expect(dataReadEntry).toBeVisible()
await dataReadEntry.click()

// Fill in the url
await fillText(page, 'path‘‘', 'Samples/Data/sample_bank_data.xlsx')

await Promise.race([
page.getByLabel('Show visualization (Space)').waitFor({ state: 'visible', timeout: 5000 }),
page
.getByText(/file not found/i)
.waitFor({ state: 'visible', timeout: 5000 })
.catch(() => null),
])

await visualizeData(page)

// Choosing the first sheet
const sheet1 = await page.getByText('Sheet1')
await expect(sheet1).toBeVisible()
await sheet1.dblclick()

await visualizeData(page)
})

// ---------------- Objective 2 ----------------
await test.step('Objective 2: Aggregating and ranking Account Type', async () => {
// Decrease zoom
await page.getByLabel('Decrease Zoom').click()

// Adding aggregate component
await createComponentText(page, 'readquery‘Sheet1’')
await page.locator('.ComponentEntry', { hasText: 'aggregate' }).click()

// Choosing parameters
const groupBy = page.getByText('group_by', { exact: true })

// Ensuring 'plus' is visible, to avoid clicking too early
await expect(page.locator('div').getByLabel('Add a new item').last()).toBeVisible()
await groupBy.click()

const productBtn = page.getByRole('button', { name: 'product_name', exact: true })

// If dropdown menu doesn't open, click groupBy again to avoid test flakyness
if (!(await productBtn.isVisible())) {
await groupBy.click()
}
Comment on lines +73 to +76
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think we avoid a flaky test here. Why does it not work on the first attempt? Perhaps we can wait for some visual indication that it is ready? Or is there some bug that prevents it from working?

await productBtn.isVisible()
await productBtn.click()

// Close the dropdown
await page.getByText('aggregate').click()

// Click the plus
await page
.locator('div.WidgetTopLevelArgument', { hasText: 'columns' })
.getByRole('list')
.filter({ hasText: /^$/ })
.getByLabel('Add a new item')
.click()
Comment on lines +84 to +89
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are three repetitions of this action; let’s extract it to a function.


// Visualize and assert the result
await visualizeData(page)
await expect(page.getByText('1026')).toBeVisible()

// Adding sort component
await createComponentText(page, 'aggregate')
await page.locator('.ComponentEntry', { hasText: 'sort' }).click()

// Click the plus
await page
.locator('div.WidgetTopLevelArgument', { hasText: 'columns' })
.nth(1)
.getByRole('list')
.filter({ hasText: /^$/ })
.getByLabel('Add a new item')
.click()

// Choosing parameters
await page
.locator('div')
.filter({ hasText: /^‘product_name’$/ })
.nth(4)
.click()
await page.getByRole('button', { name: 'Count', exact: true }).click()

await page.getByText('direction', { exact: true }).click()
await page.getByRole('button', { name: '..Descending', exact: true }).click()

await visualizeData(page)
})

// ---------------- Objective 3 ----------------
await test.step('Objective 3: Create table of currencies by product names', async () => {
// Scroll into view
await page.mouse.wheel(0, -200)

// Creating cross_tab component
const readComponent = page.getByText('read', { exact: true }).nth(2)
await readComponent.click({ button: 'right' })

await page.keyboard.press('Enter')
await page.locator('.ComponentEntry', { hasText: 'cross_tab' }).click()

// Choosing the right parameters
const crossGroup = await page.getByText('group_by', { exact: true }).nth(1)

// Ensuring 'plus' is visible, to avoid clicking too early
await expect(page.locator('div').getByLabel('Add a new item').last()).toBeVisible()
await crossGroup.click()
await page.getByRole('button', { name: 'product_name', exact: true }).click()

await page.locator('.WidgetSelection.clickable').filter({ hasText: 'names' }).click()
const curRCode = page.getByRole('button', { name: 'currency_code' }).first()
await expect(curRCode).toBeVisible()
await curRCode.click()

await page.getByText('values', { exact: true }).click()
await page.getByRole('button', { name: '..Count_Distinct', exact: true }).click()

// Click the plus and select argument
const plus = page
.locator('div.WidgetTopLevelArgument', { hasText: 'columns' })
.getByRole('list')
.filter({ hasText: /^$/ })
.getByLabel('Add a new item')
await expect(plus).toBeVisible()
await plus.click()
await page.getByRole('button', { name: 'account_id', exact: true }).click()

await visualizeData(page)

// Move cross_tab a bit down for more clearance
const crossTab = page.getByText('cross_tab')

await crossTab.hover()
await page.mouse.down()
const box = await crossTab.boundingBox()
if (box) {
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2 + 200)
}
await page.mouse.up()
Comment on lines +165 to +171
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an easier way to do dragging. Check out moveNode in collapsingAndEntering.spec.ts:

function moveNode(page: Page, binding: string, relativePos: RelativePos) {
    return grabNode(page, binding).dragTo(grabNode(page, relativePos.relativeTo ?? binding), {
      force: true,
      targetPosition: relativePos,
    })
  }

grabNode can be replaced with graphNodeIcon, it’s an oversight on my side.

})

// ---------------- Objective 4 ----------------
await test.step('Objective 4: Fixing Dirty Data', async () => {
// Scroll into view
await page.mouse.wheel(0, -200)

// Creating set component
const readComponent = page.getByText('read', { exact: true }).nth(2)
await readComponent.click({ button: 'right' })

await page.keyboard.press('Enter')
await page.locator('.ComponentEntry', { hasText: 'set' }).click()

// Choosing right parameters
await page.getByText('value', { exact: true }).click()
await page.getByRole('button', { name: '<Simple Expression>', exact: true }).click()

await page.getByText('input', { exact: true }).click()
await page.getByRole('button', { name: 'currency_code', exact: true }).click()

await page.getByText('operation', { exact: true }).click()
await page.getByRole('button', { name: 'if', exact: true }).click()

await page.getByText('condition', { exact: true }).click()
await page.getByRole('button', { name: '..Equal', exact: true }).click()

await page.locator('.WidgetSelection.clickable').filter({ hasText: /^to$/ }).click()
await page.getByRole('button', { name: '<Text Value>' }).click()

// Write in the textbox
await fillText(page, '..Equal“”', 'G')

await page.getByText('true_value', { exact: true }).click()
await page.getByRole('button', { name: '<Text Value>', exact: true }).click()

// // Write in the textbox
await fillText(page, '..If(..Equal“G”)“”', 'GBP')

await page.getByText('false_value', { exact: true }).click()
const option = page.getByRole('button', { name: 'currency_code', exact: true })
await option.hover()
await option.click()

// Write in the textbox
await fillText(page, 'as“”', 'currency_code')
await visualizeData(page)
await expect(page.getByText('191')).toBeVisible()
})
})
Loading