Skip to content
Merged
Changes from all commits
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
60 changes: 35 additions & 25 deletions packages/pic/tests/src/http-gateway.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ const II_BACKEND_ID = 'rdmx6-jaaaa-aaaaa-aaadq-cai';
const II_FRONTEND_ID = 'uqzsh-gqaaa-aaaaq-qaada-cai';
const NNS_DAPP_ID = 'qoctq-giaaa-aaaaa-aaaea-cai';

// Deploying the NNS dapp with its dependencies can take longer than the
// default timeouts on a busy CI runner.
const NNS_DAPP_PROCESSING_TIMEOUT_MS = 120_000;
const NNS_DAPP_TEST_TIMEOUT_MS = 180_000;

async function getFreePort(): Promise<number> {
return await new Promise((resolve, reject) => {
const server = createServer();
Expand Down Expand Up @@ -59,31 +64,36 @@ describe('httpGateway', () => {
}
});

it('deploys and serves the NNS dapp', async () => {
const config = IcpFeaturesConfig.DefaultConfig;
const pic = await PocketIc.create(process.env.PIC_URL, {
httpGateway: {},
icpFeatures: {
cyclesMinting: config,
icpToken: config,
nnsGovernance: config,
sns: config,
ii: config,
nnsUi: config,
},
});

try {
const gatewayPort = await pic.makeLive();
const res = await fetchFrontend(NNS_DAPP_ID, gatewayPort);

expect(res.status).toBe(200);
expect(res.headers.get('content-type')).toContain('text/html');
} finally {
await pic.stopLive();
await pic.tearDown();
}
});
it(
'deploys and serves the NNS dapp',
async () => {
const config = IcpFeaturesConfig.DefaultConfig;
const pic = await PocketIc.create(process.env.PIC_URL, {
processingTimeoutMs: NNS_DAPP_PROCESSING_TIMEOUT_MS,
httpGateway: {},
icpFeatures: {
cyclesMinting: config,
icpToken: config,
nnsGovernance: config,
sns: config,
ii: config,
nnsUi: config,
},
});

try {
const gatewayPort = await pic.makeLive();
const res = await fetchFrontend(NNS_DAPP_ID, gatewayPort);

expect(res.status).toBe(200);
expect(res.headers.get('content-type')).toContain('text/html');
} finally {
await pic.stopLive();
await pic.tearDown();
}
},
NNS_DAPP_TEST_TIMEOUT_MS,
);

it('uses the gateway created with the instance when going live', async () => {
const port = await getFreePort();
Expand Down
Loading