Skip to content

Commit df23eda

Browse files
authored
host: Add test to exercise clientRequestId check (#2253)
1 parent 4be9597 commit df23eda

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

packages/host/tests/acceptance/interact-submode-test.gts

+52-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
} from '@cardstack/runtime-common';
2424
import { Realm } from '@cardstack/runtime-common/realm';
2525

26+
import type CardService from '@cardstack/host/services/card-service';
2627
import type OperatorModeStateService from '@cardstack/host/services/operator-mode-state-service';
2728
import { claimsFromRawToken } from '@cardstack/host/services/realm';
2829
import type RecentCardsService from '@cardstack/host/services/recent-cards-service';
@@ -112,7 +113,7 @@ module('Acceptance | interact submode tests', function (hooks) {
112113
static isolated = class Isolated extends Component<typeof this> {
113114
<template>
114115
<GridContainer class='container'>
115-
<h2><@fields.title /></h2>
116+
<h2 data-test-pet-title><@fields.title /></h2>
116117
<div>
117118
<div>Favorite Treat: <@fields.favoriteTreat /></div>
118119
<div data-test-editable-meta>
@@ -574,6 +575,56 @@ module('Acceptance | interact submode tests', function (hooks) {
574575
);
575576
});
576577

578+
test<TestContextWithSave>('a realm event with known clientRequestId is ignored', async function (assert) {
579+
await visitOperatorMode({
580+
stacks: [
581+
[
582+
{
583+
id: `${testRealmURL}Pet/vangogh`,
584+
format: 'edit',
585+
},
586+
],
587+
],
588+
codePath: `${testRealmURL}Pet/vangogh.json`,
589+
});
590+
591+
let deferred = new Deferred<void>();
592+
593+
this.onSave(() => {
594+
deferred.fulfill();
595+
});
596+
597+
await fillIn(`[data-test-field="name"] input`, 'Renamed via UI');
598+
await deferred.promise;
599+
await click('[data-test-edit-button]');
600+
601+
let knownClientRequestIds = (
602+
this.owner.lookup('service:card-service') as CardService
603+
).clientRequestIds.values();
604+
605+
let knownClientRequestId = knownClientRequestIds.next().value;
606+
607+
await realm.write(
608+
'Pet/vangogh.json',
609+
JSON.stringify({
610+
data: {
611+
type: 'card',
612+
attributes: {
613+
name: 'Renamed via realm call',
614+
},
615+
meta: {
616+
adoptsFrom: { module: 'http://test-realm/test/pet', name: 'Pet' },
617+
},
618+
},
619+
}),
620+
knownClientRequestId,
621+
);
622+
623+
await settled();
624+
625+
assert.dom('[data-test-pet-title]').containsText('Renamed via UI');
626+
});
627+
577628
test('restoring the stack from query param when card is in edit format', async function (assert) {
578629
await visitOperatorMode({
579630
stacks: [

0 commit comments

Comments
 (0)