Wizard: Add tests for repositories and snapshot steps
Tests the bulk select and verifies disabled repositories.
This commit is contained in:
parent
90f7ce111a
commit
eab407c09e
3 changed files with 107 additions and 0 deletions
|
|
@ -88,6 +88,14 @@ const deselectFirstRepository = async () => {
|
|||
await waitFor(async () => user.click(row0Checkbox));
|
||||
};
|
||||
|
||||
const clickBulkSelect = async () => {
|
||||
const user = userEvent.setup();
|
||||
const bulkSelectCheckbox = await screen.findByRole('checkbox', {
|
||||
name: /select all/i,
|
||||
});
|
||||
await waitFor(async () => user.click(bulkSelectCheckbox));
|
||||
};
|
||||
|
||||
describe('repositories request generated correctly', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
|
@ -178,6 +186,18 @@ describe('repositories request generated correctly', () => {
|
|||
expect(receivedRequest).toEqual(expectedRequest);
|
||||
});
|
||||
});
|
||||
|
||||
test('bulk select', async () => {
|
||||
await renderCreateMode();
|
||||
await goToRepositoriesStep();
|
||||
await clickBulkSelect();
|
||||
await goToReviewStep();
|
||||
const receivedRequest = (await interceptBlueprintRequest(
|
||||
CREATE_BLUEPRINT
|
||||
)) as CreateBlueprintRequest;
|
||||
expect(receivedRequest.customizations.custom_repositories).toHaveLength(6);
|
||||
expect(receivedRequest.customizations.payload_repositories).toHaveLength(6);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Repositories edit mode', () => {
|
||||
|
|
|
|||
|
|
@ -67,6 +67,13 @@ const goToReviewStep = async () => {
|
|||
await clickNext();
|
||||
};
|
||||
|
||||
const searchForRepository = async (repo: string) => {
|
||||
const user = userEvent.setup();
|
||||
const search = await screen.findByLabelText('Search repositories');
|
||||
await waitFor(() => user.type(search, repo));
|
||||
await waitFor(() => expect(screen.getByText(repo)).toBeInTheDocument);
|
||||
};
|
||||
|
||||
const selectFirstRepository = async () => {
|
||||
const user = userEvent.setup();
|
||||
const row0Checkbox = await screen.findByRole('checkbox', {
|
||||
|
|
@ -75,6 +82,14 @@ const selectFirstRepository = async () => {
|
|||
await waitFor(async () => user.click(row0Checkbox));
|
||||
};
|
||||
|
||||
const clickBulkSelect = async () => {
|
||||
const user = userEvent.setup();
|
||||
const bulkSelectCheckbox = await screen.findByRole('checkbox', {
|
||||
name: /select all/i,
|
||||
});
|
||||
await waitFor(async () => user.click(bulkSelectCheckbox));
|
||||
};
|
||||
|
||||
const selectUseSnapshot = async () => {
|
||||
const user = userEvent.setup();
|
||||
const snapshotRadio = await screen.findByRole('radio', {
|
||||
|
|
@ -157,6 +172,59 @@ describe('repository snapshot tab - ', () => {
|
|||
expect(snapshotMethodElement).toHaveAttribute('aria-disabled', 'true');
|
||||
});
|
||||
});
|
||||
|
||||
test('select is disabled for non-snapshot repository', async () => {
|
||||
await renderCreateMode();
|
||||
await goToSnapshotStep();
|
||||
await selectUseSnapshot();
|
||||
await updateDatePickerWithValue('04/22/2024');
|
||||
await clickNext(); // To repositories step
|
||||
await searchForRepository('nosnapshot');
|
||||
|
||||
const row0Checkbox = await screen.findByRole('checkbox', {
|
||||
name: /select row 0/i,
|
||||
});
|
||||
expect(row0Checkbox).toBeDisabled();
|
||||
|
||||
const bulkSelectCheckbox = await screen.findByRole('checkbox', {
|
||||
name: /select all/i,
|
||||
});
|
||||
// eslint-disable-next-line testing-library/no-node-access
|
||||
expect(bulkSelectCheckbox.closest('div')).toHaveClass('pf-m-disabled');
|
||||
});
|
||||
|
||||
test('select using bulk select works ', async () => {
|
||||
await renderCreateMode();
|
||||
await goToSnapshotStep();
|
||||
await selectUseSnapshot();
|
||||
await updateDatePickerWithValue('04/22/2024');
|
||||
await clickNext(); // To repositories step
|
||||
await searchForRepository('01-test-valid-repo');
|
||||
|
||||
// wait until there's only 1 repository on the page
|
||||
await waitFor(async () => {
|
||||
const rows = await screen.findAllByRole('row');
|
||||
// header row + repo row
|
||||
expect(rows).toHaveLength(2);
|
||||
});
|
||||
|
||||
await clickBulkSelect();
|
||||
await goToReviewStep();
|
||||
|
||||
// Check the date was passed correctly to the blueprint
|
||||
const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT);
|
||||
blueprintRequest.image_requests[0].snapshot_date = '2024-04-22';
|
||||
|
||||
const expectedRequest: CreateBlueprintRequest = {
|
||||
...blueprintRequest,
|
||||
customizations: {
|
||||
custom_repositories: expectedCustomRepositories,
|
||||
payload_repositories: expectedPayloadRepositories,
|
||||
},
|
||||
};
|
||||
|
||||
expect(receivedRequest).toEqual(expectedRequest);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Snapshot edit mode', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue