Skip to content

Commit

Permalink
Add test for defaultMarketingRegion
Browse files Browse the repository at this point in the history
  • Loading branch information
willdch committed Jan 5, 2024
1 parent 04d4bdb commit 7ef6a56
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 21 deletions.
34 changes: 33 additions & 1 deletion test/location.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { faker } from '@faker-js/faker';
import { times } from 'lodash';
import { generateId, isValidId } from '../src/common';
import { generateId, IdOf, isValidId } from '../src/common';
import { Location } from '../src/components/location';
import {
createFundingAccount,
Expand Down Expand Up @@ -160,6 +160,38 @@ describe('Location e2e', () => {
expect(updated.defaultFieldRegion.value.id).toBe(newFieldRegion.id);
});

fit('update location with defaultMarketingRegion', async () => {
const defaultMarketingRegion = await createRegion(app);
const l = await createLocation(app, {
defaultMarketingRegionId: defaultMarketingRegion.id as IdOf<Location>,
});
const newMarketingRegion = await createRegion(app);

const result = await app.graphql.mutate(
gql`
mutation updateLocation($input: UpdateLocationInput!) {
updateLocation(input: $input) {
location {
...location
}
}
}
${fragments.location}
`,
{
input: {
location: {
id: l.id,
defaultMarketingRegionId: newMarketingRegion.id,
},
},
},
);
const updated = result.updateLocation.location;
expect(updated).toBeTruthy();
expect(updated.defaultMarketingRegion.value.id).toBe(newMarketingRegion.id);
});

it('update location with funding account', async () => {
const fundingAccount = await createFundingAccount(app);
const st = await createLocation(app, {
Expand Down
24 changes: 4 additions & 20 deletions test/utility/fragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,6 @@ export const org = gql`
}
}
}
defaultMarketingRegion {
value {
id
name {
value
}
}
}
}
}
}
Expand Down Expand Up @@ -321,14 +313,6 @@ export const language = gql`
}
}
}
defaultMarketingRegion {
value {
id
name {
value
}
}
}
}
}
}
Expand Down Expand Up @@ -1143,8 +1127,8 @@ export const fundingAccount = gql`
}
`;

export const defaultMarketingRegion = gql`
fragment defaultMarketingRegion on Location {
export const locationName = gql`
fragment locationName on Location {
id
name {
value
Expand Down Expand Up @@ -1187,13 +1171,13 @@ export const location = gql`
}
defaultMarketingRegion {
value {
...defaultMarketingRegion
...locationName
}
}
}
${fundingAccount}
${fieldRegion}
${defaultMarketingRegion}
${locationName}
`;

export const projectChangeRequest = gql`
Expand Down

0 comments on commit 7ef6a56

Please sign in to comment.