Skip to content

Commit ad81627

Browse files
committed
updating test after changes for test builder
1 parent b761b62 commit ad81627

2 files changed

Lines changed: 132 additions & 33 deletions

File tree

api/src/services/listing.service.ts

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -530,26 +530,51 @@ export class ListingService implements OnModuleInit {
530530
key: ListingFilterKeys.availabilities,
531531
caseSensitive: true,
532532
});
533+
const reviewOrderFilter = buildFilter({
534+
$comparison: Compare['='],
535+
$include_nulls: false,
536+
value: ReviewOrderTypeEnum.waitlistLottery,
537+
key: ListingFilterKeys.availabilities,
538+
caseSensitive: true,
539+
});
533540
return {
534-
AND: builtFilter
535-
.map((filt) => ({
536-
unitGroups: {
537-
some: {
538-
[FilterAvailabilityEnum.openWaitlist]: filt,
539-
},
540-
},
541-
}))
542-
.concat(
543-
notUnderConstruction.map((filt) => ({
544-
marketingType: filt,
545-
})),
546-
),
541+
OR: [
542+
{
543+
AND: builtFilter
544+
.map((filt) => ({
545+
unitGroups: {
546+
some: {
547+
[FilterAvailabilityEnum.openWaitlist]: filt,
548+
},
549+
},
550+
}))
551+
.concat(
552+
notUnderConstruction.map((filt) => ({
553+
marketingType: filt,
554+
})),
555+
),
556+
},
557+
{
558+
AND: reviewOrderFilter
559+
.map((filt) => ({
560+
reviewOrderType: filt,
561+
}))
562+
.concat(
563+
notUnderConstruction.map((filt) => ({
564+
marketingType: filt,
565+
})),
566+
),
567+
},
568+
],
547569
};
548570
} else if (availability === FilterAvailabilityEnum.waitlistOpen) {
549571
const builtFilter = buildFilter({
550-
$comparison: Compare['='],
572+
$comparison: Compare.IN,
551573
$include_nulls: false,
552-
value: ReviewOrderTypeEnum.waitlist,
574+
value: [
575+
ReviewOrderTypeEnum.waitlist,
576+
ReviewOrderTypeEnum.waitlistLottery,
577+
],
553578
key: ListingFilterKeys.availabilities,
554579
caseSensitive: true,
555580
});
@@ -641,6 +666,13 @@ export class ListingService implements OnModuleInit {
641666
key: ListingFilterKeys.availability,
642667
caseSensitive: true,
643668
});
669+
const reviewOrderFilter = buildFilter({
670+
$comparison: filter.$comparison,
671+
$include_nulls: false,
672+
value: ReviewOrderTypeEnum.waitlistLottery,
673+
key: ListingFilterKeys.availability,
674+
caseSensitive: true,
675+
});
644676
filters.push({
645677
OR: [
646678
{
@@ -656,6 +688,17 @@ export class ListingService implements OnModuleInit {
656688
})),
657689
),
658690
},
691+
{
692+
AND: reviewOrderFilter
693+
.map((filt) => ({
694+
reviewOrderType: filt,
695+
}))
696+
.concat(
697+
notUnderConstruction.map((filt) => ({
698+
marketingType: filt,
699+
})),
700+
),
701+
},
659702
],
660703
});
661704
} else if (

api/test/unit/services/listing.service.spec.ts

Lines changed: 74 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,16 +1419,22 @@ describe('Testing listing service', () => {
14191419
{
14201420
OR: [
14211421
{
1422-
AND: [
1422+
OR: [
14231423
{
1424-
unitGroups: {
1425-
some: { openWaitlist: { equals: true } },
1426-
},
1424+
AND: [
1425+
{
1426+
unitGroups: {
1427+
some: { openWaitlist: { equals: true } },
1428+
},
1429+
},
1430+
{ marketingType: { not: { equals: 'comingSoon' } } },
1431+
],
14271432
},
14281433
{
1429-
marketingType: {
1430-
not: { equals: MarketingTypeEnum.comingSoon },
1431-
},
1434+
AND: [
1435+
{ reviewOrderType: { equals: 'waitlistLottery' } },
1436+
{ marketingType: { not: { equals: 'comingSoon' } } },
1437+
],
14321438
},
14331439
],
14341440
},
@@ -1453,7 +1459,10 @@ describe('Testing listing service', () => {
14531459
OR: [
14541460
{
14551461
reviewOrderType: {
1456-
equals: ReviewOrderTypeEnum.waitlist,
1462+
in: [
1463+
ReviewOrderTypeEnum.waitlist,
1464+
ReviewOrderTypeEnum.waitlistLottery,
1465+
],
14571466
},
14581467
},
14591468
],
@@ -1512,16 +1521,42 @@ describe('Testing listing service', () => {
15121521
{
15131522
OR: [
15141523
{
1515-
AND: [
1524+
OR: [
15161525
{
1517-
unitGroups: {
1518-
some: { openWaitlist: { equals: true } },
1519-
},
1526+
AND: [
1527+
{
1528+
unitGroups: {
1529+
some: {
1530+
openWaitlist: {
1531+
equals: true,
1532+
},
1533+
},
1534+
},
1535+
},
1536+
{
1537+
marketingType: {
1538+
not: {
1539+
equals: 'comingSoon',
1540+
},
1541+
},
1542+
},
1543+
],
15201544
},
15211545
{
1522-
marketingType: {
1523-
not: { equals: MarketingTypeEnum.comingSoon },
1524-
},
1546+
AND: [
1547+
{
1548+
reviewOrderType: {
1549+
equals: 'waitlistLottery',
1550+
},
1551+
},
1552+
{
1553+
marketingType: {
1554+
not: {
1555+
equals: 'comingSoon',
1556+
},
1557+
},
1558+
},
1559+
],
15251560
},
15261561
],
15271562
},
@@ -1610,7 +1645,6 @@ describe('Testing listing service', () => {
16101645
} as ListingFilterParams,
16111646
];
16121647
const whereClause = service.buildWhereClause(filter, '');
1613-
16141648
expect(whereClause).toStrictEqual({
16151649
AND: [
16161650
{
@@ -1619,12 +1653,34 @@ describe('Testing listing service', () => {
16191653
AND: [
16201654
{
16211655
unitGroups: {
1622-
some: { openWaitlist: { equals: true } },
1656+
some: {
1657+
openWaitlist: {
1658+
equals: true,
1659+
},
1660+
},
16231661
},
16241662
},
16251663
{
16261664
marketingType: {
1627-
not: { equals: MarketingTypeEnum.comingSoon },
1665+
not: {
1666+
equals: 'comingSoon',
1667+
},
1668+
},
1669+
},
1670+
],
1671+
},
1672+
{
1673+
AND: [
1674+
{
1675+
reviewOrderType: {
1676+
equals: 'waitlistLottery',
1677+
},
1678+
},
1679+
{
1680+
marketingType: {
1681+
not: {
1682+
equals: 'comingSoon',
1683+
},
16281684
},
16291685
},
16301686
],

0 commit comments

Comments
 (0)