Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✅ Write new custom samMock.ts for use in amplify apps #939

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/config_files/check_config_workflow/list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ setupLocalhost.mjs client/src https://raw.githubusercontent.com/equinor/amplify-
setupTests.ts client/src/test-utils https://raw.githubusercontent.com/equinor/amplify-component-lib/refs/heads/main/config/config_files/test-utils/setupTests.ts
vitest.d.ts client/src/test-utils https://raw.githubusercontent.com/equinor/amplify-component-lib/refs/heads/main/config/config_files/test-utils/vitest.d.ts
browserMocks.ts client/src/test-utils https://raw.githubusercontent.com/equinor/amplify-component-lib/refs/heads/main/config/config_files/test-utils/browserMocks.ts
portalMock.ts client/src/test-utils https://raw.githubusercontent.com/equinor/amplify-component-lib/refs/heads/main/config/config_files/test-utils/portalMock.ts
samMock.ts client/src/test-utils https://raw.githubusercontent.com/equinor/amplify-component-lib/refs/heads/main/config/config_files/test-utils/samMock.ts
playwright.ts client/src/test-utils https://raw.githubusercontent.com/equinor/amplify-component-lib/refs/heads/main/config/config_files/test-utils/playwright.ts
build.yaml .github/workflows https://raw.githubusercontent.com/equinor/amplify-component-lib/refs/heads/main/config/config_files/workflows/build.yaml
e2e.yaml .github/workflows https://raw.githubusercontent.com/equinor/amplify-component-lib/refs/heads/main/config/config_files/workflows/e2e.yaml
Expand Down
301 changes: 0 additions & 301 deletions config/config_files/test-utils/portalMock.ts

This file was deleted.

80 changes: 80 additions & 0 deletions config/config_files/test-utils/samMock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { FeatureToggleDto, Tutorial } from '@equinor/subsurface-app-management';
import { faker } from '@faker-js/faker';

import { delay, http, HttpResponse } from 'msw';

export const handlers = [
http.get('*/api/v1/Tutorial/SASToken', async () => {
await delay('real');
return HttpResponse.text(faker.internet.mac());
}),
http.get('*/api/v1/Tutorial/{applicationName}', async () => {
await delay('real');
const body: Tutorial[] = [];
return HttpResponse.json(body);
}),
http.get('*/api/v1/FeatureToggle', async () => {
await delay('real');
const body: FeatureToggleDto = {
applicationName: 'orca',
features: [],
};
return HttpResponse.json(body);
}),
http.get('*/api/v1/AmplifyApplication/application/*/appRoles', async () => {
await delay('real');
return HttpResponse.json([]);
}),
http.get('*/api/v1/ImpersonateUser/CanImpersonate', async () => {
return HttpResponse.text('true');
}),
http.get('*/api/v1/ImpersonateUser/ActiveUser', async () => {
await delay('real');
return HttpResponse.json(undefined, { status: 204 });
}),
http.get('*/api/v1/ImpersonateUser/GetImpersonateUserForApp/*', async () => {
await delay('real');
return HttpResponse.json([]);
}),
http.get('*/api/v1/Token/AmplifyPortal', async () => {
await delay('real');
return HttpResponse.text(faker.string.nanoid());
}),
http.get('*/api/v1/Token/AmplifyPortal/*', async () => {
await delay('real');
return HttpResponse.text(faker.string.nanoid());
}),
http.get('*/api/v1/Token/SamPortal', async () => {
await delay('real');
return HttpResponse.text(faker.string.nanoid());
}),
http.get('*/api/v1/Token/SamPortal/*', async () => {
await delay('real');
return HttpResponse.text(faker.string.nanoid());
}),
http.get('*/api/v1/ReleaseNotes', async () => {
await delay('real');
return HttpResponse.json([]);
}),
http.get('*/api/v1/ReleaseNotes/:applicationName', async () => {
await delay('real');
return HttpResponse.json([]);
}),
http.get('*/api/v1/ReleaseNotes/GetContainerSasUri', async () => {
await delay('real');
return HttpResponse.text(
`${faker.internet.url()}?${faker.string.nanoid()}`
);
}),
http.get('*/api/v1/AmplifyApplication/userapplications', async () => {
await delay('real');
return HttpResponse.json([]);
}),
http.get(
'*/api/v1/FeatureToggle/:appName/:currentEnvironment/myfeatures',
async () => {
await delay('real');
return HttpResponse.json([]);
}
),
];
Loading
Loading