mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Avoid resetting the mock server (#18661)
This commit is contained in:
parent
7bc13e90f8
commit
02e8e9c679
@ -105,7 +105,7 @@ async function withFixtures(options, testSuite) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await setupMocking(mockServer, testSpecificMock);
|
const mockedEndpoint = await setupMocking(mockServer, testSpecificMock);
|
||||||
await mockServer.start(8000);
|
await mockServer.start(8000);
|
||||||
if (
|
if (
|
||||||
process.env.SELENIUM_BROWSER === 'chrome' &&
|
process.env.SELENIUM_BROWSER === 'chrome' &&
|
||||||
@ -143,10 +143,10 @@ async function withFixtures(options, testSuite) {
|
|||||||
|
|
||||||
await testSuite({
|
await testSuite({
|
||||||
driver: driverProxy ?? driver,
|
driver: driverProxy ?? driver,
|
||||||
mockServer,
|
|
||||||
contractRegistry,
|
contractRegistry,
|
||||||
ganacheServer,
|
ganacheServer,
|
||||||
secondaryGanacheServer,
|
secondaryGanacheServer,
|
||||||
|
mockedEndpoint,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
failed = true;
|
failed = true;
|
||||||
|
@ -32,6 +32,11 @@ async function setupMocking(server, testSpecificMock) {
|
|||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const mockedEndpoint = await testSpecificMock(server);
|
||||||
|
|
||||||
|
// Mocks below this line can be overridden by test-specific mocks
|
||||||
|
|
||||||
await server
|
await server
|
||||||
.forPost(
|
.forPost(
|
||||||
'https://arbitrum-mainnet.infura.io/v3/00000000000000000000000000000000',
|
'https://arbitrum-mainnet.infura.io/v3/00000000000000000000000000000000',
|
||||||
@ -369,10 +374,6 @@ async function setupMocking(server, testSpecificMock) {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
testSpecificMock(server);
|
|
||||||
|
|
||||||
// Mocks below this line can be overridden by test-specific mocks
|
|
||||||
|
|
||||||
await server.forGet(STALELIST_URL).thenCallback(() => {
|
await server.forGet(STALELIST_URL).thenCallback(() => {
|
||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
@ -399,6 +400,8 @@ async function setupMocking(server, testSpecificMock) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return mockedEndpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { setupMocking };
|
module.exports = { setupMocking };
|
||||||
|
@ -9,8 +9,6 @@ describe('ENS', function () {
|
|||||||
'https://mainnet.infura.io/v3/00000000000000000000000000000000';
|
'https://mainnet.infura.io/v3/00000000000000000000000000000000';
|
||||||
|
|
||||||
async function mockInfura(mockServer) {
|
async function mockInfura(mockServer) {
|
||||||
await mockServer.reset();
|
|
||||||
await mockServer.forAnyRequest().thenPassThrough();
|
|
||||||
await mockServer
|
await mockServer
|
||||||
.forPost(infuraUrl)
|
.forPost(infuraUrl)
|
||||||
.withJsonBodyIncluding({ method: 'eth_blockNumber' })
|
.withJsonBodyIncluding({ method: 'eth_blockNumber' })
|
||||||
@ -103,7 +101,7 @@ describe('ENS', function () {
|
|||||||
|
|
||||||
await driver.clickElement('[data-testid="eth-overview-send"]');
|
await driver.clickElement('[data-testid="eth-overview-send"]');
|
||||||
|
|
||||||
await driver.fill(
|
await driver.pasteIntoField(
|
||||||
'input[placeholder="Search, public address (0x), or ENS"]',
|
'input[placeholder="Search, public address (0x), or ENS"]',
|
||||||
sampleEnsDomain,
|
sampleEnsDomain,
|
||||||
);
|
);
|
||||||
|
@ -3,9 +3,7 @@ const { convertToHexValue, withFixtures } = require('../helpers');
|
|||||||
const FixtureBuilder = require('../fixture-builder');
|
const FixtureBuilder = require('../fixture-builder');
|
||||||
|
|
||||||
describe('Sentry errors', function () {
|
describe('Sentry errors', function () {
|
||||||
async function mockSegment(mockServer) {
|
async function mockSentry(mockServer) {
|
||||||
mockServer.reset();
|
|
||||||
await mockServer.forAnyRequest().thenPassThrough();
|
|
||||||
return await mockServer
|
return await mockServer
|
||||||
.forPost('https://sentry.io/api/0000000/store/')
|
.forPost('https://sentry.io/api/0000000/store/')
|
||||||
.thenCallback(() => {
|
.thenCallback(() => {
|
||||||
@ -36,9 +34,9 @@ describe('Sentry errors', function () {
|
|||||||
ganacheOptions,
|
ganacheOptions,
|
||||||
title: this.test.title,
|
title: this.test.title,
|
||||||
failOnConsoleError: false,
|
failOnConsoleError: false,
|
||||||
|
testSpecificMock: mockSentry,
|
||||||
},
|
},
|
||||||
async ({ driver, mockServer }) => {
|
async ({ driver, mockedEndpoint }) => {
|
||||||
const mockedEndpoint = await mockSegment(mockServer);
|
|
||||||
await driver.navigate();
|
await driver.navigate();
|
||||||
await driver.fill('#password', 'correct horse battery staple');
|
await driver.fill('#password', 'correct horse battery staple');
|
||||||
await driver.press('#password', driver.Key.ENTER);
|
await driver.press('#password', driver.Key.ENTER);
|
||||||
|
@ -4,8 +4,6 @@ const FixtureBuilder = require('../fixture-builder');
|
|||||||
|
|
||||||
describe('Segment metrics', function () {
|
describe('Segment metrics', function () {
|
||||||
async function mockSegment(mockServer) {
|
async function mockSegment(mockServer) {
|
||||||
mockServer.reset();
|
|
||||||
await mockServer.forAnyRequest().thenPassThrough();
|
|
||||||
return await mockServer
|
return await mockServer
|
||||||
.forPost('https://api.segment.io/v1/batch')
|
.forPost('https://api.segment.io/v1/batch')
|
||||||
.withJsonBodyIncluding({ batch: [{ type: 'page' }] })
|
.withJsonBodyIncluding({ batch: [{ type: 'page' }] })
|
||||||
@ -36,18 +34,17 @@ describe('Segment metrics', function () {
|
|||||||
.build(),
|
.build(),
|
||||||
ganacheOptions,
|
ganacheOptions,
|
||||||
title: this.test.title,
|
title: this.test.title,
|
||||||
failOnConsoleError: false,
|
testSpecificMock: mockSegment,
|
||||||
},
|
},
|
||||||
async ({ driver, mockServer }) => {
|
async ({ driver, mockedEndpoint }) => {
|
||||||
const mockedEndpoints = await mockSegment(mockServer);
|
|
||||||
await driver.navigate();
|
await driver.navigate();
|
||||||
await driver.fill('#password', 'correct horse battery staple');
|
await driver.fill('#password', 'correct horse battery staple');
|
||||||
await driver.press('#password', driver.Key.ENTER);
|
await driver.press('#password', driver.Key.ENTER);
|
||||||
await driver.wait(async () => {
|
await driver.wait(async () => {
|
||||||
const isPending = await mockedEndpoints.isPending();
|
const isPending = await mockedEndpoint.isPending();
|
||||||
return isPending === false;
|
return isPending === false;
|
||||||
}, 10000);
|
}, 10000);
|
||||||
const mockedRequests = await mockedEndpoints.getSeenRequests();
|
const mockedRequests = await mockedEndpoint.getSeenRequests();
|
||||||
assert.equal(mockedRequests.length, 3);
|
assert.equal(mockedRequests.length, 3);
|
||||||
const [firstMock, secondMock, thirdMock] = mockedRequests;
|
const [firstMock, secondMock, thirdMock] = mockedRequests;
|
||||||
let [mockJson] = firstMock.body.json.batch;
|
let [mockJson] = firstMock.body.json.batch;
|
||||||
|
@ -8,6 +8,7 @@ describe('Gas API fallback', function () {
|
|||||||
.forGet(
|
.forGet(
|
||||||
'https://gas-api.metaswap.codefi.network/networks/1/suggestedGasFees',
|
'https://gas-api.metaswap.codefi.network/networks/1/suggestedGasFees',
|
||||||
)
|
)
|
||||||
|
.always()
|
||||||
.thenCallback(() => {
|
.thenCallback(() => {
|
||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user