Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DO NOT MERGE Playwright sanity test automation #206

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion kokoro/gcp_ubuntu_docker/kokoro_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jupyter server extension enable dataproc_jupyter_plugin
cd ./ui-tests
jlpm install
jlpm playwright install
PLAYWRIGHT_JUNIT_OUTPUT_NAME=test-results-latest/sponge_log.xml jlpm playwright test --reporter=junit --output="test-results-latest"
PLAYWRIGHT_JUNIT_OUTPUT_NAME=test-results-latest/sponge_log.xml TEST_TAG=Sanity jlpm playwright test --reporter=junit --output="test-results-latest"
deactivate

# Test 3.6.6
Expand Down
2 changes: 1 addition & 1 deletion src/sessions/sessionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ function SessionDetails({
</div>
</div>
<div className="row-details" key={DATAPROC_CLUSTER_KEY}>
<div className="batch-details-label-level-three">
<div className="batch-details-label-level-three session-details-label-width">
{DATAPROC_CLUSTER_LABEL}
</div>
<div className="session-env-details-value">
Expand Down
2 changes: 1 addition & 1 deletion src/sessions/sessionTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const [detailedSessionView,setDetailedSessionView] = useState(true);
useEffect(() => {
});
return (
<div>
<div className="session-template-container">
{detailedSessionView && (
<SessionDetails
sessionSelected={sessionId}
Expand Down
7 changes: 7 additions & 0 deletions style/sessionDetails.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,10 @@
padding-left: 15px;
border-bottom: 1px solid var(--jp-layout-color3);
}
.session-template-container {
height: 100%;
overflow: auto;
}
.session-details-label-width {
width: 33%;
}
4 changes: 3 additions & 1 deletion ui-tests/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,7 @@ module.exports = {
trace: 'on-first-retry',
// Record video only when retrying a test for the first time.
video: 'on-first-retry'
}
},
// Add support for tags using TEST_TAG environment variable
grep: process.env.TEST_TAG ? new RegExp(process.env.TEST_TAG, 'i') : undefined,
};
155 changes: 118 additions & 37 deletions ui-tests/tests/bigquery_dataset_explorer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,122 @@

import { test, expect, galata } from '@jupyterlab/galata';

test('bigquery-dataset-explorer', async ({ page, request }) => {
const issues = await page.request.get(
'http://localhost:8888/dataproc-plugin/settings'
);
expect(issues.ok()).toBeTruthy();
const response: any = await issues.json();
expect(response.enable_bigquery_integration).toBe(true);

const tabExists = await page.isVisible(
'role=tab[name="Dataset Explorer - BigQuery"]'
);

if (tabExists) {
test.describe('bigquery-dataset-explorer', () => {
test('Dataset Explorer', async ({ page, request }) => {
// Fetch Dataproc plugin settings
const issues = await page.request.get('http://localhost:8888/dataproc-plugin/settings');
expect(issues.ok()).toBeTruthy();

// Parse response and check BigQuery integration is enabled
const response = await issues.json();
expect(response.enable_bigquery_integration).toBe(true);

// Check if the "Dataset Explorer - BigQuery" tab is visible
const tabExists = await page.isVisible('role=tab[name="Dataset Explorer - BigQuery"]');

if (tabExists) {
// Click on the "Dataset Explorer - BigQuery" tab
await page.getByRole('tab', { name: 'Dataset Explorer - BigQuery' }).click();

// Expand and navigate through the dataset tree
await page.waitForSelector('div[role="treeitem"].caret-icon.down');
await page.locator('div[role="treeitem"].caret-icon.down').nth(1).click();
await page.getByTestId('loader').waitFor({ state: "detached" });
await page.locator('div[role="treeitem"].caret-icon.down').nth(1).click();
await page.getByTestId('loader').waitFor({ state: "detached" });
await page.locator('div[role="treeitem"][aria-level="2"]').first().click();

// Wait for the dataset details to load
await page.getByText('Loading dataset details').waitFor({ state: "hidden" });

// Check dataset details are visible
await expect(page.getByText('Dataset info', { exact: true })).toBeVisible();
const datasetRowHeaders = [
'Dataset ID', 'Created', 'Default table expiration',
'Last modified', 'Data location', 'Description', 'Default collation',
'Default rounding mode', 'Time travel window', 'Storage billing model', 'Case insensitive'
];
for (const header of datasetRowHeaders) {
await expect(page.getByRole('cell', { name: header, exact: true })).toBeVisible();
}

// Click on the first table
await page.locator('div[role="treeitem"][aria-level="3"]').first().click();

// Wait for the table details to load
await page.getByText('Loading table details').waitFor({ state: "hidden" });

// Check table details are visible
await expect(page.getByText('Table info')).toBeVisible();
const tableHeaders = [
'Table ID', 'Created', 'Last modified', 'Table expiration',
'Data location', 'Default collation', 'Default rounding mode', 'Description', 'Case insensitive'
];
for (const header of tableHeaders) {
await expect(page.getByRole('cell', { name: header, exact: true })).toBeVisible();
}

// Click on the Schema tab and check all schema fields are visible
await page.getByText('Schema', { exact: true }).click();
await expect(page.getByText('Schema').nth(2)).toBeVisible();
const schemaHeaders = [
'Field name', 'Type', 'Mode', 'Key', 'Collation', 'Default Value',
'Policy Tags', 'Data Policies', 'Description'
];
for (const header of schemaHeaders) {
await expect(page.getByRole('columnheader', { name: header, exact: true })).toBeVisible();
}

// Click on the Preview tab and check if data is present
await page.getByText('Preview', { exact: true }).click();

// Wait for the preview data to load
await page.getByText('Loading Preview Data').waitFor({ state: "hidden" });

// Check if data is present in the preview table
const dataExists = await page.locator('table.clusters-list-table').isVisible();
if (dataExists) {
const rowCount = await page.locator('table.clusters-list-table tr').count();
expect(rowCount).toBeGreaterThan(0);
} else {
await expect(page.getByText('No rows to display')).toBeVisible();
}

} else {
// If the tab doesn't exist, verify BigQuery integration is disabled
expect(response.enable_bigquery_integration).toBe(false);
}
});

test('Can verify search field and refresh button', async ({ page, request }) => {
// Fetch Dataproc plugin settings
const issues = await page.request.get('http://localhost:8888/dataproc-plugin/settings');
expect(issues.ok()).toBeTruthy();

// Parse response and check BigQuery integration is enabled
const response = await issues.json();
expect(response.enable_bigquery_integration).toBe(true);
await page
.getByRole('tab', { name: 'Dataset Explorer - BigQuery' })
.click();

// Wait for the Dataset projects to populate.
await page.waitForSelector('div[role="treeitem"][aria-level="1"]');
await page.waitForSelector('div[role="treeitem"].caret-icon.down');

// Expand the first dataset project. This should always be the `bigquery-public-data` one.
await page.locator('div[role="treeitem"].caret-icon.down').nth(0).click();

// Wait for the first dataset to be displayed, and then expand it.
await page.waitForSelector('div[role="treeitem"][aria-level="2"]');
await page.waitForSelector('div[role="treeitem"].caret-icon.down');
await page.locator('div[role="treeitem"].caret-icon.down').nth(0).click();

// Click on the first table displayed.
await page.locator('div[role="treeitem"][aria-level="3"]').first().click();
await page.getByText('Schema', { exact: true }).click();
await page.getByText('Preview', { exact: true }).click();
} else {
expect(response.enable_bigquery_integration).toBe(false);
}
});

// Check if the "Dataset Explorer - BigQuery" tab is visible
const tabExists = await page.isVisible('role=tab[name="Dataset Explorer - BigQuery"]');

if (tabExists) {
// Click on the "Dataset Explorer - BigQuery" tab
await page.getByRole('tab', { name: 'Dataset Explorer - BigQuery' }).click();

await page.waitForSelector('div[role="treeitem"].caret-icon.down');

await expect(page.locator('[role="treeitem"][title="austin_311"]')).not.toBeVisible();

await page.getByPlaceholder('Enter your keyword to search').first().click();
await page.getByPlaceholder('Enter your keyword to search').first().fill('austin_311');

await page.locator('[aria-label="Loading Spinner"]').waitFor({ state: "detached" });

await page.waitForTimeout(5000);

await expect(page.locator('[role="treeitem"][title="austin_311"]')).toBeVisible();

}
});
});
Loading