test: Update tests
This commit is contained in:
parent
c851fa9b8a
commit
9d8d6d1d99
2 changed files with 55 additions and 34 deletions
|
|
@ -100,17 +100,11 @@ const getRows = async () => {
|
||||||
const comparePackageSearchResults = async () => {
|
const comparePackageSearchResults = async () => {
|
||||||
const availablePackages = await getRows();
|
const availablePackages = await getRows();
|
||||||
|
|
||||||
await waitFor(() => expect(availablePackages).toHaveLength(5));
|
await waitFor(() => expect(availablePackages).toHaveLength(3));
|
||||||
|
|
||||||
expect(availablePackages[0]).toHaveTextContent('test');
|
expect(availablePackages[0]).toHaveTextContent('test');
|
||||||
expect(availablePackages[1]).toHaveTextContent('test-lib');
|
expect(availablePackages[1]).toHaveTextContent('test-lib');
|
||||||
expect(availablePackages[2]).toHaveTextContent('testPkg');
|
expect(availablePackages[2]).toHaveTextContent('testPkg');
|
||||||
expect(availablePackages[3]).toHaveTextContent('testModule');
|
|
||||||
expect(availablePackages[4]).toHaveTextContent('testModule');
|
|
||||||
|
|
||||||
// Ensure both modules have one row
|
|
||||||
await screen.findByText('1.22');
|
|
||||||
await screen.findByText('1.24');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const clickFirstPackageCheckbox = async () => {
|
const clickFirstPackageCheckbox = async () => {
|
||||||
|
|
@ -174,7 +168,7 @@ const addAllRecommendations = async () => {
|
||||||
const deselectRecommendation = async () => {
|
const deselectRecommendation = async () => {
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
const row1Checkbox = await screen.findByRole('checkbox', {
|
const row1Checkbox = await screen.findByRole('checkbox', {
|
||||||
name: /select row 1/i,
|
name: /select row 0/i,
|
||||||
});
|
});
|
||||||
await waitFor(async () => user.click(row1Checkbox));
|
await waitFor(async () => user.click(row1Checkbox));
|
||||||
};
|
};
|
||||||
|
|
@ -411,26 +405,6 @@ describe('Step Packages', () => {
|
||||||
await within(pkgTable).findByText('recommendedPackage1');
|
await within(pkgTable).findByText('recommendedPackage1');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('only one stream gets selected, other should be disabled', async () => {
|
|
||||||
const user = userEvent.setup();
|
|
||||||
|
|
||||||
await renderCreateMode();
|
|
||||||
await goToPackagesStep();
|
|
||||||
await selectCustomRepo();
|
|
||||||
await typeIntoSearchBox('test');
|
|
||||||
|
|
||||||
const firstAppStreamRow = await screen.findByRole('checkbox', {
|
|
||||||
name: /select row 3/i,
|
|
||||||
});
|
|
||||||
await waitFor(() => user.click(firstAppStreamRow));
|
|
||||||
|
|
||||||
const secondAppStreamRow = await screen.findByRole('checkbox', {
|
|
||||||
name: /select row 4/i,
|
|
||||||
});
|
|
||||||
expect(secondAppStreamRow).toBeDisabled();
|
|
||||||
expect(secondAppStreamRow).not.toBeChecked();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('revisit step button on Review works', async () => {
|
test('revisit step button on Review works', async () => {
|
||||||
await renderCreateMode();
|
await renderCreateMode();
|
||||||
await goToPackagesStep();
|
await goToPackagesStep();
|
||||||
|
|
@ -455,9 +429,9 @@ describe('Step Packages', () => {
|
||||||
|
|
||||||
// the pagination in the top right
|
// the pagination in the top right
|
||||||
const top = await screen.findByTestId('packages-pagination-top');
|
const top = await screen.findByTestId('packages-pagination-top');
|
||||||
expect(top).toHaveTextContent('of 5');
|
expect(top).toHaveTextContent('of 3');
|
||||||
const bottom = await screen.findByTestId('packages-pagination-bottom');
|
const bottom = await screen.findByTestId('packages-pagination-bottom');
|
||||||
expect(bottom).toHaveTextContent('of 5');
|
expect(bottom).toHaveTextContent('of 3');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('itemcount correct after toggling selected', async () => {
|
test('itemcount correct after toggling selected', async () => {
|
||||||
|
|
@ -511,6 +485,47 @@ describe('Step Packages', () => {
|
||||||
await waitFor(() => expect(secondRowCells[0]).toHaveTextContent('fish2'));
|
await waitFor(() => expect(secondRowCells[0]).toHaveTextContent('fish2'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Modules', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('modules get rendered with one stream on each line', async () => {
|
||||||
|
await renderCreateMode();
|
||||||
|
await goToPackagesStep();
|
||||||
|
await selectCustomRepo();
|
||||||
|
await typeIntoSearchBox('testModule');
|
||||||
|
await screen.findByText('1.22');
|
||||||
|
const rows = await screen.findAllByRole('row');
|
||||||
|
rows.shift();
|
||||||
|
expect(rows).toHaveLength(2);
|
||||||
|
expect(rows[0]).toHaveTextContent('1.22');
|
||||||
|
expect(rows[1]).toHaveTextContent('1.24');
|
||||||
|
expect(rows[0]).toHaveTextContent('May 2025');
|
||||||
|
expect(rows[1]).toHaveTextContent('May 2027');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('only one stream gets selected, other should be disabled', async () => {
|
||||||
|
const user = userEvent.setup();
|
||||||
|
|
||||||
|
await renderCreateMode();
|
||||||
|
await goToPackagesStep();
|
||||||
|
await selectCustomRepo();
|
||||||
|
await typeIntoSearchBox('testModule');
|
||||||
|
|
||||||
|
const firstAppStreamRow = await screen.findByRole('checkbox', {
|
||||||
|
name: /select row 0/i,
|
||||||
|
});
|
||||||
|
await waitFor(() => user.click(firstAppStreamRow));
|
||||||
|
|
||||||
|
const secondAppStreamRow = await screen.findByRole('checkbox', {
|
||||||
|
name: /select row 1/i,
|
||||||
|
});
|
||||||
|
expect(secondAppStreamRow).toBeDisabled();
|
||||||
|
expect(secondAppStreamRow).not.toBeChecked();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Packages request generated correctly', () => {
|
describe('Packages request generated correctly', () => {
|
||||||
|
|
@ -557,9 +572,9 @@ describe('Packages request generated correctly', () => {
|
||||||
test('with module', async () => {
|
test('with module', async () => {
|
||||||
await renderCreateMode();
|
await renderCreateMode();
|
||||||
await goToPackagesStep();
|
await goToPackagesStep();
|
||||||
await typeIntoSearchBox('test'); // search for 'test' package
|
await typeIntoSearchBox('testModule'); // search for 'test' package
|
||||||
const moduleCheckbox = await screen.findByRole('checkbox', {
|
const moduleCheckbox = await screen.findByRole('checkbox', {
|
||||||
name: /select row 3/i,
|
name: /select row 0/i,
|
||||||
});
|
});
|
||||||
await waitFor(() => user.click(moduleCheckbox));
|
await waitFor(() => user.click(moduleCheckbox));
|
||||||
await goToReviewStep();
|
await goToReviewStep();
|
||||||
|
|
@ -579,9 +594,9 @@ describe('Packages request generated correctly', () => {
|
||||||
test('deselecting a module removes it from the request', async () => {
|
test('deselecting a module removes it from the request', async () => {
|
||||||
await renderCreateMode();
|
await renderCreateMode();
|
||||||
await goToPackagesStep();
|
await goToPackagesStep();
|
||||||
await typeIntoSearchBox('test'); // search for 'test' package
|
await typeIntoSearchBox('testModule'); // search for 'test' package
|
||||||
const moduleCheckbox = await screen.findByRole('checkbox', {
|
const moduleCheckbox = await screen.findByRole('checkbox', {
|
||||||
name: /select row 3/i,
|
name: /select row 0/i,
|
||||||
});
|
});
|
||||||
await waitFor(() => user.click(moduleCheckbox)); // select
|
await waitFor(() => user.click(moduleCheckbox)); // select
|
||||||
await toggleSelected();
|
await toggleSelected();
|
||||||
|
|
|
||||||
6
src/test/fixtures/packages.ts
vendored
6
src/test/fixtures/packages.ts
vendored
|
|
@ -51,6 +51,10 @@ export const mockSourcesPackagesResults = (
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if (search === 'testModule') {
|
||||||
|
return [
|
||||||
{
|
{
|
||||||
package_name: 'testModule',
|
package_name: 'testModule',
|
||||||
summary: 'testModule summary',
|
summary: 'testModule summary',
|
||||||
|
|
@ -59,11 +63,13 @@ export const mockSourcesPackagesResults = (
|
||||||
name: 'testModule',
|
name: 'testModule',
|
||||||
type: 'module',
|
type: 'module',
|
||||||
stream: '1.22',
|
stream: '1.22',
|
||||||
|
end_date: '2025-05-01',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'testModule',
|
name: 'testModule',
|
||||||
type: 'module',
|
type: 'module',
|
||||||
stream: '1.24',
|
stream: '1.24',
|
||||||
|
end_date: '2027-05-01',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue