Skip to content

Commit

Permalink
resolves merge comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanwrightAND committed Aug 10, 2023
1 parent d2435a3 commit a8358a8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 23 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ These are designed to run against a local environment. The following apps must b
`CYPRESS_DATABASE_URL=postgres://postgres:postgres@localhost:5432`
`CYPRESS_USER_SERVICE_DB_NAME=gapuserlocaldb`

The package.json includes shorthands to run:
The package.json within admin/applicant includes shorthands to run:

- `yarn workspace admin integration:gui` - run individual test cases against browser
- `yarn integration` - runs all tests in headless mode
Expand All @@ -76,6 +76,8 @@ It is recommended that data teardown/setup happens as part of each test run ensu

Various tasks have been added to perform tasks before and during test runs. These can be found in `cypress/plugins/index.js`

`wiremock:selectUser` - this will edit the wiremock stub mapping to One login (/userInfo) to return either an applicant, admin or super-admin. This will act as the signed in user to perform the test actions
`db:removeTestUsers` - this will remove test users directly to the database via sql
`db:addTestUsers` - this will add test users directly to the database via sql
`setup:user`

- this will remove test users directly to the database via sql
- this will add test users directly to the database via sql
- this will edit the wiremock stub mapping to One login (/userInfo) to return either an applicant, admin or super-admin. This will act as the signed in user to perform the test actions
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { login } from '../../utils/login';

describe('super-admin-dashboard', () => {
beforeEach(() => {
cy.task('db:deleteTestUsers');
cy.task('db:addTestUsers');
cy.task('wiremock:selectUser', 'superAdmin');
cy.task('setup:user', 'superAdmin');
login();
});

Expand Down
14 changes: 3 additions & 11 deletions packages/admin/cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,10 @@ module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
on('task', {
'wiremock:selectUser': (user) => {
createUserInfoStub(user).then(() => {
console.log('User info stub created');
});
return null;
},
'db:addTestUsers': async () => {
await createTestUsers();
return null;
},
'db:deleteTestUsers': async () => {
'setup:user': async (user) => {
await deleteTestUsers();
await createTestUsers();
await createUserInfoStub(user);
return null;
},
log(message) {
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/cypress/seed/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const runSQL = async (filePath, dbName) => {

console.log('SQL script executed successfully.');
} catch (error) {
console.error('Error executing SQL script:', error);
console.error('Error executing SQL script:\n\n', error);
}
};

Expand Down
9 changes: 5 additions & 4 deletions packages/admin/cypress/utils/wiremock.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ export const createUserInfoStub = async (user) => {
};

try {
const response = await axios.get(`${wireMockBaseUrl}/mappings`);
const existingMappings = response.data.mappings;
const {
data: { mappings: existingMappings },
} = await axios.get(`${wireMockBaseUrl}/mappings`);

const existingMapping = existingMappings.find(
(mapping) =>
Expand All @@ -50,9 +51,9 @@ export const createUserInfoStub = async (user) => {
`${wireMockBaseUrl}/mappings`,
userInfoStub
);
console.log('New WireMock mapping created:', createResponse.data);
console.log('New WireMock mapping created:\n\n', createResponse.data);
}
} catch (error) {
console.error('Error creating/updating WireMock stub:', error.message);
console.error('Error creating/updating WireMock stub:\n\n', error);
}
};

0 comments on commit a8358a8

Please sign in to comment.