-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: e2e test for parsing config.toml and modifying
- Loading branch information
1 parent
c1270fc
commit 6e9d0e1
Showing
5 changed files
with
171 additions
and
170 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,132 @@ | ||
import { loginAsAdmin, mockConfigToml, webuiEndpoint } from './test-util'; | ||
import { loginAsAdmin, modifyConfigToml, webuiEndpoint } from './test-util'; | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test.describe('config read and test', () => { | ||
test('showNonInstalledImages', async ({ page, context }) => { | ||
// manipulate config file from mocked one | ||
await mockConfigToml(page, './config-test.toml'); | ||
|
||
await loginAsAdmin(page); | ||
|
||
await page.getByRole('group').getByText('Environments').click(); | ||
await page | ||
.getByRole('columnheader', { name: 'Status' }) | ||
.locator('div') | ||
.click(); | ||
await page | ||
.getByRole('columnheader', { name: 'Status' }) | ||
.locator('div') | ||
.click(); | ||
|
||
const registryCell = await page | ||
.locator('.ant-table-row > td:nth-child(3)') | ||
.first(); | ||
const registry = await registryCell.textContent(); | ||
|
||
const architectureCell = await page | ||
.locator('.ant-table-row > td:nth-child(4)') | ||
.first(); | ||
const architecture = await architectureCell.textContent(); | ||
|
||
const namespaceCell = await page | ||
.getByRole('cell', { name: 'community' }) | ||
.first(); | ||
const namespace = await namespaceCell.textContent(); | ||
|
||
const languageCell = await page.getByRole('cell', { name: 'afni' }).first(); | ||
const language = await languageCell.textContent(); | ||
|
||
const versionCell = await page | ||
.getByRole('cell', { name: 'ubuntu18.04' }) | ||
.first(); | ||
const version = await versionCell.textContent(); | ||
|
||
const uninstalledImageString = `${registry}/${namespace}/${language}:${version}@${architecture}`; | ||
|
||
await page.goto(webuiEndpoint); | ||
await page.getByLabel('power_settings_new').click(); | ||
await page | ||
.getByRole('button', { name: '2 Environments & Resource' }) | ||
.click(); | ||
await page | ||
.locator( | ||
'.ant-form-item-control-input-content > .ant-select > .ant-select-selector', | ||
) | ||
.first() | ||
.click(); | ||
await page.getByLabel('Environments / Version').fill('AF'); | ||
await page | ||
.locator('.rc-virtual-list-holder-inner > div:nth-child(2)') | ||
.click(); | ||
|
||
await page | ||
.locator('span') | ||
.filter({ hasText: 'ubuntu18.04x86_64' }) | ||
.locator('div') | ||
.first() | ||
.click(); | ||
await page | ||
.locator( | ||
'div:nth-child(4) > .rc-virtual-list-holder > div > .rc-virtual-list-holder-inner > .ant-select-item > .ant-select-item-option-content > div', | ||
) | ||
.click(); | ||
await page | ||
.getByRole('button', { name: 'Skip to review double-right' }) | ||
.click(); | ||
await page.getByRole('button', { name: 'Copy' }).click(); | ||
|
||
await context.grantPermissions(['clipboard-read', 'clipboard-write']); | ||
|
||
const handle = await page.evaluateHandle(() => | ||
navigator.clipboard.readText(), | ||
); | ||
const clipboardContent = await handle.jsonValue(); | ||
|
||
expect(clipboardContent).toEqual(uninstalledImageString); | ||
}); | ||
test.describe.parallel('config.toml', () => { | ||
test( | ||
'block list', | ||
{ tag: ['@session', '@summary', '@serving'] }, | ||
async ({ page, request }) => { | ||
// modify config.toml to blocklist some menu items | ||
const requestConfig = { | ||
menu: { | ||
blocklist: 'summary, serving, job', | ||
}, | ||
}; | ||
await modifyConfigToml(page, request, requestConfig); | ||
await loginAsAdmin(page); | ||
|
||
// check if the menu items are hidden | ||
await expect( | ||
page.getByRole('menuitem', { name: 'Summary' }), | ||
).toBeHidden(); | ||
await expect( | ||
page.getByRole('menuitem', { name: 'Sessions' }), | ||
).toBeHidden(); | ||
await expect( | ||
page.getByRole('menuitem', { name: 'Serving' }), | ||
).toBeHidden(); | ||
|
||
// check if the pages are not accessible | ||
await page.goto(`${webuiEndpoint}/summary`); | ||
await expect(page).toHaveURL(/.*error/); | ||
await page.goto(`${webuiEndpoint}/serving`); | ||
await expect(page).toHaveURL(/.*error/); | ||
await page.goto(`${webuiEndpoint}/job`); | ||
await expect(page).toHaveURL(/.*error/); | ||
}, | ||
); | ||
|
||
test( | ||
'showNonInstalledImages', | ||
{ tag: ['@session'] }, | ||
async ({ page, context, request }) => { | ||
// modify config.toml to show non-installed images | ||
const requestConfig = { | ||
environments: { | ||
showNonInstalledImages: true, | ||
}, | ||
}; | ||
await modifyConfigToml(page, request, requestConfig); | ||
|
||
await loginAsAdmin(page); | ||
|
||
await page.getByRole('group').getByText('Environments').click(); | ||
await page | ||
.getByRole('columnheader', { name: 'Status' }) | ||
.locator('div') | ||
.click(); | ||
await page | ||
.getByRole('columnheader', { name: 'Status' }) | ||
.locator('div') | ||
.click(); | ||
|
||
const registryCell = await page | ||
.locator('.ant-table-row > td:nth-child(3)') | ||
.first(); | ||
const registry = await registryCell.textContent(); | ||
|
||
const architectureCell = await page | ||
.locator('.ant-table-row > td:nth-child(4)') | ||
.first(); | ||
const architecture = await architectureCell.textContent(); | ||
|
||
const namespaceCell = await page | ||
.getByRole('cell', { name: 'community' }) | ||
.first(); | ||
const namespace = await namespaceCell.textContent(); | ||
|
||
const languageCell = await page | ||
.getByRole('cell', { name: 'afni' }) | ||
.first(); | ||
const language = await languageCell.textContent(); | ||
|
||
const versionCell = await page | ||
.getByRole('cell', { name: 'ubuntu18.04' }) | ||
.first(); | ||
const version = await versionCell.textContent(); | ||
|
||
const uninstalledImageString = `${registry}/${namespace}/${language}:${version}@${architecture}`; | ||
|
||
await page.goto(webuiEndpoint); | ||
await page.getByLabel('power_settings_new').click(); | ||
await page | ||
.getByRole('button', { name: '2 Environments & Resource' }) | ||
.click(); | ||
await page | ||
.locator( | ||
'.ant-form-item-control-input-content > .ant-select > .ant-select-selector', | ||
) | ||
.first() | ||
.click(); | ||
await page.getByLabel('Environments / Version').fill('AF'); | ||
await page | ||
.locator('.rc-virtual-list-holder-inner > div:nth-child(2)') | ||
.click(); | ||
|
||
await page | ||
.locator('span') | ||
.filter({ hasText: 'ubuntu18.04x86_64' }) | ||
.locator('div') | ||
.first() | ||
.click(); | ||
await page | ||
.locator( | ||
'div:nth-child(4) > .rc-virtual-list-holder > div > .rc-virtual-list-holder-inner > .ant-select-item > .ant-select-item-option-content > div', | ||
) | ||
.click(); | ||
await page | ||
.getByRole('button', { name: 'Skip to review double-right' }) | ||
.click(); | ||
await page.getByRole('button', { name: 'Copy' }).click(); | ||
|
||
await context.grantPermissions(['clipboard-read', 'clipboard-write']); | ||
|
||
const handle = await page.evaluateHandle(() => | ||
navigator.clipboard.readText(), | ||
); | ||
const clipboardContent = await handle.jsonValue(); | ||
|
||
expect(clipboardContent).toEqual(uninstalledImageString); | ||
}, | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.