Wizard: Migrate activation keys calls to RTK Query
This migrates calls to RHSM endpoints `activation_keys` and `/activation_keys/{name}` to RTK Query.
Tests were also updated to use Mock Service Worker instead of previous Jest mock function.
This commit is contained in:
parent
02a584b36f
commit
5f99bc79cf
9 changed files with 374 additions and 360 deletions
|
|
@ -32,17 +32,6 @@ describe('Step Upload to Azure', () => {
|
|||
// scrollTo is not defined in jsdom
|
||||
window.HTMLElement.prototype.scrollTo = function () {};
|
||||
|
||||
// mock the activation key api call
|
||||
const mockActivationKeys = [{ name: 'name0' }, { name: 'name1' }];
|
||||
jest
|
||||
.spyOn(api, 'getActivationKeys')
|
||||
.mockImplementation(() => Promise.resolve(mockActivationKeys));
|
||||
|
||||
const mockActivationKey = { body: [{ name: 'name0' }, { name: 'name1' }] };
|
||||
jest.spyOn(api, 'getActivationKey').mockImplementation((name) => {
|
||||
return Promise.resolve(mockActivationKey[name]);
|
||||
});
|
||||
|
||||
jest
|
||||
.spyOn(api, 'getRepositories')
|
||||
.mockImplementation(() => Promise.resolve(mockRepositoryResults));
|
||||
|
|
|
|||
|
|
@ -143,17 +143,6 @@ beforeAll(() => {
|
|||
// scrollTo is not defined in jsdom
|
||||
window.HTMLElement.prototype.scrollTo = function () {};
|
||||
|
||||
// mock the activation key api call
|
||||
const mockActivationKeys = [{ name: 'name0' }, { name: 'name1' }];
|
||||
jest
|
||||
.spyOn(api, 'getActivationKeys')
|
||||
.mockImplementation(() => Promise.resolve(mockActivationKeys));
|
||||
|
||||
const mockActivationKey = { body: [{ name: 'name0' }, { name: 'name1' }] };
|
||||
jest.spyOn(api, 'getActivationKey').mockImplementation((name) => {
|
||||
return Promise.resolve(mockActivationKey[name]);
|
||||
});
|
||||
|
||||
global.insights = {
|
||||
chrome: {
|
||||
auth: {
|
||||
|
|
@ -804,57 +793,6 @@ describe('Click through all steps', () => {
|
|||
screen.getByRole('button', { name: /Next/ }).click();
|
||||
|
||||
// registration
|
||||
const mockActivationKeys = [
|
||||
{ id: '0', name: 'name0' },
|
||||
{ id: 1, name: 'name1' },
|
||||
];
|
||||
jest
|
||||
.spyOn(api, 'getActivationKeys')
|
||||
.mockImplementation(() => Promise.resolve(mockActivationKeys));
|
||||
const mockActivationKey = {
|
||||
name0: {
|
||||
additionalRepositories: [
|
||||
{
|
||||
repositoryLabel: 'repository0',
|
||||
},
|
||||
{
|
||||
repositoryLabel: 'repository1',
|
||||
},
|
||||
{
|
||||
repositoryLabel: 'repository2',
|
||||
},
|
||||
],
|
||||
id: '0',
|
||||
name: 'name0',
|
||||
releaseVersion: '',
|
||||
role: '',
|
||||
serviceLevel: 'Self-Support',
|
||||
usage: 'Production',
|
||||
},
|
||||
name1: {
|
||||
additionalRepositories: [
|
||||
{
|
||||
repositoryLabel: 'repository3',
|
||||
},
|
||||
{
|
||||
repositoryLabel: 'repository4',
|
||||
},
|
||||
{
|
||||
repositoryLabel: 'repository5',
|
||||
},
|
||||
],
|
||||
id: '1',
|
||||
name: 'name1',
|
||||
releaseVersion: '',
|
||||
role: '',
|
||||
serviceLevel: 'Premium',
|
||||
usage: 'Production',
|
||||
},
|
||||
};
|
||||
jest.spyOn(api, 'getActivationKey').mockImplementation((name) => {
|
||||
return Promise.resolve(mockActivationKey[name]);
|
||||
});
|
||||
|
||||
const activationKeyDropdown = await screen.findByRole('textbox', {
|
||||
name: 'Select activation key',
|
||||
});
|
||||
|
|
|
|||
|
|
@ -110,17 +110,6 @@ beforeAll(() => {
|
|||
// scrollTo is not defined in jsdom
|
||||
window.HTMLElement.prototype.scrollTo = function () {};
|
||||
|
||||
// mock the activation key api call
|
||||
const mockActivationKeys = [{ name: 'name0' }, { name: 'name1' }];
|
||||
jest
|
||||
.spyOn(api, 'getActivationKeys')
|
||||
.mockImplementation(() => Promise.resolve(mockActivationKeys));
|
||||
|
||||
const mockActivationKey = { body: [{ name: 'name0' }, { name: 'name1' }] };
|
||||
jest.spyOn(api, 'getActivationKey').mockImplementation((name) => {
|
||||
return Promise.resolve(mockActivationKey[name]);
|
||||
});
|
||||
|
||||
global.insights = {
|
||||
chrome: {
|
||||
auth: {
|
||||
|
|
@ -1380,57 +1369,6 @@ describe('Click through all steps', () => {
|
|||
screen.getByRole('button', { name: /Next/ }).click();
|
||||
|
||||
// registration
|
||||
const mockActivationKeys = [
|
||||
{ id: '0', name: 'name0' },
|
||||
{ id: 1, name: 'name1' },
|
||||
];
|
||||
jest
|
||||
.spyOn(api, 'getActivationKeys')
|
||||
.mockImplementation(() => Promise.resolve(mockActivationKeys));
|
||||
const mockActivationKey = {
|
||||
name0: {
|
||||
additionalRepositories: [
|
||||
{
|
||||
repositoryLabel: 'repository0',
|
||||
},
|
||||
{
|
||||
repositoryLabel: 'repository1',
|
||||
},
|
||||
{
|
||||
repositoryLabel: 'repository2',
|
||||
},
|
||||
],
|
||||
id: '0',
|
||||
name: 'name0',
|
||||
releaseVersion: '',
|
||||
role: '',
|
||||
serviceLevel: 'Self-Support',
|
||||
usage: 'Production',
|
||||
},
|
||||
name1: {
|
||||
additionalRepositories: [
|
||||
{
|
||||
repositoryLabel: 'repository3',
|
||||
},
|
||||
{
|
||||
repositoryLabel: 'repository4',
|
||||
},
|
||||
{
|
||||
repositoryLabel: 'repository5',
|
||||
},
|
||||
],
|
||||
id: '1',
|
||||
name: 'name1',
|
||||
releaseVersion: '',
|
||||
role: '',
|
||||
serviceLevel: 'Premium',
|
||||
usage: 'Production',
|
||||
},
|
||||
};
|
||||
jest.spyOn(api, 'getActivationKey').mockImplementation((name) => {
|
||||
return Promise.resolve(mockActivationKey[name]);
|
||||
});
|
||||
|
||||
const registrationRadio = screen.getByTestId('registration-radio-now');
|
||||
await user.click(registrationRadio);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue