Skip to content

Commit

Permalink
test: better for ci test (#1189)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timeless0911 committed Jun 17, 2024
1 parent 2ba236f commit d8bda08
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
10 changes: 9 additions & 1 deletion e2e/tests/client-redirects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ test.describe('client redirects test', async () => {
}
});

test('Should redirect correctly', async ({ page }) => {
test('Should redirect correctly - normal', async ({ page }) => {
await page.goto(`http://localhost:${appPort}/docs/old1`, {
waitUntil: 'networkidle',
});
expect(page.url()).toBe(`http://localhost:${appPort}/docs/new1`);
});

test('Should redirect correctly - array', async ({ page }) => {
await page.goto(`http://localhost:${appPort}/docs/2022`, {
waitUntil: 'networkidle',
});
Expand All @@ -34,7 +36,9 @@ test.describe('client redirects test', async () => {
waitUntil: 'networkidle',
});
expect(page.url()).toBe(`http://localhost:${appPort}/docs/2024/new`);
});

test('Should redirect correctly - reg1', async ({ page }) => {
await page.goto(`http://localhost:${appPort}/docs/old2`, {
waitUntil: 'networkidle',
});
Expand All @@ -44,7 +48,9 @@ test.describe('client redirects test', async () => {
waitUntil: 'networkidle',
});
expect(page.url()).toBe(`http://localhost:${appPort}/docs/new2/foo`);
});

test('Should redirect correctly - reg2', async ({ page }) => {
await page.goto(`http://localhost:${appPort}/docs/old3`, {
waitUntil: 'networkidle',
});
Expand All @@ -54,7 +60,9 @@ test.describe('client redirects test', async () => {
waitUntil: 'networkidle',
});
expect(page.url()).toBe(`http://localhost:${appPort}/foo/docs/new3`);
});

test('Should redirect correctly - external', async ({ page }) => {
await page.goto(`http://localhost:${appPort}/docs/old4`, {
waitUntil: 'networkidle',
});
Expand Down
16 changes: 10 additions & 6 deletions e2e/tests/i18n.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,22 @@ test.describe('i18n test', async () => {
await page.goto(`http://localhost:${appPort}/guide/basic/quick-start`, {
waitUntil: 'networkidle',
});
await page.click('a.menuLink_71eca');
expect(page.url()).toBe(
`http://localhost:${appPort}/guide/basic/install.html`,
const customLinkZh = await page.$('nav > a');
const hrefZh = await page.evaluate(
customLinkZh => customLinkZh?.getAttribute('href'),
customLinkZh,
);
expect(hrefZh).toBe('/guide/basic/install.html');

await page.goto(`http://localhost:${appPort}/en/guide/basic/quick-start`, {
waitUntil: 'networkidle',
});
await page.click('a.menuLink_71eca');
expect(page.url()).toBe(
`http://localhost:${appPort}/en/guide/basic/install.html`,
const customLinkEn = await page.$('nav > a');
const hrefEn = await page.evaluate(
customLinkEn => customLinkEn?.getAttribute('href'),
customLinkEn,
);
expect(hrefEn).toBe('/en/guide/basic/install.html');
});

test('Should not crash when switch language in api page', async ({
Expand Down

0 comments on commit d8bda08

Please sign in to comment.