Skip to content

Commit

Permalink
add: e2e test code for setting resource policy limit below minimum re…
Browse files Browse the repository at this point in the history
…quired resource of selected image in session launcher
  • Loading branch information
lizable committed Sep 10, 2024
1 parent 79f7ecb commit ae6845c
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion e2e/session.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { createSession, deleteSession, loginAsUser } from './test-util';
import {
createSession,
deleteSession,
loginAsAdmin,
loginAsUser,
navigateTo,
} from './test-util';
import { test, expect } from '@playwright/test';

test.describe('Sessions ', () => {
Expand All @@ -9,3 +15,45 @@ test.describe('Sessions ', () => {
await deleteSession(page, sessionName);
});
});

test.describe('Restrict resource policy and see resource warning message', () => {
test('superadmin to modify keypair resource policy', async ({ page }) => {
await loginAsAdmin(page);

// go to resource policy page
await navigateTo(page, 'resource-policy');

// modify resource limit (cpu, memory) to zero
await page
.getByRole('table')
.getByRole('button', { name: 'setting' })
.click();
await page.locator('.ant-checkbox-input').first().uncheck();
await page.getByLabel('CPU(optional)').click();
await page.getByLabel('CPU(optional)').fill('0');
await page
.locator(
'div:nth-child(2) > div > div > .ant-checkbox-wrapper > span:nth-child(2)',
)
.first()
.uncheck();
await page.getByLabel('Memory(optional)').click();
await page.getByLabel('Memory(optional)').fill('0');
await page.getByRole('button', { name: 'OK' }).click();

// go back to session page and see message in resource allocation section
await navigateTo(page, 'session/start');

await page.getByRole('button', { name: 'Next right' }).click();
const notEnoughCPUResourceMsg = await page
.locator('#resource_cpu_help')
.getByText('Allocatable resources falls')
.textContent();
const notEnoughRAMResourceMsg = await page
.getByText('Allocatable resources falls')
.nth(1)
.textContent();

expect(notEnoughCPUResourceMsg).toEqual(notEnoughRAMResourceMsg);
});
});

0 comments on commit ae6845c

Please sign in to comment.